To show pixels of only a certain color, the pixels of other colors need to be suppressed or assigned a value of 0. The channel selection can happen via indexing or by passing a list:
- Indexing: Keep in mind that, while indexing, the value to the right of the colon represents the higher limit of the channel. It also counts up to n-1. For example, img[:,:,1:3] will select channels up to channel 2, namely blue, starting from channel 1, namely green, but not channel 0, namely red. The snippet img[:,:,0:2] will select channel 0 (red channel) and channel 1 (green) but not channel 2 (blue).
- List: A list such as [0,2] would mean selecting channels 0 and 2, namely red and blue.
In the following ...