當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python skimage.feature.SIFT用法及代碼示例

用法:

class skimage.feature.SIFT(upsampling=2, n_octaves=8, n_scales=3, sigma_min=1.6, sigma_in=0.5, c_dog=0.013333333333333334, c_edge=10, n_bins=36, lambda_ori=1.5, c_max=0.8, lambda_descr=6, n_hist=4, n_ori=8)

基礎:skimage.feature.util.FeatureDetectorskimage.feature.util.DescriptorExtractor

SIFT 特征檢測和說明符提取。

參數

upsamplingint 可選

在特征檢測之前,圖像被放大 1 倍(無放大)、2 或 4。方法:Bi-cubic 插值。

n_octavesint 可選

最大八度音階數。每增加一個八度,圖像大小減半,sigma 加倍。八度音階的數量將根據需要減少,以在最小比例下沿每個維度保持至少 12 個像素。

n_scalesint 可選

每個八度音階的最大音階數。

sigma_min浮點數,可選

種子圖像的模糊級別。如果啟用了上采樣 sigma_min 按因子 1/上采樣進行縮放

sigma_in浮點數,可選

輸入圖像的假定模糊級別。

c_dog浮點數,可選

DoG中丟棄低對比度極值的閾值它的最終值取決於n_scales的關係:final_c_dog = (2^(1/n_scales)-1) /(2^(1/3)-1) * c_dog

c_edge浮點數,可選

丟棄位於邊的極值的閾值。如果 H 是極值的 Hessian,則其 “edgeness” 由 tr(H)²/det(H) 說明。如果邊度高於 (c_edge + 1)²/c_edge,則丟棄極值。

n_binsint 可選

直方圖中說明關鍵點周圍梯度方向的 bin 數量。

lambda_ori浮點數,可選

用於查找關鍵點參考方向的窗口的寬度為 6 * lambda_ori * sigma,並由 2 * lambda_ori * sigma 的標準差加權。

c_max浮點數,可選

方向直方圖中的次峰被接受為方向的閾值

lambda_descr浮點數,可選

用於定義關鍵點說明符的窗口具有 2 * lambda_descr * sigma * (n_hist+1)/n_hist 的寬度,並由 lambda_descr * sigma 的標準差加權。

n_histint 可選

用於定義關鍵點說明符的窗口由 n_hist * n_hist 直方圖組成。

n_oriint 可選

說明符補丁的直方圖中的 bin 數量。

注意

SIFT 算法由 David Lowe [1][2] 開發,後來獲得了不列顛哥倫比亞大學的專利。由於該專利於 2020 年到期,因此可以免費使用。此處的實現緊跟 [3] 中的詳細說明,包括使用相同的默認參數。

參考

1

D.G. Lowe. “Object recognition from local scale-invariant features”, Proceedings of the Seventh IEEE International Conference on Computer Vision, 1999, vol.2, pp. 1150-1157. DOI:10.1109/ICCV.1999.790410

2

D.G. Lowe. “Distinctive Image Features from Scale-Invariant Keypoints”, International Journal of Computer Vision, 2004, vol. 60, pp. 91-110. DOI:10.1023/B:VISI.0000029664.99615.94

3

I. R. Otero and M. Delbracio. “Anatomy of the SIFT Method”, Image Processing On Line, 4 (2014), pp. 370-396. DOI:10.5201/ipol.2014.82

例子

>>> from skimage.feature import SIFT, match_descriptors
>>> from skimage.data import camera
>>> from skimage.transform import rotate
>>> img1 = camera()
>>> img2 = rotate(camera(), 90)
>>> detector_extractor1 = SIFT()
>>> detector_extractor2 = SIFT()
>>> detector_extractor1.detect_and_extract(img1)
>>> detector_extractor2.detect_and_extract(img2)
>>> matches = match_descriptors(detector_extractor1.descriptors,
...                             detector_extractor2.descriptors,
...                             max_ratio=0.6)
>>> matches[10:15]
array([[ 10, 412],
       [ 11, 417],
       [ 12, 407],
       [ 13, 411],
       [ 14, 406]])
>>> detector_extractor1.keypoints[matches[10:15, 0]]
array([[ 95, 214],
       [ 97, 211],
       [ 97, 218],
       [102, 215],
       [104, 218]])
>>> detector_extractor2.keypoints[matches[10:15, 1]]
array([[297,  95],
       [301,  97],
       [294,  97],
       [297, 102],
       [293, 104]])

屬性

delta_min浮點數

第一個八度的采樣距離。它的最終值為 1/上采樣。

float_dtype類型

圖像的數據類型。

scalespace_sigmas(n_octaves, n_scales + 3) 數組

所有八度音階中所有音階的 sigma 值。

keypoints(N, 2) 數組

關鍵點坐標為 (row, col)

positions(N, 2) 數組

Subpixel-precision 關鍵點坐標為 (row, col)

sigmas(N, ) 數組

關鍵點的相應 sigma(模糊)值。

scales(N, ) 數組

關鍵點的相應比例。

orientations(N, ) 數組

每個關鍵點周圍的漸變方向。

octaves(N, ) 數組

關鍵點的對應八度。

descriptors(N, n_hist*n_hist*n_ori) 數組

關鍵點的說明符。

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.feature.SIFT。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。