Removing watermark from an image using bbox parameters

1.2k Views Asked by At

I am using a Computer Vision cloud service to detect watermarks on a set of images. The cloud service returns the location of the watermark in form of Bounding Box (bbox). For example, one output looked like this:

  "text": "Watermarked Text",
  "words": [
    {
      "boundingBox": [
        889,
        1043,
        939,
        1044,
        939,
        1076,
        888,
        1075
      ]

Bounding Box parameters have been previously explained on Stack Overflow.

My goal is to remove the watermark from the image by providing the bbox parameters as an input to a tool that can remove watermarks.

I think OpenCV-Python is a great fit for this task. I checked their Image Processing API but couldn't find any solutions. The closest solution I could find was inpainting.

I'm wondering what is the best way to achieve my task using OpenCV? I'd be grateful for any help.

2

There are 2 best solutions below

0
On

Watermark removing is not so trivial task, but it can be solved using GAN networks. As a reference you can chekc here.

0
On

Here is a sample code with a sample reference using opencv and numpy, This is not exactly your answer to your full question but it's good place to try. This code will work only for this image, but you can modify the code a bit to get work for your application

you can get the image and the code as well from this link https://www.kaggle.com/general/169854 I tried the code my self and it get the exact same results as the link, here's the code with the necessary packages imported

import cv2 
import numpy as np 
import matplotlib.pyplot as plt 

img = cv2.imread("waterMark1.jpg")

alpha = 2.596594846224838
beta = -161

new = alpha * img + beta
new = np.clip(new, 0, 255).astype(np.uint8)

print(alpha, beta)
plt.imshow(new)
plt.title('my picture')
plt.show()
cv2.imwrite("cleaned.png", new)