The algorithm proceeds as follows. A filtered form of the input data is first produced by replacing every input pixel by the minimum of the input values within a rectangular box centred on the pixel. This filtered data is then filtered again, using a filter that replaces every pixel value by the maximum value in a box centred on the pixel. This produces an estimate of the lower envelope of the data, but usually contains unacceptable sharp edges. In addition, this filtered data has a tendency to hug the lower envelope of the noise, thus under-estimating the true background of the noise-free data. The first problem is minimised by smoothing the background estimate using a filter that replaces every pixel value by the mean of the values in a box centred on the pixel. The second problem is minimised by estimating the difference between the input data and the background estimate within regions well removed from any bright areas. This difference is then extrapolated into the bright source regions and used as a correction to the background estimate. Specifically, the residuals between the input data and the initial background estimate are first formed, and residuals which are more than three times the RMS noise are set bad. The remaining residuals are smoothed with a mean filter. This smoothing will replace a lot of the bad values rejected above, but may not remove them all. Any remaining bad values are estimated by linear interpolation between the nearest good values along the first axis. The interpolated residuals are then smoothed again using a mean filter, to get a surface representing the bias in the initial background estimate. This surface is finally added onto the initial background estimate to obtain the output NDF.
CUPID