use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestDerivativeIntegralImage method derivYY.
@Test
public void derivYY() {
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);
for (int i = 1; i <= 5; i += 2) {
int size = i * 3;
Kernel2D_F32 kernel = createDerivXX(size);
kernel = KernelMath.transpose(kernel);
ConvolveImageNoBorder.convolve(kernel, orig, expected);
DerivativeIntegralImage.derivYY(integral, found, size);
int r = size / 2;
GrayF32 a = expected.subimage(r + 1, r + 1, expected.width - r, expected.height - r, null);
GrayF32 b = found.subimage(r + 1, r + 1, found.width - r, found.height - r, null);
BoofTesting.assertEquals(a, b, 1e-2);
}
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestPyramidDiscreteSampleBlur method _update.
public void _update(GrayF32 input) {
Kernel1D_F32 kernel = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, -1, 3);
GrayF32 convImg = new GrayF32(width, height);
GrayF32 convImg2 = new GrayF32(width / 2, height / 2);
GrayF32 storage = new GrayF32(width, height);
ConvolveImageNormalized.horizontal(kernel, input, storage);
ConvolveImageNormalized.vertical(kernel, storage, convImg);
PyramidDiscreteSampleBlur<GrayF32> alg = new PyramidDiscreteSampleBlur<>(kernel, 3, ImageType.single(GrayF32.class), true, new int[] { 1, 2, 4 });
alg.process(input);
// top layer should be the same as the input layer
BoofTesting.assertEquals(input, alg.getLayer(0), 1e-4f);
// second layer should have the same values as the convolved image
for (int i = 0; i < height; i += 2) {
for (int j = 0; j < width; j += 2) {
float a = convImg.get(j, i);
float b = alg.getLayer(1).get(j / 2, i / 2);
assertEquals(a, b, 1e-4);
}
}
storage.reshape(width / 2, height / 2);
ConvolveImageNormalized.horizontal(kernel, alg.getLayer(1), storage);
ConvolveImageNormalized.vertical(kernel, storage, convImg2);
// second layer should have the same values as the second convolved image
for (int i = 0; i < height / 2; i += 2) {
for (int j = 0; j < width / 2; j += 2) {
float a = convImg2.get(j, i);
float b = alg.getLayer(2).get(j / 2, i / 2);
assertEquals(j + " " + j, a, b, 1e-4);
}
}
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestPyramidDiscreteSampleBlur method checkSigmas.
/**
* Makes sure the amount of Gaussian blur in each level is correctly computed
*/
@Test
public void checkSigmas() {
Kernel1D_F32 kernel = FactoryKernelGaussian.gaussian(Kernel1D_F32.class, -1, 3);
PyramidDiscreteSampleBlur<GrayF32> alg = new PyramidDiscreteSampleBlur<>(kernel, 3, ImageType.single(GrayF32.class), true, new int[] { 1, 2, 4 });
assertEquals(0, alg.getSigma(0), 1e-8);
assertEquals(3, alg.getSigma(1), 1e-8);
assertEquals(6.7082, alg.getSigma(2), 1e-3);
alg = new PyramidDiscreteSampleBlur<>(kernel, 3, ImageType.single(GrayF32.class), true, new int[] { 2, 4, 8 });
assertEquals(0, alg.getSigma(0), 1e-8);
assertEquals(6, alg.getSigma(1), 1e-8);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestPyramidFloatGaussianScale method update.
/**
* Compares update to a convolution and sub-sampling of upper layers.
*/
@Test
public void update() {
GrayF32 img = new GrayF32(width, height);
BoofTesting.checkSubImage(this, "_update", true, img);
}
use of boofcv.struct.image.GrayF32 in project BoofCV by lessthanoptimal.
the class TestPyramidFloatScale method _update.
public void _update(GrayF32 input) {
InterpolatePixelS<GrayF32> interp = FactoryInterpolation.bilinearPixelS(input, BorderType.EXTENDED);
PyramidFloatScale<GrayF32> alg = new PyramidFloatScale<>(interp, new double[] { 3, 5 }, imageType);
alg.process(input);
// test the first layer
GrayF32 expected = new GrayF32((int) Math.ceil(width / 3.0), (int) Math.ceil(height / 3.0));
new FDistort(input, expected).scale().apply();
GrayF32 found = alg.getLayer(0);
BoofTesting.assertEquals(expected, found, 1e-4);
// test the second layer
GrayF32 next = new GrayF32((int) Math.ceil(width / 5.0), (int) Math.ceil(height / 5.0));
new FDistort(expected, next).scale().apply();
found = alg.getLayer(1);
BoofTesting.assertEquals(next, found, 1e-4);
}
Aggregations