In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use Python to change negatives with one click. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Preface
Knowledge points:
1. Image processing.
2.OpenCV
3.numpy
Basic knowledge of 4.python
Environment:
Windows
Pycharm
Python3
Steps
Pour into the library
Import numpy as npimport cv2
Change the name if you install it directly at the command prompt
Pip install OpenCV-python
Image import
Img = cv2.imread ('timg.jpg')
Scalin
Rows,cols,channels = img.shapeprint (rows,cols,channels) img = cv2.resize (img,None,fx=0.5,fy=0.5) rows,cols,channels = img.shapeprint (rows,cols,channels)
Display and process the content of the image
Convert an image to a binary image
Cv2.imshow ('img',img) hsv = cv2.cvtColor (img,cv2.COLOR_BGR2HSV) cv2.imshow (' hsv',hsv) lower_blue = np.array upper_blue = np.array ([110255255])
Binarization function
Mask = cv2.inRange (hsv,lower_blue,upper_blue) cv2.imshow ('Mask',mask)
Corrosion
Erosion = cv2.erode (mask,None,iterations=1) cv2.imshow ('erosion',erosion)
Expansion
Dilation = cv2.dilate (mask, None,iterations=1) cv2.imshow ('dilation',dilation)
For i in range (rows): for j in range (cols): if dilation [iMagnej] = = 25525: img [iMagnej] = (0mem0255) # rgb (255Lot0) BGR () cv2.imshow ('res',img)
Save
Cv2.imwrite ('ting.png',img) cv2.waitKey (0) # 0 infinitely waiting for cv2.destroyAllWindows () # destroy all windows thank you for reading! This is the end of this article on "how to use Python to change negatives with one click". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out 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.