I want to perform arithmetic operations on an existing HDR image using OpenCV and then write the HDR file in the .hdr format. The arithmetic operation is not important to the question, so let's just say I want to read a .hdr file and then write it into the same format.
I tried doing it the usual way, by first reading the hdr file as
img = cv2.imread('original.hdr', -1).astype(np.float32)
and then write it as
cv2.imwrite('new_original.hdr', img)
I use Mac's Finder and the OpenHDRViewer to view HDR images. When I run the above code, the Mac finder is properly able to show the new_original.hdr
file. But when I try to see the same hdr image using the OpenHDRViewer, it gives an error saying -
This file type is not supported! This site does not currently support tone-mapped or LDR images yet. Check back later for updates.
Is new_original.hdr
not a valid HDR image?
Is there some format based information that is lost when I use a conventional cv2.imwrite()
to write HDR images. What is the right way to do this ?