Search in sources :

Example 56 with GrayS32

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

the class TestImplSurfDescribeOps method gradientInner_I32.

@Test
public void gradientInner_I32() {
    GrayS32 ii = new GrayS32(width, height);
    GImageMiscOps.fillUniform(ii, rand, 0, 99);
    int r = 2;
    int w = r * 2 + 1;
    double[] expectedX = new double[w * w];
    double[] expectedY = new double[w * w];
    int[] foundX = new int[w * w];
    int[] foundY = new int[w * w];
    for (double scale = 0.2; scale <= 1.8; scale += 0.2) {
        ImplSurfDescribeOps.naiveGradient(ii, 10, 9, scale, w, 4 * scale, false, expectedX, expectedY);
        ImplSurfDescribeOps.gradientInner(ii, 10, 9, scale, w, 4 * scale, foundX, foundY);
        for (int i = 0; i < foundX.length; i++) {
            assertEquals("at " + i, expectedX[i], foundX[i], 1e-4);
            assertEquals("at " + i, expectedY[i], foundY[i], 1e-4);
        }
        for (int i = 0; i < foundX.length; i++) {
            assertTrue(foundX[i] != 0);
            assertTrue(foundY[i] != 0);
        }
    }
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 57 with GrayS32

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

the class GeneralImageSuperpixelsChecks method sequentialNumbers.

/**
 * Makes sure that there really are regions 0 N-1 in the output image
 */
@Test
public void sequentialNumbers() {
    for (ImageType<T> t : imageTypes) {
        ImageSuperpixels<T> alg = createAlg(t);
        T input = t.createImage(width, height);
        GrayS32 output = new GrayS32(width, height);
        GImageMiscOps.fillUniform(input, rand, 0, 100);
        alg.segment(input, output);
        int N = alg.getTotalSuperpixels();
        assertTrue(N > 2);
        boolean[] found = new boolean[N];
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                found[output.get(x, y)] = true;
            }
        }
        for (int i = 0; i < N; i++) {
            assertTrue(found[i]);
        }
    }
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 58 with GrayS32

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

the class GeneralImageSuperpixelsChecks method multipleCalls.

/**
 *	/**
 * Produces the same results when run multiple times
 */
@Test
public void multipleCalls() {
    for (ImageType<T> t : imageTypes) {
        ImageSuperpixels<T> alg = createAlg(t);
        T input = t.createImage(width, height);
        GrayS32 output = new GrayS32(width, height);
        GImageMiscOps.fillUniform(input, rand, 0, 100);
        alg.segment(input, output);
        GrayS32 output2 = new GrayS32(width, height);
        alg.segment(input, output2);
        for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
                assertEquals(output.get(x, y), output2.get(x, y));
            }
        }
    }
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 59 with GrayS32

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

the class GeneralImageSuperpixelsChecks method connectivity.

/**
 * Makes sure all pixels with the same label are connected
 */
@Test
public void connectivity() {
    for (ImageType<T> t : imageTypes) {
        // System.out.println("Image type "+t);
        ImageSuperpixels<T> alg = createAlg(t);
        T input = t.createImage(width, height);
        GrayS32 output = new GrayS32(width, height);
        GImageMiscOps.fillUniform(input, rand, 0, 100);
        alg.segment(input, output);
        assertTrue(alg.getTotalSuperpixels() > 4);
        GrayU8 binary = new GrayU8(width, height);
        boolean[] selected = new boolean[alg.getTotalSuperpixels()];
        for (int i = 0; i < alg.getTotalSuperpixels(); i++) {
            selected[i] = true;
            BinaryImageOps.labelToBinary(output, binary, selected);
            selected[i] = false;
            // the number of blobs should always be one
            ConnectRule rule = alg.getRule();
            assertEquals(1, BinaryImageOps.contour(binary, rule, null).size());
        }
    }
}
Also used : GrayU8(boofcv.struct.image.GrayU8) ConnectRule(boofcv.struct.ConnectRule) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 60 with GrayS32

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

the class GeneralImageSuperpixelsChecks method changeInImageSize.

/**
 * See if it won't blow up if input image size is changed
 */
@Test
public void changeInImageSize() {
    for (ImageType<T> t : imageTypes) {
        ImageSuperpixels<T> alg = createAlg(t);
        T input = t.createImage(width / 2, height / 2);
        GrayS32 output = new GrayS32(width / 2, height / 2);
        GImageMiscOps.fillUniform(input, rand, 0, 100);
        alg.segment(input, output);
        input = t.createImage(width, height);
        output = new GrayS32(width, height);
        alg.segment(input, output);
    }
}
Also used : 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