Camera Curve Calibration

A digital camera sensor typically has a near-linear response to light within its limits, but in an effort to make the images relate to photographic film images, the linear values are scaled in the camera according to some non-linear function. When the LDR images are loaded in a typical image viewer it automatically applies a fixed reverse response function (gamma correction) in order to make the values appear linear on whatever display is being used. The camera curve calibration tool allows you to recover the camera response function that was applied from a sequence of images of a scene taken from a fixed viewpoint, requiring only that you specify the relative exposure differences between the images in the sequence.

In order to recover a camera's response curve you need to have a sequence of images taken with the camera from a fixed viewpoint on a static scene, You also need to know the relative exposure differences between each image in the sequence. The recovery tool works best with exposure differences of less than or equal to 1 stop, although it should also work for larger differences and even for non-uniform differences. If you use a good exposure (that has both saturated regions, black regions, and stuff in between), the calibration can work with as little as two images, but in most cases you probably want to get four or five images to get a good curve.

Once you have the images, start up the Curve Calibrator in HDR Shop, which is under the Create menu as "Calibrate Camera Curve". The "Select Calibration Image Sequence" dialog box will open:

Set the 'Sampling density' slider and 'Usable pixel range' values (see below) and drag the images on to the window or use the 'Load Images' button. Loaded files are sorted automatically in order of increasing average brightness (displayed in the "sort" column). The tool computes which of the images has an average closest to 50% illumination (the 'best' image to sample from). and computes the locations of as wide a sampling of the possible 0-255 pixel values in each channel in that image. A subsample of the possible 256 values is selected based on where the 'Sampling density' slider is positioned (where the left position is the minimum possible number of samples that will allow curves to be computed and the right position represents as many of the 256 values that exist - this value affects the speed and accuracy of the final computation). Also note that the 'Usable pixel range' values specify the range of pixel values that are considered in all calculations involved in deriving curves. The default values have been obtained through experience in our experimentations and should be adequate for most purposes.

Now you need to enter an exposure for each image in the sequence. You can enter the data in four different formats, corresponding to the four different columns. "Abs. Stops" for example, is the exposure of each image in absolute stops. "Rel. Stops" is the exposure difference in stops relative to the previous image. The scale columns store values in terms of their linear scale multiplier. If the entire sequence is taken at a certain stop increment, you can choose one of the "Preset Scale Increments" to reflect the values already computed. Note that the worksheet boxes are editable so that you can set exotic or non-uniform values for the scales.

If you accidentally select and open the wrong files you can simply highlight them and click the Remove button.

By default, you are entering values for all three channels (Red, Green and Blue) simultaneously. If you want to enter different values for each channel, you can select R, G, or B in the "Select Channel(s)" box to enter values there. This is mainly useful if you are using filters to control the exposure level, as even supposedly "Neutral Density" filters are not always entirely neutral (that is, they tend to block more blue light than red light).

Choose the strength of the smoothing factor that will be applied to the computed curves. A small value may produce curves with a very bumpy shape and a large value will smooth out any features completely. The default value represents a reasonable value based on experience.

Once all the information on the images that make up the sequence is correct press the 'Generate' button. The image samples will now be loaded. At this stage you may encounter an error if the selected usable pixel range and/or sampling density is too restrictive. Simply start the tool again and choose a wider range before re-loading your image sequence. The tool populates a matrix with the sampled locations from all the images and then attempts to solve all available samples into a curve for each channel:

The blue cross in the middle allows you to control the scale of the visualization of the curve. It has no effect on the solver, it just lets you inspect different areas of the curve. The changing R,G,B values as you move the cursor over the image tells you how much the pixel value in parentheses should be scaled in natural log space in order to make the image appear linear.

Specify a further smoothing factor now to remove any bumps which do not appear to be part of the curve.

Once you have a curve you like, you can save the curve to a file for later reference. The default is to save the 3 separate curves, however if one curve seems more viable than the others you can choose to save 3 copies of any individual channel as the output by choosing the relevant channel radio button. Alternatively, use the 'Load Images' button to start over.