Search in sources :

Example 11 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestDescribeImageDenseSift method checkSampleLocations.

/**
 * Checks to see if the returned location is actually where it sampled
 */
@Test
public void checkSampleLocations() {
    for (Class type : imageTypes) {
        ImageGray image = GeneralizedImageOps.createSingleBand(type, width, height);
        GImageMiscOps.fillUniform(image, rand, 0, 200);
        DescribeImageDense alg = createAlg(type, 8, 9);
        alg.process(image);
        List<Point2D_I32> locations = alg.getLocations();
        for (int i = 0; i < locations.size(); i++) {
            Point2D_I32 p = locations.get(i);
            TupleDesc_F64 expected = describe(p.x, p.y, image, alg);
            TupleDesc_F64 found = (TupleDesc_F64) alg.getDescriptions().get(i);
            for (int j = 0; j < expected.size(); j++) {
                assertEquals(expected.value[j], found.value[j], 1e-8);
            }
        }
    }
}
Also used : TupleDesc_F64(boofcv.struct.feature.TupleDesc_F64) Point2D_I32(georegression.struct.point.Point2D_I32) ImageGray(boofcv.struct.image.ImageGray) FactoryDescribeImageDense(boofcv.factory.feature.dense.FactoryDescribeImageDense) Test(org.junit.Test)

Example 12 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class Contour method copy.

public Contour copy() {
    Contour ret = new Contour();
    for (Point2D_I32 p : external) {
        ret.external.add(p.copy());
    }
    for (List<Point2D_I32> l : ret.internal) {
        List<Point2D_I32> a = new ArrayList<>();
        for (Point2D_I32 p : l) {
            a.add(p.copy());
        }
        internal.add(a);
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32)

Example 13 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestBinaryImageOps method labelToClusters.

@Test
public void labelToClusters() {
    FastQueue<Point2D_I32> queue = new FastQueue<>(16, Point2D_I32.class, true);
    GrayS32 labels = new GrayS32(4, 4);
    labels.data = new int[] { 1, 2, 3, 4, 5, 0, 2, 2, 3, 4, 4, 4, 0, 0, 0, 0 };
    List<List<Point2D_I32>> ret = BinaryImageOps.labelToClusters(labels, 5, queue);
    assertEquals(5, ret.size());
    assertEquals(1, ret.get(0).size());
    assertEquals(3, ret.get(1).size());
    assertEquals(2, ret.get(2).size());
    assertEquals(4, ret.get(3).size());
    assertEquals(1, ret.get(4).size());
}
Also used : FastQueue(org.ddogleg.struct.FastQueue) Point2D_I32(georegression.struct.point.Point2D_I32) List(java.util.List) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 14 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestLinearContourLabelChang2004 method print.

private void print(List<Point2D_I32> l, int w, int h) {
    GrayU8 img = new GrayU8(w, h);
    for (Point2D_I32 p : l) {
        img.set(p.x, p.y, 1);
    }
    img.print();
    System.out.println("------------------");
}
Also used : PackedSetsPoint2D_I32(boofcv.struct.PackedSetsPoint2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32) GrayU8(boofcv.struct.image.GrayU8)

Example 15 with Point2D_I32

use of georegression.struct.point.Point2D_I32 in project BoofCV by lessthanoptimal.

the class TestLinearContourLabelChang2004 method findContour4.

/**
 * Create an unordered list of all points in the internal and external contour
 */
private List<Point2D_I32> findContour4(GrayS32 labeled, int target) {
    List<Point2D_I32> list = new ArrayList<>();
    ImageBorder<GrayS32> border = FactoryImageBorder.singleValue(labeled, 0);
    for (int y = 0; y < labeled.height; y++) {
        for (int x = 0; x < labeled.width; x++) {
            if (target == labeled.get(x, y)) {
                boolean isContour = false;
                for (int i = 0; i < local.size(); i++) {
                    Point2D_I32 a = local.get(i);
                    if (get(border, x + a.x, y + a.y) != target) {
                        isContour = true;
                    }
                }
                if (isContour)
                    list.add(new Point2D_I32(x, y));
            }
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) PackedSetsPoint2D_I32(boofcv.struct.PackedSetsPoint2D_I32) Point2D_I32(georegression.struct.point.Point2D_I32) GrayS32(boofcv.struct.image.GrayS32)

Aggregations

Point2D_I32 (georegression.struct.point.Point2D_I32)153 Test (org.junit.Test)64 ArrayList (java.util.ArrayList)41 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)21 Point2D_F64 (georegression.struct.point.Point2D_F64)11 EdgeContour (boofcv.alg.feature.detect.edge.EdgeContour)8 GrayF32 (boofcv.struct.image.GrayF32)8 GrayS32 (boofcv.struct.image.GrayS32)7 Contour (boofcv.alg.filter.binary.Contour)6 TupleDesc_F64 (boofcv.struct.feature.TupleDesc_F64)6 GrayU8 (boofcv.struct.image.GrayU8)6 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)5 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)5 UtilPoint2D_I32 (georegression.geometry.UtilPoint2D_I32)4 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)4 EdgeSegment (boofcv.alg.feature.detect.edge.EdgeSegment)3 Corner (boofcv.alg.shapes.polyline.splitmerge.PolylineSplitMerge.Corner)3 FactoryDescribeImageDense (boofcv.factory.feature.dense.FactoryDescribeImageDense)3 PointIndex_I32 (boofcv.struct.PointIndex_I32)3 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)3