图片的透视变换perspective transform——旋转矫正

本文介绍了一种基于四个角点坐标的倾斜图片矫正方法,并通过OpenCV实现了一个示例,展示了如何将一张倾斜的纸牌图像矫正为正视图。

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

简介

一幅倾斜了的图片如何进行矫正,这也许比较有用,比如,传统的车牌中有将倾斜了的车牌文字,用 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)

效果

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

何以问天涯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值