Search in sources :

Example 21 with ImageBorder_F32

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

the class TestDerivativeIntegralImage method kernelHaarX.

@Test
public void kernelHaarX() {
    GrayF32 orig = new GrayF32(width, height);
    GrayF32 integral = new GrayF32(width, height);
    ImageMiscOps.fillUniform(orig, rand, 0, 20);
    GrayF32 expected = new GrayF32(width, height);
    GrayF32 found = new GrayF32(width, height);
    IntegralImageOps.transform(orig, integral);
    ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
    for (int r = 1; r < 5; r++) {
        IntegralKernel kernelI = DerivativeIntegralImage.kernelHaarX(r, null);
        Kernel2D_F32 kernel = createHaarX(r);
        ConvolveImage.convolve(kernel, orig, expected, border);
        IntegralImageOps.convolve(integral, kernelI, found);
        BoofTesting.assertEquals(expected, found, 1e-2);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 22 with ImageBorder_F32

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

the class TestDerivativeIntegralImage method kernelDerivYY.

@Test
public void kernelDerivYY() {
    GrayF32 orig = new GrayF32(width, height);
    GrayF32 integral = new GrayF32(width, height);
    ImageMiscOps.fillUniform(orig, rand, 0, 20);
    GrayF32 expected = new GrayF32(width, height);
    GrayF32 found = new GrayF32(width, height);
    IntegralImageOps.transform(orig, integral);
    ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
    for (int i = 1; i <= 5; i += 2) {
        int size = i * 3;
        IntegralKernel kernelI = DerivativeIntegralImage.kernelDerivYY(size, null);
        Kernel2D_F32 kernel = createDerivXX(size);
        kernel = KernelMath.transpose(kernel);
        ConvolveImage.convolve(kernel, orig, expected, border);
        IntegralImageOps.convolve(integral, kernelI, found);
        BoofTesting.assertEquals(expected, found, 1e-2);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 23 with ImageBorder_F32

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

the class TestDerivativeIntegralImage method kernelDerivX.

@Test
public void kernelDerivX() {
    GrayF32 orig = new GrayF32(width, height);
    GrayF32 integral = new GrayF32(width, height);
    ImageMiscOps.fillUniform(orig, rand, 0, 20);
    GrayF32 expected = new GrayF32(width, height);
    GrayF32 found = new GrayF32(width, height);
    IntegralImageOps.transform(orig, integral);
    ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
    for (int r = 1; r < 5; r++) {
        IntegralKernel kernelI = DerivativeIntegralImage.kernelDerivX(r, null);
        Kernel2D_F32 kernel = createDerivX(r);
        ConvolveImage.convolve(kernel, orig, expected, border);
        IntegralImageOps.convolve(integral, kernelI, found);
        BoofTesting.assertEquals(expected, found, 1e-2);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Example 24 with ImageBorder_F32

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

the class ImplBilinearPixel_F32 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_F32 border = (ImageBorder_F32) 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_F32(boofcv.core.image.border.ImageBorder_F32)

Example 25 with ImageBorder_F32

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

the class TestGradientPrewitt method compareToConvolve_F32.

@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
    CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
    validator.setTarget(GradientPrewitt.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
    validator.setKernel(0, GradientPrewitt.kernelDerivX_F32);
    validator.setKernel(1, GradientPrewitt.kernelDerivY_F32);
    GrayF32 input = new GrayF32(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 10);
    GrayF32 derivX = new GrayF32(width, height);
    GrayF32 derivY = new GrayF32(width, height);
    validator.compare(input, derivX, derivY);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) ImageBorder_F32(boofcv.core.image.border.ImageBorder_F32) Test(org.junit.Test)

Aggregations

ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)29 GrayF32 (boofcv.struct.image.GrayF32)20 Test (org.junit.Test)16 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)7 ImageBorder_S32 (boofcv.core.image.border.ImageBorder_S32)2 ScalePoint (boofcv.struct.feature.ScalePoint)2 GrayS16 (boofcv.struct.image.GrayS16)2 ImageGray (boofcv.struct.image.ImageGray)2 Point2D_I16 (georegression.struct.point.Point2D_I16)2 QueueCorner (boofcv.struct.QueueCorner)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Random (java.util.Random)1