How to extract individual channels from an RGB image
The extracted red channel may look like a grayscale image but it is correct. It is simply a 2D array with values in the range [0,255]
. To visualize a specific channel, you need to set the other channels to zero. So to show the red channel, the blue and green channels need to be set to zero.
import cv2
img = cv2.imread('1.jpg')
# Set blue and green channels to 0
img[:,:,0] = 0
img[:,:,1] = 0
cv2.imshow('red_img', img)
cv2.waitKey()