Search in sources :

Example 81 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestWatershedVincentSoille1991_Connect8 method exampleSeeds2.

@Test
public void exampleSeeds2() {
    GrayU8 image = new GrayU8(4, 4);
    image.data = new byte[] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
    // try multiple seeds
    GrayS32 seed = new GrayS32(4, 4);
    seed.data = new int[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
    int[] expected = new int[] { 1, 1, 1, 0, 1, 1, 0, 2, 1, 0, 2, 2, 0, 2, 2, 2 };
    WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
    alg.process(image, seed);
    GrayS32 found = alg.getOutput();
    // found.print();
    int index = 0;
    for (int y = 0; y < image.height; y++) {
        for (int x = 0; x < image.width; x++) {
            assertEquals(expected[index++], found.get(x, y));
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 82 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestComputeRegionMeanColor method before.

@Before
public void before() {
    segments = new GrayS32(w, h);
    segments.data = new int[] { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
    regionMemberCount = new GrowQueue_I32();
    for (int i = 0; i < 4; i++) regionMemberCount.add(5);
}
Also used : GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Before(org.junit.Before)

Example 83 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestImageSegmentationOps method countRegionPixels_single.

@Test
public void countRegionPixels_single() {
    GrayS32 output = new GrayS32(4, 5);
    output.data = new int[] { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2 };
    assertEquals(5, ImageSegmentationOps.countRegionPixels(output, 0));
    assertEquals(5, ImageSegmentationOps.countRegionPixels(output, 1));
    assertEquals(8, ImageSegmentationOps.countRegionPixels(output, 2));
    assertEquals(2, ImageSegmentationOps.countRegionPixels(output, 3));
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 84 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestImageSegmentationOps method countRegionPixels_all.

@Test
public void countRegionPixels_all() {
    GrayS32 output = new GrayS32(4, 5);
    output.data = new int[] { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2 };
    int[] counts = new int[10];
    ImageSegmentationOps.countRegionPixels(output, 4, counts);
    assertEquals(5, counts[0]);
    assertEquals(5, counts[1]);
    assertEquals(8, counts[2]);
    assertEquals(2, counts[3]);
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 85 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestImageSegmentationOps method markRegionBorders1.

@Test
public void markRegionBorders1() {
    GrayS32 input = new GrayS32(4, 5);
    input.data = new int[] { 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 2, 2, 0, 2, 2, 2, 0, 2, 2, 2 };
    GrayU8 expected = new GrayU8(4, 5);
    expected.data = new byte[] { 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0 };
    GrayU8 found = new GrayU8(4, 5);
    ImageSegmentationOps.markRegionBorders(input, found);
    BoofTesting.assertEquals(expected, found, 1e-4);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Aggregations

GrayS32 (boofcv.struct.image.GrayS32)102 Test (org.junit.Test)79 GrayU8 (boofcv.struct.image.GrayU8)52 GrayF32 (boofcv.struct.image.GrayF32)13 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)10 Point2D_I32 (georegression.struct.point.Point2D_I32)7 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)4 GImageGray (boofcv.core.image.GImageGray)4 ImageGray (boofcv.struct.image.ImageGray)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 ImageDimension (boofcv.struct.image.ImageDimension)3 BufferedImage (java.awt.image.BufferedImage)3 FastQueue (org.ddogleg.struct.FastQueue)3 WatershedVincentSoille1991 (boofcv.alg.segmentation.watershed.WatershedVincentSoille1991)2 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)2 ImageRectangle (boofcv.struct.ImageRectangle)2 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2