Environment: Windows

Python version: 3.6

Install the anaconda, download address: www.anaconda.com/download/

32 – bit computer to choose 32 – bit, 64 – bit to choose 64 – bit. After installation, download OpenCV

Next comes the code

Img = cv2.imread('2.jpg',1) cv2.imshow(' SRC ',img) imgInfo = Img.shape height = imgInfo[0] width = imgInfo[1] matShift = Np.float32 ([1,0,100],[0,1,200]]) # 2*3 DST = cv2.warpAffine(img,matShift,(height,width)) # 1 data 2 mat 3 info cv2.imshow('dst',dst) cv2.waitKey(0)Copy the code

The following is the source code to achieve the displacement of the picture

import cv2
import numpy as np
img = cv2.imread('2.jpg',1)
cv2.imshow('src',img)
imgInfo = img.shape
dst = np.zeros(img.shape,np.uint8)
height = imgInfo[0]
width = imgInfo[1]
for i in range(0,height):
    for j in range(0,width-100):
        dst[i,j+100] = img[i,j]
cv2.imshow('image',dst) 
cv2.waitKey(0)
Copy the code

The final renderings are shown below