import cv2
import numpy as np
img = cv2.imread('flower.jpg',1)
Info = img.shape
height = Info[0]
width = Info[1]
desImg = np.zeros(img.shape,np.uint8) #建立与原来图像矩阵大小一样的0矩阵
for i in range (0,height):
for j in range(0,width-100): #将图像向右平移100
desImg[i,j+100] = img[i,j]
cv2.imshow('ori',img)
cv2.imshow('desimg',desImg)
cv2.waitKey(0)
11_源代码实现图片的移位
最新推荐文章于 2021-05-26 02:18:28 发布