Python影像處理(13):brisk特徵檢測

來源:互聯網
上載者:User

標籤:vs2013   opencv   python   影像處理   

快樂蝦

http://blog.csdn.net/lights_joy/

歡迎轉載,但請保留作者資訊


BRISK是BRIEF描述子的一種改進,相比於BRIEF特徵,它具有旋轉不變性、尺度不變性和對雜訊的魯棒性。本節嘗試在python下使用此特徵檢測方式,使用的測試映像為先前已經轉換為灰階圖的棉花映像:



首先讀取映像:


# 讀取原始映像img = cv2.imread(r‘F:\projects\src\opencv\images\cotton\39.gray.jpg‘)plt.imshow(img)

接著建立一個brisk特徵檢測器:

# 建立brisk檢測器brisk = cv2.BRISK_create()

接下來計算映像的特徵,此函數的原型為:

Help on built-in function detectAndCompute:detectAndCompute(...)    detectAndCompute(image, mask[, descriptors[, useProvidedKeypoints]]) -> keypoints, descriptors

調用它計算特徵點並顯示:

# 計算特徵點並顯示(kpt, desc) = brisk.detectAndCompute(img, None)bk_img = img.copy()out_img = img.copy()out_img = cv2.drawKeypoints(bk_img, kpt, out_img)plt.figure(2)plt.imshow(out_img)

結果就是這樣的:


貌似對我們的葉片識別沒有直接的協助,需要自己尋找特徵點才行。


直接將原圖旋轉30度:

# 原映像旋轉30度ang=np.pi/6rot_mat = np.array([[np.cos(ang), np.sin(ang), 0], [-np.sin(ang), np.cos(ang), 200]])img_30 = cv2.warpAffine(img, rot_mat, (600,500))plt.figure(3)plt.imshow(img_30)

計算新的特徵值:

# 特徵點檢測(kpt_30, desc_30) = brisk.detectAndCompute(img_30, None)bk_img = img_30.copy()out_img = img_30.copy()out_img = cv2.drawKeypoints(bk_img, kpt_30, out_img)plt.figure(4)plt.imshow(out_img)


直接做特徵點的匹配:

# 特徵點匹配matcher = cv2.BFMatcher()matches = matcher.match(desc, desc_30)print(matches)

最後用映像顯示匹配的結果:

# 顯示匹配結果,僅顯示前面的5個點matches.sort(None, None, True)out_img = cv2.drawMatches(img, kpt, img_30, kpt_30, matches[0:5], out_img)plt.figure(5)plt.imshow(out_img)



匹配的效果也令人失望。













??

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

Python影像處理(13):brisk特徵檢測

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.