CS 766 Homework 1 - HDR Imaging
Sarah Gilland and Alper Sarikaya
Overview
We decided to do the assignment in MATLAB, primarily due to its ease-of-use and availability of functions to read and write image files. Both of us had no experience using MATLAB, so it was a bit of a learning curve in learning to preallocate matrices and
We first ensured that our HDR assembling script worked as advertised. Through our iteration while partner programming, we used Prof Li Zhang's HDR set of images. We ran into an issue where individual pixels (on average of two) were being outputted as NaN, which prevented writing of the hdr files. We set those pixels to have a value of one to unblock ourselves.
Our MATLAB code consists of four files. The script is called by calling HDR; with MATLAB's current directory in this directory. The files and their descriptions are as follows:
- HDR.m - This is the main script that executes the entire procedure. By default, it grabs all jpg files in the current directory. This can be changed by changing the prefix to the *.jpg matching string and the argument to the subsequent strcat call. The script then calls gsolve to recover the camera response function from the sample points, then calls hdrValues to generate the irradiance values for every pixel in the scene. Finally, hdrwrite is called to write the final radiance image out.
- getIm.m - This function obtains all the images and packages them into a pixel Z matrix. The coordinates of the matrix are height x width x imagenum x channel. Two matrices are returned; z emcompasses the individual pixels outlined in the matrix pix (which must be changed when the image is changed) for all images, whereas allZ contains all pixels for all images.
- hatfunc.m - This is our implementation of the weighting "hat function", straight from the lecture notes and Debevec's paper.
- gsolve.m - This function tries to recover the camera response function by using the sampled z matrix as well as information about the exposure times. Whenever the exposure times change for the images, t in HDR.m must also be changed.
- hdrValues.m - This function recovers the original irradiance values of the scene by using the camera response function approximated from gsolve. This takes the most time; each pixel from each image from each channel is used here. The larger the image, the longer this function will take.
Image Output
We then fed our HDR image to HDRShop and used the tonemap plugin to generate an HDR image. The original image mosaic is shown below, along with the HDR image generated by our script, the tonemapped image, and the retouched tonemapped image (Photoshop CS3).
Our Images
For our own images, we ended up trekking to the WID. We took some pictures of the flora and were content with those photos, but as we were walking away, we noticed that Steenbock's had a very neat banquet room, with green highlights and a view of the alley. The combination of the interior decor that provided sufficient interior detail coupled with the bloom effect from the windows offered a pretty neat opportunity for an HDR photograph.
The images at Steenbock's were taken at f/22 in 21 exposures: 15", 10", 8", 6", 5", 4", 3", 2", 1", 2/3, 1/2, 1/3, 1/5, 1/8, 1/13, 1/20, 1/30, 1/50, 1/80, 1/125, and 1/200 with a Nikon D50 from the Graphics lab. The adjustments made to the tonemapped image in Photoshop were increased saturation, auto-level, and a teeny bit more gamma.
One caveat about running our HDR function on our images: MATLAB chews up to 4.5 GB to convert the image. Make sure the machine has at least this much memory available!
Teamwork
Both of us participated in partner programming, each taking equal turns to drive. Alper made the README.
Sarah Gilland - segill@cs.wisc.edu
Alper Sarikaya - sarikaya@cs.wisc.edu