## HDR merging

In this assignment, we will only work with images that are linear, static, and where the camera hasn't moved. The image files are provided with gamma 2.2 encoding and we have inserted lines of code in makeHDR and toneMap to decode and recode, respectively, the images. Keep these lines in your implementations of makeHDR and toneMap.

Consult the course slides for the overall merging approach. We will first compute weights for each pixel and each channel to eliminate values that are too high and too low. We will then compute the scale factor between the values of two images. Finally, we will merge a sequence of images using a weighted combination of the individual images according to the weights and scale factors.

### Weights

Use testComputeWeight in a5_main.cpp to help test this function.

### Factor

Now that we know which pixels are usable in each picture, we can compute the multiplication factor between a pair of images.

Use testComputeFactor in a5_main.cpp to help test this function.

(a) w1
(b) w2

### Merge to HDR

Use the previous functions to merge a sequence of images. You can assume that the first one is the darkest one, and that they are given in order of increasing exposure.

Use testMakeHDR in a5_main.cpp to help test this function.

## Tone mapping

Now that you have assembled HDR images, you are going to implement tone mapping. Your tone mapper will follow the method studied in class. The function will be called FloatImage toneMap(const Image &im, float targetBase, float detailAmp, bool useBila, float sigmaRange). It takes as input an HDR image, a target contrast for the base, an amplification factor for the detail, and a Boolean for the use of the bilateral filter vs. Gaussian blur.

As described in lecture slides, our goal is to reduce the contrast from the HDR image (say, 1:10000) to what we can show on a display (say 1:100). Although gamma correction would be the first thing we can think of, this results in washed out images, as you might have seen in class. The colors are actually okay (they're all there) but the high frequencies are washed out. We therefore want to work in the luminance, and increase the high frequencies, and we want to work in the log domain, since we are very sensitive to multiplicative contrast.

Next, we want to extract the detail of the (log) luminance channel. We do this by blurring the log luminance, and subtracting the original. Convince yourself that gives you the details (high frequencies)!

Great, you are finally ready to put everything together!

Enjoy your results and compare the bilateral version with the Gaussian one. Use the functions testToneMapping_ante2, testToneMapping_ante3, testToneMapping_design, testToneMapping_boston in a5_main.cpp to help test your tone mapping function.

(a) Gaussian Tone Mapping
(b) Bilaterial Tone Mapping
(a) Gaussian Tone Mapping
(b) Bilaterial Tone Mapping