use of georegression.struct.shapes.RectangleLength2D_F64 in project BoofCV by lessthanoptimal.
the class DistortImageOps method boundBox_F64.
/**
* Finds an axis-aligned bounding box which would contain a image after it has been transformed.
* The returned bounding box can be larger then the original image.
*
* @param srcWidth Width of the source image
* @param srcHeight Height of the source image
* @param transform Transform being applied to the image
* @return Bounding box
*/
public static RectangleLength2D_F64 boundBox_F64(int srcWidth, int srcHeight, PixelTransform2_F64 transform) {
ImageRectangle_F64 r = new ImageRectangle_F64();
r.x0 = r.y0 = Double.MAX_VALUE;
r.x1 = r.y1 = -Double.MAX_VALUE;
for (int y = 0; y < srcHeight; y++) {
transform.compute(0, y);
updateBoundBox(transform, r);
transform.compute(srcWidth, y);
updateBoundBox(transform, r);
}
for (int x = 0; x < srcWidth; x++) {
transform.compute(x, 0);
updateBoundBox(transform, r);
transform.compute(x, srcHeight);
updateBoundBox(transform, r);
}
return new RectangleLength2D_F64(r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0);
}
use of georegression.struct.shapes.RectangleLength2D_F64 in project BoofCV by lessthanoptimal.
the class TestDistortImageOps method boundBox_F64.
@Test
public void boundBox_F64() {
// basic sanity check
Affine2D_F64 affine = new Affine2D_F64(1, 0, 0, 1, 2, 3);
PixelTransformAffine_F64 transform = new PixelTransformAffine_F64(affine);
RectangleLength2D_F64 found = DistortImageOps.boundBox_F64(10, 20, transform);
assertEquals(2, found.x0, 1e-8);
assertEquals(3, found.y0, 1e-8);
assertEquals(10, found.width, 1e-8);
assertEquals(20, found.height, 1e-8);
}
Aggregations