y=200 #自定义转换矩阵M的y轴移动值 M=np.float32([[1,0,x],[0,1,y]]) #构造转换矩阵M move=cv2.warpAffine(img,M,(width,height)) #平移映射 cv2.imshow('orginal',img) cv2.imshow('move',move) cv2.waitKey() cv2.destroyAllWindows() 程序运行结果如下图所示,左为原图,右为平移后的图。
www.jb51.net/article/2076...htm 2025-1-30