2

Here are examples of images i work on:

example1

example 2

I already found some solutions to similar problems here on Stackoverflow (here is the most similar situation to mine) and there always was a simple solution that used thresholding. I tried out some solutions from those answers but did not get the correct result yet. I think the problem here is that my images are not scanned paper pages but photographs.

Is there any way to remove the watermark from my images and not to lose any important text? (Result images can be grayscale)

Cena
  • 3,316
  • 2
  • 17
  • 34

1 Answers1

3

If you do not have the original watermark image, then here is one way to mitigate the watermarks in Python/OpenCV using division normalization (divide a blurred copy of the image by the original image). It also whitens the background.

Input 1:

enter image description here

Input 2:

enter image description here

import cv2
import numpy as np
import skimage.exposure as exposure
import skimage.filters as filters

# read the image
img1 = cv2.imread('watermark1.jpg')
img2 = cv2.imread('watermark2.jpg')

# convert to gray
gray1 = cv2.cvtColor(img1,cv2.COLOR_BGR2GRAY)
gray2 = cv2.cvtColor(img2,cv2.COLOR_BGR2GRAY)

# blur
smooth1 = cv2.GaussianBlur(gray1, (5,5), 0)
smooth2 = cv2.GaussianBlur(gray2, (5,5), 0)

# divide gray by morphology image
division1 = cv2.divide(gray1, smooth1, scale=255)
division2 = cv2.divide(gray2, smooth2, scale=255)

# sharpen using unsharp masking
sharp1 = filters.unsharp_mask(division1, radius=3, amount=7, multichannel=False, preserve_range=False)
sharp1 = (255*sharp1).clip(0,255).astype(np.uint8)
sharp2 = filters.unsharp_mask(division2, radius=3, amount=9, multichannel=False, preserve_range=False)
sharp2 = (255*sharp2).clip(0,255).astype(np.uint8)

# save results
cv2.imwrite('watermark1_division_sharp.jpg',sharp1)
cv2.imwrite('watermark2_division_sharp.jpg',sharp2)

# show results
cv2.imshow('sharp1', sharp1)  
cv2.imshow('sharp2', sharp2)  
cv2.waitKey(0)
cv2.destroyAllWindows()

Result 1:

enter image description here

Result 2:

enter image description here

fmw42
  • 46,825
  • 10
  • 62
  • 80
  • Thank you for answer. Unfortunately i do not have original watermark image. How it could help if i have it? Let's say i would create a copy / imitation of this watermark would it be useful? In any case my goal is to make this watermarks totally invisible or at least unreadable. Are there any ways to perform this? – Bohdan Grishuk Oct 18 '20 at 00:03
  • No, you must have the exact watermark image. I know of no other ways to help with OpenCV. – fmw42 Oct 18 '20 at 01:35