# Dark-frame correction

There is a choice of two calibration schemes for the dark-frame correction: the standard calibration scheme and the advanced calibration scheme.

Standand calibration scheme

In the “standard calibration scheme”, the dark-frame correction is a subtraction of a dark frame D from a source frame X to generate an output frame Y. The following formula is applied to each pixel at coordinates (x, y) independently:

(1)Y(x, y) = X(x, y) - D(x, y)

Bad and overexposed pixels require special treatment:

- If a pixel is bad at either source frame or dark frame, it must be marked as bad on a corrected frame.

- If a pixel is overexposed on the source pixel, it must stay overexposed after the correction.

- If a pixel is overexposed on the dark frame, it is marked as bad on the corrected frame.

Advanced calibration scheme

In the “advanced calibration scheme”, a scalable dark frame, that was acquired with exposure duration t_SD is scaled to match the exposure duration t_X of a source frame X. Then, the dark frame is subtracted from a source frame to generate an output frame Y.

(2)Y(x, y) = X(x, y) - \frac{t_X}{t_SD}\,SD(x, y)

The program makes sure that the dark frame is a scalable dark frame by checking the status of the SCALABLE flag, which is stored in the file’s header.