Search in sources :

Example 11 with Kernel1D_F32

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

the class SiftDetector method createSparseDerivatives.

/**
 * Define sparse image derivative operators.
 */
private void createSparseDerivatives() {
    Kernel1D_F32 kernelD = new Kernel1D_F32(new float[] { -1, 0, 1 }, 3);
    Kernel1D_F32 kernelDD = KernelMath.convolve1D_F32(kernelD, kernelD);
    Kernel2D_F32 kernelXY = KernelMath.convolve2D(kernelD, kernelD);
    derivXX = FactoryConvolveSparse.horizontal1D(GrayF32.class, kernelDD);
    derivXY = FactoryConvolveSparse.convolve2D(GrayF32.class, kernelXY);
    derivYY = FactoryConvolveSparse.vertical1D(GrayF32.class, kernelDD);
    ImageBorder<GrayF32> border = FactoryImageBorder.single(BorderType.EXTENDED, GrayF32.class);
    derivXX.setImageBorder(border);
    derivXY.setImageBorder(border);
    derivYY.setImageBorder(border);
}
Also used : Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) GrayF32(boofcv.struct.image.GrayF32) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32)

Example 12 with Kernel1D_F32

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

the class BlurImageOps method gaussian.

/**
 * Applies Gaussian blur.
 *
 * @param input Input image. Not modified.
 * @param output (Optional) Storage for output image, Can be null. Modified.
 * @param sigmaX Gaussian distribution's sigma along x-axis. If &le; 0 then will be selected based on radius.
 * @param radiusX Radius of the Gaussian blur function along x-axis. If &le; 0 then radius will be determined by sigma.
 * @param sigmaY Gaussian distribution's sigma along y-axis. If &le; 0 then will be selected based on radius.
 * @param radiusY Radius of the Gaussian blur function along y-axis. If &le; 0 then radius will be determined by sigma.
 * @param storage (Optional) Storage for intermediate results. Same size as input image. Can be null.
 * @return Output blurred image.
 */
public static InterleavedF32 gaussian(InterleavedF32 input, @Nullable InterleavedF32 output, double sigmaX, int radiusX, double sigmaY, int radiusY, @Nullable InterleavedF32 storage) {
    output = InputSanityCheck.declareOrReshape(input, output);
    storage = InputSanityCheck.declareOrReshape(input, storage);
    boolean processed = BOverrideBlurImageOps.invokeNativeGaussian(input, output, sigmaX, radiusX, sigmaY, radiusY, storage);
    if (!processed) {
        Kernel1D_F32 kernelX = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, sigmaX, radiusX);
        Kernel1D_F32 kernelY = sigmaX == sigmaY && radiusX == radiusY ? kernelX : FactoryKernelGaussian.gaussian(Kernel1D_F32.class, sigmaY, radiusY);
        ConvolveImageNormalized.horizontal(kernelX, input, storage);
        ConvolveImageNormalized.vertical(kernelY, storage, output);
    }
    return output;
}
Also used : Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32)

Example 13 with Kernel1D_F32

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

the class ConvolveImageBox method vertical.

/**
 * Performs a vertical 1D convolution of a box kernel across the image
 *
 * @param input The original image. Not modified.
 * @param output Where the resulting image is written to. Modified.
 * @param radius Kernel size.
 */
public static void vertical(GrayF32 input, GrayF32 output, int radius, @Nullable GrowArray<DogArray_F32> work) {
    InputSanityCheck.checkSameShape(input, output);
    Kernel1D_F32 kernel = FactoryKernel.table1D_F32(radius, false);
    ConvolveJustBorder_General_SB.vertical(kernel, ImageBorderValue.wrap(input, 0), output);
    if (BoofConcurrency.USE_CONCURRENT) {
        ImplConvolveBox_MT.vertical(input, output, radius, work);
    } else {
        ImplConvolveBox.vertical(input, output, radius, work);
    }
}
Also used : Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32)

Example 14 with Kernel1D_F32

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

the class ConvolveImageBox method horizontal.

/**
 * Performs a horizontal 1D convolution of a box kernel across the image
 *
 * @param input The original image. Not modified.
 * @param output Where the resulting image is written to. Modified.
 * @param radius Kernel size.
 */
public static void horizontal(GrayF32 input, GrayF32 output, int radius) {
    InputSanityCheck.checkSameShape(input, output);
    Kernel1D_F32 kernel = FactoryKernel.table1D_F32(radius, false);
    ConvolveJustBorder_General_SB.horizontal(kernel, ImageBorderValue.wrap(input, 0), output);
    if (BoofConcurrency.USE_CONCURRENT) {
        ImplConvolveBox_MT.horizontal(input, output, radius);
    } else {
        ImplConvolveBox.horizontal(input, output, radius);
    }
}
Also used : Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32)

Example 15 with Kernel1D_F32

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

the class BenchmarkImagePyramids method createUpdate.

private static void createUpdate() {
    Kernel1D_F32 kernel = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, -1.0, 2);
    pyramidD = new PyramidDiscreteSampleBlur<>(kernel, 2, ImageType.single(GrayF32.class), true, scalesD);
    pyramidF = FactoryPyramid.scaleSpacePyramid(scalesF, GrayF32.class);
}
Also used : GrayF32(boofcv.struct.image.GrayF32) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32)

Aggregations

Kernel1D_F32 (boofcv.struct.convolve.Kernel1D_F32)24 GrayF32 (boofcv.struct.image.GrayF32)10 Test (org.junit.jupiter.api.Test)7 Kernel1D_S32 (boofcv.struct.convolve.Kernel1D_S32)3 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)2 GrayU8 (boofcv.struct.image.GrayU8)2 ImageBorder1D_F32 (boofcv.struct.border.ImageBorder1D_F32)1 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)1 GrayS16 (boofcv.struct.image.GrayS16)1 ImageGray (boofcv.struct.image.ImageGray)1 AffineTransform (java.awt.geom.AffineTransform)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 Random (java.util.Random)1