Mahotas - Speeded-Up Robust Features



Speeded−Up Robust Features (SURF) is an algorithm that is used to detect distinctive features (keypoints) in images. SURF identifies keypoints by analyzing the intensity changes in an image at multiple scales.

It assigns orientations to these points and generates descriptors that capture their unique characteristics.

The descriptors are computed in a pattern within local regions around the keypoints. These descriptors can then be used for various applications.

SURF uses two primary techniques − surf dense and surf integral. Both techniques have been discussed in detail in the upcoming chapters.

SURF Surf

SURF surf is a technique that combines the detection and description of keypoints of an image. It generates descriptors that encode the properties of these keypoints. The function takes an image as input and returns a set of SURF descriptors.

Syntax

Following is the basic syntax of the surf.surf() function in mahotas −

mahotas.features.surf.surf(f, nr_octaves=4, nr_scales=6, initial_step_size=1,
threshold=0.1, max_points=1024, descriptor_only=False)

Where,

  • f − It is the input image.

  • nr_octaves (optional) − It defines the number of octaves to be used in the SURF algorithm. An octave represents an image at different level of resolution (default is 4).

  • nr_scales (optional) − It determines the number of scales per octave. The scales are used to detect features at different levels of detail (default is 6).

  • initial_step_size (optional) − It determines the initial step size between consecutive scales. A smaller step size allows for detection of detailed features (default is 1).

  • threshold (optional) − It is the threshold value that is used to filter out weak SURF features (default is 0.1).

  • max_points (optional) − It defines the maximum number of SURF points that will be returned (default is 1024).

  • descriptor_only (optional) − It is a flag that determines whether to return only the descriptors or the descriptors and keypoints. When set to True, only the descriptors of the detected features will be returned.

    If set to False, both the keypoints and descriptors will be returned (default is False).

We can see the surf image below −

Surf

SURF Dense

SURF Dense is a technique used by the SURF algorithm. The keypoints are densely sampled across an image in SURF dense.

In other words, instead of searching for specific interesting points, SURF Dense calculates the descriptors for a grid of pixels in the image. This helps to capture information about the entire image.

In the following image, we can see SURF dense image −

Surf Dense

SURF Integral

The SURF integral technique enhances the SURF algorithm's calculation efficiency by utilizing integral images. Integral images pre−calculate the cumulative sum of pixel intensities up to specific areas of an image.

This pre−calculation eliminates redundant calculations, enabling faster and more efficient feature detection and description.

As a result, the SURF algorithm becomes well−suited for real−time applications and handling large−scale datasets.

The following is the image for SURF integral −

Surf Integral Technique

Example

In the following example, we are performing different SURF functions on an image as discussed above −

import mahotas as mh
from mahotas.features import surf
import numpy as np
import matplotlib.pyplot as mtplt
image = mh.imread('tree.tiff', as_grey=True)
# SURF dense
surf_dense = surf.dense(image, 100)
mtplt.imshow(surf_dense)
mtplt.title('SURF Dense Image')
mtplt.axis('off')
mtplt.show()
# SURF integral
surf_integral = surf.integral(image)
mtplt.imshow(surf_integral)
mtplt.title('SURF Integral Image')
mtplt.axis('off')
mtplt.show()
# SURF surf
surf_surf = surf.surf(image)
mtplt.imshow(surf_surf)
mtplt.title('SURF Surf Image')
mtplt.axis('off')
mtplt.show()

Output

The output obtained is as shown below −

SURF Dense Image:

Surf Dense1

SURF Integral Image:

Surf Integral Image

SURF Surf Image:

Surf Image1

We will discuss about the SURF Dense and the SURF Integral techniques in detail in the further chapters.

Advertisements