Search in sources :

Example 6 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class FeatureLaplacePyramid method detectCandidateFeatures.

/**
 * Use the feature detector to find candidate features in each level.  Only compute the needed image derivatives.
 */
private void detectCandidateFeatures(T image, double sigma) {
    // adjust corner intensity threshold based upon the current scale factor
    float scaleThreshold = (float) (baseThreshold / Math.pow(sigma, scalePower));
    detector.setThreshold(scaleThreshold);
    computeDerivative.setInput(image);
    D derivX = null, derivY = null;
    D derivXX = null, derivYY = null, derivXY = null;
    if (detector.getRequiresGradient()) {
        derivX = computeDerivative.getDerivative(true);
        derivY = computeDerivative.getDerivative(false);
    }
    if (detector.getRequiresHessian()) {
        derivXX = computeDerivative.getDerivative(true, true);
        derivYY = computeDerivative.getDerivative(false, false);
        derivXY = computeDerivative.getDerivative(true, false);
    }
    detector.process(image, derivX, derivY, derivXX, derivYY, derivXY);
    List<Point2D_I16> m = maximums;
    m.clear();
    if (detector.isDetectMaximums()) {
        QueueCorner q = detector.getMaximums();
        for (int i = 0; i < q.size; i++) {
            m.add(q.get(i).copy());
        }
    }
    if (detector.isDetectMinimums()) {
        QueueCorner q = detector.getMinimums();
        for (int i = 0; i < q.size; i++) {
            m.add(q.get(i).copy());
        }
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) QueueCorner(boofcv.struct.QueueCorner) ScalePoint(boofcv.struct.feature.ScalePoint)

Example 7 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class FeatureLaplacePyramid method findLocalScaleSpaceMax.

/**
 * See if each feature is a maximum in its local scale-space.
 */
protected void findLocalScaleSpaceMax(PyramidFloat<T> ss, int layerID) {
    List<Point2D_I16> candidates = maximums;
    float scale0 = (float) ss.scale[layerID - 1];
    float scale1 = (float) ss.scale[layerID];
    float scale2 = (float) ss.scale[layerID + 1];
    float sigma0 = (float) ss.getSigma(layerID - 1);
    float sigma1 = (float) ss.getSigma(layerID);
    float sigma2 = (float) ss.getSigma(layerID + 1);
    // For laplacian its t^(2*gamma) where gamma = 3/4
    // Is this divide by scale correct?
    float ss0 = (float) (Math.pow(sigma0, 2.0 * 0.75) / scale0);
    float ss1 = (float) (Math.pow(sigma1, 2.0 * 0.75) / scale1);
    float ss2 = (float) (Math.pow(sigma2, 2.0 * 0.75) / scale2);
    for (Point2D_I16 c : candidates) {
        GrayF32 intensity = detector.getIntensity();
        float target = intensity.unsafe_get(c.x, c.y);
        float fx, fy;
        {
            float x0 = intensity.unsafe_get(c.x - 1, c.y);
            float x2 = intensity.unsafe_get(c.x + 1, c.y);
            float y0 = intensity.unsafe_get(c.x, c.y - 1);
            float y2 = intensity.unsafe_get(c.x, c.y + 1);
            fx = c.x + polyPeak(x0, target, x2);
            fy = c.y + polyPeak(y0, target, y2);
        }
        // fx=c.x;fy=c.y;
        sparseLaplace.setImage(ss.getLayer(layerID));
        float val = ss1 * (float) sparseLaplace.compute(c.x, c.y);
        // search for local maximum or local minimum
        float adj = Math.signum(val);
        val *= adj;
        // find pixel location in each image's local coordinate
        int x0 = (int) (fx * scale1 / scale0 + 0.5);
        int y0 = (int) (fy * scale1 / scale0 + 0.5);
        int x2 = (int) (fx * scale1 / scale2 + 0.5);
        int y2 = (int) (fy * scale1 / scale2 + 0.5);
        if (checkMax(ss.getLayer(layerID - 1), adj * ss0, val, x0, y0) && checkMax(ss.getLayer(layerID + 1), adj * ss2, val, x2, y2)) {
            sparseLaplace.setImage(ss.getLayer(layerID - 1));
            float s0 = ss0 * (float) sparseLaplace.compute(x0, y0) * adj;
            sparseLaplace.setImage(ss.getLayer(layerID + 1));
            float s2 = ss2 * (float) sparseLaplace.compute(x2, y2) * adj;
            double adjSigma;
            // scaled from -1 to 1
            double sigmaInterp = polyPeak(s0, val, s2);
            if (sigmaInterp < 0) {
                adjSigma = sigma0 * (-sigmaInterp) + (1 + sigmaInterp) * sigma1;
            } else {
                adjSigma = sigma2 * sigmaInterp + (1 - sigmaInterp) * sigma1;
            }
            // put features into the scale of the upper image
            foundPoints.add(new ScalePoint(fx * scale1, fy * scale1, adjSigma));
        }
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) GrayF32(boofcv.struct.image.GrayF32) ScalePoint(boofcv.struct.feature.ScalePoint) ScalePoint(boofcv.struct.feature.ScalePoint)

Example 8 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class HoughTransformLinePolar method extractLines.

/**
 * Searches for local maximas and converts into lines.
 *
 * @return Found lines in the image.
 */
public FastQueue<LineParametric2D_F32> extractLines() {
    lines.reset();
    foundLines.reset();
    foundIntensity.reset();
    extractor.process(transform, null, null, null, foundLines);
    int w2 = transform.width / 2;
    for (int i = 0; i < foundLines.size(); i++) {
        Point2D_I16 p = foundLines.get(i);
        float r = (float) (r_max * (p.x - w2) / w2);
        float c = tableTrig.c[p.y];
        float s = tableTrig.s[p.y];
        float x0 = r * c + originX;
        float y0 = r * s + originY;
        foundIntensity.push(transform.get(p.x, p.y));
        LineParametric2D_F32 l = lines.grow();
        l.p.set(x0, y0);
        l.slope.set(-s, c);
        Point2D_F64 p2 = new Point2D_F64();
        lineToCoordinate(l, p2);
    }
    return lines;
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) Point2D_F64(georegression.struct.point.Point2D_F64) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Example 9 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class NonMaxCandidate method examineMinimum.

protected void examineMinimum(GrayF32 intensityImage, QueueCorner candidates, QueueCorner found) {
    final int stride = intensityImage.stride;
    final float[] inten = intensityImage.data;
    for (int iter = 0; iter < candidates.size; iter++) {
        Point2D_I16 pt = candidates.data[iter];
        if (pt.x < ignoreBorder || pt.y < ignoreBorder || pt.x >= endBorderX || pt.y >= endBorderY)
            continue;
        int center = intensityImage.startIndex + pt.y * stride + pt.x;
        float val = inten[center];
        if (val > thresholdMin || val == -Float.MAX_VALUE)
            continue;
        x0 = Math.max(0, pt.x - radius);
        y0 = Math.max(0, pt.y - radius);
        x1 = Math.min(intensityImage.width, pt.x + radius + 1);
        y1 = Math.min(intensityImage.height, pt.y + radius + 1);
        if (searchMin(center, val))
            found.add(pt.x, pt.y);
    }
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16)

Example 10 with Point2D_I16

use of georegression.struct.point.Point2D_I16 in project BoofCV by lessthanoptimal.

the class TestQueueCorner method reset.

@Test
public void reset() {
    QueueCorner queue = new QueueCorner(20);
    assertEquals(0, queue.size());
    queue.add(1, 2);
    Point2D_I16 p = queue.get(0);
    assertEquals(1, queue.size());
    queue.reset();
    assertEquals(0, queue.size());
    queue.add(1, 2);
    assertTrue(p == queue.get(0));
}
Also used : Point2D_I16(georegression.struct.point.Point2D_I16) Test(org.junit.Test)

Aggregations

Point2D_I16 (georegression.struct.point.Point2D_I16)27 QueueCorner (boofcv.struct.QueueCorner)12 GrayF32 (boofcv.struct.image.GrayF32)7 ScalePoint (boofcv.struct.feature.ScalePoint)5 ConfigExtract (boofcv.abst.feature.detect.extract.ConfigExtract)3 NonMaxSuppression (boofcv.abst.feature.detect.extract.NonMaxSuppression)3 Test (org.junit.Test)3 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)2 FactoryIntensityPoint (boofcv.factory.feature.detect.intensity.FactoryIntensityPoint)2 FactoryDetectPoint (boofcv.factory.feature.detect.interest.FactoryDetectPoint)2 ConvertBufferedImage (boofcv.io.image.ConvertBufferedImage)2 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)2 Point2D_F64 (georegression.struct.point.Point2D_F64)2 BufferedImage (java.awt.image.BufferedImage)2 DescribeRegionPoint (boofcv.abst.feature.describe.DescribeRegionPoint)1 ConfigGeneralDetector (boofcv.abst.feature.detect.interest.ConfigGeneralDetector)1 DetectorFastNaive (boofcv.alg.feature.detect.intensity.DetectorFastNaive)1 EasyGeneralFeatureDetector (boofcv.alg.feature.detect.interest.EasyGeneralFeatureDetector)1 GeneralFeatureDetector (boofcv.alg.feature.detect.interest.GeneralFeatureDetector)1 OrientationImageAverage (boofcv.alg.feature.orientation.OrientationImageAverage)1