Search in sources :

Example 11 with Kernel1D_S32

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

the class ConvolveImageMean method vertical.

/**
 * Performs a vertical 1D mean box filter. Outside pixels are specified by a border.
 *
 * @param input The input image. Not modified.
 * @param output Where the resulting image is written to. Modified.
 * @param offset Start offset from pixel coordinate
 * @param binput Used to process image borders. If null borders are not processed.
 * @param work (Optional) Storage for work array
 */
public static void vertical(GrayS16 input, GrayI16 output, int offset, int length, @Nullable ImageBorder_S32<GrayS16> binput, @Nullable GrowArray<DogArray_I32> workspaces) {
    output.reshape(input);
    if (binput != null) {
        binput.setImage(input);
        Kernel1D_S32 kernel = FactoryKernel.table1D_S32(offset, length);
        ConvolveJustBorder_General_SB.vertical(kernel, binput, output, kernel.computeSum());
    }
    if (length <= input.height) {
        if (BoofConcurrency.USE_CONCURRENT) {
            ImplConvolveMean_MT.vertical(input, output, offset, length, workspaces);
        } else {
            ImplConvolveMean.vertical(input, output, offset, length, workspaces);
        }
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32)

Example 12 with Kernel1D_S32

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

the class ConvolveImageMean method vertical.

/**
 * Performs a vertical 1D mean box filter. Outside pixels are specified by a border.
 *
 * @param input The input image. Not modified.
 * @param output Where the resulting image is written to. Modified.
 * @param offset Start offset from pixel coordinate
 * @param binput Used to process image borders. If null borders are not processed.
 * @param work (Optional) Storage for work array
 */
public static void vertical(GrayU16 input, GrayI16 output, int offset, int length, @Nullable ImageBorder_S32<GrayU16> binput, @Nullable GrowArray<DogArray_I32> workspaces) {
    output.reshape(input);
    if (binput != null) {
        binput.setImage(input);
        Kernel1D_S32 kernel = FactoryKernel.table1D_S32(offset, length);
        ConvolveJustBorder_General_SB.vertical(kernel, binput, output, kernel.computeSum());
    }
    if (length <= input.height) {
        if (BoofConcurrency.USE_CONCURRENT) {
            ImplConvolveMean_MT.vertical(input, output, offset, length, workspaces);
        } else {
            ImplConvolveMean.vertical(input, output, offset, length, workspaces);
        }
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32)

Example 13 with Kernel1D_S32

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

the class TestConvolveImageStandardSparse method checkMethod.

private void checkMethod(Method method, int width, int height, int kernelOffset, int kernelWidth, Random rand) {
    GrayU8 seedImage = new GrayU8(width, height);
    ImageMiscOps.fillUniform(seedImage, rand, 0, 255);
    // creates a floating point image with integer elements
    GrayF32 floatImage = new GrayF32(width, height);
    ConvertImage.convert(seedImage, floatImage);
    sumKernelI32 = 0;
    kernelI32 = FactoryKernelGaussian.gaussian(Kernel1D_S32.class, -1, kernelWidth / 2);
    kernelF32 = new Kernel1D_F32(kernelI32.width);
    for (int i = 0; i < kernelI32.width; i++) {
        kernelF32.data[i] = kernelI32.data[i];
        sumKernelI32 += kernelI32.data[i];
    }
    kernelI32.offset = kernelOffset;
    kernelF32.offset = kernelOffset;
    boolean isFloatingKernel = method.getParameterTypes()[0] == Kernel1D_F32.class;
    boolean isDivisor = method.getParameterTypes().length != 6;
    expectedOutput = computeExpected(seedImage, !isFloatingKernel, isDivisor);
    ImageGray inputImage = GConvertImage.convert(floatImage, null, (Class) method.getParameterTypes()[2]);
    Object inputKernel = isFloatingKernel ? kernelF32 : kernelI32;
    Object inputStorage = isFloatingKernel ? new float[kernelI32.width] : new int[kernelI32.width];
    checkResults(method, inputKernel, inputImage, inputStorage);
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) GrayF32(boofcv.struct.image.GrayF32) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32) GrayU8(boofcv.struct.image.GrayU8) ImageGray(boofcv.struct.image.ImageGray)

Example 14 with Kernel1D_S32

use of boofcv.struct.convolve.Kernel1D_S32 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 GrayU8 gaussian(GrayU8 input, @Nullable GrayU8 output, double sigmaX, int radiusX, double sigmaY, int radiusY, @Nullable GrayU8 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_S32 kernelX = FactoryKernelGaussian.gaussian(Kernel1D_S32.class, sigmaX, radiusX);
        Kernel1D_S32 kernelY = sigmaX == sigmaY && radiusX == radiusY ? kernelX : FactoryKernelGaussian.gaussian(Kernel1D_S32.class, sigmaY, radiusY);
        ConvolveImageNormalized.horizontal(kernelX, input, storage);
        ConvolveImageNormalized.vertical(kernelY, storage, output);
    }
    return output;
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32)

Example 15 with Kernel1D_S32

use of boofcv.struct.convolve.Kernel1D_S32 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 InterleavedU16 gaussian(InterleavedU16 input, @Nullable InterleavedU16 output, double sigmaX, int radiusX, double sigmaY, int radiusY, @Nullable InterleavedU16 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_S32 kernelX = FactoryKernelGaussian.gaussian(Kernel1D_S32.class, sigmaX, radiusX);
        Kernel1D_S32 kernelY = sigmaX == sigmaY && radiusX == radiusY ? kernelX : FactoryKernelGaussian.gaussian(Kernel1D_S32.class, sigmaY, radiusY);
        ConvolveImageNormalized.horizontal(kernelX, input, storage);
        ConvolveImageNormalized.vertical(kernelY, storage, output);
    }
    return output;
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32)

Aggregations

Kernel1D_S32 (boofcv.struct.convolve.Kernel1D_S32)41 Test (org.junit.jupiter.api.Test)9 GrayU8 (boofcv.struct.image.GrayU8)7 Kernel1D_F32 (boofcv.struct.convolve.Kernel1D_F32)3 InterleavedU8 (boofcv.struct.image.InterleavedU8)3 GrayF32 (boofcv.struct.image.GrayF32)2 GrayS16 (boofcv.struct.image.GrayS16)2 FilterImageInterface (boofcv.abst.filter.FilterImageInterface)1 ImageBorder1D_S32 (boofcv.struct.border.ImageBorder1D_S32)1 Kernel2D_F32 (boofcv.struct.convolve.Kernel2D_F32)1 Kernel2D_S32 (boofcv.struct.convolve.Kernel2D_S32)1 GrayU16 (boofcv.struct.image.GrayU16)1 ImageGray (boofcv.struct.image.ImageGray)1 InterleavedU16 (boofcv.struct.image.InterleavedU16)1 Planar (boofcv.struct.image.Planar)1 Random (java.util.Random)1