刚体变换:长度、角度、形状、基本结构保持不变。
仿射变换:直线保持不变。
# -*- 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()