Search in sources :

Example 26 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestImplIntegralImageConvolve 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) ImageGray(boofcv.struct.image.ImageGray) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32) GrayS32(boofcv.struct.image.GrayS32)

Example 27 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestHessianFromGradient method hessianPrewitt_I8.

@Test
void hessianPrewitt_I8() throws NoSuchMethodException {
    CompareHessianToConvolution validator = new CompareHessianToConvolution();
    validator.setTarget(HessianFromGradient.class.getMethod("hessianPrewitt", GrayS16.class, GrayS16.class, GrayS16.class, GrayS16.class, GrayS16.class, ImageBorder_S32.class));
    validator.setKernel(0, GradientPrewitt.kernelDerivX_I32);
    validator.setKernel(1, GradientPrewitt.kernelDerivY_I32);
    GrayS16 derivX = new GrayS16(width, height);
    GrayS16 derivY = new GrayS16(width, height);
    ImageMiscOps.fillUniform(derivX, rand, -10, 10);
    ImageMiscOps.fillUniform(derivY, rand, -10, 10);
    GrayS16 derivXX = new GrayS16(width, height);
    GrayS16 derivYY = new GrayS16(width, height);
    GrayS16 derivXY = new GrayS16(width, height);
    validator.compare(derivX, derivY, derivXX, derivYY, derivXY);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32) Test(org.junit.jupiter.api.Test)

Example 28 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestHessianSobel method compareToConvolve_I8.

@Test
void compareToConvolve_I8() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(HessianSobel.class.getMethod("process", GrayU8.class, GrayS16.class, GrayS16.class, GrayS16.class, ImageBorder_S32.class));
    validator.setKernel(0, HessianSobel.kernelXX_I32);
    validator.setKernel(1, HessianSobel.kernelYY_I32);
    validator.setKernel(2, HessianSobel.kernelXY_I32);
    GrayU8 input = new GrayU8(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 10);
    GrayS16 derivXX = new GrayS16(width, height);
    GrayS16 derivYY = new GrayS16(width, height);
    GrayS16 derivXY = new GrayS16(width, height);
    validator.compare(input, derivXX, derivYY, derivXY);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32) Test(org.junit.jupiter.api.Test)

Example 29 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestHessianThreeDeterminant_Inner method hessianDetFromConv_U8_S16.

public static GrayS16 hessianDetFromConv_U8_S16(GrayU8 img) {
    ImageBorder_S32<GrayU8> border = (ImageBorder_S32) FactoryImageBorder.single(BorderType.EXTENDED, GrayU8.class);
    GrayS16 Lxx = new GrayS16(img.width, img.height);
    GrayS16 Lyy = new GrayS16(img.width, img.height);
    GrayS16 Lxy = new GrayS16(img.width, img.height);
    ConvolveImage.horizontal(HessianThree.kernelXXYY_I32, img, Lxx, border);
    ConvolveImage.vertical(HessianThree.kernelXXYY_I32, img, Lyy, border);
    ConvolveImage.convolve(HessianThree.kernelCross_I32, img, Lxy, border);
    GrayS16 expected = new GrayS16(img.width, img.height);
    for (int y = 0; y < img.height; y++) {
        for (int x = 0; x < img.width; x++) {
            expected.data[expected.getIndex(x, y)] = (short) (Lxx.get(x, y) * Lyy.get(x, y) - Lxy.get(x, y) * Lxy.get(x, y));
        }
    }
    return expected;
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32)

Example 30 with ImageBorder_S32

use of boofcv.struct.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestGradientSobel method compareToConvolve_I8.

@Test
void compareToConvolve_I8() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientSobel.class.getMethod("process", GrayU8.class, GrayS16.class, GrayS16.class, ImageBorder_S32.class));
    validator.setKernel(0, GradientSobel.kernelDerivX_I32);
    validator.setKernel(1, GradientSobel.kernelDerivY_I32);
    GrayU8 input = new GrayU8(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 10);
    GrayS16 derivX = new GrayS16(width, height);
    GrayS16 derivY = new GrayS16(width, height);
    validator.compare(input, derivX, derivY);
}
Also used : GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8) ImageBorder_S32(boofcv.struct.border.ImageBorder_S32) Test(org.junit.jupiter.api.Test)

Aggregations

ImageBorder_S32 (boofcv.struct.border.ImageBorder_S32)37 GrayS16 (boofcv.struct.image.GrayS16)23 GrayU8 (boofcv.struct.image.GrayU8)15 Test (org.junit.jupiter.api.Test)15 ImageGray (boofcv.struct.image.ImageGray)4 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 ImageRectangle (boofcv.struct.ImageRectangle)2 ImageBorder_F32 (boofcv.struct.border.ImageBorder_F32)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 GrayF32 (boofcv.struct.image.GrayF32)2 GrayS32 (boofcv.struct.image.GrayS32)2