The Gradient That Sneaks Past Your Flats: How to Spot It and Fix It in Processing
Flats fix vignetting and dust, but some gradients survive calibration because they are additive, not multiplicative. Here is how to identify those gradients and which tool removes them without eating the real signal underneath.

Calibration frames are supposed to clean the frame. Darks remove thermal noise, flats fix vignetting and dust, and the result should be a flat, even canvas ready for stacking. But many imagers reach that point and still see a gradient: a smooth brightness tilt from one side of the frame to the other, or a diffuse glow in a corner that shifts between subs. The flats did their job, and the gradient stayed.
This is not a calibration mistake. It is a fundamental difference between what flats correct and what the sky adds.
Why flats cannot fix every gradient
A flat frame measures a multiplicative error. Vignetting dims the corners by a percentage of the signal, say 30 percent darker at the edge than the center. Dust donuts block a fixed fraction of the light that passes through that spot. Dividing a light frame by a master flat removes those effects because the ratio is the same whether the pixel records a bright nebula or empty sky.
Light pollution gradients and sky glow are additive. A streetlamp or a dome glow adds a fixed number of photons per pixel, not a percentage of the existing signal. If a gradient adds 100 electrons to every pixel on the left side of the frame, dividing by a flat that measured a 10 percent vignetting at that spot corrects the vignetting but leaves the 100 electrons untouched. The additive component survives flat division intact.
This distinction matters because the wrong correction approach makes things worse. Trying to fix an additive gradient with stronger flats only overcorrects the multiplicative component while the additive gradient stays. The fix has to happen after calibration, in processing.
How to tell if the gradient is additive
Open a single calibrated sub and look at the background. If the gradient shifts position or intensity between subs taken an hour apart, it is almost certainly sky glow: moonlight, dome glow, or a low cloud bank catching a city's lights. If the gradient stays in the same place relative to the frame edges in every sub, it may be an internal reflection or a light leak in the optical train.
The second test is more reliable. In PixInsight, extract the luminance from two subs taken at different sky positions and subtract one from the other with PixelMath. If the difference image shows a smooth gradient, the gradient is additive and moved with the sky. If the difference shows only noise, the gradient is multiplicative and your flats are not matching the optical train.
Knowing which type you have determines which tool to reach for.
DBE and ABE: the manual approach
Dynamic Background Extraction in PixInsight is the oldest method and still the most precise when used carefully. The idea is to place a grid of sample points across the empty sky background, and the software fits a mathematical surface through those points and subtracts it. The risk is placing a sample point over real nebular signal: the fit interprets that brightness as sky and removes it.
To avoid eating signal, place samples only on areas you know are empty sky. Use a starless version if needed: run StarXTerminator first and place samples on the starless image, then apply the same correction to the original. This is the step most imagers skip, and it is the difference between a clean background and one that looks flat but lost the faint outer halo of the nebula.
Automatic Background Extraction (ABE) in PixInsight does the same thing without manual samples, using a statistical model of what the background should look like. It works well when the gradient is smooth and the target does not fill more than about a third of the frame. When the target fills most of the frame, ABE often mistakes the target itself for background.
GraXpert: the AI shortcut that works
GraXpert has become popular because it handles both additive gradients and vignetting residuals in one pass, and it is much harder to accidentally remove real signal. It runs as a standalone application or as a PixInsight plugin through the GraXpertSuite.
The default AI model works well on most data. The key parameter is the correction strength. Start at the default and increase only if the background still shows a visible tilt. Going too strong flattens the faintest signal just like placing a sample on a nebula in DBE. The visual check is the same: stretch the background and look for real structure being removed.
GraXpert can also output a synthetic flat: a model of the gradient alone, which you can subtract from the image manually with PixelMath. This is useful when you want to apply the same correction to a set of already-stacked images without running the tool on each one.
MARS and MGC: the reference-based approach
PixInsight introduced Multiscale Gradient Correction (MGC) in 2024, which uses the MARS all-sky reference database to model what the background should look like at your specific sky position. Because it compares your image to a known model of the night sky free of local light pollution, it can separate sky glow from real astronomical signal more reliably than any interpolation-based method.
The trade-off is setup. The image must be plate-solved, and the Gaia reference files are several gigabytes each. Once downloaded and configured, however, MGC handles gradients that DBE and GraXpert struggle with, especially broad, low-contrast tilts across the whole frame. For an imager who processes regularly, the upfront download time pays for itself after a few uses.
MGC is not perfect on heavily gradient-dominated images. If the sky glow is so strong that it washes out most of the frame, MGC may still leave a residual. In that case, run GraXpert first to remove the bulk of the gradient and then MGC to clean the remaining unevenness.
The order that matters: when to remove the gradient
Gradient correction should come after stacking but before any nonlinear stretch. Applying it earlier, on individual subs, gives the stacking algorithm a more uniform input, but the gradient model from a single sub is noisier and may introduce artifacts that get amplified during integration. Applying it after a stretch, on the other hand, guarantees that the correction eats signal, because the stretching already mapped the faintest nebulosity into the same brightness range as the background.
The one exception is star removal for DBE. If you run StarXTerminator on the stacked, unstretched image, place your DBE samples on the starless version, and apply the correction to the original, that works because the gradient model itself is computed from the same linear data. The starless version simply helps you avoid placing samples on stars.
After any correction, do a quick sanity check. In PixInsight, subtract the corrected image from the original using PixelMath. The difference image should show only the gradient pattern and noise, with no trace of the target's faint structure. If you can see the outer halo of the nebula in the difference, the correction was too aggressive. Go back, use a lower order model in ABE, fewer samples in DBE, or a weaker strength in GraXpert, and run the check again.
When the cure is not processing
If every image from the same setup shows the same gradient in the same position regardless of target or sky direction, suspect the optical train. A filter that is not fully seated, a window reflection in the camera housing, or a dew shield that protrudes into the light path can all create a fixed gradient that no software can fully remove because it is built into every single exposure. Test by rotating the camera 180 degrees. If the gradient rotates with the camera, the source is in the optics, not the sky.
A subtle gradient that moves with the sky is a sign of local light pollution. Under Bortle 1 skies, the additive component from sky glow is effectively zero, and the dominant gradient source is the multiplicative one from the optics, which flats handle correctly. That is the cleanest starting point for processing: no time spent wrestling with background extraction, and no risk of losing faint signal to an overzealous correction.