use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestHistogramFeatureOps method histogram_PL_F32_compareToSingle.
/**
* Compare to single band image. Results should be identical
*/
@Test
public void histogram_PL_F32_compareToSingle() {
GrayF32 image = new GrayF32(width, height);
ImageMiscOps.fillUniform(image, rand, -100, 100);
Planar<GrayF32> ms = new Planar<>(GrayF32.class, width, height, 1);
ms.setBand(0, image);
TupleDesc_F64 expected = new TupleDesc_F64(200);
Histogram_F64 found = new Histogram_F64(200);
found.setRange(0, -100, 100);
HistogramFeatureOps.histogram(image, -100, 100, expected);
HistogramFeatureOps.histogram_F32(ms, found);
for (int i = 0; i < found.size(); i++) {
assertEquals(expected.getDouble(i), found.getDouble(i), 1e-8);
}
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestHistogramFeatureOps method histogram_U8.
@Test
public void histogram_U8() {
GrayU8 image = new GrayU8(width, height);
image.set(2, 3, 40);
image.set(2, 4, 40);
image.set(2, 5, 40);
image.set(2, 6, 40);
image.set(5, 6, 255);
image.set(5, 7, 255);
TupleDesc_F64 histogram = new TupleDesc_F64(256);
randomFill(histogram);
double[] expected = new double[256];
expected[0] = width * height - 6;
expected[40] = 4.0;
expected[255] = 2.0;
HistogramFeatureOps.histogram(image, 255, histogram);
checkEquals(histogram, expected);
// now have a different max and less bins than values
histogram = new TupleDesc_F64(30);
randomFill(histogram);
image.set(5, 6, 150);
image.set(5, 7, 150);
image.set(5, 8, 41);
expected = new double[30];
expected[0] = width * height - 7;
expected[5] = 4.0;
expected[6] = 1.0;
expected[22] = 2.0;
HistogramFeatureOps.histogram(image, 200, histogram);
checkEquals(histogram, expected);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestHistogramFeatureOps method histogram_F32.
@Test
public void histogram_F32() {
GrayF32 image = new GrayF32(width, height);
image.set(2, 3, 40);
image.set(2, 4, 40);
image.set(2, 5, 40);
image.set(2, 6, 40);
image.set(5, 6, 255);
// should just barely be in bin 255
image.set(5, 7, 255f * 255f / 256f);
// this should go into bin 255 also
image.set(5, 8, 254.9f);
TupleDesc_F64 histogram = new TupleDesc_F64(256);
randomFill(histogram);
double[] expected = new double[256];
expected[0] = width * height - 7;
expected[40] = 4.0;
expected[255] = 3.0;
HistogramFeatureOps.histogram(image, 0, 255, histogram);
checkEquals(histogram, expected);
// now have a different max and less bins than values
histogram = new TupleDesc_F64(30);
randomFill(histogram);
image.set(5, 6, 150);
image.set(5, 7, 150);
image.set(5, 8, 150);
image.set(5, 9, 49);
expected = new double[30];
expected[10] = width * height - 8;
expected[14] = 5.0;
expected[25] = 3.0;
HistogramFeatureOps.histogram(image, -100, 200, histogram);
checkEquals(histogram, expected);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestHistogramFeatureOps method histogram_U16.
@Test
public void histogram_U16() {
GrayU16 image = new GrayU16(width, height);
image.set(2, 3, 40000);
image.set(2, 4, 40000);
image.set(2, 5, 40000);
image.set(2, 6, 40000);
image.set(5, 6, 65535);
image.set(5, 7, 65535);
TupleDesc_F64 histogram = new TupleDesc_F64(256);
randomFill(histogram);
double[] expected = new double[256];
expected[0] = width * height - 6;
expected[156] = 4.0;
expected[255] = 2.0;
HistogramFeatureOps.histogram(image, 65535, histogram);
checkEquals(histogram, expected);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestDescribeDenseSiftAlg method process.
public void process(GrayF32 derivX, GrayF32 derivY) {
DescribeDenseSiftAlg<GrayF32> alg = new DescribeDenseSiftAlg<>(4, 4, 8, 0.5, 0.2, 10, 10, GrayF32.class);
alg.setImageGradient(derivX, derivY);
alg.process();
List<TupleDesc_F64> list = alg.getDescriptors().toList();
int r = alg.getCanonicalRadius();
int cols = (100 - 2 * r) / 10;
int rows = (102 - 2 * r) / 10;
assertEquals(cols * rows, list.size());
int w = derivX.width - 2 * r;
int h = derivX.height - 2 * r;
TupleDesc_F64 expected = new TupleDesc_F64(128);
int i = 0;
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++, i++) {
int x = col * w / (cols - 1) + r;
int y = row * h / (rows - 1) + r;
TupleDesc_F64 found = list.get(i);
alg.computeDescriptor(x, y, expected);
for (int j = 0; j < 128; j++) {
assertEquals(expected.value[j], found.value[j], 1e-8);
}
}
}
}
Aggregations