ABSTRACT

This appendix describes how to use the HDR Toolbox used in this book. This toolbox is self-contained, although it uses some functions from the Image Processing Toolbox by Mathworks [141]. Note that HDR built-in functions of Matlab such as hdrread.m, hdrwrite.m, and tonemap.m, need Matlab version 2008b or above. Furthermore, Matlab version 2010a and the respective Image Processing Toolbox are needed for compressing images for HDR JPEG2000. The initial process for handling HDR images/frames in Matlab is to load them. The HDR Toolbox provides the function hdrimread.m to read HDR images. This function takes as input a Matlab string and outputs a m-n-3 matrix. An example how to launch this functions is:

>> img = hdrimread(‘memorial.pfm’);

Note that hdrimread.m can read portable float maps files (.pfm) and uncompressed radiance files (.hdr/.pic). Moreover, this function can read all supported LDR formats that are supported natively by Matlab and it automatically stores them in the range [0, 1] with double precision. Matlab from version 2008b onwards provides support for reading radiance files both compressed (using run-length encoding) and uncompressed. An example of how to use this function for loading ‘memorial.hdr’ is:

>> img = hdrread(‘memorial.hdr’);

Once images are loaded into memory, a useful operation is to visualize them. A simple operation that allows single-exposure images to be shown is GammaTMO.m. This function applies gamma correction to an HDR image at a given f-stop value and visualizes it on the screen. Note that values are clamped between [0, 1]. For example, if we want to display an HDR image

at f-stop −7, with gamma correction 2.2, we have just to type the following on the Matlab console:

>> GammaTMO(img, 2.2, -7, 1);

The result of this operation can be seen in Figure C.1. In the case we want to save this gamma-corrected exposure into a matrix, we just need to set the visualization flag to 0:

>> imgOut = GammaTMO(img, 2.2, -7, 0);

Gamma-corrected single-exposure images are a straightforward way to view HDR images, but they do not permit the large range of luminance in an HDR image to be properly viewed. The HDR toolbox provides several TMOs that can be used to compress the luminance in order to be visualized on an LDR monitor. For example, if we want to tone map an image using Drago et al.’s operator [60], the DragoTMO.m function is used and the image is saved into a temporary image. Then, this image is visualized using the GammaTMO.m function as shown before:

>> imgTMO = DragoTMO(img);

>> GammaTMO(imgTMO, 2.2, 0, 1);

The result of this can be seen in Figure C.2. In the case the tone mapping parameters are not satisfactory, they can be changed. Each TMO can be queried with the command help that can be used to understand which parameters can be set and what these parameters do. The help is called using the command help nameFunction. We demonstrate the previous example with the call to help. Figure C.3 shows the resulting image.