Class SiftDetector

java.lang.Object
boofcv.alg.feature.detect.interest.SiftDetector

public class SiftDetector extends Object

Implementation of SIFT [1] feature detector. Feature detection is first done by creating the first octave in a scale space. Then the Difference-of-Gaussian (DoG) is computed from sequential scales inside the scale-space. From the DoG images, pixels which are maximums and minimums spatially and with in scale are found. Edges of objects can cause false positives so those are suppressed. The remaining features are interpolated spatially and across scale.

This class is designed so that it can operate as a stand alone feature detector or so that it can be extended to compute feature descriptors too. The advantage of the former is that the scale-space only needs to be constructed once.

Processing Steps

  1. Construct first octave of DoG images using SiftScaleSpace
  2. For DoG images 1 to N+1, detect features
  3. Use NonMaxLimiter to detect features spatially.
  4. Check to see if detected features are minimums or maximums in DoG scale space by checking the equivalent 3x3 regions in the DoG images above and below it. isScaleSpaceExtremum(int, int, float, float)
  5. Detect false positive edges using trace and determinant from Hessian of DoG image
  6. Interpolate feature's (x,y,sigma) coordinate using the peak of a 2nd order polynomial (quadratic). createDetection(int, int, float, boolean)

Where N is the number of scale parameters. There are N+3 scale images and N+2 DoG images in an octave.

Edge Detection

Edges can also cause local extremes (false positives) in the DoG image. To remove those false positives an edge detector is proposed by Lowe. The edge detector is turned with the parameter 'r' and a point is considered an edge if the following is true:
Tr2/Det < (r+1)2/r
where Tr and Det are the trace an determinant of a 2x2 hessian matrix computed from the DoG hessian at that point, [dXX,dXY;dYX,dYY]

Deviations from standard SIFT

  1. Spatial maximums are not limited to a 3x3 region like they are in the paper. User configurable.
  2. Quadratic interpolation is used independently on x,y, and scale axis.
  3. What the scale of a DoG image is isn't specified in the paper. Assumed to be the same as the lower indexed scale image it was computed from.

[1] Lowe, D. "Distinctive image features from scale-invariant keypoints". International Journal of Computer Vision, 60, 2 (2004), pp.91--110.

  • Field Details

    • maxFeaturesAll

      public int maxFeaturesAll
      Maximum number of features after combining results across all scales. if <= 0 then all are returned
    • detectionsAll

      protected DogArray<SiftDetector.SiftPoint> detectionsAll
  • Constructor Details

    • SiftDetector

      public SiftDetector(FeatureSelectLimitIntensity<ScalePoint> selectFeaturesAll, double edgeR, NonMaxLimiter extractor)
      Configures SIFT detector
      Parameters:
      edgeR - Threshold used to remove edge responses. Larger values means its less strict. Try 10
      extractor - Spatial feature detector that can be configured to limit the number of detected features in each scale.
  • Method Details

    • process

      public void process(SiftScaleSpace scaleSpace)
      Detects SIFT features inside the input image
      Parameters:
      scaleSpace - (Input) Precomputed scale space. Not modified.
    • detectFeatures

      protected void detectFeatures(int octaveIndex, int scaleIndex)
      Detect features inside the Difference-of-Gaussian image at the current scale
      Parameters:
      scaleIndex - Which scale in the octave is it detecting features inside up. Primarily provided here for use in child classes.
    • createDetection

      protected SiftDetector.SiftPoint createDetection(int x, int y, float positiveIntensity, boolean maximum)
      Examines a local spatial extremum and interpolates its coordinates using a quadratic function. Very first thing it does is check to see if the feature is really an edge/false positive. After that interpolates the coordinate independently using a quadratic function along each axis. Resulting coordinate will be in the image image's coordinate system.
      Parameters:
      x - x-coordinate of extremum
      y - y-coordinate of extremum
      positiveIntensity - value of the extremum. Positive intensity value.
      maximum - true if it was a maximum
    • getDetections

      public List<SiftDetector.SiftPoint> getDetections()
      All the found and selected detections across scale space