Search in sources :

Example 6 with Kernel1D

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

the class TestConvolveImageStandard_SB method verticalDiv.

/**
 * Unit test for vertical convolution with division.
 */
public void verticalDiv(ImageGray img, ImageGray dest) {
    Kernel1D ker = FactoryKernel.createKernelForImage(kernelWidth, kernelRadius, 1, img.getClass());
    // standard symmetric odd kernel shape
    ker = FactoryKernel.random(ker.getClass(), kernelWidth, kernelRadius, 0, maxKernelValue, rand);
    checkVerticalDiv(ker, img, dest);
    // odd non-symmetric kernel shape
    ker = FactoryKernel.random(ker.getClass(), kernelWidth, 0, 0, maxKernelValue, rand);
    checkVerticalDiv(ker, img, dest);
    // even non-symmetric kernel shape
    ker = FactoryKernel.random(ker.getClass(), 2, 1, 0, maxKernelValue, rand);
    checkVerticalDiv(ker, img, dest);
}
Also used : Kernel1D(boofcv.struct.convolve.Kernel1D)

Example 7 with Kernel1D

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

the class TestImageLocalNormalization method zeroMeanStdOne_kernel.

@Test
public void zeroMeanStdOne_kernel() {
    for (Class type : types) {
        int bits = type == GrayF32.class ? 32 : 64;
        Kernel1D kernel = FactoryKernelGaussian.gaussian(1, true, bits, -1, radius);
        GrayF input = (GrayF) GeneralizedImageOps.createSingleBand(type, width, height);
        GrayF found = (GrayF) GeneralizedImageOps.createSingleBand(type, width, height);
        GImageMiscOps.fillUniform(input, rand, 0, maxPixelValue);
        ImageLocalNormalization alg = new ImageLocalNormalization(type, BorderType.NORMALIZED);
        alg.zeroMeanStdOne(kernel, input, maxPixelValue, delta, found);
        compareToExpected(input, kernel, found);
    }
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel1D(boofcv.struct.convolve.Kernel1D) GrayF(boofcv.struct.image.GrayF) Test(org.junit.Test)

Example 8 with Kernel1D

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

the class TestImageLocalNormalization method zeroMeanStdOne.

@Test
public void zeroMeanStdOne() {
    Kernel1D kernel = FactoryKernel.table1D_F64(radius, false);
    for (Class type : types) {
        GrayF input = (GrayF) GeneralizedImageOps.createSingleBand(type, width, height);
        GrayF found = (GrayF) GeneralizedImageOps.createSingleBand(type, width, height);
        GImageMiscOps.fillUniform(input, rand, 0, maxPixelValue);
        ImageLocalNormalization alg = new ImageLocalNormalization(type, BorderType.NORMALIZED);
        alg.zeroMeanStdOne(radius, input, maxPixelValue, delta, found);
        compareToExpected(input, kernel, found);
    }
}
Also used : Kernel1D(boofcv.struct.convolve.Kernel1D) GrayF(boofcv.struct.image.GrayF) Test(org.junit.Test)

Example 9 with Kernel1D

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

the class FactoryPyramid method discreteGaussian.

/**
 * Creates an updater for discrete pyramids where a Gaussian is convolved across the input
 * prior to sub-sampling.
 *
 * @param imageType Type of input image.
 * @param sigma Gaussian sigma.  If < 0 then a sigma is selected using the radius.  Try -1.
 * @param radius Radius of the Gaussian kernel.  If < 0 then the radius is selected using sigma. Try 2.
 * @return PyramidDiscrete
 */
public static <T extends ImageBase<T>> PyramidDiscrete<T> discreteGaussian(int[] scaleFactors, double sigma, int radius, boolean saveOriginalReference, ImageType<T> imageType) {
    Class<Kernel1D> kernelType = FactoryKernel.getKernelType(imageType.getDataType(), 1);
    Kernel1D kernel = FactoryKernelGaussian.gaussian(kernelType, sigma, radius);
    return new PyramidDiscreteSampleBlur<>(kernel, sigma, imageType, saveOriginalReference, scaleFactors);
}
Also used : Kernel1D(boofcv.struct.convolve.Kernel1D) PyramidDiscreteSampleBlur(boofcv.alg.transform.pyramid.PyramidDiscreteSampleBlur)

Example 10 with Kernel1D

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

the class NoCacheScaleSpace method setActiveScale.

@Override
public void setActiveScale(int index) {
    this.currentScale = index;
    double sigma = scales[index];
    int radius = FactoryKernelGaussian.radiusForSigma(sigma, 0);
    Kernel1D kernel = FactoryKernelGaussian.gaussian1D(inputType, sigma, radius);
    ImageType<I> _imageType = ImageType.single(inputType);
    ConvolveInterface<I, I> blurX = FactoryConvolve.convolve(kernel, _imageType, _imageType, borderBlur, true);
    ConvolveInterface<I, I> blurY = FactoryConvolve.convolve(kernel, _imageType, _imageType, borderBlur, false);
    // compute the scale image
    blurX.process(originalImage, workImage);
    blurY.process(workImage, scaledImage);
    anyDeriv.setInput(scaledImage);
}
Also used : Kernel1D(boofcv.struct.convolve.Kernel1D)

Aggregations

Kernel1D (boofcv.struct.convolve.Kernel1D)17 Kernel2D (boofcv.struct.convolve.Kernel2D)3 FDistort (boofcv.abst.distort.FDistort)2 GrayF (boofcv.struct.image.GrayF)2 Test (org.junit.Test)2 SteerableKernel (boofcv.alg.filter.kernel.SteerableKernel)1 SteerableKernel_F32 (boofcv.alg.filter.kernel.impl.SteerableKernel_F32)1 SteerableKernel_I32 (boofcv.alg.filter.kernel.impl.SteerableKernel_I32)1 PyramidDiscreteSampleBlur (boofcv.alg.transform.pyramid.PyramidDiscreteSampleBlur)1 KernelBase (boofcv.struct.convolve.KernelBase)1 GrayF32 (boofcv.struct.image.GrayF32)1 ImageGray (boofcv.struct.image.ImageGray)1 BufferedImage (java.awt.image.BufferedImage)1