Flipping an image is equivalent to a mirror effect. Let's learn how to flip an image across the x axis (vertical flipping), y axis (horizontal flipping), or both axes. OpenCV offers the flip() function to flip an image. The flip() function will take two arguments: image and flipcode. The image is a NumPy array of pixel values and the flipcode used defines the type of flip, such as horizontal, vertical, or both. The following flipcode values are for different types of flips:
- Flipcode > 0 is for a horizontal flip.
- Flipcode = 0 is for a vertical flip.
- Flipcode < 0 is for both a horizontal and vertical flip.
Let's see an example of flipping an image:
# Import OpenCV module
import cv2
# Import NumPy
import numpy as np
# Import matplotlib for showing the image
import matplotlib.pyplot as plt
# magic function to render the figure in a notebook
%matplotlib inline
# Read image
image = cv2.imread('messi.png')
# Convert image color space BGR to RGB
rgb_image=cv2...