use of boofcv.struct.convolve.Kernel1D_F32 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(GrayF32 input, GrayF32 output, int radius) {
boolean processed = BOverrideConvolveImageMean.invokeNativeVertical(input, output, radius);
if (!processed) {
Kernel1D_F32 kernel = FactoryKernel.table1D_F32(radius, true);
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);
}
}
}
use of boofcv.struct.convolve.Kernel1D_F32 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(GrayF32 input, GrayF32 output, int radius) {
InputSanityCheck.checkSameShape(input, output);
Kernel1D_F32 kernel = FactoryKernel.table1D_F32(radius, false);
ConvolveJustBorder_General_SB.vertical(kernel, ImageBorderValue.wrap(input, 0), output);
ImplConvolveBox.vertical(input, output, radius);
}
use of boofcv.struct.convolve.Kernel1D_F32 in project BoofCV by lessthanoptimal.
the class TestFactoryConvolveDown method convolve1D_F32.
@Test
void convolve1D_F32() {
Kernel1D_F32 kernel = FactoryKernel.random1D_F32(kernelWidth, radius, 1, 6, rand);
FilterImageInterface<GrayF32, GrayF32> conv;
GrayF32 input = new GrayF32(width, height);
GrayF32 found = new GrayF32(width / skip, height);
GrayF32 expected = new GrayF32(width / skip, height);
ImageMiscOps.fillUniform(input, rand, 0, 5);
// CHECK NO BORDER
conv = FactoryConvolveDown.convolveSB(kernel, BorderType.SKIP, true, skip, GrayF32.class, GrayF32.class);
conv.process(input, found);
ConvolveImageDownNoBorder.horizontal(kernel, input, expected, skip);
BoofTesting.assertEquals(expected, found, 1e-4f);
// CHECK EXTENDED
// conv = FactoryConvolveDown.convolve( kernel,GrayF32.class,GrayF32.class,BorderType.EXTENDED,true);
// conv.process(input,found);
// ConvolveWithBorder.horizontal(kernel,input,expected);
// BoofTesting.assertEquals(expected,found,0,1e-4f);
// CHECK NORMALIZED
conv = FactoryConvolveDown.convolveSB(kernel, BorderType.NORMALIZED, true, skip, GrayF32.class, GrayF32.class);
conv.process(input, found);
ConvolveImageDownNormalized.horizontal(kernel, input, expected, skip);
BoofTesting.assertEquals(expected, found, 1e-4f);
}
use of boofcv.struct.convolve.Kernel1D_F32 in project BoofCV by lessthanoptimal.
the class TestAnyImageDerivative method test.
@Test
void test() {
ImageGradient<GrayF32, GrayF32> g = FactoryDerivative.three(GrayF32.class, null);
GrayF32 derivX = new GrayF32(width, height);
GrayF32 derivY = new GrayF32(width, height);
GrayF32 derivXX = new GrayF32(width, height);
GrayF32 derivYY = new GrayF32(width, height);
GrayF32 derivXY = new GrayF32(width, height);
GrayF32 derivYX = new GrayF32(width, height);
GrayF32 derivYYX = new GrayF32(width, height);
GrayF32 derivYYY = new GrayF32(width, height);
GImageMiscOps.fillUniform(original, rand, 0, 40);
g.process(original, derivX, derivY);
g.process(derivX, derivXX, derivXY);
g.process(derivY, derivYX, derivYY);
g.process(derivYY, derivYYX, derivYYY);
Kernel1D_F32 kernelX = (Kernel1D_F32) GradientThree.getKernelX(false);
AnyImageDerivative<GrayF32, GrayF32> alg = new AnyImageDerivative<>(kernelX, GrayF32.class, GrayF32.class);
alg.setInput(original);
// do one out of order which will force it to meet all the dependencies
BoofTesting.assertEquals(derivYYY, alg.getDerivative(false, false, false), 1e-4);
BoofTesting.assertEquals(derivX, alg.getDerivative(true), 1e-4);
BoofTesting.assertEquals(derivY, alg.getDerivative(false), 1e-4);
BoofTesting.assertEquals(derivXX, alg.getDerivative(true, true), 1e-4);
BoofTesting.assertEquals(derivXY, alg.getDerivative(true, false), 1e-4);
BoofTesting.assertEquals(derivYY, alg.getDerivative(false, false), 1e-4);
BoofTesting.assertEquals(derivYYX, alg.getDerivative(false, false, true), 1e-4);
}
use of boofcv.struct.convolve.Kernel1D_F32 in project BoofCV by lessthanoptimal.
the class TestAnyImageDerivative method changeInputImageSize.
/**
* See if changing the input image size causes an exception to be thrown.
*/
@Test
void changeInputImageSize() {
Kernel1D_F32 kernelX = (Kernel1D_F32) GradientThree.getKernelX(false);
AnyImageDerivative<GrayF32, GrayF32> alg = new AnyImageDerivative<>(kernelX, GrayF32.class, GrayF32.class);
alg.setInput(original);
alg.getDerivative(true);
GrayF32 smaller = new GrayF32(width - 5, height - 5);
GImageMiscOps.fillUniform(smaller, rand, 0, 40);
// assume that if it can't handle variable sized inputs then an exception is thrown
alg.setInput(smaller);
alg.getDerivative(true);
}
Aggregations