Skip to content

SURF-inspired detector

Fact Value
Also called SURF-inspired speeded features, Fast-Hessian detector
Status Implemented and tested
Family Texture, corners, blobs and features
Engine Science engine
Type Nonlinear, spatial, box-filter Hessian determinant extrema
Output Features
Operator shown as algorithm (exact)
Support radius global
Code engine/src/pixelnexus_engine/filters/surf.py, surf_inspired
Operator code engine/src/pixelnexus_engine/filters/surf.py, surf_representation
Packages NumPy, SciPy

Overview

The SURF-inspired detector finds blob keypoints with the Fast-Hessian detector of SURF, by Bay and coworkers. It approximates the Hessian with box filters on the integral image, so a large filter costs as much as a small one. Each keypoint gets a size, an orientation from Haar wavelets, and the sign of its Laplacian. SURF itself is patented and missing from the default builds of OpenCV, so this is PixelNexus's own code after the paper. Only the detector and the orientation are built, not the descriptor. The keypoints go to the Features panel and are drawn on the canvas.

Four panels: a Siemens star with 36 spokes, and SURF-inspired keypoints as small rings with angle lines. On the star, many small rings sit along the spokes and the rim. The turned star shows the same rings in the turned places. On the Disks image, rings sit inside three of the smaller disks only. Four panels: a Siemens star with 36 spokes, and SURF-inspired keypoints as small rings with angle lines. On the star, many small rings sit along the spokes and the rim. The turned star shows the same rings in the turned places. On the Disks image, rings sit inside three of the smaller disks only.
The keypoints with the defaults on the Siemens star, on the star turned a quarter counterclockwise, and on the Disks image. Each keypoint is a ring of its sigma with a line along its angle.

How it works

  1. Take the luma from 0 to 1 and its integral image.
  2. At each filter size, compute the three box responses and the determinant at every pixel.
  3. Keep maxima over position and size above the threshold, one per group of equal maxima.
  4. Give each keypoint the dominant direction of its Haar wavelet responses.
  5. Report the position, sigma, filter size, angle, determinant and the sign of the Laplacian.

Mathematical foundation

\[ \det H \approx D_{xx} D_{yy} - (0.9\, D_{xy})^2, \qquad \sigma = 1.2\, \frac{L}{9}, \qquad \det H \ge 0.005 \]

The formula shows the default parameter values.

where

  • \(D_{xx}, D_{yy}, D_{xy}\): The box-filter second derivatives, divided by L^2
  • \(L\): The filter size
  • \(\sigma\): The scale the filter stands for

The Hessian determinant is large at the middle of blobs. SURF approximates the Gaussian second derivatives by box filters of size L with lobes of L / 3 pixels. With the integral image, each box takes four lookups, so a large filter costs as much as a small one. Instead of shrinking the image, the filters grow. The first octave has the sizes 9, 15, 21 and 27, and each next octave doubles the step. Each response is divided by L^2. The weight 0.9 balances the box D_xy against the others, as in the paper. Keypoints are maxima over their 3 x 3 x 3 neighbors in position and size, above the threshold. The orientation is the longest sum of Haar wavelet responses within a window of 60 degrees. The sign of the Laplacian D_xx + D_yy tells bright blobs (negative) from dark ones (positive).

The integral image S holds at each point the sum of all pixels above and to the left. The sum over any box then takes four lookups: S at its four corners. This is the trick behind SURF's speed.

The second derivatives of a Gaussian look like a positive bump between two negative lobes, or four lobes of alternating sign for the mixed derivative. SURF replaces them by boxes of constant weight. A filter of size L = 3 l has lobes of l pixels. D_yy has three lobes of l rows and 2 l - 1 columns, with weights 1, -2 and 1, and D_xx is the same turned. D_xy has four lobes of l x l, one pixel away from the center row and column. The smallest filter, 9 x 9, stands for a Gaussian of sigma 1.2, so a filter of size L stands for sigma = 1.2 L / 9. Each response is divided by L^2, so all sizes give comparable values.

The weight 0.9 balances the box D_xy against the other two, since boxes are not exact Gaussian derivatives. Bay and coworkers found it from the Frobenius norms of the filters. Keypoints are maxima of the determinant over their 26 neighbors in position and filter size, above the threshold. Since the octaves overlap in size, a blob can appear in two octaves.

For the orientation, Haar wavelets of side about 4 s measure the change in x and in y. They sit on a grid of step s within a radius of 6 s around the keypoint. A Gaussian of 2 s weights them. A window of 60 degrees slides around the circle, and the longest sum of the responses inside it gives the angle.

Kernel or operator

The Inspector asks the engine for the stages with the current settings. They are the integral image, the box Hessian with the filter sizes of each octave, the maxima, and the orientation when it is on.

Parameters

Parameter Default Values Meaning
Octaves octaves 4 1 to 4 The number of octaves. Each one doubles the filter sizes, from 9 to 27 px in the first to 51 to 195 px in the fourth.
Threshold threshold 0.005 0.0001 to 0.1 The smallest box-filter Hessian determinant a keypoint needs, for an image from 0 to 1.
Orientation orientation on On or off Give each keypoint an orientation from Haar wavelet responses. Off gives every keypoint the angle 0, as upright SURF does.

Implementation

surf_inspired in engine/src/pixelnexus_engine/filters/surf.py builds the integral image of the luma from 0 to 1. The hessian_boxes function computes the three box responses of one filter size at every pixel with whole-array lookups, and detect finds the maxima with a 3 x 3 x 3 maximum filter. A blob centered between two pixels gives two equal maxima side by side, so only the first of each touching group stays. The orientation function samples the Haar wavelets. They span 4 s + 1 pixels and leave out the center row or column, so a quarter turn of the image turns the responses exactly. The window moves in steps of 5 degrees, which is our choice.

This code differs from SURF in three ways. It computes the responses at every pixel instead of at a coarser step in the higher octaves. It does not refine positions and sizes between pixels and filter sizes. And it builds no descriptor. The table has x and y, sigma, the filter size, the angle and the determinant as the score. Its last column is the sign of the Laplacian D_xx + D_yy, which is negative for bright blobs.

Worked example

Image Keypoints Radius (px) Found after a quarter turn (%)
Siemens star 832 2.0 to 13.2 99
Disks 6 2.8 to 19.6 17

The SURF-inspired detector with the defaults on the 512 x 512 test images. The last column is the share of keypoints found again after the image is turned a quarter counterclockwise: within 1 pixel of the turned place, with a radius within 10 percent, and with an angle 90 degrees larger, within 5 degrees. A quarter turn moves pixels exactly onto pixels, so any loss comes from the detector itself.

On the Disks image, each disk looks the same in every direction, so its angle has no meaning, and a quarter turn rarely gives the turned angle. The Siemens star has a clear direction at every keypoint.

Complexity

  • Time: \(O(S N)\)
  • Memory: \(O(N)\)

N is the number of pixels and S the number of filter sizes. Each box costs four lookups, whatever its size.

Artifacts and limitations

Limitations

  • This is PixelNexus's own code after the paper, not SURF itself. It computes responses at every pixel and has no subpixel refinement, so positions and sizes are coarser than in SURF.
  • The descriptor is not built.
  • A blob can be found in two octaves, since the filter sizes of neighboring octaves overlap.
  • On a round blob, the angle only roughly follows the brightness around it. On a disk on a ramp, it is within about 30 degrees of the direction of the ramp.

Artifacts

  • Many keypoints along fine, high-contrast patterns, such as the spokes of the Siemens star.

Tests

The box responses must equal a direct correlation with the kernels of the paper, written out as arrays, for the sizes 9, 15, 27 and 51. Each kernel must sum to 0. The filter sizes of the four octaves must be those of the paper. The score must be the box determinant with the weight 0.9. Bright disks must be found with a negative Laplacian, and dark disks at the same places with a positive one. A quarter turn of the Siemens star must give the same number of keypoints, with at least 95 percent at the turned place with the turned angle. Touching equal maxima must give one keypoint. The engine API tests check the JSON and the stages.

References

  • Bay, H., Ess, A., Tuytelaars, T., and Van Gool, L. Speeded-up robust features (SURF). Computer Vision and Image Understanding 110(3), 346 to 359, 2008. DOI 10.1016/j.cviu.2007.09.014.