Search in sources :

Example 21 with Kernel1D_S32

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

the class ConvolveImageMean method vertical.

/**
 * Performs a vertical 1D convolution which computes the mean value of elements
 * inside the kernel.
 *
 * @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(GrayU8 input, GrayI8 output, int radius) {
    boolean processed = BOverrideConvolveImageMean.invokeNativeVertical(input, output, radius);
    if (!processed) {
        Kernel1D_S32 kernel = FactoryKernel.table1D_I32(radius);
        if (kernel.width > input.height) {
            ConvolveImageNormalized.vertical(kernel, input, output);
        } else {
            InputSanityCheck.checkSameShape(input, output);
            ConvolveNormalized_JustBorder_SB.vertical(kernel, input, output);
            ImplConvolveMean.vertical(input, output, radius);
        }
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32)

Example 22 with Kernel1D_S32

use of boofcv.struct.convolve.Kernel1D_S32 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(GrayS16 input, GrayI16 output, int radius) {
    InputSanityCheck.checkSameShape(input, output);
    Kernel1D_S32 kernel = FactoryKernel.table1D_I32(radius);
    ConvolveJustBorder_General_SB.vertical(kernel, ImageBorderValue.wrap(input, 0), output);
    ImplConvolveBox.vertical(input, output, radius);
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32)

Example 23 with Kernel1D_S32

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

the class TestPlanarConvolveDown method compareToSingleBand.

@Test
void compareToSingleBand() {
    Kernel1D_S32 kernel = FactoryKernelGaussian.gaussian1D(GrayU8.class, -1, 3);
    ConvolveDown<GrayU8, GrayU8> downU8 = FactoryConvolveDown.convolveSB(kernel, BorderType.NORMALIZED, true, 2, GrayU8.class, GrayU8.class);
    Planar<GrayU8> original = new Planar<>(GrayU8.class, 20, 30, 3);
    Planar<GrayU8> found = new Planar<>(GrayU8.class, 10, 30, 3);
    GImageMiscOps.fillUniform(original, rand, 0, 100);
    GrayU8[] expected = new GrayU8[original.getNumBands()];
    for (int i = 0; i < expected.length; i++) {
        expected[i] = new GrayU8(found.width, found.height);
        downU8.process(original.getBand(i), expected[i]);
    }
    PlanarConvolveDown<GrayU8, GrayU8> alg = new PlanarConvolveDown<>(downU8, original.getNumBands());
    alg.process(original, found);
    for (int i = 0; i < expected.length; i++) {
        BoofTesting.assertEquals(expected[i], found.getBand(i), 1e-4);
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) Planar(boofcv.struct.image.Planar) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.jupiter.api.Test)

Example 24 with Kernel1D_S32

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

the class CommonBenchmarkConvolve_IL method setup.

public void setup(int radius) {
    Random rand = new Random(234);
    ImageMiscOps.fillUniform(input_U8, rand, 0, 20);
    ImageMiscOps.fillUniform(input_S16, rand, 0, 20);
    ImageMiscOps.fillUniform(input_S32, rand, 0, 20);
    ImageMiscOps.fillUniform(input_F32, rand, 0, 20);
    ImageMiscOps.fillUniform(input_F64, rand, 0, 20);
    System.arraycopy(input_S16.data, 0, input_U16.data, 0, input_S16.data.length);
    kernelF32 = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, -1, radius);
    kernelI32 = FactoryKernelGaussian.gaussian(Kernel1D_S32.class, -1, radius);
    kernel2D_F32 = FactoryKernelGaussian.gaussian(Kernel2D_F32.class, -1, radius);
    kernel2D_I32 = FactoryKernelGaussian.gaussian(Kernel2D_S32.class, -1, radius);
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) Kernel2D_F32(boofcv.struct.convolve.Kernel2D_F32) Random(java.util.Random) Kernel2D_S32(boofcv.struct.convolve.Kernel2D_S32) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32)

Example 25 with Kernel1D_S32

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

the class TestConvolveNormalizedNaive_SB method vertical.

/**
 * Check it against one specific type to see if the core algorithm is correct
 */
@Test
void vertical() {
    Kernel1D_S32 kernel = new Kernel1D_S32(new int[] { 1, 2, 3, 4, 5, 6 }, 6, 4);
    GrayU8 input = new GrayU8(15, 16);
    ImageMiscOps.fillUniform(input, rand, 0, 50);
    GrayU8 output = new GrayU8(15, 16);
    ConvolveNormalizedNaive_SB.vertical(kernel, input, output);
    for (int y = 0; y < output.height; y++) {
        for (int x = 0; x < output.width; x++) {
            int expected = vertical(x, y, kernel, input);
            int found = output.get(x, y);
            assertEquals(expected, found);
        }
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) GrayU8(boofcv.struct.image.GrayU8) Test(org.junit.jupiter.api.Test)

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