When working on the 2006 ski slopes lighting report, we noticed an unpleasant phenomenon: mildly underexposed regions of images gave lower luminances than the same regions of well exposed images. I've noticed that it might be caused by non-linearity of AD conversion of CCD signal by this camera type.
Further investigations showed, fortunately, that this is not the case. The effect had been caused by the common subtraction of a dark frame. For many cameras, and of course for all scientific CCD cameras, a simple subtraction gives a signal which is directly proportional to the amount of light incident on each pixel (and therefor to the scene luminance). For our camera, it's more complicated however.
The complication consists in this camera type subtracting some constant from the raw digitised data (or at least, not adding any positive constant), so that up to one half of dark frame pixels is zero. Just the other half of them carries some information, having non-zero positive values. These have a roughly normal distribution with standard deviation of about 30, centred on zero. To complete the data, the “below zero'' half of them misses however. Another cameras solve the problem by adding some constant, as 128, and the amount of zero pixels is negligible then, the darkframe contains an almost complete record of noise (originating both in the CCD or CMOS sensor, during the measurement and during the conversion of the signal to the digital form).
During our work on the April 2006 report, one problem had been solved already: by the least exposed images, containing many zero pixels even when taken with open lens, there is no information on the amount of light in those zero pixels. In extreme cases of very insufficient exposure, just one half of incident light is registered – that which hit the non-zero pixels. The true amount light incident onto all pixels is up to twice larger. This effect can be compensated for sets of pixels of sufficient size, and works entirely well just for scenes of uniform luminance.
In the output of raw2lum this compensation is, if adequate, expressed by a multiplier (less than 1.0) given by the space angle occupied by the pixels: the total amount of registered light (flux density) concerns just the diminished space angle comprised of non-zero pixels. And it is applied for luminances (or flux densities) of the individual tiles of a chosen grid. If it is, however, a tile with a single non-saturated lamp with black surrounding, such a compensation can overestimate the amount of light up to twice. There are no such extreme cases in our report, fortunately: the amount of light from bright point sources is computed just from well exposed pixels.
Dark frame subtraction and compensation of the effect of zero-level pixels is adequate for scene of uniform, very low luminance where almost half of the pixels are zero and median value is zero or just a few units, much below the standard deviation of the hypothetical complete darkframe. However, if the median is several tens (for Fuji S 5000, a 14-bit camera), i.e. if the image is not totally underexposed and something begins to be visible there, such a simple computation underestimates the luminance. Let's explain it at an example of a well exposed image: all its pixels are non-zero, but we subtract a darkframe with non-zero average (about 12, usually). Actually, we should subtract nothing, the mean value of a “correct'' darkframe containing even negative-value pixels, would be about zero. If common values of image pixels are about one thousand or more, subtracting 12 can be neglected, we don't know the exposure time with one per cent accuracy anyway. When, on the other side, the common image readings are about thirty, subtracting twelve takes away more than a third of the signal. This was the reason why the luminances of underexposed regions of images resulted as surprisingly low.
The solution, applied since version 1.21 of raw2lum, is based on the distributions of pixel values of darkframes. It uses the integral of [percentile, its pixel value] function. If the mean value of lit image pixels in some region is (after darkframe subtraction) is equal or higher than 99-th percentile value of darkframes (it uses to be 80 for Fuji S 5000), then I add one per cent of the integral from zero to 99, what is almost the same as the mean value of the darkframe. If the mean value of the lit region is less then 80, then the corresponding integral is computed just up to the percentile which corresponds to that value (for pixel mean value of 30, one per cent of such integral is about 4 for our camera). The definite integral value, as a function of its upper bound, has been approximated by a polynome applied to a set of darkframes.
Further statistic analysis of dark and low-lit frames would surely find some better algorithm. This is not much urgent, however: comparing mean values for tiles 32x32 from low and well exposed images revealed that such a compensation is good, luminance ratios of tile means from both images are independent on the luminance of the good exposed image (even if ratios differ from 1, due to the difference of true exposures from those which are reported in EXIF headings of the images).
The correction is fully adequate, again, just in regions of uniform luminance. I don't use it for a whole image (its luminance is seldom uniform), but just for its single tiles.
In a coarser variant the correction is employed also for colour-coded luminances in noisy regions, if they are displayed as means over a set of pixels (mostly 16, if all of them have values below 100). The proper amount of correction is poorly known here, of course, as the mean value from such a small sample is also quite noisy. And we don't use separate R and G pixel values as an input (they are forgotten in this phase of computation), just the uncorrected value of mean luminance, assuming the image to be slightly reddish (having similar values for R and G pixels – this is often true for artificial light sources). Even such a coarse correction improves a lot the previous, obvious discrepancy among colour-coded outputs from richly and poorly exposed images (as the couple 5245 and 5246 in javor directory had been).
Since 1.22 version of raw2lum the values for individual tiles are summarised at the end – as an alternative computation of illuminance produced by the scene (a sum over tiles, valid for scene space angle including zero-value pixels, just without overexposed pixels and out-of-range ones) and as an average tile luminance. For Fuji S 5000, if the pixel value medians are about tens and the relative standard deviation of tile luminance is not more than tens of per cent, the summary values obtained in this way give a good information on illuminance from the scene or about its average luminance (this may hold for sky images of zenith).
This can be answered by analysing darkframes by means of raw2lum – in photometry-grade cameras, even the first percentile should have a non-zero value (it can be negative, if some constant is subtracted, e.g. such one that the median results as zero). Canon D60, Nikon 990, Olympus E-300 are among such cameras. Nikon D50, however, behaves like Fuji S 5000, i.e. half of the pixels have zero value. The only advantage of D50 is that the non-discarded pixels have about twice narrower distribution (eight time narrower, actually, but this due to the fact that D50 gives just 12 bits, not 14 bits like our old Fuji). This is a bad news for D50 (it is not really suitable for faint light photometry) but a pleasing one, regarding the amount of work I've devoted to solve the enigma posed by S 5000: the effort will not go in vain, such sub-ideal cameras are still produced.
If you can choose, however, use just cameras which don't discard information from many pixels, if doing faint-light photometry.
Jan Hollan, Brno 2006 June 23