How can you display only a single color from a RGB image with OpenCV in python ? The idea is to be able to print the image in a grey scale corresponding to the intensity of a certain color in the RGB spectrum.
You can either use split:
blue, green, red = cv2.split(img)
Or, as this is a costly operation in terms of time and you only need one of the channles (for instance, red) you can directly slice the original image like as follows:
red = img[:,:,2]
Which will return a greyscaled image where the brighter pixels are the ones that have higher red values in the original image.
Hope this helped!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With