I'm trying to write the code of this paper
The 64*64 watermark I used
The watermarked Image :
The extracted Watermark I get:
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:
- In
Merge_W1_W2
you are usingint
to convert fromfloat
toint
but that introduces errors for numbers where the floating point representation is not exact (e.g.14.99999999999997
); this can be fixed by usinground
instead. - Saving
cv2.imwrite('Watermarked_img.png', IDWT)
is a lossy operation because it rounds the values inIDWT
to the nearest integer; if you useWatermarked_Image = IDWT
then you will get back the exact same watermark image.