In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to quickly de-watermark Python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Principle of image de-watermarking
1. Calibrate the characteristics of the noise. Use cv2.inRange binarization marking noise to binarize the image. Specific code: cv2.inRange (img, np.array ([200,200,240]), np.array ([255,255,255])). The colors other than [200,200,200] ~ [255,255,255] are processed to 0.
2. Use the dilate method of OpenCV to expand the area of features and optimize the effect of image processing.
3. Using inpaint method, taking the mask of noise as a parameter, reasoning and repairing the image.
Remove the watermark in the lower right corner
1. Capture the lower right corner from the original picture and save it as a new picture.
2. Identify the watermark. The color value is: [200,200,200] ~ [255,255,255]
3. Remove the watermark and restore the picture
4. Overlap and merge the original image and the new one without watermark.
The code implements import cv2import numpy as npfrom PIL import Imageimport osdir = os.getcwd () path = "1.jpg" newPath = "new.jpg" img=cv2.imread (path,1) hight,width,depth=img.shape [0:3] # intercept cropped = img [int (hight*0.8): hight, int (width*0.7): width] # crop coordinates as [y0:y1, x0:x1] cv2.imwrite (newPath, cropped) imgSY = cv2.imread (newPath,1) # Image binarization processing Change colors other than [200200200]-[250250250] to 0thresh = cv2.inRange (imgSY,np.array ([200200200]), np.array ([250250250250])) # create structural elements of shape and size kernel = np.ones ((3d3), np.uint8) # extend the area to be repaired hi_mask = cv2.dilate (thresh,kernel,iterations=10) specular = cv2.inpaint (imgSY,hi_mask,5,flags=cv2.INPAINT_TELEA) cv2.imwrite (newPath) Specular) # overlay image imgSY = Image.open (newPath) img = Image.open (path) img.paste (imgSY, (int (width*0.7), int (hight*0.8), width,hight)) img.save (newPath) "how to get rid of watermarks quickly by Python" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.