From CS294-69 Image Manipulation and Computational Photography Fa11
Name: Viraj Kulkarni
Assignment: Gradient Domain/Resizing and Warping
Course: CS294-69, Fall 2011, UC Berkeley
Paper Implemented: Gradient Domain High Dynamic Range Compression. Raanan Fattal, Dani Lischinski and Michael Werman. SIGGRAPH 2002. (pdf)
I have implemented the assignment in MATLAB. I wanted to use my own pictures for this assignment. I took the below photographs which I have used as examples from the top floor of the International House. I initially took the photographs by varying only the shutter speed since varying the aperture changes the depth of field. However, it turned to be a bit difficult. Without a tripod, eliminating hand shake between two shots was difficult. I ended up using the exposure bracketing of the Nikon to take the shots in quick succession.
Gradient Domain HDR compression works on an observation that any drastic change of luminance across an image would also amount to large magnitude gradients at those points. The algorithm works by identifying these large gradients and attenuating them in a way that larger gradients are compressed more than smaller ones. These attenuated gradients are then used to rebuild the lower dynamic range image.
1. Load HDR Image
I do not generate the HDR image from the RAW photographs myself. I used a third party HDR image generation for this purpose which generates a high dynamic range .exr/.hdr file.
2. Calculate Gradient Matrix
The gradient field is generated by taking forward differences for the pixels in the image. This process, and everything henceforth, is carried out only on the luminance channel.
3. Attenuation of the Gradients
A Gaussian pyramid is constructed as described in the paper. A scaling factor needs to be calculated for every pixel and this factor is controlled by two parameters, alpha and beta. The first parameter, alpha, acts as a threshold that determines which gradients should be attenuated. Gradients larger than alpha are attenuated while those smaller than alpha are slightly magnified. Beta acts as a measure to control the factor by which this attenuation is carried out.
In the paper, the authors set alpha to the 0.1 times the average gradient magnitude and beta is set arbitrarily between 0.8 and 0.9. However, I found that some trial and error with the choice of alpha and beta can produce better tone mapped images. Ofcourse, 'better' is subjective here and its open to personal preference. For the example images below, I played around a little with these factors to get a better result.
4. Solving the Poisson Equation
The Poisson equation is then solved as described in the paper. For implementing some of the equation-solving, I took help from a reference code. See credits section for details.
The Golden Gate Bridge as seen from the International House.
Original Picture 1: The golden color of the sky is visible but the buildings are a bit dark
Original Picture 2: The building are correctly exposed but the sky is overexposed
These are the pictures of the campanile taken from the International House.
Picture 1: The sky is visible but the lower third of the image is underexposed.
Picture 2: This is the middle exposure image. Some parts of the sky are overexposed.
Picture 3: This is the high exposure image. The upper half of the image is washed out but the lower half is correctly exposed.
I used a third party tool developed by Andy Cotter (firstname.lastname@example.org) to generate the high dynamic range radiance maps from the pictures I clicked using my camera. For help with the implementation, I referred to the some work done by Gabriel Peyre (email@example.com) which I came across on MATLAB central.