use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestContourEdgeIntensity method computeContourVertexes.
public static GrowQueue_I32 computeContourVertexes(RectangleLength2D_I32 r) {
GrowQueue_I32 out = new GrowQueue_I32();
out.add(r.width - 2);
out.add(r.width + r.height - 3);
out.add(2 * r.width + r.height - 4);
out.add(2 * r.width + 2 * r.height - 5);
return out;
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestMergeRegionMeanShift method basicAll.
@Test
public void basicAll() {
MergeRegionMeanShift alg = new MergeRegionMeanShift(1, 1);
GrayS32 pixelToRegion = new GrayS32(4, 4);
pixelToRegion.data = new int[] { 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1, 0, 0, 3, 1 };
GrowQueue_I32 regionMemberCount = new GrowQueue_I32();
regionMemberCount.data = new int[] { 1, 2, 3, 4 };
regionMemberCount.size = 4;
FastQueue<float[]> regionColor = createList(5, 1, 6, 4);
FastQueue<Point2D_I32> modeLocation = new FastQueue<>(Point2D_I32.class, true);
modeLocation.grow().set(0, 0);
modeLocation.grow().set(3, 3);
modeLocation.grow().set(0, 1);
modeLocation.grow().set(2, 3);
alg.process(pixelToRegion, regionMemberCount, regionColor, modeLocation);
GrayS32 expectedP2R = new GrayS32(4, 4);
expectedP2R.data = new int[] { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 2, 1 };
int[] expectedCount = new int[] { 4, 2, 4 };
for (int i = 0; i < expectedP2R.data.length; i++) assertEquals(expectedP2R.data[i], pixelToRegion.data[i]);
for (int i = 0; i < expectedCount.length; i++) assertEquals(expectedCount[i], regionMemberCount.data[i]);
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestRegionMergeTree method setToRootNodeNewID.
@Test
public void setToRootNodeNewID() {
GrowQueue_I32 regionMemberCount = new GrowQueue_I32(7);
regionMemberCount.size = 7;
regionMemberCount.data = new int[] { 1, 2, 3, 4, 5, 6, 7 };
RegionMergeTree alg = new RegionMergeTree();
alg.mergeList.resize(7);
alg.mergeList.data = new int[] { 1, 1, 2, 2, 2, 2, 2 };
alg.rootID.resize(7);
alg.rootID.data = new int[] { 0, 0, 1, 0, 0, 0, 0 };
alg.setToRootNodeNewID(regionMemberCount);
int[] expectedCount = new int[] { 2, 3 };
int[] expectedMerge = new int[] { 0, 0, 1, 1, 1, 1, 1 };
assertEquals(2, regionMemberCount.size);
for (int i = 0; i < expectedCount.length; i++) {
assertEquals(expectedCount[i], regionMemberCount.data[i]);
}
for (int i = 0; i < expectedMerge.length; i++) assertEquals(expectedMerge[i], alg.mergeList.data[i]);
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestRegionMergeTree method flowIntoRootNode.
@Test
public void flowIntoRootNode() {
RegionMergeTree alg = new RegionMergeTree();
alg.mergeList.resize(7);
alg.mergeList.data = new int[] { 1, 1, 2, 2, 2, 3, 5 };
GrowQueue_I32 regionMemberCount = new GrowQueue_I32(7);
regionMemberCount.size = 7;
regionMemberCount.data = new int[] { 1, 2, 3, 4, 5, 6, 7 };
alg.flowIntoRootNode(regionMemberCount);
// check member count
int[] expectedCount = new int[] { 1, 3, 3 + 4 + 5 + 6 + 7, 4, 5, 6, 7 };
for (int i = 0; i < expectedCount.length; i++) assertEquals(expectedCount[i], regionMemberCount.data[i]);
// check mergeList
int[] expectedMerge = new int[] { 1, 1, 2, 2, 2, 2, 2 };
for (int i = 0; i < expectedMerge.length; i++) assertEquals(expectedMerge[i], alg.mergeList.data[i]);
// check root id
assertEquals(0, alg.rootID.get(1));
assertEquals(1, alg.rootID.get(2));
}
use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.
the class TestSegmentMeanShiftSearchColor method simpleTest.
/**
* Process a random image and do a basic sanity check on the output
*/
@Test
public void simpleTest() {
Planar<GrayF32> image = new Planar<>(GrayF32.class, 20, 25, 2);
GImageMiscOps.fillUniform(image, rand, 0, 256);
SegmentMeanShiftSearchColor<Planar<GrayF32>> alg = new SegmentMeanShiftSearchColor<>(30, 0.05f, interp, 2, 2, 200, false, imageType);
alg.process(image);
FastQueue<Point2D_I32> locations = alg.getModeLocation();
GrowQueue_I32 counts = alg.getRegionMemberCount();
GrayS32 peaks = alg.getPixelToRegion();
FastQueue<float[]> values = alg.getModeColor();
// there should be a fair number of local peaks due to the image being random
assertTrue(locations.size > 20);
// all the lists should be the same size
assertEquals(locations.size, counts.size);
assertEquals(locations.size, values.size);
// total members should equal the number of pixels
int totalMembers = 0;
for (int i = 0; i < counts.size; i++) {
totalMembers += counts.get(i);
}
assertEquals(20 * 25, totalMembers);
// see if the peak to index image is set up correctly and that all the peaks make sense
for (int y = 0; y < peaks.height; y++) {
for (int x = 0; x < peaks.width; x++) {
int peak = peaks.get(x, y);
// can't test the value because its floating point location which is interpolated using the kernel
// and the location is lost
// assertEquals(x+" "+y,computeValue(peakX,peakY,image),value,50);
assertTrue(counts.get(peak) > 0);
}
}
}
Aggregations