In this project I detail the process of preparing and tonemapping a HDR image for viewing via Matlab.

## Opening HDR Images in Matlab

The command to open HDR files on Matlab is hdrread(). What you will receive is a [x,y,3] matrix for an image of (x,y) resolution. The three matrices in depth hold the RGB information separately. Since we will have to reuse the information, it’s best that the image file is stored in a handle like such:

IMG = hdread('img.hdr');

## Extraciting Luminance

Since tonemapping is applied on luminance, it would make sense to extract the luminance of our image. To do that we will use the relative luminance equation.

lum = 0.213*IMG(:,:,1)+0.715*IMG(:,:,2)+0.072*IMG(:,:,3);
x = log10(lum)

Very important here that log10 is used instead of log, as the latter computes the natural log that will give you problems.

## Performing Histogram Equalization

The problem of performing histogram equalization on Matlab is that the native image equalization function on Matlab will not work, thus the range of luminace that are dealt with are different. Thus it was necessary to perform manual histogram equalization.

Where:
• Wmax = max log luminance value
• Wmin = min log luminance value
• Lum = log luminance value scaled between [1,250] so can be used as index
• nk = density
• rk = bins
• pr = percentage density
• cdf = cumulative sum of percentage density of old histogram
• s = converting bins to index values
• fin = final equalized histogram

## Applying Linear Ceiling

The next step is to apply a ceiling. The original purpose of this project was to examine the difference between linear ceilings and perceptual ceilings. First this is my approach to a linear ceiling:

## Perceptual Ceiling

Below is my approach to achieving a perceptual ceiling based on Larson et al. (2011)

Here, the pbw max and min values are the target display range in log10 scale with 252 levels corresponding to the number of bins I used. And the look up table used in the code is:

## Conversion back into luminance Space and Normalization

Now that the image has been modified, the image needs to be processed for display. To do so, each pixel is interpolated using the histogram modified in the previous section, then together as a matrix converted out of log space and normalized.

## Results

Hopefully when I have more time, I can upload pictures of better quality including the histogram changes through the process as well

Project from assignment of partial fulfillment of EECE 421, December 2016.