Mahotas 简明教程
Mahotas - Speeded-Up Robust Features
加速稳健特征 (SURF) 是一种算法,用于检测图像中的识别特征 (关键点)。SURF 通过分析不同比例的图像中的强度变化来标识关键点。
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 使用两种主要技术 - surf dense 和 surf integral。将在后面的章节中详细讨论这两种技术。
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 是一种将图像关键点的检测和描述相结合的技术。它生成描述这些关键点属性的描述符。该函数将图像作为输入,并返回一组 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
以下是 mahotas 中 surf.surf() 函数的基本语法 -
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 Dense
SURF 稠密是 SURF 算法使用的一种技术。SURF 稠密在图像中对关键点进行稠密采样。
SURF Dense is a technique used by the SURF algorithm. The keypoints are densely sampled across an image in SURF dense.
换句话说,SURF 稠密不搜索特定的兴趣点,而是计算图像中像素网格的描述符。这有助于获取有关整幅图像的信息。
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.
在以下图像中,我们可以看到 SURF 稠密图像 −
In the following image, we can see SURF dense image −
SURF Integral
SURF 积分技术通过使用积分图像来提高 SURF 算法的计算效率。积分图像预先计算了像素强度在图像特定区域内的累加和。
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.
结果,SURF 算法非常适合于实时应用程序和处理大规模数据集。
As a result, the SURF algorithm becomes well−suited for real−time applications and handling large−scale datasets.
以下为 SURF 积分图像 −
The following is the image for SURF integral −
Example
在下面的示例中,我们对图像执行了上面讨论的不同 SURF 函数 −
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()
获得的输出如下所示 −
The output obtained is as shown below −
SURF Dense Image:
SURF Dense Image:
SURF Integral Image:
SURF Integral Image:
SURF Surf Image:
SURF Surf Image:
我们将在后面的章节中详细讨论 SURF 稠密和 SURF 积分技术。
We will discuss about the SURF Dense and the SURF Integral techniques in detail in the further chapters.