matrix = np.float32([[1,0,50],[0,1,50]])
show_img_9 = cv2.warpAffine(img,matrix,(cols,rows))
matrix = np.float32([[1,0,100],[0,1,0]])
show_img_10 = cv2.warpAffine(img,matrix,(cols,rows))
plt.subplot(131)
plt.imshow(show_img_8)
plt.subplot(132)
plt.imshow(show_img_9)
plt.subplot(133)
plt.imshow(show_img_10)
plt.show()
图像裁剪
#[左上角x轴坐标:右下角x轴坐标,左上角y轴坐标:右下角y轴坐标]
show_img_11 = img[50:150,50:150]
plt.imshow(show_img_11)
plt.show()
图像翻转
srcPoints = np.float32([[0,0],[0,150],[200,200]])
canvasPoints = np.float32([[0,0],[0,150],[150,150]])
matrix = cv2.getRotationMatrix2D((0,0),0,0.5)
show_img_12 = cv2.warpAffine(img,matrix,(cols,rows))
plt.subplot(121)
plt.imshow(show_img_12)
matrix = cv2.getAffineTransform(np.array(srcPoints),np.array(canvasPoints))
show_img_13 = cv2.warpAffine(img,matrix,(cols,rows))
plt.subplot(122)
plt.imshow(show_img_13)
plt.show()</