Search in sources :

Example 21 with GrowQueue_I32

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

the class TestContourEdgeIntensity method computeContourVertexes.

public static GrowQueue_I32 computeContourVertexes(RectangleLength2D_I32 r) {
    GrowQueue_I32 out = new GrowQueue_I32();
    out.add(r.width - 2);
    out.add(r.width + r.height - 3);
    out.add(2 * r.width + r.height - 4);
    out.add(2 * r.width + 2 * r.height - 5);
    return out;
}
Also used : GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32)

Example 22 with GrowQueue_I32

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

the class TestMergeRegionMeanShift method basicAll.

@Test
public void basicAll() {
    MergeRegionMeanShift alg = new MergeRegionMeanShift(1, 1);
    GrayS32 pixelToRegion = new GrayS32(4, 4);
    pixelToRegion.data = new int[] { 0, 0, 0, 1, 2, 0, 0, 1, 2, 0, 1, 1, 0, 0, 3, 1 };
    GrowQueue_I32 regionMemberCount = new GrowQueue_I32();
    regionMemberCount.data = new int[] { 1, 2, 3, 4 };
    regionMemberCount.size = 4;
    FastQueue<float[]> regionColor = createList(5, 1, 6, 4);
    FastQueue<Point2D_I32> modeLocation = new FastQueue<>(Point2D_I32.class, true);
    modeLocation.grow().set(0, 0);
    modeLocation.grow().set(3, 3);
    modeLocation.grow().set(0, 1);
    modeLocation.grow().set(2, 3);
    alg.process(pixelToRegion, regionMemberCount, regionColor, modeLocation);
    GrayS32 expectedP2R = new GrayS32(4, 4);
    expectedP2R.data = new int[] { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 2, 1 };
    int[] expectedCount = new int[] { 4, 2, 4 };
    for (int i = 0; i < expectedP2R.data.length; i++) assertEquals(expectedP2R.data[i], pixelToRegion.data[i]);
    for (int i = 0; i < expectedCount.length; i++) assertEquals(expectedCount[i], regionMemberCount.data[i]);
}
Also used : FastQueue(org.ddogleg.struct.FastQueue) Point2D_I32(georegression.struct.point.Point2D_I32) GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 23 with GrowQueue_I32

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

the class TestRegionMergeTree method setToRootNodeNewID.

@Test
public void setToRootNodeNewID() {
    GrowQueue_I32 regionMemberCount = new GrowQueue_I32(7);
    regionMemberCount.size = 7;
    regionMemberCount.data = new int[] { 1, 2, 3, 4, 5, 6, 7 };
    RegionMergeTree alg = new RegionMergeTree();
    alg.mergeList.resize(7);
    alg.mergeList.data = new int[] { 1, 1, 2, 2, 2, 2, 2 };
    alg.rootID.resize(7);
    alg.rootID.data = new int[] { 0, 0, 1, 0, 0, 0, 0 };
    alg.setToRootNodeNewID(regionMemberCount);
    int[] expectedCount = new int[] { 2, 3 };
    int[] expectedMerge = new int[] { 0, 0, 1, 1, 1, 1, 1 };
    assertEquals(2, regionMemberCount.size);
    for (int i = 0; i < expectedCount.length; i++) {
        assertEquals(expectedCount[i], regionMemberCount.data[i]);
    }
    for (int i = 0; i < expectedMerge.length; i++) assertEquals(expectedMerge[i], alg.mergeList.data[i]);
}
Also used : GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 24 with GrowQueue_I32

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

the class TestRegionMergeTree method flowIntoRootNode.

@Test
public void flowIntoRootNode() {
    RegionMergeTree alg = new RegionMergeTree();
    alg.mergeList.resize(7);
    alg.mergeList.data = new int[] { 1, 1, 2, 2, 2, 3, 5 };
    GrowQueue_I32 regionMemberCount = new GrowQueue_I32(7);
    regionMemberCount.size = 7;
    regionMemberCount.data = new int[] { 1, 2, 3, 4, 5, 6, 7 };
    alg.flowIntoRootNode(regionMemberCount);
    // check member count
    int[] expectedCount = new int[] { 1, 3, 3 + 4 + 5 + 6 + 7, 4, 5, 6, 7 };
    for (int i = 0; i < expectedCount.length; i++) assertEquals(expectedCount[i], regionMemberCount.data[i]);
    // check mergeList
    int[] expectedMerge = new int[] { 1, 1, 2, 2, 2, 2, 2 };
    for (int i = 0; i < expectedMerge.length; i++) assertEquals(expectedMerge[i], alg.mergeList.data[i]);
    // check root id
    assertEquals(0, alg.rootID.get(1));
    assertEquals(1, alg.rootID.get(2));
}
Also used : GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

Example 25 with GrowQueue_I32

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

the class TestSegmentMeanShiftSearchColor method simpleTest.

/**
 * Process a random image and do a basic sanity check on the output
 */
@Test
public void simpleTest() {
    Planar<GrayF32> image = new Planar<>(GrayF32.class, 20, 25, 2);
    GImageMiscOps.fillUniform(image, rand, 0, 256);
    SegmentMeanShiftSearchColor<Planar<GrayF32>> alg = new SegmentMeanShiftSearchColor<>(30, 0.05f, interp, 2, 2, 200, false, imageType);
    alg.process(image);
    FastQueue<Point2D_I32> locations = alg.getModeLocation();
    GrowQueue_I32 counts = alg.getRegionMemberCount();
    GrayS32 peaks = alg.getPixelToRegion();
    FastQueue<float[]> values = alg.getModeColor();
    // there should be a fair number of local peaks due to the image being random
    assertTrue(locations.size > 20);
    // all the lists should be the same size
    assertEquals(locations.size, counts.size);
    assertEquals(locations.size, values.size);
    // total members should equal the number of pixels
    int totalMembers = 0;
    for (int i = 0; i < counts.size; i++) {
        totalMembers += counts.get(i);
    }
    assertEquals(20 * 25, totalMembers);
    // see if the peak to index image is set up correctly and that all the peaks make sense
    for (int y = 0; y < peaks.height; y++) {
        for (int x = 0; x < peaks.width; x++) {
            int peak = peaks.get(x, y);
            // can't test the value because its floating point location which is interpolated using the kernel
            // and the location is lost
            // assertEquals(x+" "+y,computeValue(peakX,peakY,image),value,50);
            assertTrue(counts.get(peak) > 0);
        }
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Planar(boofcv.struct.image.Planar) Point2D_I32(georegression.struct.point.Point2D_I32) GrayS32(boofcv.struct.image.GrayS32) GrowQueue_I32(org.ddogleg.struct.GrowQueue_I32) Test(org.junit.Test)

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