Sometimes, you have to work with specific channels on multichannel images. To do this, you have to split the multichannel image into several single-channel images. Additionally, once the processing has been done, you may want to create one multichannel image from different single-channel images. In order to both split and merge channels, you can use the cv2.split() and cv2.merge() functions, respectively. The cv2.split() function splits the source multichannel image into several single-channel images. The cv2.merge() function merges several single-channel images into a multichannel image.
In the next example, splitting_and_merging.py, you will learn how to work with these two aforementioned functions. Using the cv2.split() function, if you want to get the three channels from a loaded BGR image, then you should use the following code:
...