use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestGradientThree method compareToConvolve_F32.
@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
validator.setTarget(GradientThree.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
validator.setKernel(0, GradientThree.kernelDeriv_F32, true);
validator.setKernel(1, GradientThree.kernelDeriv_F32, false);
GrayF32 input = new GrayF32(width, height);
ImageMiscOps.fillUniform(input, rand, 0, 10);
GrayF32 derivX = new GrayF32(width, height);
GrayF32 derivY = new GrayF32(width, height);
validator.compare(input, derivX, derivY);
}
use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestHessianFromGradient method hessianSobel_F32.
@Test
public void hessianSobel_F32() throws NoSuchMethodException {
CompareHessianToConvolution validator = new CompareHessianToConvolution();
validator.setTarget(HessianFromGradient.class.getMethod("hessianSobel", GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
validator.setKernel(0, GradientSobel.kernelDerivX_F32);
validator.setKernel(1, GradientSobel.kernelDerivY_F32);
GrayF32 derivX = new GrayF32(width, height);
GrayF32 derivY = new GrayF32(width, height);
ImageMiscOps.fillUniform(derivX, rand, -10, 10);
ImageMiscOps.fillUniform(derivY, rand, -10, 10);
GrayF32 derivXX = new GrayF32(width, height);
GrayF32 derivYY = new GrayF32(width, height);
GrayF32 derivXY = new GrayF32(width, height);
validator.compare(derivX, derivY, derivXX, derivYY, derivXY);
}
use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestHessianSobel method compareToConvolve_F32.
@Test
public void compareToConvolve_F32() throws NoSuchMethodException {
CompareDerivativeToConvolution validator = new CompareDerivativeToConvolution();
validator.setTarget(HessianSobel.class.getMethod("process", GrayF32.class, GrayF32.class, GrayF32.class, GrayF32.class, ImageBorder_F32.class));
validator.setKernel(0, HessianSobel.kernelXX_F32);
validator.setKernel(1, HessianSobel.kernelYY_F32);
validator.setKernel(2, HessianSobel.kernelXY_F32);
GrayF32 input = new GrayF32(width, height);
ImageMiscOps.fillUniform(input, rand, 0, 10);
GrayF32 derivXX = new GrayF32(width, height);
GrayF32 derivYY = new GrayF32(width, height);
GrayF32 derivXY = new GrayF32(width, height);
validator.compare(input, derivXX, derivYY, derivXY);
}
use of boofcv.core.image.border.ImageBorder_F32 in project BoofCV by lessthanoptimal.
the class TestImplEdgeNonMaxSuppressionCrude method border.
public static <D extends ImageGray<D>> void border(Method m, GrayF32 input, D derivX, D derivY, GrayF32 output) {
Random rand = new Random(123);
GImageMiscOps.fillUniform(input, rand, 0, 30);
GImageMiscOps.fillUniform(derivX, rand, -30, 30);
GImageMiscOps.fillUniform(derivY, rand, -30, 30);
try {
m.invoke(null, input, derivX, derivY, output);
ImageBorder_F32 intensity = (ImageBorder_F32) FactoryImageBorderAlgs.value(input, 0);
for (int y = 0; y < input.height; y++) {
if (y != 0 && y != input.height - 1)
continue;
for (int x = 0; x < input.width; x++) {
if (x != 0 && x != input.width - 1)
continue;
int dx = GeneralizedImageOps.get(derivX, x, y) > 0 ? 1 : -1;
int dy = GeneralizedImageOps.get(derivY, x, y) > 0 ? 1 : -1;
float left = intensity.get(x - dx, y - dy);
float middle = intensity.get(x, y);
float right = intensity.get(x + dx, y + dy);
assertEquals((left < middle && right < middle), output.get(x, y) != 0);
}
}
// uniform case should be NOT suppressed
GImageMiscOps.fill(input, 2);
m.invoke(null, input, derivX, derivY, output);
for (int y = 0; y < input.height; y++) {
if (y != 0 && y != input.height - 1)
continue;
for (int x = 0; x < input.width; x++) {
if (x != 0 && x != input.width - 1)
continue;
// the two adjacent pixels could be outside the image, depending on gradient direction
if ((x == 0 && y == 0) || (x == input.width - 1 && y == 0))
continue;
if ((x == input.width - 1 && y == input.height - 1) || (x == 0 && y == input.height - 1))
continue;
assertTrue(output.get(x, y) == 2);
}
}
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
Aggregations