图片旋转,翻转

20230315

旋转

cv2.rotate(src, rotateCode) 或者 np.rot90(np_array, k=1, axes=(0,1))

顺时针旋转90度:
cv2.rotate(src, cv2.ROTATE_90_CLOCKWISE) == np.rot90(image_np_array, k=3, axes=(0, 1))

逆时针旋转90度
cv2.rotate(src, cv2.ROTATE_90_COUNTERCLOCKWISE) == np.rot90(src, k=1, axes=(0,1))

参考:
[1] https://numpy.org/doc/stable/reference/generated/numpy.rot90.html
[2] https://www.geeksforgeeks.org/python-opencv-cv2-rotate-method/

翻转

cv2.flip(src, flipCode) 或者np.flip(), np.fliplr(), np.flipud()

水平翻转
cv2.flip(src, 1) == np.fliplr(src)

竖直翻转 flip vertically
cv2.flip(src, 0) == np.flipud(src)

参考:
[1] https://numpy.org/doc/stable/reference/generated/numpy.fliplr.html#numpy.fliplr
[2] https://www.geeksforgeeks.org/python-opencv-cv2-flip-method/

posted @ 2023-03-15 07:02  xiaoxuxli  阅读(31)  评论(0编辑  收藏  举报