-
大小: 68KB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2021-05-20
- 語言: Python
- 標(biāo)簽: Python??SIFT??RANSAC??圖像配準(zhǔn)??
資源簡介
基于SIFT算法的特征提取,RANSAC隨機(jī)采樣一致算法的圖像配準(zhǔn)、融合、拼接Python代碼,里邊用測試用例

代碼片段和文件信息
#?-*-?coding:?utf-8?-*-
“““
Created?on?Thu?May?11?17:32:56?2017
@author:?Administrator
“““
import?cv2
import?numpy?as?np
import?random
color?=?[(25500)(2551560)(2552550)(02550)(0255255)(00255)(2550255)]
#圖片大小一致
def?display(img1?img2?kp1?kp2):
????height1?=?img1.shape[0]
????width1?=?img1.shape[1]
????height2?=?img2.shape[0]
????width2?=?img2.shape[1]
????emptyImage?=?np.concatenate((img1img2)axis=1)?
????
????for?i?in?range(len(kp1)):
????????number?=?random.randint(06)
????????x1?=?int(kp1[i][0])
????????y1?=?int(kp1[i][1])
????????x2?=?int(kp2[i][0])
????????y2?=?int(kp2[i][1])
????????cv2.circle(emptyImage(x1?y1)2(25500)2)
????????cv2.circle(emptyImage(width1+x2?y2)2(25500)2)
????????cv2.line(emptyImage?(x1y1)?(width1+x2?y2)?color[number]?thickness=1?lineType=1)
????
????return?emptyImage
????
#圖片大小不一致
def?display1(img1?img2?kp1?kp2):
????height1?=?img1.shape[0]
????width1?=?img1.shape[1]
????height2?=?img2.shape[0]
????width2?=?img2.shape[1]
????#?三通道圖片:
????emptyImage?=?np.zeros((max(height1height2)width1+width23)dtype=np.uint8)
????emptyImage[0:height10:width1:]=img1[0:height10:width1:]
????emptyImage[0:height2width1:width1+width2:]=img2[0:height20:width2:]
????#?#?灰度圖片:
????#?emptyImage?=?np.zeros((max(height1?height2)?width1?+?width2)?dtype=np.uint8)
????#?emptyImage[0:height1?0:width1]?=?img1
????#?emptyImage[0:height2?width1:width1?+?width2]?=?img2
????
????for?i?in?range(len(kp1)):
????????x1?=?int(kp1[i][0])
????????y1?=?int(kp1[i][1])
????????x2?=?int(kp2[i][0])
????????y2?=?int(kp2[i][1])
????????cv2.circle(emptyImage(x1?y1)2(00255)2)
????????cv2.circle(emptyImage(width1+x2?y2)2(00255)2)
????????cv2.line(emptyImage?(x1y1)?(width1+x2?y2)?(02550)?thickness=1?lineType=0)
????return?emptyImage
#show?image?with?key?point????????
def?show_image(img?keypoit):
????image?=?np.zeros((img.shape[0]img.shape[1]3)dtype=np.uint8)
????image[:::]?=?img[:::]
????for?i?in?range(len(keypoit)):
????????x1?=?int(keypoit[i][0])
????????y1?=?int(keypoit[i][1])
????????cv2.circle(image(x1?y1)1(25500)1)
????return?image
????
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-11-17?11:07??Register優(yōu)化程序\
?????文件???????46026??2017-08-18?11:17??Register優(yōu)化程序\51.jpg
?????文件???????15672??2018-05-08?16:51??Register優(yōu)化程序\53.jpg
?????文件????????2269??2018-05-08?17:59??Register優(yōu)化程序\register_display.py
?????文件????????4216??2018-05-09?18:31??Register優(yōu)化程序\register_image_fusion.py
?????文件????????6264??2019-10-09?09:45??Register優(yōu)化程序\register_main.py
?????文件????????2094??2018-04-27?09:28??Register優(yōu)化程序\register_match.py
?????文件????????3777??2018-04-27?09:28??Register優(yōu)化程序\register_ransac.py
評論
共有 條評論