How it works...

To change the color space of an image with OpenCV, you should use the cvtColor function. It takes the source image and the special value, which encodes the source and targets the color spaces. The return value of the function is the converted image. OpenCV supports over 200 conversion types. The results of the code execution should be as follows:

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.