OpenEXR image is very dark when displaying

asked 2015-03-30 16:56:16 -0600

jann gravatar image

Hello, i am trying to show an OpenEXR file with OpenCV. The code is quite simple and loading of the OpenEXR seems to work.

cv::Mat inputImage = cv::imread("e:\\Daten\\Maya\\Projects\\bedroom\\tmp\\Bedroom2012.exr);
cv::imshow("Display Image", inputImage);

When I load the a jpg everything looks the same compared to other image viewer. When I now load the exr file, the image is totally black. But there is a bright spot where i have very high white values (light bulb).

Do I need to convert the image data somehow? It is not the normal gamma 2.2 issue you got with exr files. Any ideas?

edit retag flag offensive close merge delete

Comments

To me it seems that the data might be incorrectly scaled to the proper range for the imshow function. How are normal EXR values ranged (limited experience with EXR here)?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-31 02:30:30 -0600 )edit

Hi Steven, thanks for the quick reply.

Do you mean the bit range? Normally the exr is saved in 32 bit float. The image resolution is recognized correctly when I load an exr file.

Maybe I am missing some flags witth imread or imshow?

jann gravatar imagejann ( 2015-03-31 03:30:03 -0600 )edit

Looking at the docs of imshow, it seems that there are three possible ranges for imshow

  • If the image is 8-bit unsigned, it is displayed as is.
  • If the image is 16-bit unsigned or 32-bit integer, the pixels are divided by 256. That is, the value range [0,255*256] is mapped to [0,255].
  • If the image is 32-bit floating-point, the pixel values are multiplied by 255. That is, the value range [0,1] is mapped to [0,255].

Can you verify that in your case all values are in the range [0 1]?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-31 05:03:29 -0600 )edit

I think the problem here is that the range is higher than 1. E.g: 0 - 2000. And that is whay the values are getting to dark. So I need something like a mapping colors based on the max value of the image file.

jann gravatar imagejann ( 2015-03-31 06:37:31 -0600 )edit

Hmm that can be done by grabbing your max and min value, mapping those to 0 and 1 then calculating the step you need to take and retransfer all data in between 0 1. The high values are indeed the killer in the visualisation here.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-03-31 06:39:35 -0600 )edit