基于Python的图像投影变换(图像的偏移矫正)

基于Anaconda(python)的图像投影变换

一、安装和配置Anacond3

1.安装Anacond3,安装vscode,jupyter notebook等软件;在这里插入图片描述

2.配置环境

pip install numpy
pip install matplotlib
pip install opencv-python

二、基于图像的逆透视变换完成目标的倾斜纠正,在vscode里用python编程完成。

1.基于透视的图像矫正(自动获取图像顶点变换)

以灰度图读入
腐蚀膨胀,闭合等操作
二值化图像
获取图像顶点
透视矫正
直接获取图像轮廓矫正
在这里插入图片描述

from imutils.perspective import four_point_transform
import imutils
import cv2

def Get_Outline(input_dir):
    image = cv2.imread(input_dir)
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    blurred = cv2.GaussianBlur(gray, (5,5),0)
    edged = cv2.Canny(blurred,75,200)
    return image,gray,edged

def Get_cnt(edged):
    cnts = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
    cnts = cnts[0] if  imutils.is_cv2()  else   cnts[1]
    docCnt =None

    if len(cnts) > 0:
        cnts =sorted(cnts,key=cv2.contourArea,reverse=True)
        for c in cnts:
            peri = cv2.arcLength(c,True)                   # 轮廓按大小降序排序
            approx = cv2.approxPol
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值