缩放
import numpy as np
import cv2 as cv
img = cv.imread('test.jpg')
res = cv.resize(img, None, fx=2, fy=2, interpolation=cv.INTER_CUBIC)
# OR
height, width = img.shape[:2]
res = cv.resize(img, (2*width, 2*height), interpolation=cv.INTER_CUBIC)
cv.resize(src, dsize[, dst[, fx[, fy[, interpolation]]]])
dsize:输出图片的大小,如果为None,dsize = Size(round(fx*src.cols), round(fy*src.rwos))
fx:沿x轴的比例因子,当其等于0时,fx = (double)dsize.width / src.cols
fy:沿y轴的比例因子,当其等于0时,fy = (double)dsize.height / src.rows
dsize和fx、fy不能同时为0;当dsize和fx、fy都定义时,以dsize为准
interpolation:插值方式,默认为cv.INTER_LINEAR;详见cv::InterpolationFlags
位移
import cv2 as cv
import numpy as np
img = cv.imread('opencv.jpg', 0)
rows, cols = img.shape
M =