OpenCV remove watermark

55 Views Asked by At

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()

enter image description here

This is the result:

enter image description here

Some ideas of how solve this

1

There are 1 best solutions below

0
Tim Roberts On

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.