use of boofcv.struct.sparse.SparseImageGradient in project BoofCV by lessthanoptimal.
the class DescribePointSurf method describe.
/**
* Compute SURF descriptor, but without laplacian sign
*
* @param x Location of interest point.
* @param y Location of interest point.
* @param angle The angle the feature is pointing at in radians.
* @param scale Scale of the interest point. Null is returned if the feature goes outside the image border.
* @param ret storage for the feature. Must have 64 values.
*/
public void describe(double x, double y, double angle, double scale, TupleDesc_F64 ret) {
double c = Math.cos(angle), s = Math.sin(angle);
// By assuming that the entire feature is inside the image faster algorithms can be used
// the results are also of dubious value when interacting with the image border.
boolean isInBounds = SurfDescribeOps.isInside(ii, x, y, radiusDescriptor, widthSample, scale, c, s);
// declare the feature if needed
if (ret == null)
ret = new BrightFeature(featureDOF);
else if (ret.value.length != featureDOF)
throw new IllegalArgumentException("Provided feature must have " + featureDOF + " values");
gradient.setImage(ii);
gradient.setWidth(widthSample * scale);
// use a safe method if its along the image border
SparseImageGradient gradient = isInBounds ? this.gradient : this.gradientSafe;
// extract descriptor
features(x, y, c, s, scale, gradient, ret.value);
}
use of boofcv.struct.sparse.SparseImageGradient in project BoofCV by lessthanoptimal.
the class GeneralGradientSparse method compareToFullImage_noBorder.
@Test
public void compareToFullImage_noBorder() {
createGradient().process(image, derivX, derivY);
SparseImageGradient alg = createAlg(null);
alg.setImage(image);
for (int i = 0; i < image.height; i++) {
for (int j = 0; j < image.width; j++) {
if (i >= -lower && j >= -lower && i < image.height - upper && j < image.width - upper) {
assertTrue(j + " " + i, image.isInBounds(j, i));
GradientValue g = alg.compute(j, i);
double expectedX = GeneralizedImageOps.get(derivX, j, i);
double expectedY = GeneralizedImageOps.get(derivY, j, i);
assertEquals(expectedX, g.getX(), 1e-4f);
assertEquals(j + " " + i, expectedY, g.getY(), 1e-4f);
} else {
assertFalse(j + " " + i, alg.isInBounds(j, i));
}
}
}
}
use of boofcv.struct.sparse.SparseImageGradient in project BoofCV by lessthanoptimal.
the class GeneralGradientSparse method compareToFullImage_Border.
@Test
public void compareToFullImage_Border() {
ImageBorder border = FactoryImageBorder.single(imageType, BorderType.EXTENDED);
ImageGradient gradient = createGradient();
gradient.setBorderType(BorderType.EXTENDED);
gradient.process(image, derivX, derivY);
SparseImageGradient alg = createAlg(border);
alg.setImage(image);
for (int i = 0; i < image.height; i++) {
for (int j = 0; j < image.width; j++) {
assertTrue(j + " " + i, image.isInBounds(j, i));
GradientValue g = alg.compute(j, i);
double expectedX = GeneralizedImageOps.get(derivX, j, i);
double expectedY = GeneralizedImageOps.get(derivY, j, i);
assertEquals(expectedX, g.getX(), 1e-4f);
assertEquals(expectedY, g.getY(), 1e-4f);
}
}
}
Aggregations