Search in sources :

Example 21 with Kernel2D_F32

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

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

the class TestDerivativeIntegralImage method derivXY.

@Test
public void derivXY() {
    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);
    for (int i = 1; i <= 5; i += 2) {
        int size = i * 3;
        Kernel2D_F32 kernel = createDerivXY(size);
        ConvolveImageNoBorder.convolve(kernel, orig, expected);
        DerivativeIntegralImage.derivXY(integral, found, size);
        int r = size / 2;
        GrayF32 a = expected.subimage(r + 1, r + 1, expected.width - r, expected.height - r, null);
        GrayF32 b = found.subimage(r + 1, r + 1, found.width - r, found.height - r, null);
        BoofTesting.assertEquals(a, b, 1e-2);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) Test(org.junit.Test)

Example 23 with Kernel2D_F32

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

the class TestDerivativeIntegralImage method derivXX.

@Test
public void derivXX() {
    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);
    for (int i = 1; i <= 5; i += 2) {
        int size = i * 3;
        Kernel2D_F32 kernel = createDerivXX(size);
        ConvolveImageNoBorder.convolve(kernel, orig, expected);
        DerivativeIntegralImage.derivXX(integral, found, size);
        int r = size / 2;
        GrayF32 a = expected.subimage(r + 1, r + 1, expected.width - r, expected.height - r, null);
        GrayF32 b = found.subimage(r + 1, r + 1, found.width - r, found.height - r, null);
        BoofTesting.assertEquals(a, b, 1e-2);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) Test(org.junit.Test)

Example 24 with Kernel2D_F32

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

the class TestFactorySteerable method gaussian.

/**
 * Very basis tests to see if the algorithm explodes or not.
 */
@Test
public void gaussian() {
    for (int totalOrder = 1; totalOrder <= 4; totalOrder++) {
        for (int orderX = 0; orderX <= totalOrder; orderX++) {
            int orderY = totalOrder - orderX;
            SteerableKernel<Kernel2D_F32> alg = FactorySteerable.gaussian(Kernel2D_F32.class, orderX, orderY, -1, 10);
            Kernel2D_F32 k = alg.compute(0.1);
            // make sure its not zero.
            boolean notZero = false;
            for (int y = 0; y < k.width; y++) {
                for (int x = 0; x < k.width; x++) {
                    if (k.get(x, y) != 0)
                        notZero = true;
                }
            }
            assertTrue(notZero);
        }
    }
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) Test(org.junit.Test)

Example 25 with Kernel2D_F32

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

the class SteerableKernel_F32 method compute.

@Override
public Kernel2D_F32 compute(double angle) {
    // set the output to zero
    KernelMath.fill(output, 0);
    int N = output.width * output.width;
    for (int i = 0; i < basis.length; i++) {
        double c = coef.compute(angle, i);
        Kernel2D_F32 k = (Kernel2D_F32) basis[i];
        for (int j = 0; j < N; j++) {
            output.data[j] += (k.data[j]) * c;
        }
    }
    return output;
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32)

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