In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail the example analysis of OpenCV bit-by-bit AND OR XOR and NOT. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
1. Effect picture
The circular effect of a rectangular VS is as follows:
The effect of the AND operation is shown below, and you can see that the edge of the square is lost, because the rectangle does not cover an area as large as a circle, so neither pixel is "on".
The effect of the OR operation is shown below, and you can see that the rectangle and circle are merged.
The effect of the XOR operation is shown below, and you can see that the center of the square has been removed, because XOR operations cannot have pixels greater than zero at the same time.
The effect picture of the NOT operation is as follows, you can see that the circle changes from the white background of the foreground to the black of the foreground.
two。 The source code # applies the AND, OR, XOR, and NOT operators to the sample image. # USAGE# python opencv_bitwise.py# Import necessary package import numpy as npimport cv2# draw a rectangle rectangle = np.zeros ((300,300), dtype= "uint8") cv2.rectangle (rectangle, (25,25), (275,275), 255,255,1) cv2.imshow ("Rectangle", rectangle) # draw a circle circle = np.zeros ((300,300), dtype= "uint8") cv2.circle (circle, (150,150), 150,255) -1) cv2.imshow ("Circle", circle) # 'AND' operation-when the input is all > 0 pixels The on operation pixel is 255 white, otherwise it is set to off, and the pixel is 0 black # if and only if both pixels are greater than 00:00, the bitwise AND is true. BitwiseAnd = cv2.bitwise_and (rectangle, circle) cv2.imshow ("AND", bitwiseAnd) cv2.waitKey (0) # 'OR' operation to get the union of rectangle and circle, as long as there is a > 0, you get 255white, otherwise, "bitwise" or "is true if either of the two pixels is greater than zero. BitwiseOr = cv2.bitwise_or (rectangle, circle) cv2.imshow ("OR", bitwiseOr) cv2.waitKey (0) # 'XOR' is a complement of OR. Only if one of the two pixels is > 0, it is white 255bitwiseXor = cv2.bitwise_xor (rectangle, circle) cv2.imshow ("XOR", bitwiseXor) cv2.waitKey (0) #' NOT' operation: 0 becomes 255i Change into 0bitwiseNot = cv2.bitwise_not (circle) cv2.imshow ("NOT", bitwiseNot) cv2.waitKey (0) the sample analysis of OpenCV bit-by-bit AND OR XOR and NOT is shared here. I hope the above content can be helpful to everyone and 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: 300
*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.