Exemple #1
0
        public void SlicSimple()
        {
            using var image = Image("building.jpg", ImreadModes.Grayscale);
            using var slic  = SuperpixelSLIC.Create(image);

            slic.Iterate(10);

            var superpixels = slic.GetNumberOfSuperpixels();

            Assert.True(superpixels > 0, $"GetNumberOfSuperpixels() => {superpixels}");

            using var labels = new Mat();
            slic.GetLabels(labels);
            Assert.False(labels.Empty());
            Assert.Equal(image.Size(), labels.Size());
            Assert.Equal(MatType.CV_32SC1, labels.Type());

            using var labelContourMask1 = new Mat();
            using var labelContourMask2 = new Mat();
            slic.GetLabelContourMask(labelContourMask1, true);
            slic.GetLabelContourMask(labelContourMask2, false);
            Assert.False(labelContourMask1.Empty());
            Assert.False(labelContourMask2.Empty());

            slic.EnforceLabelConnectivity();
        }
Exemple #2
0
 public void SlicNew()
 {
     using var image = Image("building.jpg", ImreadModes.Grayscale);
     using var slic  = SuperpixelSLIC.Create(image);
     GC.KeepAlive(slic);
 }