Skip to content Skip to sidebar Skip to footer

OpenCV For Remove Watermark

I am trying cv2.inpaint, if you add watermark by myself, and then use cv2.inpaint, the result is perfect. But, if I use internet image like below: Source Image Watermark image Th

Solution 1:

It seems that the watermark mask and the watermark in the image are not aligned, you can dilate the mask to compensate for small mis-alignments.

Code with dilate that removes the watermark properly:

zhihuimage = cv2.imread('../input/zhihumask/OpenCV_11.jpg')
zhihuwatermask = cv2.imread('../input/zhihumask/OpenCV_22.jpg',cv2.IMREAD_GRAYSCALE)
# remove watermark with mark
dilatekernel = np.ones((5, 5), 'uint8')
zhihuwatermask = cv2.dilate(zhihuwatermask, dilatekernel)
zhihuoutput = cv2.inpaint(zhihuimage, zhihuwatermask, 3, flags=cv2.INPAINT_NS)

Post a Comment for "OpenCV For Remove Watermark"