I am trying to remove this watermark, I have tried a thousand ways but none of them work, any ideas, here is the code
if __name__ == '__main__':
img = cv2.imread("doc.jpg")
cv2.imshow("Image With Water Mark", img)
img1 = cv2.imread("doc.jpg")
_, thresh = cv2.threshold(img1, 150, 255, cv2.THRESH_BINARY)
#cv2.imshow('Image Without Water Mark', thresh)
cv2.imshow('Image Without Water Mark', thresh)
cv2.waitKey(0)
cv2.destroyAllWindows()

This is the result:

Some ideas of how solve this
This does a pretty good job. It may need additional smoothing. The text is all pretty much black and white, but the watermark is gray. So, convert everything less than 60% black to white.
from PIL import Image
x = Image.open('vodRX.jpg')
x1 = x.convert('L')
x2 = x1.point( lambda p: (p > 100) * 255 )
x2.save('after.jpg')
However, be aware that what you're doing may be illegal. They add these watermarks for a reason.

I am trying to remove this watermark, I have tried a thousand ways but none of them work
The problem can be fixed.
You need to add more algorithms.
Snippet:
import cv2
import numpy as np
def wartermark_remove(filename):
img = cv2.imread(filename)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
for i in range(5):
kernel2 = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,
(2 * i + 1, 2 * i + 1))
bg = cv2.morphologyEx(gray, cv2.MORPH_CLOSE, kernel2)
bg = cv2.morphologyEx(bg, cv2.MORPH_OPEN, kernel2)
dif = cv2.subtract(bg, gray)
bw = cv2.threshold(dif, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
dark = cv2.threshold(bg, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
darkpix = gray[np.where(dark > 0)]
darkpix = cv2.threshold(darkpix, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
bw[np.where(dark > 0)] = darkpix.T
cv2.imshow('Watermark Image', bw)
cv2.waitKey(0)
wartermark_remove('w.jpg')
Screenshot:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With