cv2.flip(src, flipCode[, dst]) → dst
- src: original image matrix;
- dst: the transformation matrix;
- flipMode: Toggle mode, there are three modes;
0 - --- flipped vertically;
. 1 ----- - Invert the horizontal direction;
flip -1 ------ simultaneously horizontal and vertical directions
from matplotlib import pyplot as plt
import numpy as np
import cv2
image = cv2.imread("aier.jpg")
h_flip = cv2.flip(image, 1)
v_flip = cv2.flip(image, 0)
hv_flip = cv2.flip(image, -1)
plt.figure(figsize=(8,8))
plt.subplot(221)
plt.imshow(image[:,:,::-1])
plt.title('original')
plt.subplot(222)
plt.imshow(h_flip[:,:,::-1])
plt.title('horizontal flip')
plt.subplot(223)
plt.imshow(v_flip[:,:,::-1])
plt.title(' vertical flip')
plt.subplot(224)
plt.imshow(hv_flip[:,:,::-1])
plt.title('h_v flip')