For CS148 assignment 6 (HDR Imaging), I was excited to write some tone-mapping operators. I've previously had some experience with HDR photography (many of my photos have involved some sort of contrast management), but had never written my own code for it. I started out by implementing the simple operator suggested by the assignment instructions. Unfortunately, this operator produced fairly disappointing results, since it was merely a global operator. In some cases, it was even difficult distinguishing the "tone-mapped" image from the original.
To improve upon the results, I added a local component. By making a copy of the image, blurring it, then subtracting it from the original, local tone-mapping compresses dynamic range in the low-frequencies of the image, while keeping the upper frequencies intact. The advantage of this is that allows for much greater dynamic range compression without completely flattening the details of the image. The disadvantage is it is much, much slower to compute: O(ImageSize*blurKernelSize). Separable blur functions are a bit faster, but I eventually settled on a bilateral filter for image quality.
With a small blur kernel size, this algorithm is actually just an unsharp mask (see the comparison of original vs small blur kernel below).
By expanding the kernel size though, we begin to get good tone-mapping results. One thing that becomes noticeable, though, is an artifact known as "haloing" around the edges between light-dark regions. As popularized by Durand 2002, I use a bilateral filter (instead of Gaussian) to reduce this artifact. The bilateral filter is similar to other blur functions, except it preserves edges between regions:
With this filter, I tone-mapped a scene with an extremely high-dynamic range. Pictured below, see the linearly-mapped image, the suggested global operator, and the local operator:
I'd like to try optimizing and porting this code to Android.
It's currently very slow, but there's plenty of room for algorithmic optimization.
I'm also interested in exploring interactive tone-mapping,
because the work-flow of producing compelling HDR imagery is an interesting problem that can definitely be improved.