Search in sources :

Example 26 with Kernel1D_S32

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

the class TestConvolveNormalizedNaive_SB method horizontal.

/**
 * Check it against one specific type to see if the core algorithm is correct
 */
@Test
void horizontal() {
    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.horizontal(kernel, input, output);
    for (int y = 0; y < output.height; y++) {
        for (int x = 0; x < output.width; x++) {
            int expected = horizontal(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)

Example 27 with Kernel1D_S32

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

the class TestConvolveNormalizedNaive_SB method vertical2_U16_U8.

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

Example 28 with Kernel1D_S32

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

the class TestConvolveNormalizedNaive_IL 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);
    InterleavedU8 input = new InterleavedU8(width, height, numBands);
    ImageMiscOps.fillUniform(input, rand, 0, 50);
    InterleavedU8 output = new InterleavedU8(width, height, numBands);
    ConvolveNormalizedNaive_IL.vertical(kernel, input, output);
    for (int y = 0; y < output.height; y++) {
        for (int x = 0; x < output.width; x++) {
            for (int band = 0; band < numBands; band++) {
                int expected = vertical(x, y, band, kernel, input);
                int found = output.getBand(x, y, band);
                assertEquals(expected, found);
            }
        }
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) InterleavedU8(boofcv.struct.image.InterleavedU8) Test(org.junit.jupiter.api.Test)

Example 29 with Kernel1D_S32

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

the class TestConvolveNormalizedNaive_IL method vertical2_U16_U8.

/**
 * Check it against one specific type to see if the core algorithm is correct
 */
@Test
void vertical2_U16_U8() {
    Kernel1D_S32 kernelY = new Kernel1D_S32(new int[] { 1, 2, 3, 4, 5, 6 }, 6, 4);
    Kernel1D_S32 kernelX = new Kernel1D_S32(new int[] { 4, 2, 1, 4, 3, 6 }, 5, 2);
    InterleavedU16 input = new InterleavedU16(width, height, numBands);
    ImageMiscOps.fillUniform(input, rand, 0, 80);
    InterleavedU8 output = new InterleavedU8(width, height, numBands);
    ConvolveNormalizedNaive_IL.vertical(kernelX, kernelY, input, output);
    InterleavedU8 alt = new InterleavedU8(width, height, numBands);
    ConvolveImageNoBorder.vertical(kernelY, input, alt, kernelX.computeSum() * kernelY.computeSum());
    for (int y = 0; y < output.height; y++) {
        for (int x = 0; x < output.width; x++) {
            for (int band = 0; band < numBands; band++) {
                int expected = vertical2(x, y, band, kernelX, kernelY, input);
                int found = output.getBand(x, y, band);
                assertEquals(expected, found);
            }
        }
    }
}
Also used : Kernel1D_S32(boofcv.struct.convolve.Kernel1D_S32) InterleavedU8(boofcv.struct.image.InterleavedU8) InterleavedU16(boofcv.struct.image.InterleavedU16) Test(org.junit.jupiter.api.Test)

Example 30 with Kernel1D_S32

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

the class TestConvolveNormalizedStandardSparse method checkMethod.

private void checkMethod(Method method, int width, int height, int kernelRadius, 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);
    GrayS16 shortImage = new GrayS16(width, height);
    ConvertImage.convert(seedImage, shortImage);
    kernelI32 = FactoryKernelGaussian.gaussian(Kernel1D_S32.class, -1, kernelRadius);
    kernelF32 = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, -1, kernelRadius);
    boolean isFloatingKernel = method.getParameterTypes()[0] == Kernel1D_F32.class;
    Class<?> imageType = method.getParameterTypes()[2];
    ImageGray<?> inputImage;
    if (imageType == GrayF32.class) {
        inputImage = floatImage;
        expectedOutput = computeExpected(floatImage);
    } else if (imageType == GrayU8.class) {
        inputImage = seedImage;
        expectedOutput = computeExpected(seedImage);
    } else {
        inputImage = shortImage;
        expectedOutput = computeExpected(shortImage);
    }
    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) GrayS16(boofcv.struct.image.GrayS16) Kernel1D_F32(boofcv.struct.convolve.Kernel1D_F32) GrayU8(boofcv.struct.image.GrayU8)

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