March 2020
Intermediate to advanced
366 pages
9h 8m
English
Displaying HDR images is tricky. As we said, HDR has more values than the camera, so we need to figure out a way to display that. Luckily, OpenCV is here to help us again, and, as you've probably guessed by now, we can use gamma correction to map all the different values we have into a smaller spectrum of values in the range 0 to 255. This process is called Tone Mapping.
OpenCV has a method for it that takes gamma as an argument:
tonemap = cv2.createTonemap(gamma=2.2) res_debevec = tonemap.process(hdr_debevec)
Now we have to clip all the values to become integers:
res_8bit = np.clip(res_debevec * 255, 0, 255).astype('uint8')
After that, we can show our resulting HDR image using pyplot:
plt.imshow(res_8bit) plt.show() ...