use of boofcv.struct.image.Planar in project BoofCV by lessthanoptimal.
the class TestDescribePointSurfPlanar method failShape.
@Test(expected = IllegalArgumentException.class)
public void failShape() {
Planar<GrayF32> input = new Planar<>(GrayF32.class, width, height, 3);
GImageMiscOps.addUniform(input, rand, 0, 200);
DescribePointSurf<GrayF32> desc = new DescribePointSurf<>(GrayF32.class);
DescribePointSurfPlanar<GrayF32> alg = new DescribePointSurfPlanar<>(desc, 4);
GrayF32 gray = ConvertImage.average(input, null);
gray.reshape(width - 1, height);
alg.setImage(gray, input);
}
use of boofcv.struct.image.Planar in project BoofCV by lessthanoptimal.
the class TestGHistogramFeatureOps method histogram_pl.
@Test
public void histogram_pl() {
for (Class type : supported) {
Planar image = new Planar(type, width, height, 2);
GImageMiscOps.fillUniform(image, rand, 0, 200);
Histogram_F64 found = new Histogram_F64(50, 40);
found.setRange(0, 0, 200);
found.setRange(1, 0, 200);
Histogram_F64 expected = new Histogram_F64(50, 40);
expected.setRange(0, 0, 200);
expected.setRange(1, 0, 200);
GHistogramFeatureOps.histogram(image, found);
if (type == GrayF32.class) {
HistogramFeatureOps.histogram_F32(image, expected);
} else {
HistogramFeatureOps.histogram_U8(image, expected);
}
assertEquals(0, DescriptorDistance.euclidean(expected, found), 1e-8);
}
}
use of boofcv.struct.image.Planar in project BoofCV by lessthanoptimal.
the class TestHistogramFeatureOps method histogram_PL_U8_compareToSingle.
/**
* Compare to single band image. Results should be identical
*/
@Test
public void histogram_PL_U8_compareToSingle() {
GrayU8 image = new GrayU8(width, height);
ImageMiscOps.fillUniform(image, rand, 0, 255);
Planar<GrayU8> ms = new Planar<>(GrayU8.class, width, height, 1);
ms.setBand(0, image);
TupleDesc_F64 expected = new TupleDesc_F64(256);
Histogram_F64 found = new Histogram_F64(256);
found.setRange(0, 0, 255);
HistogramFeatureOps.histogram(image, 255, expected);
HistogramFeatureOps.histogram_U8(ms, found);
for (int i = 0; i < found.size(); i++) {
assertEquals(expected.getDouble(i), found.getDouble(i), 1e-8);
}
}
use of boofcv.struct.image.Planar in project BoofCV by lessthanoptimal.
the class TestPlanarConvolveDown method compareToSingleBand.
@Test
public void compareToSingleBand() {
Kernel1D_S32 kernel = FactoryKernelGaussian.gaussian1D(GrayU8.class, -1, 3);
ConvolveDown<GrayU8, GrayU8> downU8 = FactoryConvolveDown.convolveSB(kernel, BorderType.NORMALIZED, true, 2, GrayU8.class, GrayU8.class);
Planar<GrayU8> original = new Planar<>(GrayU8.class, 20, 30, 3);
Planar<GrayU8> found = new Planar<>(GrayU8.class, 10, 30, 3);
GImageMiscOps.fillUniform(original, rand, 0, 100);
GrayU8[] expected = new GrayU8[original.getNumBands()];
for (int i = 0; i < expected.length; i++) {
expected[i] = new GrayU8(found.width, found.height);
downU8.process(original.getBand(i), expected[i]);
}
PlanarConvolveDown<GrayU8, GrayU8> alg = new PlanarConvolveDown<>(downU8, original.getNumBands());
alg.process(original, found);
for (int i = 0; i < expected.length; i++) {
BoofTesting.assertEquals(expected[i], found.getBand(i), 1e-4);
}
}
use of boofcv.struct.image.Planar in project BoofCV by lessthanoptimal.
the class TestImageGradientThenReduce method stuff.
@Test
public void stuff() {
HelperGradient gradient = new HelperGradient();
HelperReduce reduce = new HelperReduce();
Planar<GrayF32> input = new Planar<>(GrayF32.class, 10, 12, 3);
GrayF32 outDerivX = new GrayF32(10, 12);
GrayF32 outDerivY = new GrayF32(10, 12);
ImageGradientThenReduce<Planar<GrayF32>, Planar<GrayF32>, GrayF32> alg = new ImageGradientThenReduce<>(gradient, reduce);
alg.process(input, outDerivX, outDerivY);
assertEquals(1, outDerivX.get(2, 3), 1e-4f);
assertEquals(2, outDerivY.get(2, 3), 1e-4f);
alg.setBorderType(BorderType.EXTENDED);
assertTrue(gradient.setBorderCalled);
}
Aggregations