5

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.

wsdookadr
  • 2,584
  • 1
  • 21
  • 44
George Chalhoub
  • 14,968
  • 3
  • 38
  • 61
  • 9
    This is a research project, not a narrow coding question. I could _very much_ imagine a book describing different techniques for the purpose and under which circumstances each is applicable (pertinence: as https://stackoverflow.com/help/dont-ask says, "if you can imagine a book that answers your question, you're asking too much"). – Charles Duffy Dec 02 '20 at 00:26
  • 2
    I do not think that the bounding box alone provides enough information for simple image processing to remove any watermark other than simply filling it with a constant color. Patch based inpainting might be able to fill it with image texture. – fmw42 Dec 02 '20 at 04:45
  • 1
    post a sample picture with watermark that you expect to be removable? – Christoph Rackwitz Dec 07 '20 at 05:59
  • 1
    give a sample image – Yash Makan Dec 08 '20 at 07:42

2 Answers2

0

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

Andrey Smorodov
  • 10,649
  • 2
  • 35
  • 42
0

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)
Abdelsalam Hamdi
  • 465
  • 3
  • 13