Search in sources :

Example 56 with ImageRectangle

use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.

the class TextureGrayTrackerObjectRectangleChecks method convexFill.

public static void convexFill(Polygon2D_I32 poly, GrayU8 image, double value) {
    int minX = Integer.MAX_VALUE;
    int maxX = Integer.MIN_VALUE;
    int minY = Integer.MAX_VALUE;
    int maxY = Integer.MIN_VALUE;
    for (int i = 0; i < poly.size(); i++) {
        Point2D_I32 p = poly.vertexes.data[i];
        if (p.y < minY) {
            minY = p.y;
        } else if (p.y > maxY) {
            maxY = p.y;
        }
        if (p.x < minX) {
            minX = p.x;
        } else if (p.x > maxX) {
            maxX = p.x;
        }
    }
    ImageRectangle bounds = new ImageRectangle(minX, minY, maxX, maxY);
    BoofMiscOps.boundRectangleInside(image, bounds);
    Point2D_F64 p = new Point2D_F64();
    Polygon2D_F64 poly64 = new Polygon2D_F64(4);
    for (int i = 0; i < 4; i++) poly64.vertexes.data[i].setTo(poly.vertexes.data[i].x, poly.vertexes.data[i].y);
    for (int y = bounds.y0; y < bounds.y1; y++) {
        p.y = y;
        for (int x = bounds.x0; x < bounds.x1; x++) {
            p.x = x;
            if (Intersection2D_F64.containsConvex(poly64, p)) {
                GeneralizedImageOps.set(image, x, y, value);
            }
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Point2D_I32(georegression.struct.point.Point2D_I32) ImageRectangle(boofcv.struct.ImageRectangle) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Example 57 with ImageRectangle

use of boofcv.struct.ImageRectangle in project BoofCV by lessthanoptimal.

the class VideoSequenceSimulator method convexFill.

private void convexFill(Polygon2D_I32 poly, ImageGray image, double value) {
    int minX = Integer.MAX_VALUE;
    int maxX = Integer.MIN_VALUE;
    int minY = Integer.MAX_VALUE;
    int maxY = Integer.MIN_VALUE;
    for (int i = 0; i < poly.size(); i++) {
        Point2D_I32 p = poly.vertexes.data[i];
        if (p.y < minY) {
            minY = p.y;
        } else if (p.y > maxY) {
            maxY = p.y;
        }
        if (p.x < minX) {
            minX = p.x;
        } else if (p.x > maxX) {
            maxX = p.x;
        }
    }
    ImageRectangle bounds = new ImageRectangle(minX, minY, maxX, maxY);
    BoofMiscOps.boundRectangleInside(image, bounds);
    Point2D_F64 p = new Point2D_F64();
    Polygon2D_F64 poly64 = new Polygon2D_F64(4);
    for (int i = 0; i < 4; i++) poly64.vertexes.data[i].setTo(poly.vertexes.data[i].x, poly.vertexes.data[i].y);
    for (int y = bounds.y0; y < bounds.y1; y++) {
        p.y = y;
        for (int x = bounds.x0; x < bounds.x1; x++) {
            p.x = x;
            if (Intersection2D_F64.containsConvex(poly64, p)) {
                GeneralizedImageOps.set(image, x, y, value);
            }
        }
    }
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Point2D_I32(georegression.struct.point.Point2D_I32) ImageRectangle(boofcv.struct.ImageRectangle) Polygon2D_F64(georegression.struct.shapes.Polygon2D_F64)

Aggregations

ImageRectangle (boofcv.struct.ImageRectangle)57 Test (org.junit.jupiter.api.Test)15 GrayU8 (boofcv.struct.image.GrayU8)12 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)5 ImageGray (boofcv.struct.image.ImageGray)5 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)4 GrayS32 (boofcv.struct.image.GrayS32)4 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)3 GImageGray (boofcv.core.image.GImageGray)3 Point2D_F64 (georegression.struct.point.Point2D_F64)3 Point2D_I32 (georegression.struct.point.Point2D_I32)3 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)3 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ImageBorder_S32 (boofcv.struct.border.ImageBorder_S32)2 Point2D_F32 (georegression.struct.point.Point2D_F32)2 Rectangle2D_F64 (georegression.struct.shapes.Rectangle2D_F64)1 DogArray (org.ddogleg.struct.DogArray)1 GrowQueue_F64 (org.ddogleg.struct.GrowQueue_F64)1