use of georegression.struct.point.Point2D_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);
}
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestShapeFittingOps method createRectangle_I32.
public static List<Point2D_I32> createRectangle_I32(int width, int height, int numPoints) {
List<Point2D_I32> points = new ArrayList<>();
int length = width * 2 + height * 2 - 4;
for (int i = 0; i < numPoints; i++) {
int x = i * length / numPoints;
if (x < width) {
points.add(new Point2D_I32(x, 0));
} else if (x < width + height - 2) {
int y = x - width + 1;
points.add(new Point2D_I32(width - 1, y));
} else if (x < width * 2 + height - 2) {
int xx = x - width - height + 3;
points.add(new Point2D_I32(width - xx, height - 1));
} else {
int y = x - width * 2 - height + 4;
points.add(new Point2D_I32(0, height - y));
}
}
return points;
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestSplitMergeLineFitSegment method checkZeroOne.
/**
* Tests contours with zero and one points in them
*/
@Test
public void checkZeroOne() {
List<Point2D_I32> contour = new ArrayList<>();
SplitMergeLineFitSegment alg = new SplitMergeLineFitSegment(0.15, MIN_SPLIT, 100);
alg.process(contour, splits);
assertEquals(0, splits.size);
contour.add(new Point2D_I32(2, 3));
alg.process(contour, splits);
assertEquals(0, splits.size);
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestPackedSetsPoint2D_I32 method writeOverSet_badsize.
@Test
public void writeOverSet_badsize() {
PackedSetsPoint2D_I32 alg = new PackedSetsPoint2D_I32(6);
alg.grow();
for (int i = 0; i < 12; i++) {
alg.addPointToTail(1, i);
}
List<Point2D_I32> expected = new ArrayList<>();
for (int i = 0; i < 20; i++) {
expected.add(new Point2D_I32(3, i));
}
try {
alg.writeOverSet(0, expected);
fail("exception expected");
} catch (RuntimeException ignore) {
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestImageBase method indexToPixel.
@Test
public void indexToPixel() {
Dummy a = new Dummy();
a.startIndex = 7;
a.stride = 5;
a.width = 4;
a.height = 11;
Point2D_I32 p = a.indexToPixel(7 + 6 * 5 + 2);
assertEquals(2, p.x);
assertEquals(6, p.y);
}
Aggregations