Search in sources :

Example 21 with GrayS32

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

the class TestImplIntegralImageOps method convolve.

public void convolve(Method m) throws InvocationTargetException, IllegalAccessException {
    Kernel2D_S32 kernel = new Kernel2D_S32(3, new int[] { 1, 1, 1, 2, 2, 2, 1, 1, 1 });
    GrayU8 input = new GrayU8(width, height);
    GrayS32 expected = new GrayS32(width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 10);
    ImageBorder_S32 border = FactoryImageBorderAlgs.value(input, 0);
    ConvolveImage.convolve(kernel, input, expected, border);
    Class[] paramType = m.getParameterTypes();
    Class inputType = paramType[0];
    Class outputType = paramType[2];
    ImageGray inputII = GeneralizedImageOps.createSingleBand(inputType, width, height);
    ImageGray integral = GeneralizedImageOps.createSingleBand(outputType, width, height);
    ImageGray expectedII = GeneralizedImageOps.createSingleBand(outputType, width, height);
    ImageGray found = GeneralizedImageOps.createSingleBand(outputType, width, height);
    GConvertImage.convert(input, inputII);
    GConvertImage.convert(expected, expectedII);
    GIntegralImageOps.transform(inputII, integral);
    IntegralKernel kernelII = new IntegralKernel(2);
    kernelII.blocks[0] = new ImageRectangle(-2, -2, 1, 1);
    kernelII.blocks[1] = new ImageRectangle(-2, -1, 1, 0);
    kernelII.scales = new int[] { 1, 1 };
    m.invoke(null, integral, kernelII, found);
    BoofTesting.assertEqualsRelative(expected, found, 1e-4f);
}
Also used : Kernel2D_S32(boofcv.struct.convolve.Kernel2D_S32) IntegralKernel(boofcv.alg.transform.ii.IntegralKernel) ImageRectangle(boofcv.struct.ImageRectangle) GrayU8(boofcv.struct.image.GrayU8) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32) GrayS32(boofcv.struct.image.GrayS32)

Example 22 with GrayS32

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

the class TestImplIntegralImageOps method convolveBorder.

public void convolveBorder(Method m) throws InvocationTargetException, IllegalAccessException {
    Kernel2D_S32 kernel = new Kernel2D_S32(3, new int[] { 1, 1, 1, 2, 2, 2, 1, 1, 1 });
    GrayU8 input = new GrayU8(width, height);
    GrayS32 expected = new GrayS32(width, height);
    GImageMiscOps.fillUniform(input, rand, 0, 10);
    ImageBorder_S32 border = FactoryImageBorderAlgs.value(input, 0);
    ConvolveImage.convolve(kernel, input, expected, border);
    Class[] paramType = m.getParameterTypes();
    Class inputType = paramType[0];
    Class outputType = paramType[2];
    ImageGray inputII = GeneralizedImageOps.createSingleBand(inputType, width, height);
    ImageGray integral = GeneralizedImageOps.createSingleBand(outputType, width, height);
    ImageGray expectedII = GeneralizedImageOps.createSingleBand(outputType, width, height);
    ImageGray found = GeneralizedImageOps.createSingleBand(outputType, width, height);
    GConvertImage.convert(input, inputII);
    GConvertImage.convert(expected, expectedII);
    GIntegralImageOps.transform(inputII, integral);
    IntegralKernel kernelII = new IntegralKernel(2);
    kernelII.blocks[0] = new ImageRectangle(-2, -2, 1, 1);
    kernelII.blocks[1] = new ImageRectangle(-2, -1, 1, 0);
    kernelII.scales = new int[] { 1, 1 };
    m.invoke(null, integral, kernelII, found, 4, 5);
    BoofTesting.assertEqualsBorder(expected, found, 1e-4f, 4, 5);
}
Also used : Kernel2D_S32(boofcv.struct.convolve.Kernel2D_S32) IntegralKernel(boofcv.alg.transform.ii.IntegralKernel) ImageRectangle(boofcv.struct.ImageRectangle) GrayU8(boofcv.struct.image.GrayU8) GImageGray(boofcv.core.image.GImageGray) FactoryGImageGray(boofcv.core.image.FactoryGImageGray) ImageGray(boofcv.struct.image.ImageGray) ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32) GrayS32(boofcv.struct.image.GrayS32)

Example 23 with GrayS32

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

the class TestImplWaveletTransformNaive method testEncodeDecode_I32.

private void testEncodeDecode_I32(int widthOrig, int heightOrig, int widthOut, int heightOut) {
    GrayU8 orig = new GrayU8(widthOrig, heightOrig);
    ImageMiscOps.fillUniform(orig, rand, 0, 10);
    GrayS32 transformed = new GrayS32(widthOut, heightOut);
    GrayU8 reconstructed = new GrayU8(widthOrig, heightOrig);
    BoofTesting.checkSubImage(this, "checkTransforms_I", true, orig, transformed, reconstructed);
}
Also used : GrayU8(boofcv.struct.image.GrayU8) GrayS32(boofcv.struct.image.GrayS32)

Example 24 with GrayS32

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

the class TestImplIntegralImageFeatureIntensity method inner_S32.

/**
 * Compares the inner() function against the output from the naive function.
 */
@Test
public void inner_S32() {
    GrayS32 original = new GrayS32(width, height);
    GrayS32 integral = new GrayS32(width, height);
    GrayF32 found = new GrayF32(width, height);
    GrayF32 expected = new GrayF32(width, height);
    GImageMiscOps.fillUniform(original, rand, 0, 50);
    IntegralImageOps.transform(original, integral);
    int size = 9;
    int r = size / 2 + 1;
    r++;
    for (int skip = 1; skip <= 4; skip++) {
        found.reshape(width / skip, height / skip);
        expected.reshape(width / skip, height / skip);
        ImplIntegralImageFeatureIntensity.hessianNaive(integral, skip, size, expected);
        ImplIntegralImageFeatureIntensity.hessianInner(integral, skip, size, found);
        int w = found.width;
        int h = found.height;
        GrayF32 f = found.subimage(r + 1, r + 1, w - r, h - r, null);
        GrayF32 e = expected.subimage(r + 1, r + 1, w - r, h - r, null);
        BoofTesting.assertEquals(e, f, 1e-4f);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) GrayS32(boofcv.struct.image.GrayS32) Test(org.junit.Test)

Example 25 with GrayS32

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

the class TestIntegralImageFeatureIntensity method hessian_S32.

/**
 * Compares hessian intensity against a naive implementation
 */
@Test
public void hessian_S32() {
    GrayS32 original = new GrayS32(width, height);
    GrayS32 integral = new GrayS32(width, height);
    GrayF32 found = new GrayF32(width, height);
    GrayF32 expected = new GrayF32(width, height);
    GImageMiscOps.fillUniform(original, rand, 0, 50);
    IntegralImageOps.transform(original, integral);
    int size = 9;
    for (int skip = 1; skip <= 4; skip++) {
        found.reshape(width / skip, height / skip);
        expected.reshape(width / skip, height / skip);
        ImplIntegralImageFeatureIntensity.hessianNaive(integral, skip, size, expected);
        IntegralImageFeatureIntensity.hessian(integral, skip, size, found);
        BoofTesting.assertEquals(expected, found, 1e-4f);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) 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