OpenCV讲堂 Python Opencv旋转图片90度

1.图片旋转90度

方法一:cv2针对<class 'numpy.ndarray'>

import numpy as np
import cv2
 
img=cv2.imread("/home/lisa/dataset/HandDataSet_720_1280/lisa/image/0.jpg",1)
cv2.imshow("temp",img)
cv2.waitKey(0)
 
img90=np.rot90(img)  逆时针旋转90度
 
cv2.imshow("rotate",img90)
cv2.waitKey(0)

其他方法

https://blog.csdn.net/qq_37674858/article/details/80708393

https://blog.csdn.net/qq_37674858/article/details/80708393

def rotate(image, angle, center=None, scale=1.0): #1
    (h, w) = image.shape[:2] #2
    if center is None: #3
        center = (w // 2, h // 2) #4
 
    M = cv2.getRotationMatrix2D(center, angle, scale) #5
 
    rotated = cv2.warpAffine(image, M, (w, h)) #6
 

方法一:Image针对<class 'PIL.Image.Image'>

image = image.rotate(-90)  # -90是顺时针旋转90度

猜你喜欢

转载自blog.csdn.net/zjc910997316/article/details/85109975