Search in sources :

Example 11 with Kernel2D_F32

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

the class GeneralSearchLocalPeakChecks method gaussian.

@Test
public void gaussian() {
    ImageMiscOps.fill(image, 0);
    Kernel2D_F32 k = FactoryKernelGaussian.gaussian(2, true, 32, -1, 5);
    int cx = 12;
    int cy = 15;
    for (int j = 0; j < 11; j++) {
        for (int i = 0; i < 11; i++) {
            image.set(i + cx - 5, j + cy - 5, k.get(i, j));
        }
    }
    SearchLocalPeak<GrayF32> search = createSearch(imageType);
    search.setImage(image);
    search.setSearchRadius(5);
    searchSolution(cx, cy, search);
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) GrayF32(boofcv.struct.image.GrayF32) Test(org.junit.Test)

Example 12 with Kernel2D_F32

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

the class TestFactoryConvolve method convolve2D_F32.

@Test
public void convolve2D_F32() {
    Kernel2D_F32 kernel = FactoryKernel.random2D_F32(kernelWidth, radius, 1, 6, rand);
    ConvolveInterface<GrayF32, GrayF32> conv;
    GrayF32 input = new GrayF32(width, height);
    GrayF32 found = new GrayF32(width, height);
    GrayF32 expected = new GrayF32(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 5);
    // CHECK NO BORDER
    conv = FactoryConvolve.convolve(kernel, GrayF32.class, GrayF32.class, BorderType.SKIP);
    conv.process(input, found);
    ConvolveImageNoBorder.convolve(kernel, input, expected);
    BoofTesting.assertEquals(expected, found, 1e-4f);
    // CHECK EXTENDED
    conv = FactoryConvolve.convolve(kernel, GrayF32.class, GrayF32.class, BorderType.EXTENDED);
    conv.process(input, found);
    ConvolveImage.convolve(kernel, input, expected, new ImageBorder1D_F32(BorderIndex1D_Extend.class));
    BoofTesting.assertEquals(expected, found, 1e-4f);
    // CHECK NORMALIZED
    conv = FactoryConvolve.convolve(kernel, GrayF32.class, GrayF32.class, BorderType.NORMALIZED);
    conv.process(input, found);
    ConvolveImageNormalized.convolve(kernel, input, expected);
    BoofTesting.assertEquals(expected, found, 1e-4f);
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) ImageBorder1D_F32(boofcv.core.image.border.ImageBorder1D_F32) BorderIndex1D_Extend(boofcv.core.image.border.BorderIndex1D_Extend) Test(org.junit.Test)

Example 13 with Kernel2D_F32

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

the class TestFactoryConvolveDown method convolve2D_F32.

@Test
public void convolve2D_F32() {
    Kernel2D_F32 kernel = FactoryKernel.random2D_F32(kernelWidth, radius, 1, 6, rand);
    FilterImageInterface<GrayF32, GrayF32> conv;
    GrayF32 input = new GrayF32(width, height);
    GrayF32 found = new GrayF32(width / skip, height / skip);
    GrayF32 expected = new GrayF32(width / skip, height / skip);
    ImageMiscOps.fillUniform(input, rand, 0, 5);
    // CHECK NO BORDER
    conv = FactoryConvolveDown.convolveSB(kernel, BorderType.SKIP, skip, GrayF32.class, GrayF32.class);
    conv.process(input, found);
    ConvolveImageDownNoBorder.convolve(kernel, input, expected, skip);
    BoofTesting.assertEquals(expected, found, 1e-4f);
    // CHECK EXTENDED
    // conv = FactoryConvolveDown.convolve( kernel,GrayF32.class,GrayF32.class,BorderType.EXTENDED);
    // conv.process(input,found);
    // ConvolveWithBorder.convolve(kernel,input,expected);
    // BoofTesting.assertEquals(expected,found,0,1e-4f);
    // CHECK NORMALIZED
    conv = FactoryConvolveDown.convolveSB(kernel, BorderType.NORMALIZED, skip, GrayF32.class, GrayF32.class);
    conv.process(input, found);
    ConvolveImageDownNormalized.convolve(kernel, input, expected, skip);
    BoofTesting.assertEquals(expected, found, 1e-4f);
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) Test(org.junit.Test)

Example 14 with Kernel2D_F32

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

the class TestDerivativeIntegralImage method kernelHaarY.

@Test
public void kernelHaarY() {
    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++) {
        int size = i * 2;
        IntegralKernel kernelI = DerivativeIntegralImage.kernelHaarY(size, null);
        Kernel2D_F32 kernel = createHaarX(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 15 with Kernel2D_F32

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

the class TestDerivativeIntegralImage method kernelDerivY.

@Test
public void kernelDerivY() {
    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.kernelDerivY(r, null);
        Kernel2D_F32 kernel = createDerivX(r);
        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