title: Tone mapping a HDR image using OpenCV 4.0
body: <p>I want to create a script which takes a <code>.HDR</code> file and tonemaps it into a <code>.JPG</code>. I have looked at a few <a href="https://www.learnopencv.com/high-dynamic-range-hdr-imaging-using-opencv-cpp-python/" rel="noreferrer">OpenCV tutorials</a> and it seems it should be able to do this.</p>
  
  <p>I have written this script:</p>
  
  <pre class="lang-py prettyprint-override"><code>import cv2
  import numpy as np
  
  filename = "image/gg.hdr"
  im = cv2.imread(filename)
  
  cv2.imshow('', im.astype(np.uint8))
  cv2.waitKey(0)
  
  tonemapDurand = cv2.createTonemapDurand(2.2)
  ldrDurand = tonemapDurand.process(im.copy())
  
  new_filename = filename + ".jpg"
  im2_8bit = np.clip(ldrDurand * 255, 0, 255).astype('uint8')
  cv2.imwrite(new_filename, ldrDurand)
  
  cv2.imshow('', ldrDurand.astype(np.uint8))
  </code></pre>
  
  <p>Which according to the tutorials should work. I am getting a black image in the end though. I have verified that the result it saves is <code>.JPG</code>, as well as that the input image (a 1.6 megapixel HDR envrionment map) is a valid <code>.HDR</code>.</p>
  
  <p>OpenCV should be able to load <code>.HDR</code>s according to <a href="https://docs.opencv.org/3.1.0/d4/da8/group__imgcodecs.html#ga288b8b3da0892bd651fce07b3bbd3a56" rel="noreferrer">the documentation</a>.</p>
  
  <p>I have tried reproducing the tutorial linked and that worked correctly, so the issue is in the <code>.HDR</code> image, anybody know what to do?</p>
  
  <p>Thanks</p>
  
  <p>EDIT: I used <a href="http://blog.gregzaal.com/2014/03/29/pano-golden-gate/" rel="noreferrer">this HDR image</a>. Providing a link rather than a direct download due to copyright etc.</p>