opencv------图片的翻转和旋转

一、图片的翻转

flip(src, flipCode[, dst])
flipCode=0表示上下翻,
flipCode>0表示左右翻转
flipCode<0山下+左右

代码:

import cv2
import numpy as np
dog=cv2.imread('./dog1.jpeg')
img=cv2.flip(dog,0)
#下面的语句也能实现图片的翻转
#img=dog[::-1]
#左右翻转
#img=dog[::,::-1]
#上下+左右
#img=dog[::-1,::-1]
cv2.imshow('dog',img)
key=cv2.waitKey(0) 
cv2.destroyAllWindows()

二、图片的旋转

rotate(src, rotateCode[, dst])
Rotate by 90 degrees clockwise (rotateCode = ROTATE_90_CLOCKWISE).
Rotate by 180 degrees clockwise (rotateCode = ROTATE_180).
Rotate by 270 degrees clockwise (rotateCode = ROTATE_90_COUNTERCLOCKWISE).
COUNTERCLOCKWISE逆时针,CLOCKWISE顺时针

代码:

import cv2
import numpy as np
dog=cv2.imread('./dog1.jpeg')
img=cv2.rotate(dog,cv2.ROTATE_90_COUNTERCLOCKWISE)

cv2.imshow('dog',img)
key=cv2.waitKey(0) 
cv2.destroyAllWindows()

你可能感兴趣的:(opencv,opencv,计算机视觉,人工智能)