November 2018
Intermediate to advanced
492 pages
12h 19m
English
We can use the split() function to separate the channels of a multi-channel image, as is shown in the following code for an RGB image:
ch_r, ch_g, ch_b = im.split() # split the RGB image into 3 channels: R, G and B# we shall use matplotlib to display the channelsplt.figure(figsize=(18,6))plt.subplot(1,3,1); plt.imshow(ch_r, cmap=plt.cm.Reds); plt.axis('off')plt.subplot(1,3,2); plt.imshow(ch_g, cmap=plt.cm.Greens); plt.axis('off')plt.subplot(1,3,3); plt.imshow(ch_b, cmap=plt.cm.Blues); plt.axis('off')plt.tight_layout()plt.show() # show the R, G, B channels
The following figure shows three output images created for each of the R (red), G (green), and B (blue) channels generated by running the previous ...
Read now
Unlock full access