Tuesday, 29 October 2019

How to save float64 image data without loss of information, while being able to visualize it

I'm trying to implement frequency spectrum image watermarking, using the Fast Fourier Transform and everything is working perfectly, except the fact that I can't save the resulting watermarked image without running into trouble.

The code basically goes like this:

import cv, imageio

image = cv2.imread(imagePath, cv2.IMREAD_UNCHANGED)
watermark = cv2.imread(wmPath, cv2.IMREAD_UNCHANGED)

# result is float64, due to the transition from the frequency spectrum to spatial
result = embed_watermark(image, watermark)
imageio.imwrite('result.tiff', result)
result2 = imageio.imread('result.tiff') # Still float64, thanks to tiff format
detection = detect_watermark(result, image)

So, the code is working as wanted, it prevents data loss, thanks to the tiff container, which allows for floating-point pixel values. However, the saved file ('result.tiff') can't be opened with any photo viewer included in MS Windows. If I use any other of the usual containers (jpeg, png, bmp), I am able to visualise the resulting image, but end up losing the watermark information.

I've tried solutions discussed here and here and read the documentation, but I don't seem to wrap my head around this. I have also tried opening the image using FIJI (following Ander Biguri's suggestion, but I get this error: "ImageJ can only open 8 and 16 bit/channel images (64)"

How could I possibly save the file without losing the watermark data, nor the ability to open the resulting file for visualisation?



from How to save float64 image data without loss of information, while being able to visualize it

No comments:

Post a Comment