You can convert to YUV by using the following flag:
yuv_img = cv2.cvtColor(img, cv2.COLOR_BGR2YUV)
The image will look something like the following one:
This may look like a deteriorated version of the original image, but it's not. Let's separate out the three channels:
# Alternative 1y,u,v = cv2.split(yuv_img)cv2.imshow('Y channel', y)cv2.imshow('U channel', u)cv2.imshow('V channel', v)cv2.waitKey()
# Alternative 2 (Faster)cv2.imshow('Y channel', yuv_img[:, :, 0])cv2.imshow('U channel', yuv_img[:, :, 1])cv2.imshow('V channel', yuv_img[:, :, 2])cv2.waitKey()
Since yuv_img is a NumPy (which provides dimensional selection ...