use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class DescribeDenseHogFastAlg method computeDescriptor.
/**
* Compute the descriptor from the specified cells. (row,col) to (row+w,col+w)
* @param row Lower extent of cell rows
* @param col Lower extent of cell columns
*/
void computeDescriptor(int row, int col) {
// set location to top-left pixel
locations.grow().set(col * pixelsPerCell, row * pixelsPerCell);
TupleDesc_F64 d = descriptions.grow();
int indexDesc = 0;
for (int i = 0; i < cellsPerBlockY; i++) {
for (int j = 0; j < cellsPerBlockX; j++) {
Cell c = cells[(row + i) * cellCols + (col + j)];
for (int k = 0; k < c.histogram.length; k++) {
d.value[indexDesc++] = c.histogram[k];
}
}
}
// Apply SIFT style L2-Hys normalization
DescribeSiftCommon.normalizeDescriptor(d, 0.2);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class StandardTupleDescribeTests method checkSubImage.
/**
* Does it produce a the same features when given a subimage?
*/
@Test
public void checkSubImage() {
TupleDesc_F64 expected = describe(c_x, c_y, 0, image);
GrayF32 sub = BoofTesting.createSubImageOf(image);
TupleDesc_F64 found = describe(c_x, c_y, 0, sub);
BoofTesting.assertEquals(expected.value, found.value, 1e-8);
}
use of boofcv.struct.feature.TupleDesc_F64 in project BoofCV by lessthanoptimal.
the class StandardTupleDescribeTests method changeRotation.
/**
* Does it produce a different feature when rotated?
*/
@Test
public void changeRotation() {
TupleDesc_F64 a = describe(c_x, c_y, 0, image);
TupleDesc_F64 b = describe(c_x, c_y, 1, image);
boolean equals = true;
for (int i = 0; i < a.value.length; i++) {
double diff = Math.abs(a.value[i] - b.value[i]);
if (diff > 1e-8) {
equals = false;
break;
}
}
assertFalse(equals);
}
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
public 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);
alg.descriptor = new TupleDesc_F64(128);
alg.computeRawDescriptor(60 + r, 60 + r, 1, 0);
int numHit = computeInside(alg);
assertEquals(4 * 4, numHit);
alg.descriptor = new TupleDesc_F64(128);
alg.computeRawDescriptor(60 + r, 60 + r, 2, 0);
numHit = computeInside(alg);
// 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
public 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);
alg.descriptor = new TupleDesc_F64(128);
alg.computeRawDescriptor(20, 21, 1, angle);
int bin = (int) (UtilAngle.domain2PI(-angle) * 8 / (2 * Math.PI));
for (int j = 0; j < 128; j++) {
if (j % 8 == bin) {
assertTrue(alg.descriptor.value[j] > 0);
} else {
assertEquals(0, alg.descriptor.value[j], 1e-4);
}
}
}
}
Aggregations