How to do it

You need to complete the following steps:

  1. Import the necessary modules:
import cv2import numpy as np
  1. Load the images and exposure times:
imgs_names = ['33', '100', '179', '892', '1560', '2933']exp_times = []images = []for name in imgs_names:    exp_times.append(1/float(name))    images.append(cv2.imread('../data/hdr/%s.jpg' % name, cv2.IMREAD_COLOR))exp_times = np.array(exp_times).astype(np.float32)
  1. Recover the CRF:
calibrate = cv2.createCalibrateDebevec()response = calibrate.process(images, exp_times)
  1. Compute an HDR image:
merge_debevec = cv2.createMergeDebevec()hdr = merge_debevec.process(images, exp_times, response)
  1. Turn the HDR image into a Low Dynamic Range (LDR) image to be able to display it:
tonemap = cv2.createTonemapDurand(2.4) ...

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.