open cv 旋转图像
zibuyu1995 opened this issue · comments
Mousse commented
# coding=utf-8
import cv2
import numpy as np
in_image = cv2.imread('./image/image6.jpg')
h, w, ch = in_image.shape
forward_rotate = np.zeros((w, h, ch))
image_flip = np.fliplr(in_image)
for c in range(ch):
for row in range(h):
forward_rotate[:, row, c] = image_flip[row, :, c]
reverse_rotate = np.zeros((w, h, ch))
output = np.zeros((w, h, ch))
for c in range(ch):
for row in range(h):
output[:, h - 1 - row, c] = in_image[row, :, c]
cv2.imshow('in_image', in_image)
cv2.imshow('flip_image', image_flip)
cv2.imshow('forward_rotate', forward_rotate)
cv2.imshow('reverse_rotate', reverse_rotate)
# x86 cv2.waitKey(0) x64 cv2.waitKey(0) & 0xFF
key = cv2.waitKey(0) & 0xFF
if key == ord('q'):
cv2.destroyAllWindows()