Public Lab Research note

High Dynamic Range (HDR) Imaging (revisited)

by MaggPi | July 17, 2018 08:07 17 Jul 08:07 | #16726 | #16726

This research note considers HDR imaging techniques for spectroscopy and microscope applications.


Past efforts such as and have looked at High Dynamic Range (HDR) techniques for increasing the dynamic range of measurements. This note re-examines HDR spectral applications using current computer vision (OpenCV) algorithms and Raspberry Pi NoIR v2 controlled time exposures.

High Dynamic Range:

HDR has become a standard method to increase image dynamic range and is described in and

HDR approach used for this research note consist of the following steps:

  • 1)Four (8 bit/256) pictures are taken of the image scene. Exposure times are selected to cover a wide dynamic range that includes under and over exposed images.
  • 2)OpenCV software is used to merge the four pictures into a single HDR file. Two algorithms are available (Robertson and Debevek) to merge the images. The HDR file maintains an effective 32 bit range and is stored in .hdr or RGB Exponent (RGBE) format (see
  • 3)HDR pictures are tonemapped/converted to LDR (Low Dynamic Range)/ 8 bit images for viewing. Several processing options are used to display the HDR images: low/high scaling of Robertson/Debevek, Mertel Fusion and 32 bit contrast optimization (using Adobe Photoshop). Note that each of these tonemapping options have several adjustment parameters that can be used to further optimize the LDR image.

Spectral HDR Examples

Three spectral HDR imaging examples were observed:

-- Source/Grating/Camera

  • White light LED/crossed grating/Raspberry PI NoIR camera
  • CFL light bulb/crossed grating/ Raspberry PI NoIR camera
  • CFL light bulb/linear grating/ Raspberry PI NoIR camera

The examples were selected to observe how saturation of the zero/first order impacts higher order spectra that have higher resolution. Slide image format (displayed left to right) consists of image collected with auto exposure, different timed exposures and processed tonemapped images.

White light LED/Crossed grating/Raspberry PI NoIR camera

Crossed grating camera setup has been described in: This setup observes the 0, /- 1, /-2 and multiple sub orders in horizontal and vertical directions. The HDR processed images permit viewing all orders including orders saturated during long exposure times.


CFL light bulb/crossed grating/ Raspberry PI NoIR camera.

The picture below uses the same crossed grating setup but with a CFL light bulb. In this example, the HDR processed images permit viewing additional orders than cannot be observed in the initial timed exposures.


--CFL light bulb/linear grating/ Raspberry PI NoIR camera

Linear grating camera setup has been described in This setup observes the first, second and third orders of a CFL light bulb. In this example, both the longer timed exposures and the HDR images permit a good view of the second order.


Microscope example: Unlike the above HDR spectral example, the microscope example illustrates an imaging condition where there are no saturated pixels. The image is of human blood cells observed with a 20x microscope objective/Raspberry PI camera/ white LED light illumination. Set up is described at: The picture below shows the different HDR tonemapped images. In this example, HDR images seem to provide picture quality similar to the image collected with auto exposure settings.


Next steps: The different examples show how HDR processing permits imaging over a wide dynamic range. The next step is to determine if line spectra (vs an image) can be collected direct from the 32bit RGBE file and be used for spectral analysis. If anyone is familiar with mapping RGBE intensity profiles please provide comments.

Software code posted at: Python/OpenCV software ( ) used for HDR processing consists of two separate programs. The first program,, collects four (or more) pictures and saves the images and exposure times. The second program,, loads the images/exposure time data and creates the RGBE file/tonemapped images.

@warren, @icarito, @amirberAgain


Login to comment.