Search in sources :

Example 1 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(GrayS16 input, GrayI16 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 2 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(GrayU8 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 3 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(GrayU8 input, GrayS32 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 4 with Kernel1D_S32

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

the class ExampleConvolution method convolve1D.

/**
 * Convolves a 1D kernel horizontally and vertically
 */
private static void convolve1D(GrayU8 gray) {
    ImageBorder<GrayU8> border = FactoryImageBorder.wrap(BorderType.EXTENDED, gray);
    Kernel1D_S32 kernel = new Kernel1D_S32(2);
    // specify the kernel's origin
    kernel.offset = 1;
    kernel.data[0] = 1;
    kernel.data[1] = -1;
    GrayS16 output = new GrayS16(gray.width, gray.height);
    GConvolveImageOps.horizontal(kernel, gray, output, border);
    panel.addImage(VisualizeImageData.standard(output, null), "1D Horizontal");
    GConvolveImageOps.vertical(kernel, gray, output, border);
    panel.addImage(VisualizeImageData.standard(output, null), "1D Vertical");
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) GrayS16(boofcv.struct.image.GrayS16) GrayU8(boofcv.struct.image.GrayU8)

Example 5 with Kernel1D_S32

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

the class TestFactoryConvolve method convolve1D_I32.

@Test
void convolve1D_I32() {
    Kernel1D_S32 kernel = FactoryKernel.random1D_I32(kernelWidth, radius, 1, 6, rand);
    ConvolveInterface conv;
    GrayU8 input = new GrayU8(width, height);
    GrayS16 found = new GrayS16(width, height);
    GrayS16 expected = new GrayS16(width, height);
    ImageMiscOps.fillUniform(input, rand, 0, 5);
    // CHECK NO BORDER
    conv = FactoryConvolve.convolve(kernel, input.imageType, found.imageType, BorderType.SKIP, true);
    conv.process(input, found);
    ConvolveImageNoBorder.horizontal(kernel, input, expected);
    BoofTesting.assertEquals(expected, found, 0);
    // CHECK EXTENDED
    conv = FactoryConvolve.convolve(kernel, input.imageType, found.imageType, BorderType.EXTENDED, true);
    conv.process(input, found);
    ConvolveImage.horizontal(kernel, input, expected, new ImageBorder1D_S32(BorderIndex1D_Extend::new));
    BoofTesting.assertEquals(expected, found, 0);
    // CHECK NORMALIZED
    GrayU8 found8 = new GrayU8(width, height);
    GrayU8 expected8 = new GrayU8(width, height);
    conv = FactoryConvolve.convolve(kernel, input.imageType, ImageType.single(GrayI8.class), BorderType.NORMALIZED, true);
    conv.process(input, found8);
    ConvolveImageNormalized.horizontal(kernel, input, expected8);
    BoofTesting.assertEquals(expected8, found8, 0);
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) ImageBorder1D_S32(boofcv.struct.border.ImageBorder1D_S32) 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