January 2018
Intermediate to advanced
268 pages
6h 20m
English
Considering all the color spaces, there are around 190 conversion options available in OpenCV. If you want to see a list of all available flags, go to the Python shell and type the following:
import cv2print([x for x in dir(cv2) if x.startswith('COLOR_')])
You will see a list of options available in OpenCV for converting from one color space to another. We can pretty much convert any color space to any other color space. Let's see how we can convert a color image to a grayscale image:
import cv2img = cv2.imread('./images/input.jpg', cv2.IMREAD_COLOR)gray_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)cv2.imshow('Grayscale image', gray_img)cv2.waitKey()
Read now
Unlock full access