python 图像配准,python opencv实现图像配准与比较

本文通过Python的OpenCV库演示了如何进行图像配准与比较,使用ORB关键点检测和BFMatcher进行匹配,然后找到最佳匹配并应用单应性矩阵进行透视变换。最后展示了配准结果及差异图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文实例为大家分享了python opencv实现图像配准与比较的具体代码,供大家参考,具体内容如下

代码

from skimage import io

import cv2 as cv

import numpy as np

import matplotlib.pyplot as plt

img_path1 = "2_HE_maxarea.png"

img_path2 = "2_IHC_maxarea.png"

img1 = io.imread(img_path1)

img2 = io.imread(img_path2)

img1 = np.uint8(img1)

img2 = np.uint8(img2)

# find the keypoints and descriptors with ORB

orb = cv.ORB_create()

kp1, des1 = orb.detectAndCompute(img1,None)

kp2, des2 = orb.detectAndCompute(img2,None)

# def get_good_match(des1,des2):

# bf = cv.BFMatcher()

# matches = bf.knnMatch(des1, des2, k=2)

# good = []

# for m, n in matches:

# if m.distance < 0.75 * n.distance:

# good.append(m)

# return good,matches

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值