Search in sources :

Example 1 with ScalePoint

use of boofcv.struct.feature.ScalePoint in project BoofCV by lessthanoptimal.

the class ScaleSpacePointPanel method setLevel.

public synchronized void setLevel(int level) {
    // System.out.println("level "+level);
    if (level > 0) {
        ss.setActiveScale(level - 1);
        // if the input image size has changed reallocate the levelImage
        if (levelImage != null && (levelImage.getWidth() != background.getWidth() || levelImage.getHeight() != background.getHeight()))
            levelImage = null;
        levelImage = ConvertBufferedImage.convertTo(ss.getScaledImage(), levelImage, true);
        double scale = ss.getCurrentScale();
        levelPoints.clear();
        for (ScalePoint p : points) {
            if (p.scale == scale) {
                levelPoints.add(p);
            }
        }
    }
    this.activeLevel = level;
}
Also used : ScalePoint(boofcv.struct.feature.ScalePoint)

Example 2 with ScalePoint

use of boofcv.struct.feature.ScalePoint in project BoofCV by lessthanoptimal.

the class ScaleSpacePyramidPointPanel method setLevel.

private synchronized void setLevel(int level) {
    // System.out.println("level "+level);
    if (level > 0 && ss != null) {
        ImageGray small = (ImageGray) ss.getLayer(level - 1);
        ImageGray enlarge = GeneralizedImageOps.createSingleBand(small.getClass(), ss.getInputWidth(), ss.getInputHeight());
        new FDistort(small, enlarge).interpNN().apply();
        // if the size isn't the same null it so a new image will be declared
        if (levelImage != null && (levelImage.getWidth() != enlarge.width || levelImage.getHeight() != enlarge.height)) {
            levelImage = null;
        }
        levelImage = ConvertBufferedImage.convertTo(enlarge, levelImage, true);
        double scale = ss.getScale(level - 1);
        levelPoints.clear();
        for (ScalePoint p : points) {
            if (p.scale == scale) {
                levelPoints.add(p);
            }
        }
    } else {
        levelPoints.clear();
        levelPoints.addAll(points);
    }
    this.activeLevel = level;
}
Also used : FDistort(boofcv.abst.distort.FDistort) ScalePoint(boofcv.struct.feature.ScalePoint) ImageGray(boofcv.struct.image.ImageGray)

Example 3 with ScalePoint

use of boofcv.struct.feature.ScalePoint in project BoofCV by lessthanoptimal.

the class VisualizeFeatures method drawScalePoints.

public static void drawScalePoints(Graphics2D g2, java.util.List<ScalePoint> points, double scaleToRadius) {
    g2.setStroke(new BasicStroke(3));
    for (ScalePoint p : points) {
        if (p.white) {
            g2.setColor(Color.BLUE);
        } else {
            g2.setColor(Color.RED);
        }
        int r = (int) (p.scale * scaleToRadius + 0.5);
        int w = r * 2 + 1;
        g2.drawOval((int) p.x - r, (int) p.y - r, w, w);
    }
}
Also used : ScalePoint(boofcv.struct.feature.ScalePoint) ScalePoint(boofcv.struct.feature.ScalePoint)

Example 4 with ScalePoint

use of boofcv.struct.feature.ScalePoint 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 5 with ScalePoint

use of boofcv.struct.feature.ScalePoint in project BoofCV by lessthanoptimal.

the class CompleteSift method handleDetection.

@Override
protected void handleDetection(ScalePoint p) {
    // adjust the image for the down sampling in each octave
    double localX = p.x / pixelScaleToInput;
    double localY = p.y / pixelScaleToInput;
    double localSigma = p.scale / pixelScaleToInput;
    // find potential orientations first
    orientation.process(localX, localY, localSigma);
    // describe each feature
    GrowQueue_F64 angles = orientation.getOrientations();
    for (int i = 0; i < angles.size; i++) {
        BrightFeature feature = features.grow();
        feature.white = p.white;
        describe.process(localX, localY, localSigma, angles.get(i), feature);
        orientations.add(angles.get(i));
        locations.add(p);
    }
}
Also used : BrightFeature(boofcv.struct.feature.BrightFeature) GrowQueue_F64(org.ddogleg.struct.GrowQueue_F64) ScalePoint(boofcv.struct.feature.ScalePoint)

Aggregations

ScalePoint (boofcv.struct.feature.ScalePoint)16 GrayF32 (boofcv.struct.image.GrayF32)6 Test (org.junit.Test)4 BrightFeature (boofcv.struct.feature.BrightFeature)3 Point2D_I16 (georegression.struct.point.Point2D_I16)2 GrowQueue_F64 (org.ddogleg.struct.GrowQueue_F64)2 FDistort (boofcv.abst.distort.FDistort)1 ConfigExtract (boofcv.abst.feature.detect.extract.ConfigExtract)1 NonMaxSuppression (boofcv.abst.feature.detect.extract.NonMaxSuppression)1 FastHessianFeatureDetector (boofcv.alg.feature.detect.interest.FastHessianFeatureDetector)1 ImageBorder_F32 (boofcv.core.image.border.ImageBorder_F32)1 ImageGray (boofcv.struct.image.ImageGray)1 ArrayList (java.util.ArrayList)1