Library/OpenCV
09. 이미지 회전
Python Developer
2024. 11. 18. 21:35
In [1]:
from Custom.mediahelper import show_image_with_pil # 개발자 정의 모듈
9. 이미지 회전¶
방향 회전¶
In [2]:
import cv2
img = cv2.imread('../Media/images/img.png')
rotate_90 = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE) # 시계 방향 90도 회전
rotate_180 = cv2.rotate(img, cv2.ROTATE_180) # 180도 회전
rotate_reverse_90 = cv2.rotate(img, cv2.ROTATE_90_COUNTERCLOCKWISE) # 시계 반대 방향 90도 회전
cv2.imshow('img',img)
cv2.imshow('rotate_90', rotate_90)
cv2.imshow('rotate_reverse_90', rotate_reverse_90)
cv2.waitKey(0)
cv2.destroyAllWindows()
show_image_with_pil(img, 'img')
show_image_with_pil(rotate_90, 'rotate_90')
show_image_with_pil(rotate_reverse_90, 'rotate_reverse_90')
'img'
'rotate_90'
'rotate_reverse_90'