use of boofcv.struct.convolve.Kernel2D in project BoofCV by lessthanoptimal.
the class TestBlurImageOps method mean.
// ImageType.il(2,InterleavedU8.class),ImageType.il(2,InterleavedF32.class)}; TODO add in future
@Test
public void mean() {
for (ImageType type : imageTypes) {
ImageBase input = type.createImage(width, height);
ImageBase found = type.createImage(width, height);
ImageBase expected = type.createImage(width, height);
GImageMiscOps.fillUniform(input, rand, 0, 20);
for (int radius = 1; radius <= 4; radius++) {
GImageMiscOps.fill(expected, 0);
GImageMiscOps.fill(found, 0);
int w = radius * 2 + 1;
// convolve with a kernel to compute the expected value
Kernel2D kernel = FactoryKernel.createKernelForImage(w, w / 2, 2, type.getDataType());
FactoryKernel.setTable(kernel);
GConvolveImageOps.convolveNormalized(kernel, input, expected);
try {
Class storage = type.getFamily() == ImageType.Family.PLANAR ? ImageGray.class : input.getClass();
Method m = BlurImageOps.class.getMethod("mean", input.getClass(), found.getClass(), int.class, storage);
m.invoke(null, input, found, radius, null);
BoofTesting.assertEquals(expected, found, 2);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
}
}
Aggregations