Search in sources :

Example 1 with ImageRectangle_F64

use of boofcv.struct.ImageRectangle_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);
}
Also used : ImageRectangle_F64(boofcv.struct.ImageRectangle_F64) RectangleLength2D_F64(georegression.struct.shapes.RectangleLength2D_F64)

Aggregations

ImageRectangle_F64 (boofcv.struct.ImageRectangle_F64)1 RectangleLength2D_F64 (georegression.struct.shapes.RectangleLength2D_F64)1