use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestWatershedVincentSoille1991_Connect8 method example1.
@Test
public void example1() {
GrayU8 image = new GrayU8(4, 4);
image.data = new byte[] { 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1 };
WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
alg.process(image);
assertEquals(3, alg.getTotalRegions());
GrayS32 found = alg.getOutput();
int a = found.get(0, 0);
int b = found.get(3, 0);
assertTrue(a > 0);
assertTrue(b > 0);
assertTrue(a != b);
for (int y = 0; y < image.height; y++) {
assertEquals(a, found.get(0, y));
assertEquals(a, found.get(1, y));
assertEquals(b, found.get(2, y));
assertEquals(b, found.get(3, y));
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestWatershedVincentSoille1991_Connect8 method example2.
@Test
public void example2() {
GrayU8 image = new GrayU8(5, 4);
image.data = new byte[] { 5, 5, 5, 5, 5, 5, 1, 5, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
alg.process(image);
GrayS32 found = alg.getOutput();
assertEquals(3, alg.getTotalRegions());
int a = found.get(0, 0);
int b = found.get(4, 0);
assertTrue(a > 0);
assertTrue(b > 0);
assertTrue(a != b);
for (int y = 0; y < image.height; y++) {
assertEquals(a, found.get(0, y));
assertEquals(a, found.get(1, y));
assertEquals(0, found.get(2, y));
assertEquals(b, found.get(3, y));
assertEquals(b, found.get(4, y));
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestWatershedVincentSoille1991_Connect8 method example5.
@Test
public void example5() {
GrayU8 image = new GrayU8(5, 4);
image.data = new byte[] { 1, 1, 1, 5, 5, 1, 1, 1, 5, 5, 0, 1, 1, 5, 5, 1, 1, 1, 5, 5 };
WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
alg.process(image);
GrayS32 found = alg.getOutput();
// found.print();
assertEquals(2, alg.getTotalRegions());
for (int y = 0; y < image.height; y++) {
for (int x = 0; x < image.width; x++) {
assertEquals(1, found.get(x, y));
}
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestWatershedVincentSoille1991_Connect8 method example0.
@Test
public void example0() {
GrayU8 image = new GrayU8(3, 4);
image.data = new byte[] { 1, 5, 1, 1, 5, 1, 1, 5, 1, 1, 5, 1 };
WatershedVincentSoille1991 alg = new WatershedVincentSoille1991.Connect8();
alg.process(image);
assertEquals(3, alg.getTotalRegions());
GrayS32 found = alg.getOutput();
int a = found.get(0, 0);
int b = found.get(2, 0);
assertTrue(a > 0);
assertTrue(b > 0);
assertTrue(a != b);
for (int y = 0; y < image.height; y++) {
assertEquals(a, found.get(0, y));
assertEquals(0, found.get(1, y));
assertEquals(b, found.get(2, y));
}
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestImageSegmentationOps method regionPixelId_to_Compact.
private void regionPixelId_to_Compact(GrayS32 graph, GrayS32 output) {
GrayS32 input = new GrayS32(4, 5);
input.data = new int[] { 2, 2, 2, 5, 5, 5, 5, 5, 2, 2, 2, 2, 15, 15, 15, 15, 15, 15, 15, 15 };
// graph might be a sub-image
for (int y = 0; y < graph.height; y++) {
for (int x = 0; x < graph.width; x++) {
graph.set(x, y, adjust(input.get(x, y), graph));
}
}
GrowQueue_I32 rootNodes = new GrowQueue_I32();
rootNodes.add(adjust(2, graph));
rootNodes.add(adjust(5, graph));
rootNodes.add(adjust(15, graph));
ImageSegmentationOps.regionPixelId_to_Compact(graph, rootNodes, output);
GrayS32 expected = new GrayS32(4, 5);
expected.data = new int[] { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2 };
BoofTesting.assertEquals(expected, output, 1e-4);
}
Aggregations