Home > database >  Why the extracted watermark is not the same as the embedded one?
Why the extracted watermark is not the same as the embedded one?

Time:06-22

I'm trying to write the code of this paper enter image description here

The 64*64 watermark I used

enter image description here

The watermarked Image :

enter image description here

The extracted Watermark I get:

enter image description here

I calculated the similarity between the two watermarks using SSIM :

from skimage.metrics import structural_similarity

 original_Watermark = cv2.imread('Copyright.png')
    extracted_watermark = cv2.imread('Extracted_Watermark.png')
    # Convert images to grayscale
    original_watermark = cv2.cvtColor(original_Watermark, cv2.COLOR_BGR2GRAY)
    extracted_Watermark = cv2.cvtColor(extracted_watermark, cv2.COLOR_BGR2GRAY)
    # Compute SSIM between two images
    (score, diff) = structural_similarity(original_Watermark, extracted_Watermark, full=True)
    print("SSIM = ", score)

I didn't apply any modification on the watermarked image and The SSIM I got is 0.8445354561524052. however the SSIM of the extracted watermark should be 0.99 according to the paper. I don't know what's wrong with my code and I have a deadline after two days so I really need help. thanks in advance.

CodePudding user response:

There are two issues:

  1. In Merge_W1_W2 you are using int to convert from float to int but that introduces errors for numbers where the floating point representation is not exact (e.g. 14.99999999999997); this can be fixed by using round instead.
  2. Saving cv2.imwrite('Watermarked_img.png', IDWT) is a lossy operation because it rounds the values in IDWT to the nearest integer; if you use Watermarked_Image = IDWT then you will get back the exact same watermark image.
  • Related