use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method kernelDerivXY.
@Test
public void kernelDerivXY() {
GrayF32 orig = new GrayF32(width, height);
GrayF32 integral = new GrayF32(width, height);
ImageMiscOps.fillUniform(orig, rand, 0, 20);
GrayF32 expected = new GrayF32(width, height);
GrayF32 found = new GrayF32(width, height);
IntegralImageOps.transform(orig, integral);
ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
for (int i = 1; i <= 5; i += 2) {
int size = i * 3;
IntegralKernel kernelI = DerivativeIntegralImage.kernelDerivXY(size, null);
Kernel2D_F32 kernel = createDerivXY(size);
ConvolveImage.convolve(kernel, orig, expected, border);
IntegralImageOps.convolve(integral, kernelI, found);
BoofTesting.assertEquals(expected, found, 1e-2);
}
}
use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method createHaarX.
private Kernel2D_F32 createHaarX(int r) {
int size = r * 2;
// TODO kernels only support odd sizes right now... change if that changes (remove +1)
Kernel2D_F32 ret = new Kernel2D_F32(size + 1);
for (int y = 1; y <= size; y++) {
for (int x = 1; x <= r; x++) {
ret.set(x, y, -1);
ret.set(x + r, y, 1);
}
}
return ret;
}
use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method kernelHaarX.
@Test
public void kernelHaarX() {
GrayF32 orig = new GrayF32(width, height);
GrayF32 integral = new GrayF32(width, height);
ImageMiscOps.fillUniform(orig, rand, 0, 20);
GrayF32 expected = new GrayF32(width, height);
GrayF32 found = new GrayF32(width, height);
IntegralImageOps.transform(orig, integral);
ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
for (int r = 1; r < 5; r++) {
IntegralKernel kernelI = DerivativeIntegralImage.kernelHaarX(r, null);
Kernel2D_F32 kernel = createHaarX(r);
ConvolveImage.convolve(kernel, orig, expected, border);
IntegralImageOps.convolve(integral, kernelI, found);
BoofTesting.assertEquals(expected, found, 1e-2);
}
}
use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method createDerivXX.
private Kernel2D_F32 createDerivXX(int size) {
int blockW = size / 3;
int blockH = size - blockW - 1;
int borderY = (size - blockH) / 2;
Kernel2D_F32 ret = new Kernel2D_F32(size);
for (int y = borderY; y < size - borderY; y++) {
for (int x = 0; x < blockW; x++) {
ret.set(x, y, 1);
ret.set(x + blockW * 2, y, 1);
}
for (int x = blockW; x < 2 * blockW; x++) {
ret.set(x, y, -2);
}
}
return ret;
}
use of boofcv.struct.convolve.Kernel2D_F32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method kernelDerivYY.
@Test
public void kernelDerivYY() {
GrayF32 orig = new GrayF32(width, height);
GrayF32 integral = new GrayF32(width, height);
ImageMiscOps.fillUniform(orig, rand, 0, 20);
GrayF32 expected = new GrayF32(width, height);
GrayF32 found = new GrayF32(width, height);
IntegralImageOps.transform(orig, integral);
ImageBorder_F32 border = (ImageBorder_F32) FactoryImageBorderAlgs.value(orig, 0);
for (int i = 1; i <= 5; i += 2) {
int size = i * 3;
IntegralKernel kernelI = DerivativeIntegralImage.kernelDerivYY(size, null);
Kernel2D_F32 kernel = createDerivXX(size);
kernel = KernelMath.transpose(kernel);
ConvolveImage.convolve(kernel, orig, expected, border);
IntegralImageOps.convolve(integral, kernelI, found);
BoofTesting.assertEquals(expected, found, 1e-2);
}
}
Aggregations