欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

如何运用skimage.feature模块的功能详解

最编程 2024-07-23 18:44:37
...

feature

    • blob_dog
    • blob_doh
    • blob_log
    • canny
    • skimage.sobel
    • corner_fast
    • corner_foerstner
    • corner_harris
    • corner_kitchen_rosenfeld
  • only select one feature over two

项目 Value
skimage.feature.blob_dog(image[, min_sigma, …]) Finds blobs in the given grayscale image.在给定的灰度图像中查找斑点。
skimage.feature.blob_doh(image[, min_sigma, …]) Finds blobs in the given grayscale image.在给定的灰度图像中查找斑点。
skimage.feature.blob_log(image[, min_sigma, …]) Finds blobs in the given grayscale image.在给定的灰度图像中查找斑点。
skimage.feature.canny(image[, sigma, …]) Edge filter an image using the Canny algorithm.使用 Canny 算法对图像进行边缘过滤。
skimage.feature.corner_fast(image[, n, …]) Extract FAST corners for a given image.提取给定图像的 FAST 角。
skimage.feature.corner_foerstner(image[, sigma]) Compute Foerstner corner measure response image.计算 Foerstner 角测量响应图像。
skimage.feature.corner_harris(image[, …]) Compute Harris corner measure response image.计算 Harris 角测量响应图像。
skimage.feature.corner_kitchen_rosenfeld(image) Compute Kitchen and Rosenfeld corner measure response image.计算 Kitchen 和 Rosenfeld 角测量响应图像。
skimage.feature.corner_moravec(image[, …]) Compute Moravec corner measure response image.计算 Moravec 角测量响应图像。
skimage.feature.corner_orientations(image, …) Compute the orientation of corners.计算角的方向。
skimage.feature.corner_peaks(image[, …]) Find peaks in corner measure response image.在角测量响应图像中查找峰值。
skimage.feature.corner_shi_tomasi(image[, sigma]) Compute Shi-Tomasi (Kanade-Tomasi) corner measure response image.计算 Shi-Tomasi (Kanade-Tomasi) 角测量响应图像。
skimage.feature.corner_subpix(image, corners) Determine subpixel position of corners.确定角的亚像素位置。
skimage.feature.daisy(image[, step, radius, …]) Extract DAISY feature descriptors densely for the given image.为给定图像密集提取 DAISY 特征描述符。
skimage.feature.draw_haar_like_feature(…) Visualization of Haar-like features.类 Haar 特征的可视化。
skimage.feature.draw_multiblock_lbp(image, …) Multi-block local binary pattern visualization.多块本地二进制模式可视化。
skimage.feature.graycomatrix(image, …[, …]) Calculate the gray-level co-occurrence matrix.计算灰度共生矩阵。
skimage.feature.graycoprops(P[, prop]) Calculate texture properties of a GLCM.计算 GLCM 的纹理属性。
skimage.feature.greycomatrix(image, …[, …]) Deprecated function.弃用的功能。
skimage.feature.greycoprops(P[, prop]) Deprecated function.弃用的功能。
skimage.feature.haar_like_feature(int_image, …) Compute the Haar-like features for a region of interest (ROI) of an integral image.计算积分图像的感兴趣区域 (ROI) 的类 Haar 特征。
skimage.feature.haar_like_feature_coord(…) Compute the coordinates of Haar-like features.计算类 Haar 特征的坐标。
skimage.feature.hessian_matrix(image[, …]) Compute the Hessian matrix.计算 Hessian 矩阵。
skimage.feature.hessian_matrix_det(image[, …]) Compute the approximate Hessian Determinant over an image.计算图像上的近似 Hessian 行列式。
skimage.feature.hessian_matrix_eigvals(H_elems) Compute eigenvalues of Hessian matrix.计算 Hessian 矩阵的特征值。
skimage.feature.hog(image[, orientations, …]) Extract Histogram of Oriented Gradients (HOG) for a given image.提取给定图像的定向梯度直方图 (HOG)。
skimage.feature.local_binary_pattern(image, P, R) Gray scale and rotation invariant LBP (Local Binary Patterns).灰度和旋转不变 LBP(局部二进制模式)。
skimage.feature.match_descriptors(…[, …]) Brute-force matching of descriptors.描述符的蛮力匹配。
skimage.feature.match_template(image, template) Match a template to a 2-D or 3-D image using normalized correlation.使用归一化相关将模板与 2-D 或 3-D 图像匹配。
skimage.feature.multiblock_lbp(int_image, r, …) Multi-block local binary pattern (MB-LBP).多块本地二进制模式 (MB-LBP)。
skimage.feature.multiscale_basic_features(image) Local features for a single- or multi-channel nd image.单通道或多通道 nd 图像的局部特征。
skimage.feature.peak_local_max(image[, …]) Find peaks in an image as coordinate list or boolean mask.以坐标列表或布尔掩码的形式查找图像中的峰值。
skimage.feature.plot_matches(ax, image1, …) Plot matched features.绘制匹配的特征。
skimage.feature.shape_index(image[, sigma, …]) Compute the shape index.计算形状指数。
skimage.feature.structure_tensor(image[, …]) Compute structure tensor using sum of squared differences.使用平方差和计算结构张量。
skimage.feature.structure_tensor_eigenvalues(A_elems) Compute eigenvalues of structure tensor.计算结构张量的特征值。
skimage.feature.structure_tensor_eigvals(…) Compute eigenvalues of structure tensor.计算结构张量的特征值。
skimage.feature.BRIEF([descriptor_size, …]) BRIEF binary descriptor extractor.简要的二进制描述符提取器。
skimage.feature.CENSURE([min_scale, …]) CENSURE keypoint detector. CENSURE 关键点检测器。
skimage.feature.Cascade Class for cascade of classifiers that is used for object detection.用于对象检测的级联分类器的类。
skimage.feature.ORB([downscale, n_scales, …]) Oriented FAST and rotated BRIEF feature detector and binary descriptor extractor.面向 FAST 和旋转的 BRIEF 特征检测器和二进制描述符提取器。
skimage.feature.SIFT([upsampling, …]) SIFT feature detection and descriptor extraction.SIFT 特征检测和描述符提取。

blob_dog

skimage.feature.blob_dog(image, min_sigma=1, max_sigma=50, sigma_ratio=1.6, threshold=0.5, overlap=0.5, *, threshold_rel=None, exclude_border=False)[source]

在给定的灰度图像中查找斑点。

使用高斯差分 (DoG) 方法[1]、[2]找到斑点。对于找到的每个 blob,该方法返回其坐标和检测到 blob 的高斯核的标准偏差。

  • 参数
  1. 图像数组
    输入灰度图像,假设斑点在深色背景上是浅色的(黑底白字)。

  2. min_sigma标量或标量序列,可选
    高斯核的最小标准偏差。保持这个低以检测较小的斑点。每个轴的高斯滤波器的标准偏差作为序列或单个数字给出,在这种情况下,它对所有轴都相等。

  3. max_sigma标量或标量序列,可选
    高斯核的最大标准偏差。保持这个高以检测更大的斑点。每个轴的高斯滤波器的标准偏差作为序列或单个数字给出,在这种情况下,它对所有轴都相等。

  4. sigma_ratio浮点数,可选
    用于计算高斯差分的高斯核的标准偏差之间的比率

  5. 阈值浮动或无,可选
    尺度空间最大值的绝对下限。小于阈值的局部最大值被忽略。减少它以检测强度较低的斑点。如果threshold_rel还指定,取阈值较大将被使用。如果没有,则使用threshold_rel代替。

  6. 重叠浮动,可选
    一个介于 0 和 1 之间的值。如果两个 blob 的区域重叠的分数大于threshold,则消除较小的 blob。

  7. threshold_rel浮点数或无,可选
    峰值的最小强度,计算为 ,其中指的是内部计算的高斯差分 (DoG) 图像堆栈。这应该有一个介于 0 和 1 之间的值。如果没有,则使用阈值。max(dog_space) * threshold_reldog_space

  8. exclude_border整数、整数或 False 的元组,可选
    如果是整数元组,则元组的长度必须与输入数组的维度匹配。元组的每个元素都将沿该维度排除图像边界的exclude_border -pixels内的峰值。如果非零整数,exclude_border从图像边界的exclude_border -pixels内排除峰值 。如果为零或假,则无论峰距边界的距离如何,都会识别峰。

  • Returns
    A (n, image.ndim + sigma) ndarray
    一个 2d 数组,每行代表 2D 图像的 2 个坐标值,或 3D 图像的 3 个坐标值,加上使用的 sigma。当传递单个 sigma 时,输出为: 或其中或 是 blob 的坐标,是检测 blob 的高斯核的标准偏差。当使用各向异性高斯(每个维度的 sigma)时,会返回每个维度的检测到的 sigma。(r, c, sigma)(p, r, c, sigma)(r, c)(p, r, c)sigma

  • See also
    skimage.filters.difference_of_gaussians

  • Notes
    The radius of each blob is approximately 2–√σ for a 2-D image and 3–√σ for a 3-D image.

  • References
    1.https://en.wikipedia.org/wiki/Blob_detection#The_difference_of_Gaussians_approach

  1. Lowe, D. G. “Distinctive Image Features from Scale-Invariant Keypoints.” International Journal of Computer Vision 60, 91–110 (2004). https://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf DOI:10.1023/B:VISI.0000029664.99615.94
  • Examples
from skimage import data, feature
coins = data.coins()
feature.blob_dog(coins, threshold=.05, min_sigma=10, max_sigma=40)
array([[128., 155.,  10.],
       [198., 155.,  10.],
       [124., 338.,  10.],
       [127., 102.,  10.],
       [193., 281.,  10.],
       [126., 208.,  10.],
       [267., 115.,  10.],
       [197., 102.,  10.],
       [198., 215.,  10.],
       [123., 279.,  10.],
       [126.,  46.,  10.],
       [259., 247.,  10.],
       [196.,  43.,  10.],
       [ 54., 276.,  10.],
       [267., 358.,  10.],
       [ 58., 100.,  10.],
       [259., 305.,  10.],
       [185., 347.,  16.],
       [261., 174.,  16.],
       [ 46., 336.,  16.],
       [ 54., 217.,  10.],
       [ 55., 157.,  10.],
       [ 57.,  41.,  10.],
       [260.,  47.,  16.]])

在这里插入图片描述

blob_doh

skimage.feature.blob_doh(image, min_sigma=1, max_sigma=30, num_sigma=10, threshold=0.01, overlap=0.5, log_scale=False, *, threshold_rel=None)[source]

在给定的灰度图像中查找斑点。

使用 Hessian 行列式方法[1]找到斑点。对于找到的每个 blob,该方法返回其坐标和用于 Hessian 矩阵的 Gaussian Kernel 的标准偏差,其行列式检测到 blob。Hessians 的行列式近似使用[2]。

  • 参数
  1. 图像二维数组
    输入灰度图像。斑点可以是亮暗暗,反之亦然。

  2. min_sigma浮点数,可选
    用于计算 Hessian 矩阵的高斯核的最小标准偏差。保持这个低以检测较小的斑点。

  3. max_sigma浮点数,可选
    用于计算 Hessian 矩阵的高斯核的最大标准偏差。保持这个高以检测更大的斑点。

  4. num_sigma int,可选
    min_sigma和max_sigma之间要考虑的标准偏差中间值的数量。

  5. 阈值浮动或无,可选
    尺度空间最大值的绝对下限。小于阈值的局部最大值被忽略。减少它以检测强度较低的斑点。如果threshold_rel还指定,取阈值较大将被使用。如果没有,则使用threshold_rel代替。

  6. 重叠浮动,可选
    一个介于 0 和 1 之间的值。如果两个 blob 的区域重叠的分数大于threshold,则消除较小的 blob。

  7. log_scale布尔值,可选
    如果设置的标准偏差中间值使用对数刻度内插到基数10。如果不是,则使用线性插值。

  8. threshold_rel浮点数或无,可选
    峰值的最小强度,计算为 ,其中指的是内部计算的 Hessian 行列式 (DoH) 图像堆栈。这应该有一个介于 0 和 1 之间的值。如果没有,则使用阈值。max(doh_space) * threshold_reldoh_space

  • Returns
    A (n, 3) ndarray
    一个二维数组,每行代表 3 个值,(y,x,sigma) 其中(y,x)是 blob 的坐标,sigma是 Hessian 矩阵的高斯核的标准偏差,其行列式检测到 blob。

  • Notes
    每个 blob 的半径约为sigma。Hessians 行列式的计算与标准偏差无关。因此检测更大的斑点不会花费更多时间。在方法线blob_dog()和blob_log()高斯计算更大的西格玛需要更多的时间。缺点是该方法不能用于检测半径小于3px 的斑点, 因为在 Hessian 行列式的近似中使用了盒式过滤器。

  • References

  1. https://en.wikipedia.org/wiki/Blob_detection#The_determinant_of_the_Hessian
  2. Herbert Bay、Andreas Ess、Tinne Tuytelaars、Luc Van Gool,“冲浪:加速强大的功能” ftp://ftp.vision.ee.ethz.ch/publications/articles/eth_biwi_00517.pdf
from skimage import data, feature
img = data.coins()
feature.blob_doh(img)
array([[197.        , 153.        ,  20.33333333],
       [124.        , 336.        ,  20.33333333],
       [126.        , 153.        ,  20.33333333],
       [195.        , 100.        ,  23.55555556],
       [192.        , 212.        ,  23.55555556],
       [121.        , 271.        ,  30.        ],
       [126.        , 101.        ,  20.33333333],
       [193.        , 275.        ,  23.55555556],
       [123.        , 205.        ,  20.33333333],
       [270.        , 363.        ,  30.        ],
       [265.        , 113.        ,  23.55555556],
       [262.        , 243.        ,  23.55555556],
       [185.        , 348.        ,  30.        ],
       [156.        , 302.        ,  30.        ],
       [123.        ,  44.        ,  23.55555556],
       [260.        , 173.        ,  30.        ],
       [197.        ,  44.        ,  20.33333333]])

blob_log

skimage.feature.blob_log(image, min_sigma=1, max_sigma=50, num_sigma=10, threshold=0.2, overlap=0.5, log_scale=False, *, threshold_rel=None, exclude_border=False)[source]
  • 参数
  1. 图像数组
    输入灰度图像,假设斑点在深色背景上是浅色的(黑底白字)。

  2. min_sigma标量或标量序列,可选
    高斯核的最小标准偏差。保持这个低以检测较小的斑点。每个轴的高斯滤波器的标准偏差作为序列或单个数字给出,在这种情况下,它对所有轴都相等。

  3. max_sigma标量或标量序列,可选
    高斯核的最大标准偏差。保持这个高以检测更大的斑点。每个轴的高斯滤波器的标准偏差作为序列或单个数字给出,在这种情况下,它对所有轴都相等。

  4. num_sigma int,可选
    min_sigma和max_sigma之间要考虑的标准偏差中间值的数量。

  5. 阈值浮动或无,可选
    尺度空间最大值的绝对下限。小于阈值的局部最大值被忽略。减少它以检测强度较低的斑点。如果threshold_rel还指定,取阈值较大将被使用。如果没有,则使用threshold_rel代替。

  6. 重叠浮动,可选
    一个介于 0 和 1 之间的值。如果两个 blob 的区域重叠的分数大于threshold,则消除较小的 blob。

  7. log_scale布尔值,可选
    如果设置的标准偏差中间值使用对数刻度内插到基数10。如果不是,则使用线性插值。

  8. threshold_rel浮点数或无,可选
    峰值的最小强度,计算为 ,其中指的是内部计算的拉普拉斯高斯 (LoG) 图像堆栈。这应该有一个介于 0 和 1 之间的值。如果没有,则使用阈值。max(log_space) * threshold_rellog_space

  9. exclude_border整数、整数或 False 的元组,可选
    如果是整数元组,则元组的长度必须与输入数组的维度匹配。元组的每个元素都将沿该维度排除图像边界的exclude_border -pixels内的峰值。如果非零整数,exclude_border从图像边界的exclude_border -pixels内排除峰值 。如果为零或假,则无论峰距边界的距离如何,都会识别峰。

  • 退货
    A (n, image.ndim + sigma) ndarray
    一个 2d 数组,每行代表 2D 图像的 2 个坐标值,或 3D 图像的 3 个坐标值,加上使用的 sigma。当传递单个 sigma 时,输出为: 或其中或 是 blob 的坐标,是检测 blob 的高斯核的标准偏差。当使用各向异性高斯(每个维度的 sigma)时,会返回每个维度的检测到的 sigma。(r, c, sigma)(p, r, c, sigma)(r, c)(p, r, c)sigma

  • 笔记
    每个 blob 的半径约为 2–√σ 对于二维图像和 3–√σ 对于 3D 图像。

  • 参考

1 https://en.wikipedia.org/wiki/Blob_detection#The_Laplacian_of_Gaussian

from skimage import data, feature, exposure
img = data.coins()
img = exposure.equalize_hist(img)  # improves detection
feature.blob_log(img, threshold = .3)
array([[124.        , 336.        ,  11.88888889],
       [198.        , 155.        ,  11.88888889],
       [194.        , 213.        ,  17.33333333],
       [121.        , 272.        ,  17.33333333],
       [263.        , 244.        ,  17.33333333],
       [194.        , 276.        ,  17.33333333],
       [266.        , 115.        ,  11.88888889],
       [128.        , 154.        ,  11.88888889],
       [260.        , 174.        ,  17.33333333],
       [198.        , 103.        ,  11.88888889],
       [126.        , 208.        ,  11.88888889],
       [127.        , 102.        ,  11.88888889],
       [263.        , 302.        ,  17.33333333],
       [197.        ,  44.        ,  11.88888889],
       [185.        , 344.        ,  17.33333333],
       [126.        ,  46.        ,  11.88888889],
       [113.        , 323.        ,   1.        ]])

canny

skimage.feature.canny(image, sigma=1.0, low_threshold=None, high_threshold=None, mask=None, use_quantiles=False, *, mode='constant', cval=0.0)[source]

使用 Canny 算法对图像进行边缘过滤。

  • 参数
  1. 图像二维数组
    灰度输入图像以检测边缘;可以是任何数据类型。

  2. 西格玛浮点数,可选
    高斯滤波器的标准偏差。

  3. low_threshold浮点数,可选
    滞后阈值的下限(链接边缘)。如果没有,low_threshold 设置为 dtype 最大值的 10%。

  4. 高阈值浮动,可选
    滞后阈值的上限(链接边缘)。如果没有,high_threshold 设置为 dtype 最大值的 20%。

  5. 掩码数组,dtype=bool,可选
    将 Canny 的应用限制在某个区域的掩码。

  6. use_quantiles bool,可选
    如果True然后将 low_threshold 和 high_threshold 视为边缘幅度图像的分位数,而不是绝对边缘幅度值。如果True那么阈值必须在 [0, 1] 范围内。

  7. 模式str, {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}
    该mode参数决定了在高斯滤波期间如何处理数组边界,其中cvalmode 等于 ‘constant’ 时的值。

  8. cval浮点数,可选
    如果模式为“常量” ,则填充过去输入边缘的值。

  • returns
    输出二维数组(图像)
    二进制边缘图。

也可以看看

skimage.sobel

笔记

  1. 该算法的步骤如下:

  2. 使用具有sigma宽度的高斯平滑图像。

  3. 应用水平和垂直 Sobel 算子来获得图像内的梯度。边缘强度是梯度的范数。

  4. 将潜在边缘细化为 1 像素宽的曲线。首先,找到每个点边缘的法线。这是通过查看 X-Sobel 和 Y-Sobel 的符号和相对大小将点分为 4 类来完成的:水平、垂直、对角线和对角线。然后查看正方向和反方向,看看这两个方向中的任何一个方向的值是否大于所讨论的点。使用插值来获得点的混合,而不是选择最接近法线的点。

  5. 执行滞后阈值处理:首先将高于高阈值的所有点标记为边缘。然后递归地将任何高于低阈值的点标记为 8 连接到标记点作为边缘。

  • 参考
    1 Canny, J.,边缘检测的计算方法,IEEE Trans。模式分析和机器智能,8:679-714,1986 DOI:10.1109/TPAMI.1986.47678512 William Green 的 Canny 教程 https://en.wikipedia.org/wiki/Canny_edge_detector

  • 例子

from skimage import feature
rng = np.random.default_rng()
# Generate noisy image of a square
im = np.zeros((256, 256))
im[64:-64, 64:-64] = 1
im += 0.2 * rng.random(im.shape)
# First trial with the Canny filter, with the default smoothing
edges1 = feature.canny(im)
# Increase the smoothing for better results
edges2 = feature.canny(im, sigma=3)

corner_fast

skimage.feature.corner_fast(image, n=12, threshold=0.15)[source]

提取给定图像的 FAST 角。

  • Parameters
  1. 图像(M, N) ndarray
    输入图像。

  2. n int,可选
    圆圈上 16 个像素中的最小连续像素数,这些像素都应该比测试像素更亮或更暗。如果Ic < Ip-阈值,则圆上的点 c 比测试像素 p 更暗 ,如果Ic > Ip + 阈值,则更亮。也代表FAST-n角点检测器中的 n。

  3. 阈值浮动,可选
    用于决定圆圈上的像素是否比测试像素更亮、更暗或相似的阈值。当需要更多拐角时降低阈值,反之亦然。

  • Returns
    响应数组
    快速角响应图像。

  • References

  1. Rosten, E., & Drummond, T. (2006, May). Machine learning for high-speed corner detection. In European conference on computer vision (pp. 430-443). Springer, Berlin, Heidelberg. DOI:10.1007/11744023_34 http://www.edwardrosten.com/work/rosten_2006_machine.pdf
  2. Wikipedia, “Features from accelerated segment test”, https://en.wikipedia.org/wiki/Features_from_accelerated_segment_test
    Examples
>>> from skimage.feature import corner_fast, corner_peaks
>>> square = np.zeros((12, 12))
>>> square[3:9, 3:9] = 1
>>> square.astype(int)
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])
>>> corner_peaks(corner_fast(square, 9), min_distance=1
																				
															

推荐阅读