Search in sources :

Example 51 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class GeneralSegmentSlicColorChecks method easyTest.

/**
 * Give it an easy image to segment and see how well it does.
 */
@Test
public void easyTest() {
    T input = imageType.createImage(30, 40);
    GrayS32 output = new GrayS32(30, 40);
    GImageMiscOps.fillRectangle(input, 100, 0, 0, 15, 40);
    SegmentSlic<T> alg = createAlg(12, 200, 10, ConnectRule.EIGHT);
    alg.process(input, output);
    GrowQueue_I32 memberCount = alg.getRegionMemberCount();
    checkUnique(alg, output, memberCount.size);
    // see if the member count is correctly computed
    GrowQueue_I32 foundCount = new GrowQueue_I32(memberCount.size);
    foundCount.resize(memberCount.size);
    ImageSegmentationOps.countRegionPixels(output, foundCount.size, foundCount.data);
    for (int i = 0; i < memberCount.size; i++) {
        assertEquals(memberCount.get(i), foundCount.get(i));
    }
}
Also used : GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 52 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class TestSegmentSlic method assignLabelsToPixels.

@Test
public void assignLabelsToPixels() {
    DummySlic alg = new DummySlic(4, 1, 10);
    SegmentSlic.Cluster c0 = alg.clusters.grow();
    SegmentSlic.Cluster c1 = alg.clusters.grow();
    SegmentSlic.Cluster c2 = alg.clusters.grow();
    c0.id = 0;
    c1.id = 1;
    c2.id = 2;
    alg.pixels.resize(6);
    alg.pixels.get(0).add(c0, 2);
    alg.pixels.get(0).add(c1, 4);
    alg.pixels.get(0).add(c2, 0.1f);
    alg.pixels.get(1).add(c1, 1);
    alg.pixels.get(1).add(c0, 2);
    for (int i = 2; i < 6; i++) {
        alg.pixels.get(i).add(c1, 0);
        alg.pixels.get(i).add(c2, 0.2f);
    }
    GrayS32 image = new GrayS32(2, 3);
    GrowQueue_I32 regionMemberCount = new GrowQueue_I32();
    FastQueue<float[]> regionColor = new ColorQueue_F32(1);
    alg.assignLabelsToPixels(image, regionMemberCount, regionColor);
    assertEquals(3, regionMemberCount.size);
    assertEquals(3, regionColor.size);
    assertEquals(0, regionMemberCount.get(0));
    assertEquals(5, regionMemberCount.get(1));
    assertEquals(1, regionMemberCount.get(2));
    assertEquals(2, image.get(0, 0));
    assertEquals(1, image.get(1, 0));
    for (int i = 2; i < 6; i++) {
        assertEquals(1, image.data[i]);
    }
}
Also used : ColorQueue_F32(boofcv.struct.feature.ColorQueue_F32) GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 53 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class TestComputeRegionMeanColor method before.

@Before
public void before() {
    segments = new GrayS32(w, h);
    segments.data = new int[] { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
    regionMemberCount = new GrowQueue_I32();
    for (int i = 0; i < 4; i++) regionMemberCount.add(5);
}
Also used : GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Before(org.junit.Before)

Example 54 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class DetectPolylineApp method detectorProcess.

@Override
protected void detectorProcess(ImageGray input, GrayU8 binary) {
    // System.out.println("processing image "+count++);
    binaryToContour.process(binary, labeled);
    contours = BinaryImageOps.convertContours(binaryToContour);
    int minContourPixels = minimumContourSize.computeI(Math.min(input.width, input.height));
    polylines.clear();
    GrowQueue_I32 indices = new GrowQueue_I32();
    for (int i = 0; i < contours.size(); i++) {
        List<Point2D_I32> contour = contours.get(i).external;
        if (contour.size() < minContourPixels)
            continue;
        if (contourToPolyline.process(contour, indices)) {
            List<Point2D_I32> l = new ArrayList<>();
            for (int j = 0; j < indices.size; j++) {
                l.add(contour.get(indices.get(j)));
            }
            polylines.add(l);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Point2D_I32(georegression.struct.point.Point2D_I32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 55 with GrowQueue_I32

use of org.ddogleg.struct.GrowQueue_I32 in project BoofCV by lessthanoptimal.

the class SplitMergeLineFitSegment method mergeSegments.

/**
 * Merges lines together which have an acute angle less than the threshold.
 * @return true the list being changed
 */
protected boolean mergeSegments() {
    // can't merge a single line
    if (splits.size <= 2)
        return false;
    boolean change = false;
    work.reset();
    // first point is always at the start
    work.add(splits.data[0]);
    for (int i = 0; i < splits.size - 2; i++) {
        if (selectSplitBetween(splits.data[i], splits.data[i + 2]) < 0) {
            // merge the two lines by not adding it
            change = true;
        } else {
            work.add(splits.data[i + 1]);
        }
    }
    // and end
    work.add(splits.data[splits.size - 1]);
    // swap the two lists
    GrowQueue_I32 tmp = work;
    work = splits;
    splits = tmp;
    return change;
}
Also used : GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Aggregations

GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)60 Test (org.junit.Test)35 Point2D_I32 (georegression.struct.point.Point2D_I32)21 GrayS32 (boofcv.struct.image.GrayS32)10 ArrayList (java.util.ArrayList)7 AssociatedIndex (boofcv.struct.feature.AssociatedIndex)6 Point2D_F64 (georegression.struct.point.Point2D_F64)5 FastQueue (org.ddogleg.struct.FastQueue)5 DetectDescribePoint (boofcv.abst.feature.detdesc.DetectDescribePoint)3 ColorQueue_F32 (boofcv.struct.feature.ColorQueue_F32)3 GrayF32 (boofcv.struct.image.GrayF32)3 GrowQueue_I8 (org.ddogleg.struct.GrowQueue_I8)3 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 BrightFeature (boofcv.struct.feature.BrightFeature)2 LineGeneral2D_F64 (georegression.struct.line.LineGeneral2D_F64)2 Point3D_F64 (georegression.struct.point.Point3D_F64)2 Se3_F64 (georegression.struct.se.Se3_F64)2 Polygon2D_F64 (georegression.struct.shapes.Polygon2D_F64)2 RectangleLength2D_I32 (georegression.struct.shapes.RectangleLength2D_I32)2 BufferedImage (java.awt.image.BufferedImage)2