opencv学习8——图像缩放(矩阵变换)

一、

1.图片仿射变换之图片移动,

2.cv2.warpAffine,将其中的变换矩阵变为(coe代表缩放比例)

结果:

实现缩放

二、

# 图像缩放的矩阵操作实现方法


import cv2
import numpy as np

coe = 0.4

img = cv2.imread('image01.jpg',1)
imgHeight,imgWidth,imgMode = img.shape
dstHeight, dstWidth = int(imgHeight * coe), int(imgWidth * coe)

matMove = np.float32([[coe,0,0],
                       [0,coe,0]])

dstImg = cv2.warpAffine(img,matMove,(dstWidth,dstHeight))

cv2.imshow('image', dstImg)

cv2.waitKey(0)
cv2.destroyAllWindows()

猜你喜欢

转载自blog.csdn.net/nominior/article/details/82794591