Image cut / displacement

Image pixels is to cut a portion of the image taken out, assigned to the new image

And image displacement cut similar to the interception of a part image, the new image into the displacement position corresponding to

code show as below:

CV2 Import 
Import numpy AS NP
IMG = cv2.imread ( '../ IMG / zidan.jpg',. 1)
imgInfo img.shape =
height = imgInfo [0]
width = imgInfo [. 1]
matShif np.float32 = ([[ 1,0,200], [0,1,200]]) # 2 * 3 matrix displaced rightward downward movement respectively 200px
DST1 = cv2.warpAffine (IMG, matShif, (width, height)) for mobile image #api
dst2 = np. zeros (imgInfo, np.uint8) # mobile image source implementation
for I in Range (0, 200 is height-):
for J in Range (0, 200 is width-):
dst2 [+ 200 is I, J 200 is +] = IMG [ I, J]
cutImg IMG = [100: 300, 100: 500] # image shear
cv2.imshow ( 'the src', IMG)
cv2.imshow ( 'cutImg', cutImg)
cv2.imshow ( 'moveImg', DST1)
CV2. imshow ( 'moveImg2', dst2)
cv2.waitKey (0)

renderings:

 

Guess you like

Origin www.cnblogs.com/cxxBoo/p/11447947.html
cut