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));
}
}
}
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);
}
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));
}
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]);
}
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);
}
Aggregations