Gradient Removal
Step: Linear
Removes a smooth brightness gradient from the background: light pollution that brightens one side of the frame, moonlight, a vignetting that darkens the corners. The module measures the sky in a grid of small boxes, leaves out every box that holds a nebula, galaxy or bright star, fits a smooth surface through the rest, and takes that surface out of the image. The overall background level stays where it was.
Parameters
| Parameter | Range | Default | Effect |
|---|---|---|---|
| Samples per side | 4…32 | 12 | The grid has this many boxes along each side, so 12 gives 144 boxes. More boxes follow the sky more closely and cope better when many of them are dropped; fewer boxes are faster and steadier. |
| Polynomial degree | 1…4 | 2 | How curved the fitted surface may be. 1 is a tilted plane (a simple gradient from one side to the other), 2 adds a bowl or saddle shape, 3 and 4 follow more complex patterns. A higher degree can also start to follow real structure; use the lowest degree that flattens the sky. |
| Rejection tolerance | 0.5…5 | 2 | How far above the typical sky level a box may lie before it is treated as an object and dropped, in units of the sky's spread. Lower values drop more boxes, higher values keep more. |
| Correction | Subtract, Divide | Subtract | Subtract removes an additive glow such as light pollution. Divide removes a multiplicative effect such as vignetting. |
When to use it
Use it on the linear image, after stacking and cropping the stacking edges, and before stretching: a gradient that is hardly visible in the linear data becomes obvious after the stretch.
Choose Subtract for sky glow, which adds light to every pixel alike, and Divide when the whole image is scaled brighter or darker towards one side or the corners (vignetting, dust shadows, a flat field that did not fully correct). If you are not sure, start with Subtract.
How it works
Samples. The image is cut into a regular grid of boxes,
samples × samplesof them (fewer if the image has fewer pixels than that). For each box and each color channel the module takes the median of its pixels, ignoring pixels without a value. The median shrugs off single stars inside a box.Dropping objects. A box is dropped if its median lies above the median of all boxes by more than tolerance × 1.4826 × MAD (the median absolute deviation, a robust estimate of the spread). A box that is dropped in one channel is dropped in all channels. After the first fit, boxes that lie far from the fitted surface (more than three times the spread of the residuals) are dropped as well, and the surface is fitted again; this is done at most twice.
Model. A two-dimensional polynomial of the chosen degree is fitted to the remaining boxes by least squares, separately for each channel. Positions are normalized to −1…1 across the image so the numbers stay well behaved.
Correction. With M the median value of the model over the image:
Subtract: result = pixel − model + M Divide: result = pixel ÷ model × MAdding or multiplying by M keeps the median background level the same as before, so the image does not get darker or brighter overall.
Pixels without a value stay without a value, and the file information (exposure time, filter and so on) is kept.
Small images. The grid cannot have more boxes than the image has pixels. On an image smaller than the grid, the degree is lowered to what the boxes can carry (a 2 × 1 image gets a constant background).
Divide and dark backgrounds. Dividing needs a background above zero. If the median of the model is zero or below, the module shows an error; use Subtract. Where the fitted surface dips below 1 % of its median, for example in a far corner, the module divides by that 1 % instead, so a few pixels cannot blow up.
Errors
- Too few background samples are left for this polynomial degree. The degree needs at least as many boxes per side as its value plus one, and at least as many accepted boxes as the surface has terms (3, 6, 10 and 15 for degrees 1 to 4). Increase Samples per side, raise the Rejection tolerance or lower the degree.
- The image is an undebayered mosaic. The color pattern of the sensor would be taken for background. Run Debayer first.
Tips
- If the result still shows a gradient, raise the degree by one. If it shows rings or blotches where nebulosity was, lower it, or lower the tolerance so more of the nebula is left out.
- Images that are mostly covered by a bright object (a large nebula filling the frame) have no empty sky to measure; the module cannot tell the nebula from the background there.
Source
The approach follows the background estimation of Bertin & Arnouts (1996): robust median values in a grid of cells, with cells that are contaminated by objects left out (E. Bertin & S. Arnouts, "SExtractor: Software for source extraction", Astronomy & Astrophysics Supplement 117, 393, 1996). Instead of interpolating the grid, Siderea fits a low-order polynomial surface through the cell values; that choice is Siderea's own.