use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TestImplDescribePointPixelRegionNCC_U8 method checkInner.
public void checkInner(GrayU8 image, int c_x, int c_y, int w, int h) {
ImplDescribePointPixelRegionNCC_U8 alg = new ImplDescribePointPixelRegionNCC_U8(w, h);
NccFeature desc = new NccFeature(alg.getDescriptorLength());
alg.setImage(image);
assertTrue(alg.isInBounds(c_x, c_y));
alg.process(c_x, c_y, desc);
int y0 = c_y - h / 2;
int x0 = c_x - w / 2;
double mean = 0;
for (int y = y0; y < y0 + h; y++) {
for (int x = x0; x < x0 + w; x++) {
mean += image.get(x, y);
}
}
mean /= w * h;
double variance = 0;
for (int y = y0; y < y0 + h; y++) {
for (int x = x0; x < x0 + w; x++) {
double a = image.get(x, y) - mean;
variance += a * a;
}
}
variance /= w * h;
assertEquals(desc.mean, mean, 1e-8);
assertEquals(desc.sigma, Math.sqrt(variance), 1e-8);
int index = 0;
for (int y = y0; y < y0 + h; y++) {
for (int x = x0; x < x0 + w; x++, index++) {
assertEquals(image.get(x, y) - mean, desc.value[index], 1e-4);
}
}
}
use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TestConvertDescriptors method convertNcc_F64.
@Test
public void convertNcc_F64() {
TupleDesc_F64 desc = new TupleDesc_F64(100);
for (int i = 0; i < desc.size(); i++) {
desc.value[i] = rand.nextDouble() * 2 - 1;
}
NccFeature found = new NccFeature(100);
ConvertDescriptors.convertNcc(desc, found);
for (int i = 0; i < desc.size(); i++) {
assertEquals(desc.value[i], found.value[i] + found.mean, 1e-8);
}
// crude test. just makes sure signa has been set really.
assertTrue(found.sigma > 0);
}
use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TestImplDescribePointPixelRegionNCC_F32 method checkInner.
public void checkInner(GrayF32 image, int c_x, int c_y, int w, int h) {
ImplDescribePointPixelRegionNCC_F32 alg = new ImplDescribePointPixelRegionNCC_F32(w, h);
NccFeature desc = new NccFeature(alg.getDescriptorLength());
alg.setImage(image);
assertTrue(alg.isInBounds(c_x, c_y));
alg.process(c_x, c_y, desc);
int y0 = c_y - h / 2;
int x0 = c_x - w / 2;
double mean = 0;
for (int y = y0; y < y0 + h; y++) {
for (int x = x0; x < x0 + w; x++) {
mean += image.get(x, y);
}
}
mean /= w * h;
double variance = 0;
for (int y = y0; y < y0 + h; y++) {
for (int x = x0; x < x0 + w; x++) {
double a = image.get(x, y) - mean;
variance += a * a;
}
}
variance /= w * h;
assertEquals(desc.mean, mean, 1e-8);
assertEquals(desc.sigma, Math.sqrt(variance), 1e-8);
int index = 0;
for (int y = y0; y < y0 + h; y++) {
for (int x = x0; x < x0 + w; x++, index++) {
assertEquals(image.get(x, y) - mean, desc.value[index], 1e-4);
}
}
}
use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TestImplDescribePointPixelRegionNCC_U8 method checkBorder.
public void checkBorder(GrayU8 image, int c_x, int c_y, int w, int h) {
ImplDescribePointPixelRegionNCC_U8 alg = new ImplDescribePointPixelRegionNCC_U8(w, h);
NccFeature desc = new NccFeature(alg.getDescriptorLength());
alg.setImage(image);
assertFalse(alg.isInBounds(c_x, c_y));
}
use of boofcv.struct.feature.NccFeature in project BoofCV by lessthanoptimal.
the class TestScoreAssociateNccFeature method compareToExpected.
@Test
public void compareToExpected() {
ScoreAssociateNccFeature scorer = new ScoreAssociateNccFeature();
NccFeature a = new NccFeature(5);
NccFeature b = new NccFeature(5);
a.sigma = 12;
b.sigma = 7;
a.value = new double[] { 1, 2, 3, 4, 5 };
b.value = new double[] { 2, -1, 7, -8, 10 };
assertEquals(-0.46429 / 5.0, scorer.score(a, b), 1e-2);
}
Aggregations