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);
}
}
}
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);
}
}
}
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);
}
}
}
}
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);
}
}
}
}
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);
}
Aggregations