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


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

用法:

class skimage.feature.BRIEF(descriptor_size=256, patch_size=49, mode='normal', sigma=1, sample_seed=1)

基礎:skimage.feature.util.DescriptorExtractor

簡要二進製說明符提取器。

Brief(Binary Robust Independent Elementary Features)是一種有效的特征點說明符。即使使用相對較少的位,它也具有很高的辨別力,並且使用簡單的強度差異測試來計算。

對於每個關鍵點,對 pixel-pairs 的特定分布數 N 進行強度比較,得到長度為 N 的二進製說明符。對於二進製說明符,漢明距離可用於特征匹配,與L2 範數。

參數

descriptor_sizeint 可選

每個關鍵點的簡要說明符的大小。作者推薦的尺碼 128、256 和 512。默認值為 256。

patch_sizeint 可選

關鍵點周圍的二維正方形補丁采樣區域的長度。默認值為 49。

mode{‘normal’, ‘uniform’},可選

關鍵點周圍決策pixel-pairs 的采樣位置的概率分布。

sample_seed{無,int numpy.random.Generator },可選

如果sample_seed是沒有的numpy.random.Generator使用單例。如果sample_seed是一個int 一個新的Generator使用實例,播種sample_seed.如果sample_seed已經是一個Generator實例然後使用該實例。

決策pixel-pairs的隨機抽樣種子。從長度為patch_size 的方形窗口,使用模式參數對像素對進行采樣,以使用強度比較構建說明符。 sample_seed 的值必須與構建說明符時要匹配的圖像相同。

sigma浮點數,可選

應用於圖像以減輕噪聲敏感性的高斯low-pass 濾波器的標準差,強烈建議使用此方法來獲得有辨別力的良好說明符。

例子

>>> from skimage.feature import (corner_harris, corner_peaks, BRIEF,
...                              match_descriptors)
>>> import numpy as np
>>> square1 = np.zeros((8, 8), dtype=np.int32)
>>> square1[2:6, 2:6] = 1
>>> square1
array([[0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0, 0, 0]], dtype=int32)
>>> square2 = np.zeros((9, 9), dtype=np.int32)
>>> square2[2:7, 2:7] = 1
>>> square2
array([[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, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 1, 1, 1, 1, 1, 0, 0],
       [0, 0, 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]], dtype=int32)
>>> keypoints1 = corner_peaks(corner_harris(square1), min_distance=1)
>>> keypoints2 = corner_peaks(corner_harris(square2), min_distance=1)
>>> extractor = BRIEF(patch_size=5)
>>> extractor.extract(square1, keypoints1)
>>> descriptors1 = extractor.descriptors
>>> extractor.extract(square2, keypoints2)
>>> descriptors2 = extractor.descriptors
>>> matches = match_descriptors(descriptors1, descriptors2)
>>> matches
array([[0, 0],
       [1, 1],
       [2, 2],
       [3, 3]])
>>> keypoints1[matches[:, 0]]
array([[2, 2],
       [2, 5],
       [5, 2],
       [5, 5]])
>>> keypoints2[matches[:, 1]]
array([[2, 2],
       [2, 6],
       [6, 2],
       [6, 6]])

屬性

descriptors(問,descriptor_size) dtype bool 數組

大小的二進製說明符的 2D ndarraydescriptor_size過濾掉具有索引值的邊界關鍵點後的 Q 關鍵點(i, j)或者是True或者False表示 j-th 決策 pixel-pair 上 i-th 關鍵點的強度比較結果。這是Q == np.sum(mask).

mask(N, ) dtype bool 數組

指示是否已過濾掉關鍵點的掩碼 (False) 或在說明符大批 (True)。

相關用法


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