use of boofcv.struct.convolve.Kernel1D_S32 in project BoofCV by lessthanoptimal.
the class TestFactoryConvolveDown method convolve1D_I32.
@Test
void convolve1D_I32() {
Kernel1D_S32 kernel = FactoryKernel.random1D_I32(kernelWidth, radius, 1, 6, rand);
FilterImageInterface conv;
GrayU8 input = new GrayU8(width, height);
GrayS16 found = new GrayS16(width / skip, height);
GrayS16 expected = new GrayS16(width / skip, height);
ImageMiscOps.fillUniform(input, rand, 0, 5);
// CHECK NO BORDER
conv = FactoryConvolveDown.convolveSB(kernel, BorderType.SKIP, true, skip, GrayU8.class, GrayI16.class);
conv.process(input, found);
ConvolveImageDownNoBorder.horizontal(kernel, input, expected, skip);
BoofTesting.assertEquals(expected, found, 0);
// CHECK EXTENDED
// conv = FactoryConvolveDown.convolve( kernel,GrayU8.class, ImageInt16.class,BorderType.EXTENDED,true);
// conv.process(input,found);
// ConvolveWithBorder.horizontal(kernel,input,expected);
// BoofTesting.assertEquals(expected,found,0);
// CHECK NORMALIZED
GrayU8 found8 = new GrayU8(width / skip, height);
GrayU8 expected8 = new GrayU8(width / skip, height);
conv = FactoryConvolveDown.convolveSB(kernel, BorderType.NORMALIZED, true, skip, GrayU8.class, GrayI8.class);
conv.process(input, found8);
ConvolveImageDownNormalized.horizontal(kernel, input, expected8, skip);
BoofTesting.assertEquals(expected8, found8, 0);
}
use of boofcv.struct.convolve.Kernel1D_S32 in project BoofCV by lessthanoptimal.
the class ConvolveImageMean method horizontal.
/**
* Performs a horizontal 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 length How long the mean filter is
*/
public static void horizontal(GrayS16 input, GrayI16 output, int offset, int length, @Nullable ImageBorder_S32<GrayS16> binput) {
output.reshape(input.width, output.height);
if (binput != null) {
binput.setImage(input);
Kernel1D_S32 kernel = FactoryKernel.table1D_S32(offset, length);
ConvolveJustBorder_General_SB.horizontal(kernel, binput, output, kernel.computeSum());
}
if (length <= input.width) {
if (BoofConcurrency.USE_CONCURRENT) {
ImplConvolveMean_MT.horizontal(input, output, offset, length);
} else {
ImplConvolveMean.horizontal(input, output, offset, length);
}
}
}
use of boofcv.struct.convolve.Kernel1D_S32 in project BoofCV by lessthanoptimal.
the class ConvolveImageMean method vertical.
/**
* Performs a vertical 1D mean box filter. Borders are handled by reducing the box size.
*
* @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 length How long the mean filter is
* @param work (Optional) Storage for work array
*/
public static void vertical(GrayU8 input, GrayI8 output, int offset, int length, @Nullable GrowArray<DogArray_I32> workspaces) {
output.reshape(input);
if (BOverrideConvolveImageMean.invokeNativeVertical(input, output, offset, length))
return;
Kernel1D_S32 kernel = FactoryKernel.table1D_S32(offset, length);
if (length > input.height) {
ConvolveImageNormalized.vertical(kernel, input, output);
} else {
ConvolveNormalized_JustBorder_SB.vertical(kernel, input, output);
if (BoofConcurrency.USE_CONCURRENT) {
ImplConvolveMean_MT.vertical(input, output, offset, length, workspaces);
} else {
ImplConvolveMean.vertical(input, output, offset, length, workspaces);
}
}
}
use of boofcv.struct.convolve.Kernel1D_S32 in project BoofCV by lessthanoptimal.
the class ConvolveImageMean method horizontal.
/**
* Performs a horizontal 1D mean box filter. Borders are handled by reducing the box size.
*
* @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 length How long the mean filter is
*/
public static void horizontal(GrayS16 input, GrayI16 output, int offset, int length) {
output.reshape(input);
if (BOverrideConvolveImageMean.invokeNativeHorizontal(input, output, offset, length))
return;
Kernel1D_S32 kernel = FactoryKernel.table1D_S32(offset, length);
if (length > input.width) {
ConvolveImageNormalized.horizontal(kernel, input, output);
} else {
ConvolveNormalized_JustBorder_SB.horizontal(kernel, input, output);
if (BoofConcurrency.USE_CONCURRENT) {
ImplConvolveMean_MT.horizontal(input, output, offset, length);
} else {
ImplConvolveMean.horizontal(input, output, offset, length);
}
}
}
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(GrayU8 input, GrayI8 output, int offset, int length, @Nullable ImageBorder_S32<GrayU8> 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);
}
}
}
Aggregations