Search in sources :

Example 16 with Kernel2D_F32

use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.

the class TestDerivativeIntegralImage method kernelDerivXY.

@Test
public void kernelDerivXY() {
    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.kernelDerivXY(size, null);
        Kernel2D_F32 kernel = createDerivXY(size);
        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 17 with Kernel2D_F32

use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.

the class TestDerivativeIntegralImage method createHaarX.

private Kernel2D_F32 createHaarX(int r) {
    int size = r * 2;
    // TODO kernels only support odd sizes right now...  change if that changes (remove +1)
    Kernel2D_F32 ret = new Kernel2D_F32(size + 1);
    for (int y = 1; y <= size; y++) {
        for (int x = 1; x <= r; x++) {
            ret.set(x, y, -1);
            ret.set(x + r, y, 1);
        }
    }
    return ret;
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32)

Example 18 with Kernel2D_F32

use of boofcv.struct.convolve.Kernel2D_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 19 with Kernel2D_F32

use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.

the class TestDerivativeIntegralImage method createDerivXX.

private Kernel2D_F32 createDerivXX(int size) {
    int blockW = size / 3;
    int blockH = size - blockW - 1;
    int borderY = (size - blockH) / 2;
    Kernel2D_F32 ret = new Kernel2D_F32(size);
    for (int y = borderY; y < size - borderY; y++) {
        for (int x = 0; x < blockW; x++) {
            ret.set(x, y, 1);
            ret.set(x + blockW * 2, y, 1);
        }
        for (int x = blockW; x < 2 * blockW; x++) {
            ret.set(x, y, -2);
        }
    }
    return ret;
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32)

Example 20 with Kernel2D_F32

use of boofcv.struct.convolve.Kernel2D_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)

Aggregations

Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)25 Test (org.junit.Test)15 GrayF32 (boofcv.struct.image.GrayF32)13 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)7 ImageFunctionSparse (boofcv.abst.filter.ImageFunctionSparse)1 ImageConvolveSparse (boofcv.abst.filter.convolve.ImageConvolveSparse)1 BorderIndex1D_Extend (boofcv.core.image.border.BorderIndex1D_Extend)1 ImageBorder1D_F32 (boofcv.core.image.border.ImageBorder1D_F32)1 Kernel1D_F32 (boofcv.struct.convolve.Kernel1D_F32)1 Kernel2D (boofcv.struct.convolve.Kernel2D)1