Search in sources :

Example 51 with GrayS32

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

the class GeneralImageSuperpixelsChecks method subimage.

/**
 * Make sure subimages produce the same results
 */
@Test
public void subimage() {
    for (ImageType<T> t : imageTypes) {
        // System.out.println("Image type "+t);
        ImageSuperpixels<T> alg = createAlg(t);
        T input = t.createImage(width, height);
        GrayS32 expected = new GrayS32(width, height);
        GImageMiscOps.fillUniform(input, rand, 0, 100);
        alg.segment(input, expected);
        // provide an output which is a sub-image
        GrayS32 found = new GrayS32(width + 3, height + 2).subimage(2, 1, width + 2, height + 1);
        alg.segment(input, found);
        BoofTesting.assertEquals(expected, found, 0);
        // Now make the input image an output
        input = BoofTesting.createSubImageOf(input);
        found = new GrayS32(width, height);
        alg.segment(input, found);
        BoofTesting.assertEquals(expected, found, 0);
    }
}
Also used : GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 52 with GrayS32

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

the class WaveletTransformOps method inverseN.

/**
 * <p>Performs a level N inverse fast wavelet transform (FWT).</p>
 *
 * <p>To save memory the input image is used to store intermediate results and is modified.</p>
 *
 * @param desc Description of the inverse wavelet.
 * @param input Input wavelet transform and is used as internal workspace. Modified.
 * @param output Reconstruction of original image. Modified.
 * @param storage Optional storage image.  Should be the same size as the input image. If null then
 * an image is declared internally.
 * @param numLevels Number of levels in the transform.
 * @param minValue Minimum allowed pixel value
 * @param maxValue Maximum allowed pixel value
 */
public static void inverseN(WaveletDescription<WlCoef_I32> desc, GrayS32 input, GrayS32 output, GrayS32 storage, int numLevels, int minValue, int maxValue) {
    if (numLevels == 1) {
        inverse1(desc, input, output, storage, minValue, maxValue);
        PixelMath.boundImage(output, minValue, maxValue);
        return;
    }
    UtilWavelet.checkShape(desc.getForward(), output, input, numLevels);
    storage = InputSanityCheck.checkDeclare(input, storage);
    // modify the shape of a temporary image not the original
    storage = storage.subimage(0, 0, input.width, input.height, null);
    storage.subImage = false;
    int width, height;
    int scale = UtilWavelet.computeScale(numLevels);
    width = input.width / scale;
    height = input.height / scale;
    width += width % 2;
    height += height % 2;
    GrayS32 levelIn = input.subimage(0, 0, width, height, null);
    GrayS32 levelOut = output.subimage(0, 0, width, height, null);
    storage.reshape(width, height);
    inverse1(desc, levelIn, levelOut, storage, Integer.MIN_VALUE, Integer.MAX_VALUE);
    for (int i = numLevels - 1; i >= 1; i--) {
        // copy the decoded segment into the input
        levelIn.setTo(levelOut);
        if (i > 1) {
            scale /= 2;
            width = input.width / scale;
            height = input.height / scale;
            width += width % 2;
            height += height % 2;
            storage.reshape(width, height);
            levelIn = input.subimage(0, 0, width, height, null);
            levelOut = output.subimage(0, 0, width, height, null);
        } else {
            levelIn = input;
            levelOut = output;
        }
        storage.reshape(levelIn.width, levelIn.height);
        inverse1(desc, levelIn, levelOut, storage, Integer.MIN_VALUE, Integer.MAX_VALUE);
    }
    if (minValue != Integer.MIN_VALUE && maxValue != Integer.MAX_VALUE)
        PixelMath.boundImage(output, minValue, maxValue);
}
Also used : GrayS32(boofcv.struct.image.GrayS32)

Example 53 with GrayS32

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

the class GenericBinaryContourFinder method saveInternal.

@Test
public void saveInternal() {
    GrayU8 input = TEST3.clone();
    GrayS32 labeled = input.createSameShape(GrayS32.class);
    BinaryContourFinder alg = create();
    alg.process(input, labeled);
    checkInternalSize(alg, 0, 0, 8);
    alg.setSaveInnerContour(false);
    alg.process(input, labeled);
    checkInternalSize(alg, 0, 0, 0);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 54 with GrayS32

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

the class GenericBinaryContourFinder method minContour.

@Test
public void minContour() {
    GrayU8 input = TEST3.clone();
    GrayS32 labeled = input.createSameShape(GrayS32.class);
    BinaryContourFinder alg = create();
    alg.setMinContour(1000);
    alg.process(input, labeled);
    assertEquals(1, alg.getContours().size());
    checkExternalSize(alg, 0, 0);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 55 with GrayS32

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

the class GenericBinaryContourFinder method connectRule.

@Test
public void connectRule() {
    GrayU8 input = TEST3.clone();
    GrayS32 labeled = input.createSameShape(GrayS32.class);
    BinaryContourFinder alg = create();
    alg.process(input, labeled);
    checkExternalSize(alg, 0, 10);
    alg.setConnectRule(ConnectRule.EIGHT);
    alg.process(input, labeled);
    checkExternalSize(alg, 0, 8);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) 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