Black Calibration

From apertus wiki
Revision as of 08:41, 6 February 2016 by A1ex (talk | contribs)
Jump to: navigation, search

[WIP]

1 What does this mean?

Finding the sensor output value, per pixel, in the absence of any illumination.

It covers: - dark frame subtraction - dark current compensation - using black reference columns (called "optical black" by other manufacturers) to find the black level and to correct some of the row noise

Note: black reference columns can be used to reduce row noise, that's why we include it here. That means, we will correct some (but not all) of the row noise as part of black calibration process.

2 Calibration methods

2.1 Dark frame subtraction

This is a basic technique: take a picture with the lens cap on, and subtract it from your image. To make really sure no light is reaching the sensor, also cover the entire camera with something.

2.1.1 How many dark frames?

Problem: if you take only one dark frame, it will also contain read noise (assummed to be Gaussian and uncorrelated with the read noise from other frames). Therefore, subtracting only one image will actually increase the noise in the final output, by sqrt(2).

Solution: use a master dark frame, averaged from many images.

How many?

If you take N images, the signal will be multiplied by N, and the noise will be multiplied by sqrt(N). Therefore, the SNR will increase by log2(sqrt(N)) stops.

So, 16 dark frames will reduce the read noise in the dark frame by 2 stops, 64 frames by 3 stops, and 256 frames by 4 stops.

Okay, but how much noise will be added in the output image?

Let's say the read noise stdev in one image is r, so a dark frame averaged from N frames will have noise stdev = r/sqrt(N). Therefore, the noise in the output image will be: sqrt(r^2 + r^2/N) = r * sqrt(1 + 1/N).

Check it in octave:

octave:1>  N = 4;
octave:2>  a = randn(1,1000000);    # one noise sample
octave:3>  b = randn(N,1000000);    # N noise samples
octave:4>  std(a + mean(b))         # add one noise sample to N averaged noise samples
ans =  1.1180

So, it seems that averaging a small of dark frames will not introduce significant noise in your images (4 should be enough if you are in a hurry, and 16 should give a very good result).

2.1.2 What about camera settings?

Unfortunately, dark frames depend on most of the camera settings: gain (ISO), exposure, and other sensor settings like offset, black shading protection, PLR configuration and so on. Temperature is a variable as well.

Luckily, the dependence on exposure appears to be linear, so we can take calibration frames at various exposures, combine them into a single dark frame, adjust it for the dark current and use it for the entire range of exposure settings (hopefully). We'll discuss that in the next section.

2.2 Dark current

The overall brightness in the dark frame changes with exposure in a linear fashion. We'll try to account for this in two ways: with a simple scalar value, and with a per-pixel correction.

The values in the black reference columns do not appear to compensate for the dark current, so we'll need to do it ourselves.

Currently, calibration frames are identified by gain, so we compute a set of calibration frames at gain x1, another at gain x2, and so on.

2.2.1 Simple correction

Experimentally, we have found the dark frame changes with exposure at roughly 0.055 digital units for each ms (without looking at black reference columns), or 0.06 dn/ms after subtracting the black reference columns. This value is multiplied by gain. To find this value, take the dark frames at different exposure times (say 1...50 ms), then do a linear fit for the frame average (or median).

Command-line:

raw2dng *x1*.raw12 --calc-darkframe
2.2.2 Dark current nonuniformity correction

"One common use of bias frames is for scaling dark frames. By subtracting a bias frame from a dark frame, you end up with a “thermal frame.” A thermal frame contains pixel values showing just the effect of dark current. Because dark current in any given pixel accumulates at a constant rate, a thermal frame allows you to predict with reasonable accuracy how much dark current there would be for different length exposures. However, given the opportunity, you’re always better off taking dark frames that match the exposure times of your light frames." [1]

"Dark current non-uniformity is a noise that results from the fact that each pixel generates a slightly different amount of dark current. This noise can be eliminated by subtracting a dark reference frame from each image. The dark reference frame should be taken at the same temperature and with the same integration time as the image." [2]

Rather than using a single scalar value (0.06 dn/ms/gain) for all pixels, we can try finding the individual dark current for each pixel. So, rather than doing a linear fit on the overall dark frame brightness (vs exposure), we will do the linear fit per pixel. We'll have to acquire a lot more dark frames to compute a good result, but it might be worth the trouble.

Command-line:

raw2dng *x1*.raw12 --calc-dcnuframe

2.3 Black reference columns

This sensor has 8+8 columns that can be used for calibrating the black levels; they are also useful for reducing the dynamic row noise.

In raw2dng, this correction is enabled by default, as long as you use a dark frame. You can turn it off with --no-blackcol, if you want.

2.3.1 Black level
2.3.2 Row noise correction from black columns

3 Proposed calibration pipeline

Step 1: use black reference columns to find the black levels for odd and even rows Step 2: subtract dark offset and dark current Step 3: use variations in black reference columns to reduce row noise

4 Calibration procedure

4.1 Acquiring the images

4.2 Creating the reference frames

4.3 Using the reference frames to correct raw12 files

5 Samples