Links:
- https://pyimagesearch.com/2021/01/23/splitting-and-merging-channels-with-opencv/
- OpenCV Official: https://docs.opencv.org/3.4/d3/df2/tutorial_py_basic_ops.html
Splitting and Merging Image Channels
- Sometimes you will need to work separately on the B,G,R channels of an image.
In this case, you need to split the BGR image into single channels.
In other cases, you may need to join these individual channels to create a BGR image.
You can do this simply by:
b, g, r = cv.split(img)
img = cv.merge((b, g, r))
Or
b, g, r =img[:,:,0], img[:,:,0] img[:,:,0]
img = cv.merge((b, g, r))
- Suppose you want to set all the red pixels to zero
Numpy indexing is faster, so you do not need to split the channels first.:
img[:,:,2] = 0
标签:ImageProcessing,img,image,Splitting,channels,OpenCV,need,cv
From: https://www.cnblogs.com/abaelhe/p/18343054