R2-D2
R2-D2

Reputation: 1624

Open .hdr files with OpenCV

I try to read .hdr files like this:

img = cv2.imread(sys.argv[1])
cv2.imshow('Image', img)

This gives me a 3-channel 8-bit Mat which is either (nearly) completely white or a very dark picture. So I suppose it only gives me one image of the exposure sequence? How do I get a proper Mat with all the information?

Upvotes: 1

Views: 6087

Answers (1)

jamalin
jamalin

Reputation: 76

The data you have is the merged stack not individual exposures. To display it correctly, you need to tone-map the data. This is the correct procedure, for example:

Mat hdr = imread("xxx.hdr",-1); // correct element size should be CV_32FC3
Mat ldr;
Ptr<TonemapReinhard> tonemap = createTonemapReinhard(2.2f);
tonemap->process(hdr, ldr);
ldr.convertTo(ldr, CV_8UC3, 255);

Then display your ldr with highgui.

Upvotes: 1

Related Questions