Search in sources :

Example 11 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestLinearContourLabelChang2004 method test1_8.

@Test
public void test1_8() {
    GrayU8 input = TEST1.clone();
    GrayS32 labeled = new GrayS32(input.width, input.height);
    LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
    alg.process(input, labeled);
    assertEquals(1, alg.getContours().size);
    checkContour(alg, labeled, 8);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 12 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestLinearContourLabelChang2004 method test3_8.

@Test
public void test3_8() {
    GrayU8 input = TEST4.clone();
    GrayS32 labeled = new GrayS32(input.width, input.height);
    LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
    alg.process(input, labeled);
    assertEquals(1, alg.getContours().size);
    checkContour(alg, labeled, 8);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 13 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestLinearContourLabelChang2004 method test2_8.

@Test
public void test2_8() {
    GrayU8 input = TEST2.clone();
    GrayS32 labeled = new GrayS32(input.width, input.height);
    LinearContourLabelChang2004 alg = new LinearContourLabelChang2004(ConnectRule.EIGHT);
    alg.process(input, labeled);
    assertEquals(4, alg.getContours().size);
    checkContour(alg, labeled, 8);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 14 with GrayS32

use of boofcv.struct.image.GrayS32 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)

Example 15 with GrayS32

use of boofcv.struct.image.GrayS32 in project BoofCV by lessthanoptimal.

the class TestWaveletTransformInt method compareToWaveletTransformOps.

@Test
public void compareToWaveletTransformOps() {
    GrayS32 orig = new GrayS32(width, height);
    GImageMiscOps.fillUniform(orig, rand, 0, 20);
    GrayS32 origCopy = orig.clone();
    int N = 3;
    ImageDimension dimen = UtilWavelet.transformDimension(orig, N);
    GrayS32 found = new GrayS32(dimen.width, dimen.height);
    GrayS32 expected = new GrayS32(dimen.width, dimen.height);
    WaveletDescription<WlCoef_I32> desc = FactoryWaveletDaub.biorthogonal_I32(5, BorderType.REFLECT);
    GrayS32 storage = new GrayS32(dimen.width, dimen.height);
    WaveletTransformOps.transformN(desc, orig.clone(), expected, storage, N);
    WaveletTransformInt<GrayS32> alg = new WaveletTransformInt<>(desc, N, 0, 255, GrayS32.class);
    alg.transform(orig, found);
    // make sure the original input was not modified like it is in WaveletTransformOps
    BoofTesting.assertEquals(origCopy, orig, 0);
    // see if the two techniques produced the same results
    BoofTesting.assertEquals(expected, found, 0);
    // test inverse transform
    GrayS32 reconstructed = new GrayS32(width, height);
    alg.invert(found, reconstructed);
    BoofTesting.assertEquals(orig, reconstructed, 0);
    // make sure the input has not been modified
    BoofTesting.assertEquals(expected, found, 0);
}
Also used : WlCoef_I32(boofcv.struct.wavelet.WlCoef_I32) ImageDimension(boofcv.struct.image.ImageDimension) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Aggregations

GrayS32 (boofcv.struct.image.GrayS32)102 Test (org.junit.Test)79 GrayU8 (boofcv.struct.image.GrayU8)52 GrayF32 (boofcv.struct.image.GrayF32)13 GrowQueue_I32 (org.ddogleg.struct.GrowQueue_I32)10 Point2D_I32 (georegression.struct.point.Point2D_I32)7 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)4 GImageGray (boofcv.core.image.GImageGray)4 ImageGray (boofcv.struct.image.ImageGray)4 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)3 ImageDimension (boofcv.struct.image.ImageDimension)3 BufferedImage (java.awt.image.BufferedImage)3 FastQueue (org.ddogleg.struct.FastQueue)3 WatershedVincentSoille1991 (boofcv.alg.segmentation.watershed.WatershedVincentSoille1991)2 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ListDisplayPanel (boofcv.gui.ListDisplayPanel)2 ImageRectangle (boofcv.struct.ImageRectangle)2 PackedSetsPoint2D_I32 (boofcv.struct.PackedSetsPoint2D_I32)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2