cv2 picture rotation

import cv2 
import numpy as np 

iamge_path ='xuanzhu.jpg' 


# Rotate 90 degrees clockwise 
def RotateClockWise90(img): 
    trans_img = cv2.transpose(img) 
    new_img = cv2.flip(trans_img, 1) 
    return new_img 


# rotate 90 degrees counterclockwise Degree 
def RotateAntiClockWise90(img): 
    trans_img = cv2.transpose(img) 
    new_img = cv2.flip(trans_img, 0) 
    return new_img
def image_porcess(): 
    from PIL import Image 
    import matplotlib.pyplot as plt 

    img = Image.open(iamge_path) # Open the picture 
    # Rotate 45 degrees counterclockwise (with black background) 
    img01 = img.rotate(45) 
    plt.imshow(img01 ) 
    plt.show() 
    # No black background 
    img02 = img.transpose(Image.ROTATE_90) 
    plt.imshow(img02) 
    plt.show()

Guess you like

Origin blog.csdn.net/xkx_07_10/article/details/101430704