Search in sources :

Example 1 with SparseImageGradient

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);
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) SparseImageGradient(boofcv.struct.sparse.SparseImageGradient)

Example 2 with SparseImageGradient

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));
            }
        }
    }
}
Also used : SparseImageGradient(boofcv.struct.sparse.SparseImageGradient) GradientValue(boofcv.struct.sparse.GradientValue) Test(org.junit.Test)

Example 3 with SparseImageGradient

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);
        }
    }
}
Also used : SparseImageGradient(boofcv.struct.sparse.SparseImageGradient) GradientValue(boofcv.struct.sparse.GradientValue) ImageBorder(boofcv.core.image.border.ImageBorder) FactoryImageBorder(boofcv.core.image.border.FactoryImageBorder) ImageGradient(boofcv.abst.filter.derivative.ImageGradient) SparseImageGradient(boofcv.struct.sparse.SparseImageGradient) Test(org.junit.Test)

Aggregations

SparseImageGradient (boofcv.struct.sparse.SparseImageGradient)3 GradientValue (boofcv.struct.sparse.GradientValue)2 Test (org.junit.Test)2 ImageGradient (boofcv.abst.filter.derivative.ImageGradient)1 FactoryImageBorder (boofcv.core.image.border.FactoryImageBorder)1 ImageBorder (boofcv.core.image.border.ImageBorder)1 BrightFeature (boofcv.struct.feature.BrightFeature)1