October 2019
Beginner to intermediate
674 pages
16h 43m
English
As we saw earlier, the third dimension denotes the RGB channel. Hence, to filter all the pixels in one channel, we should select all the pixels in the first two dimensions and only the channel of interest. Also, the indexing in Python starts from 0, thus 0 represents red, 1 represents green, and 2 represents blue. Keeping these in mind, let's have a look at the snippets to select the red, green, and blue channels of an image.
The snippet to select the red is as follows:
img_r=img[:,:,0]plt.imshow(img_r)
The following is the output:

Read now
Unlock full access