OpenCV-Python系列·第六集-1:刚体变换、仿射变换

版权声明:本文为博主原创文章,未经博主允许不得转载。若有任何问题,请联系QQ:575925154(加好友时,请备注:CSDN) https://blog.csdn.net/Miracle0_0/article/details/82022685

刚体变换:长度、角度、形状、基本结构保持不变。

仿射变换:直线保持不变。

# -*- coding: utf-8 -*-
"""
Created on Fri Aug 24 17:14:56 2018

@author: Miracle
"""
import cv2
import numpy as np

image = cv2.imread('../data/lena.jpg')
rows,cols,channel = image.shape
#对应点
src_points = np.float32([[0,0],[cols-1,0],[0,rows-1]])
dst_points = np.float32([[0,0],[int(0.6*(cols-1)),0],
                         [int(0.4*(cols-1)),rows-1]])
#6参数。三个点计算放射矩阵。
affine_matrix = cv2.getAffineTransform(src_points,dst_points)
affine_image = cv2.warpAffine(image,affine_matrix,(cols,rows))

cv2.imshow('Original Image',image)
cv2.imshow('Affine Image',affine_image)

cv2.waitKey()

猜你喜欢

转载自blog.csdn.net/Miracle0_0/article/details/82022685
今日推荐