use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestBinaryEllipseDetectorPixel method undistortContour_WithDistortion.
/**
* Undistort the image when distortion model is provided
*/
@Test
public void undistortContour_WithDistortion() {
List<Point2D_I32> input = new ArrayList<>();
FastQueue<Point2D_F64> output = new FastQueue<>(Point2D_F64.class, true);
for (int i = 0; i < 10; i++) {
input.add(new Point2D_I32(i, i));
}
BinaryEllipseDetectorPixel alg = new BinaryEllipseDetectorPixel();
alg.setLensDistortion(new PixelTransformAffine_F32(new Affine2D_F32(1, 0, 0, 1, 10.0f, 0)));
alg.undistortContour(input, output);
assertEquals(input.size(), output.size);
for (int i = 0; i < input.size(); i++) {
Point2D_I32 p = input.get(i);
assertEquals(p.x + 10, output.get(i).x, 1e-8);
assertEquals(p.y, output.get(i).y, 1e-8);
}
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestContourEdgeIntensity method smallContours.
@Test
public void smallContours() {
GrayU8 image = new GrayU8(200, 150);
RectangleLength2D_I32 r = new RectangleLength2D_I32(20, 25, 5, 4);
ImageMiscOps.fillRectangle(image, 200, r.x0, r.y0, r.width, r.height);
List<Point2D_I32> contour = rectToContour(r);
ContourEdgeIntensity<GrayU8> alg = new ContourEdgeIntensity<>(30, 2, 1.0, GrayU8.class);
alg.setImage(image);
alg.process(contour, true);
assertTrue(alg.getOutsideAverage() < 8);
assertTrue(alg.getInsideAverage() > 195);
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestContourEdgeIntensity method rectToContour.
public static List<Point2D_I32> rectToContour(RectangleLength2D_I32 r) {
List<Point2D_I32> contour = new ArrayList<>();
int x1 = r.x0 + r.width - 1;
int y1 = r.y0 + r.height - 1;
for (int i = 1; i < r.width; i++) {
contour.add(new Point2D_I32(r.x0 + i, r.y0));
}
for (int i = 1; i < r.height; i++) {
contour.add(new Point2D_I32(x1, r.y0 + i));
}
for (int i = 1; i < r.width; i++) {
contour.add(new Point2D_I32(x1 - i, y1));
}
for (int i = 1; i < r.height; i++) {
contour.add(new Point2D_I32(r.x0, y1 - i));
}
return contour;
}
use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.
the class TestContourEdgeIntensity method simpleCase.
@Test
public void simpleCase() {
GrayU8 image = new GrayU8(200, 150);
RectangleLength2D_I32 r = new RectangleLength2D_I32(20, 25, 30, 35);
ImageMiscOps.fillRectangle(image, 200, r.x0, r.y0, r.width, r.height);
List<Point2D_I32> contour = rectToContour(r);
ContourEdgeIntensity<GrayU8> alg = new ContourEdgeIntensity<>(20, 2, 1.0, GrayU8.class);
alg.setImage(image);
alg.process(contour, true);
assertTrue(alg.getOutsideAverage() < 8);
assertTrue(alg.getInsideAverage() > 195);
// test the CCW flag AND multiple calls
alg.process(contour, false);
assertTrue(alg.getOutsideAverage() > 195);
assertTrue(alg.getInsideAverage() < 8);
// change the number of contour samples
alg = new ContourEdgeIntensity<>(10, 2, 1.0, GrayU8.class);
alg.setImage(image);
alg.process(contour, true);
assertTrue(alg.getOutsideAverage() < 8);
assertTrue(alg.getInsideAverage() > 195);
// change the number of tangent samples
alg = new ContourEdgeIntensity<>(20, 1, 1.0, GrayU8.class);
alg.setImage(image);
alg.process(contour, true);
assertTrue(alg.getOutsideAverage() < 8);
assertTrue(alg.getInsideAverage() > 195);
}
use of georegression.struct.point.Point2D_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]);
}
Aggregations