invisible-watermark icon indicating copy to clipboard operation
invisible-watermark copied to clipboard

Enhancement: Determining if an image can hold the desired watermark

Open mexicantexan opened this issue 6 months ago • 3 comments

Using the following code block to create a sample image, encode it with a uuid, and then decode it results in erroneous restructuring of uuid that was encoded.

from imwatermark import WatermarkEncoder, WatermarkDecoder
import cv2
if __name__ == "__main__":
    large_image = np.ones((256, 256, 3), dtype=np.uint8)
    large_image *= 255

    encoder = WatermarkEncoder()
    original_uuid = 'urn:uuid:a9c072b1-c796-4a0c-8b81-25e4f2259c01'
    # Have also tried:
    #     original_uuid = 'a9c072b1-c796-4a0c-8b81-25e4f2259c01'
    #     original_uuid = 'a9c072b1c7964a0c8b8125e4f2259c01'
    encoder.set_watermark('uuid', original_uuid)
    # Have also tried:
    #     encoder.set_by_uuid(original_uuid)
    bgr_encoded = encoder.encode(large_image, 'dwtDct')
    cv2.imwrite('test.png', bgr_encoded)
    print(bgr_encoded.min(), bgr_encoded.max())  # results in: 251 255
    decoder = WatermarkDecoder('uuid')
    watermark = decoder.decode(bgr_encoded, 'dwtDct')
    print(watermark)  # results in: 00000000-0000-0000-0000-000000000000
    assert watermark == original_uuid.replace('urn:uuid:', '')  # results in: False

Have also tried dwtDctSvd

Environment:

  • Ubuntu 22.04
  • Python 3.10
  • invisible-watermark -- 0.2.0 (latest)

mexicantexan avatar Jan 29 '24 21:01 mexicantexan