Search in sources :

Example 6 with EdgeContour

use of boofcv.alg.feature.detect.edge.EdgeContour in project BoofCV by lessthanoptimal.

the class VisualizeBinaryData method renderContours.

public static BufferedImage renderContours(List<EdgeContour> edges, int[] colors, int width, int height, BufferedImage out) {
    if (out == null) {
        out = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    } else {
        Graphics2D g2 = out.createGraphics();
        g2.setColor(Color.BLACK);
        g2.fillRect(0, 0, width, height);
    }
    colors = checkColors(colors, edges.size());
    for (int i = 0; i < edges.size(); i++) {
        EdgeContour e = edges.get(i);
        int color = colors[i];
        for (EdgeSegment s : e.segments) {
            for (Point2D_I32 p : s.points) {
                out.setRGB(p.x, p.y, color);
            }
        }
    }
    return out;
}
Also used : EdgeSegment(boofcv.alg.feature.detect.edge.EdgeSegment) Point2D_I32(georegression.struct.point.Point2D_I32) EdgeContour(boofcv.alg.feature.detect.edge.EdgeContour)

Aggregations

EdgeContour (boofcv.alg.feature.detect.edge.EdgeContour)6 EdgeSegment (boofcv.alg.feature.detect.edge.EdgeSegment)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 Point2D_I32 (georegression.struct.point.Point2D_I32)3 BufferedImage (java.awt.image.BufferedImage)3 Contour (boofcv.alg.filter.binary.Contour)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)1 PointIndex_I32 (boofcv.struct.PointIndex_I32)1 GrayF32 (boofcv.struct.image.GrayF32)1 GrayS16 (boofcv.struct.image.GrayS16)1 GrayU8 (boofcv.struct.image.GrayU8)1 Random (java.util.Random)1