use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class BaseTestDescribeSurf method features_increasing.
/**
* Create an image which has a constant slope. The features aligned along that
* direction should be large. This also checks that the orientation parameter
* is being used correctly and that absolute value is being done.
*/
@Test
void features_increasing() {
// test the gradient along the x-axis only
TestImplSurfDescribeOps.createGradient(0, input);
GIntegralImageOps.transform(input, ii);
sparse = TestImplSurfDescribeOps.createGradient(ii, 1);
// orient the feature along the x-axis
alg.setImage(ii);
TupleDesc_F64 feat = alg.createDescription();
alg.describe(15, 15, 0, 1, true, feat);
for (int i = 0; i < 64; i += 4) {
assertEquals(feat.data[i], feat.data[i + 1], 1e-4);
assertTrue(feat.data[i] > 0);
assertEquals(0, feat.data[i + 2], 1e-4);
assertEquals(0, feat.data[i + 3], 1e-4);
}
// now orient the feature along the y-axis
alg.describe(15, 15, Math.PI / 2.0, 1, true, feat);
for (int i = 0; i < 64; i += 4) {
assertEquals(-feat.data[i + 2], feat.data[i + 3], 1e-4);
assertTrue(feat.data[i + 2] < 0);
assertEquals(0, feat.data[i], 1e-4);
assertEquals(0, feat.data[i + 1], 1e-4);
}
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class BaseTestDescribeSurf method changeScale.
/**
* Does it produce a different feature when scalled?
*/
@Test
void changeScale() {
GImageMiscOps.fillUniform(ii, rand, 0, 100);
alg.setImage(ii);
TupleDesc_F64 a = alg.createDescription();
TupleDesc_F64 b = alg.createDescription();
alg.describe(c_x, c_y, 0, 1, true, a);
alg.describe(c_x, c_y, 0, 1.5, true, b);
assertFalse(isSimilar(a, b));
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestDescribePointSift method computeRawDescriptor_scale.
/**
* Only put gradient inside a small area that fills the descriptor. Then double the scale and see if
* only a 1/4 of the original image is inside
*/
@Test
void computeRawDescriptor_scale() {
GrayF32 derivX = new GrayF32(200, 200);
GrayF32 derivY = new GrayF32(200, 200);
DescribePointSift<GrayF32> alg = new DescribePointSift<>(4, 4, 8, 1.5, 0.5, 0.2, GrayF32.class);
int r = alg.getCanonicalRadius();
ImageMiscOps.fillRectangle(derivX, 5.0f, 60, 60, 2 * r, 2 * r);
alg.setImageGradient(derivX, derivY);
TupleDesc_F64 descriptor = new TupleDesc_F64(128);
alg.computeRawDescriptor(60 + r, 60 + r, 1, 0, descriptor);
int numHit = computeInside(descriptor);
assertEquals(4 * 4, numHit);
descriptor = new TupleDesc_F64(128);
alg.computeRawDescriptor(60 + r, 60 + r, 2, 0, descriptor);
numHit = computeInside(descriptor);
// would be 2x2 if there was no interpolation
assertEquals(3 * 3, numHit);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestDescribePointSift method computeRawDescriptor_rotation.
/**
* Have a constant gradient, which has an easy to understand descriptor, then rotate the feature and see
* if the description changes as expected.
*/
@Test
void computeRawDescriptor_rotation() {
GrayF32 derivX = new GrayF32(60, 55);
GrayF32 derivY = new GrayF32(60, 55);
ImageMiscOps.fill(derivX, 5.0f);
DescribePointSift<GrayF32> alg = new DescribePointSift<>(4, 4, 8, 1.5, 0.5, 0.2, GrayF32.class);
alg.setImageGradient(derivX, derivY);
for (int i = 0; i < 8; i++) {
double angle = UtilAngle.bound(i * Math.PI / 4);
TupleDesc_F64 descriptor = new TupleDesc_F64(128);
alg.computeRawDescriptor(20, 21, 1, angle, descriptor);
int bin = (int) (UtilAngle.domain2PI(-angle) * 8 / (2 * Math.PI));
for (int j = 0; j < 128; j++) {
if (j % 8 == bin) {
assertTrue(descriptor.data[j] > 0);
} else {
assertEquals(0, descriptor.data[j], 1e-4);
}
}
}
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class TestDescribeSiftCommon method normalizeDescriptor.
@Test
void normalizeDescriptor() {
TupleDesc_F64 descriptor = new TupleDesc_F64(128);
descriptor.data[5] = 100;
descriptor.data[20] = 120;
descriptor.data[60] = 20;
DescribeSiftCommon alg = new DescribeSiftCommon(4, 4, 8, 0.5, 0.2);
alg.normalizeDescriptor(descriptor, alg.maxDescriptorElementValue);
assertEquals(1, normL2(descriptor), 1e-8);
// cropping should make 5 and 20 the same
assertEquals(descriptor.data[5], descriptor.data[20], 1e-8);
}
Aggregations