In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to use the cv2..split () and cv2.merge () functions in opencv. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Separate the three channels of the image, and notice that the order of the channels is BGR:
Import numpy as npimport cv2 # Import opencv module image=cv2.imread ("bryant.jpg") # read the picture to be processed BMagne R = cv2.split (image) # separate out the picture G color channel cv2.imshow ("RED COMPONENT FOR ALL THREE CHANNELS", R) # shows the picture cv2.imshow ("GREEN COMPONENT FOR ALL THREE CHANNELS", G) # shows the picture when the values of all three channels are R ("BLUE COMPONENT FOR ALL THREE CHANNELS", B) # shows the picture cv2.waitKey (0) when the values of all three channels are B values # does not let the program end suddenly
Screenshot of the execution result:
Separate the three channels of the image, and set the rest to zero. Note that the order of the channels is BGR:
Import numpy as npimport cv2 # Import opencv module image=cv2.imread ("bryant.jpg") # read the picture to be processed BMagazine R = cv2.split (image) # separate out the color channel zeros = np.zeros (image.shape [: 2], dtype= "uint8") # create a zero matrix cv2.imshow of the same size as image ("DISPLAY BLUE COMPONENT", cv2.merge ([Bdazeros])) # display (B 0) cv2.imshow ("DISPLAY GREEN COMPONENT", cv2.merge ([zeros,G,zeros])) # display (0MagneGMagne0) Image cv2.imshow ("DISPLAY RED COMPONENT", cv2.merge ([zeros,zeros,R])) # display (0Magne0Min R) Image cv2.waitKey (0)
Screenshot of the running result:
Remerge the extracted three channels back:
Import numpy as npimport cv2 # Import opencv module image=cv2.imread ("bryant.jpg") # read the picture to be processed BMagazine R = cv2.split (image) # separate the image from the image, cv2.imshow ("MERGE RED,GREEN AND BLUE CHANNELS", cv2.merge ([BMGMAI R])) # display (BMGMAR) image cv2.waitKey (0)
Screenshot of the running result:
About how to use the cv2..split () and cv2.merge () functions in opencv is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.