Search in sources :

Example 6 with ImageBorder_S32

use of boofcv.core.image.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class ImplBilinearPixel_U8 method get_border.

public float get_border(float x, float y) {
    float xf = (float) Math.floor(x);
    float yf = (float) Math.floor(y);
    int xt = (int) xf;
    int yt = (int) yf;
    float ax = x - xf;
    float ay = y - yf;
    ImageBorder_S32 border = (ImageBorder_S32) this.border;
    // (x,y)
    float val = (1.0f - ax) * (1.0f - ay) * border.get(xt, yt);
    // (x+1,y)
    val += ax * (1.0f - ay) * border.get(xt + 1, yt);
    // (x+1,y)
    ;
    // (x+1,y+1)
    val += ax * ay * border.get(xt + 1, yt + 1);
    // (x+1,y+1)
    ;
    // (x,y+1)
    val += (1.0f - ax) * ay * border.get(xt, yt + 1);
    // (x,y+1)
    ;
    return val;
}
Also used : ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32)

Example 7 with ImageBorder_S32

use of boofcv.core.image.border.ImageBorder_S32 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 8 with ImageBorder_S32

use of boofcv.core.image.border.ImageBorder_S32 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 9 with ImageBorder_S32

use of boofcv.core.image.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestGradientThree method compareToConvolve_I16.

@Test
public void compareToConvolve_I16() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientThree.class.getMethod("process", GrayS16.class, GrayS16.class, GrayS16.class, ImageBorder_S32.class));
    validator.setKernel(0, GradientThree.kernelDeriv_I32, true);
    validator.setKernel(1, GradientThree.kernelDeriv_I32, false);
    GrayS16 input = new GrayS16(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) ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32) Test(org.junit.Test)

Example 10 with ImageBorder_S32

use of boofcv.core.image.border.ImageBorder_S32 in project BoofCV by lessthanoptimal.

the class TestGradientTwo0 method compareToConvolve_I16.

@Test
public void compareToConvolve_I16() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientTwo0.class.getMethod("process", GrayS16.class, GrayS16.class, GrayS16.class, ImageBorder_S32.class));
    validator.setKernel(0, GradientTwo0.kernelDeriv_I32, true);
    validator.setKernel(1, GradientTwo0.kernelDeriv_I32, false);
    GrayS16 input = new GrayS16(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) ImageBorder_S32(boofcv.core.image.border.ImageBorder_S32) Test(org.junit.Test)

Aggregations

ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)28 GrayS16 (boofcv.struct.image.GrayS16)15 Test (org.junit.Test)13 GrayU8 (boofcv.struct.image.GrayU8)8 ImageGray (boofcv.struct.image.ImageGray)4 IntegralKernel (boofcv.alg.transform.ii.IntegralKernel)2 FactoryGImageGray (boofcv.core.image.FactoryGImageGray)2 GImageGray (boofcv.core.image.GImageGray)2 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 ImageRectangle (boofcv.struct.ImageRectangle)2 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)2 GrayF32 (boofcv.struct.image.GrayF32)2 GrayS32 (boofcv.struct.image.GrayS32)2