admin 管理员组文章数量: 1184232
简介
一幅倾斜了的图片如何进行矫正,这也许比较有用,比如,传统的车牌中有将倾斜了的车牌文字,用 Radon变换进行矫正。如果我们知道了四个点的坐标,是否也可以进行矫正处理?
代码
'''
Created on 2017年8月20日
@author: XT
'''
# import the necessary packages
import matplotlib.pyplot as plt
import imutils
from imutils import perspective
import numpy as np
import cv2
# load the notecard code image, clone it, and initialize the 4 points
# that correspond to the 4 corners of the notecard
notecard = cv2.imread("../image/notecard.png")
clone = notecard.copy()
pts = np.array([(73, 239), (356, 117), (475, 265), (187, 443)])
# loop over the points and draw them on the cloned image
for (x, y) in pts:
cv2.circle(clone, (x, y), 5, (0, 255, 0), -1)
# apply the four point tranform to obtain a "birds eye view" of
# the notecard
warped = perspective.four_point_transform(notecard, pts)
# show the original and warped images
cv2.imshow("Original", clone)
cv2.imshow("Warped", warped)
plt.figure("Original opencv2matplotlib")
plt.imshow(imutils.opencv2matplotlib(clone))
plt.show()
cv2.waitKey(0)
效果
本文标签: 透视 图片 transform perspective
版权声明:本文标题:图片的透视变换perspective transform——旋转矫正 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1758746064a3089994.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论