use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestImageSegmentationOps method markRegionBorders2.
@Test
public void markRegionBorders2() {
GrayS32 input = new GrayS32(4, 5);
input.data = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
GrayU8 expected = new GrayU8(4, 5);
expected.data = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1 };
GrayU8 found = new GrayU8(4, 5);
ImageSegmentationOps.markRegionBorders(input, found);
BoofTesting.assertEquals(expected, found, 1e-4);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestSegmentFelzenszwalbHuttenlocher04 method find.
@Test
public void find() {
SegmentFelzenszwalbHuttenlocher04 alg = new SegmentFelzenszwalbHuttenlocher04(300, 20, null);
alg.graph = new GrayS32(4, 5);
alg.graph.data = new int[] { 2, 0, 2, 5, 3, 5, 4, 6, 2, 2, 2, 1, 15, 15, 15, 15, 15, 15, 15, 15 };
assertEquals(2, alg.find(11));
assertEquals(2, alg.graph.data[11]);
assertEquals(0, alg.graph.data[1]);
assertEquals(2, alg.find(2));
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestSegmentFelzenszwalbHuttenlocher04 method computeOutput.
@Test
public void computeOutput() {
SegmentFelzenszwalbHuttenlocher04 alg = new SegmentFelzenszwalbHuttenlocher04(300, 20, null);
alg.graph = new GrayS32(4, 5);
alg.graph.data = new int[] { 2, 0, 2, 5, 3, 5, 4, 6, 2, 2, 2, 1, 15, 15, 15, 15, 15, 15, 15, 15 };
for (int i = 0; i < alg.graph.data.length; i++) alg.regionSize.add(i + 1);
alg.computeOutput();
GrowQueue_I32 regionId = alg.getRegionId();
assertEquals(3, regionId.size);
assertEquals(2, regionId.get(0));
assertEquals(5, regionId.get(1));
assertEquals(15, regionId.get(2));
GrowQueue_I32 outputRegionSize = alg.getRegionSizes();
assertEquals(3, outputRegionSize.size);
assertEquals(3, outputRegionSize.get(0));
assertEquals(6, outputRegionSize.get(1));
assertEquals(16, outputRegionSize.get(2));
GrayS32 expected = new GrayS32(4, 5);
expected.data = new int[] { 2, 2, 2, 5, 5, 5, 5, 5, 2, 2, 2, 2, 15, 15, 15, 15, 15, 15, 15, 15 };
BoofTesting.assertEquals(expected, alg.graph, 1e-4);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestSegmentFelzenszwalbHuttenlocher04 method process.
/**
* Test it on a trivial segmentation problem
*/
@Test
public void process() {
GrayU8 image = new GrayU8(20, 25);
ImageMiscOps.fillRectangle(image, 100, 0, 0, 10, 25);
GrayS32 output = new GrayS32(20, 25);
// normal images
process(image, output);
// sub-images
process(BoofTesting.createSubImageOf(image), output);
}
use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.
the class TestSegmentFelzenszwalbHuttenlocher04 method mergeSmallRegions.
@Test
public void mergeSmallRegions() {
SegmentFelzenszwalbHuttenlocher04 alg = new SegmentFelzenszwalbHuttenlocher04(0, 10, null);
alg.regionSize.resize(20);
alg.regionSize.set(2, 10);
alg.regionSize.set(5, 20);
alg.regionSize.set(15, 9);
// regions: 2,5,15
alg.graph = new GrayS32(4, 5);
alg.graph.data = new int[] { 2, 0, 2, 5, 3, 5, 4, 6, 2, 2, 2, 1, 15, 15, 15, 15, 15, 15, 15, 15 };
alg.edgesNotMatched.add(new SegmentFelzenszwalbHuttenlocher04.Edge(1, 5));
alg.edgesNotMatched.add(new SegmentFelzenszwalbHuttenlocher04.Edge(12, 8));
alg.mergeSmallRegions();
// see if the regions were merged
assertEquals(15, alg.find(15));
assertEquals(15, alg.find(2));
assertEquals(5, alg.find(5));
}
Aggregations