## Adventures in HDR |
Updated: |

A while ago I did some experiments with HDR or High Dynamic Range imaging. I've now updated the algorithms a bit and I did a second try with a bunch of pictures taken right outside my front door.

I used two input images, one overexposed and one underexposed. You are really supposed to use more than two images (and one of them should be correctly exposed), but these two covered each other's under/over exposed parts:

Then I mixed them together. Each pixel was weighted according to a weight function and the final output pixel was the weighted average of the inputs. The weight function is:

w(x) = e ^ ( text(gain) * ( ( x - text(center) ) ^ gamma ) )

That is, take the brightess of the input pixel in an input image. Scale it to be between 0 and 1. Then subtract the center value. Raise the result to gamma. Multiply by gain. And finally, raise e to that. The end result will be the relative weight of the pixel among all input pixels for the corresponding output pixel.

Here's a small applet to play with values of center, gain and gamma: