Midwest Astronomy

How to Remove Gradients in Astrophotography (Light Pollution, Moon and Vignetting)

Quick answer: To remove a gradient in astrophotography, first make sure it is not a calibration problem: vignetting and dust need flat frames, and amp glow needs matching darks. Then crop the stacked edges and, while the image is still linear, run a background extraction tool (Siril Background Extraction, GraXpert, or PixInsight GradientCorrection, DBE or MGC) using subtraction. Sample only true background, inspect the model, and do it before color calibration and stretching.

As an Amazon Associate, Midwest Astronomy earns from qualifying purchases.

Almost every deep-sky stack from a suburban backyard has a gradient: one side of the frame brighter or a different color than the other. It is easy to ignore on the linear image and impossible to ignore after a strong stretch, when it turns into a wash of orange or green that hides faint signal and makes color calibration unreliable. The good news is that a smooth gradient is one of the easiest problems to fix, as long as you identify its cause and remove it at the right point in the workflow.

This guide is part of our astrophotography troubleshooting series. For a deep dive into one tool, see our GraXpert tutorial.

Three panels of the Rosette Nebula: one with a strong orange gradient brightening toward the lower right, the smooth gradient model alone, and the corrected image on an even dark background
What gradient removal does: a stack with a light-pollution gradient (left), the smooth background model (center) and the result after subtraction (right). Illustrative simulation on our Rosette Nebula image. Image: Midwest Astronomy

What causes gradients?

A gradient is any large-scale brightness or color variation across the background that is not real sky signal. The causes fall into two families, and the distinction decides how you fix them.

Four heat-map panels showing a linear light-pollution slope, a curved glow from the Moon or a light dome, a vignetting pattern bright in the center, and amp glow at one edge
Common background patterns and their fixes: additive sky gradients are subtracted, while vignetting and amp glow are calibration problems for flats and darks. Chart: Midwest Astronomy
Source What it looks like Type Correct fix
Light pollution and light domes Brighter, usually orange or green, toward the horizon or a town Additive Background extraction (subtraction); filters at capture
Moonlight Strong one-sided glow, often blue or neutral Additive Avoid the Moon for broadband; subtraction
Airglow and twilight Faint large-scale green or red banding, worst at low altitude Additive Subtraction; image targets higher in the sky
Vignetting Darker corners in a symmetrical pattern Multiplicative Flat frames (division as a last resort)
Dust and filter reflections Dark rings, donuts or bright halos Multiplicative / optical Flat frames, cleaning, baffling
Amp glow and sensor edge glow Bright corner or edge, fixed relative to the sensor Additive, sensor-fixed Matched dark frames
Stray light Uneven glow from nearby lights or an unshielded tube Additive Dew shield, light shield, flocking

Additive sources add light on top of your target, so they are removed by subtraction. Multiplicative effects scale the light that reaches the sensor, so they are removed by division, which is exactly what flats do. Trying to remove vignetting with an additive background tool produces uneven results, especially around bright objects, and leaves a lingering pattern that changes with stretch. Our guide on how to take flat frames is the right fix for that half of the table.

How to tell them apart

  • It is centered and symmetrical: vignetting, so check your flats.
  • It has rings or donuts: dust; flats again, taken without moving focus or rotation.
  • It sits in the same corner in every sub, regardless of where the sky is: amp glow or stray light in the optical train; check darks and shielding.
  • It moves or rotates between subs and points toward the horizon: light pollution, Moon or airglow; a background-extraction job.
  • It changes direction between nights: different sky conditions per session. Consider removing it per night or per sub before combining (see below).
A starry night sky over Joshua trees and rocks, brightening to an orange glow along the horizon from distant city lights
Light pollution from the Coachella Valley brightens the horizon at Joshua Tree National Park. Any frame aimed low toward a light dome records this as a gradient. Photo: NPS/Lian Law, public domain, via Wikimedia Commons

Reduce gradients at capture time

Everything you prevent at the telescope is signal you do not have to repair later.

  • Image targets high in the sky. Gradients grow quickly below about 30 degrees altitude, where you look through more atmosphere and closer to light domes. Plan sessions around the meridian crossing.
  • Avoid the Moon for broadband work. Save bright-Moon nights for narrowband, which rejects most of the sky’s continuum.
  • Use a filter that suits your sky. Dual-band and narrowband filters (for example the Optolong L-eXtreme) cut light-pollution gradients dramatically for emission nebulae. Broadband light-pollution filters help less with modern LED lighting. Our guide to astrophotography filters compares the types.
  • Shield the optics. A dew shield also blocks side light from porch lights, neighbors and streetlights. Turn off your own lights, including the laptop screen pointing at the scope.
  • Take good flats every session. A flat panel makes this repeatable.
  • Dither. Dithering does not remove gradients, but it prevents the correlated patterns that make background models misbehave.

If your sky is the main problem, our article on the Bortle scale explains how sky brightness affects gradients and integration time.

Where gradient removal belongs in the workflow

Order matters. Gradient removal works best on linear data, after calibration and stacking, and before anything that depends on an even background.

  1. Calibrate with darks, flats and bias or dark flats.
  2. Register and stack.
  3. Crop the stacking edges. Dithering and field rotation leave ragged borders with fewer subs. Background tools read those edges as a gradient and overcorrect.
  4. Remove gradients (this step).
  5. Color calibrate (photometric or spectrophotometric calibration) and neutralize the background.
  6. Denoise, stretch and continue processing.

A light second pass after stretching is sometimes useful for faint residual blotches, but heavy correction on stretched data tends to create artifacts.

Method 1: Siril Background Extraction

Siril (version 1.4.5 as of December 2026) includes a sample-based background extraction tool with two models: RBF (radial basis functions), the modern, flexible option, and Polynomial, the original method with a degree of 1 to 4.

  1. Open the cropped, linear stack and enable an autostretch preview so you can see the gradient.
  2. Open Image Processing, then Background Extraction.
  3. Set Samples per line (the default is 20) and click Generate. The Grid tolerance setting keeps samples off areas brighter than the background; raise it if too few samples appear, lower it if samples land on nebulosity.
  4. Remove any sample that sits on a nebula, galaxy halo, dust or a bright star (right-click a sample to delete it; left-click to add one on empty sky).
  5. Choose RBF and start with Smoothing at 50%, as Siril’s documentation suggests. Higher smoothing suits broad, simple gradients; lower smoothing follows tighter, local variations.
  6. Set Correction to Subtraction and click Compute Background. Hold Show original image to compare: the corrected background should be even, and the target should not have lost its faint outer structure.
  7. Apply, and re-check the stretched preview for halos or dark holes around the target. If the result shows color banding on a very weak gradient, enable Add dither and recompute.

For simple, one-directional gradients, Polynomial degree 1 or 2 is often safer than a flexible model, because it cannot bend around the target. Siril’s documentation also recommends degree 1 for removing gradients from individual subs before stacking. The sequence version of the tool (the seqsubsky command) is useful for multi-night projects whose gradients point in different directions, and for mosaic panels that need matching backgrounds.

Method 2: GraXpert (AI background extraction)

GraXpert is a free, open-source tool whose AI background-extraction model needs no manual samples. Version 3.0.2 is the stable release, with 3.1.0 release candidates adding deconvolution models. The AI model has two controls: Smoothing, and Correction (Subtraction or Division).

GraXpert runs on its own or inside Siril 1.4 through the GraXpert-AI.py script (Scripts menu, Get Scripts), with the GraXpert executable set in Siril’s Preferences under Miscellaneous so the script can download models. It works well on fields with lots of nebulosity where placing samples by hand is difficult, but always inspect the model it produces: on frames filled with faint dust or emission, any automatic tool can treat real signal as background. Our GraXpert tutorial covers the settings in detail.

Method 3: PixInsight gradient tools

PixInsight offers four main options, each suited to a different situation.

Tool How it works Best for Watch out for
AutomaticBackgroundExtractor (ABE) Automatic sample grid with rejection, polynomial model Small targets in lots of empty sky; a first pass on simple slopes Takes nebulosity with it on busy fields
DynamicBackgroundExtraction (DBE) You place samples; spline model Complex or local gradients where you know the background Time-consuming; bad samples create halos
GradientCorrection Automatic model with structure protection Most fields; good default results Check protection masks on bright, large targets
MultiscaleGradientCorrection (MGC) Compares your image with the MARS all-sky reference survey Faint, large-scale nebulosity that other tools erase Needs plate solving, flux calibration, Gaia data and MARS coverage of your field

MGC deserves a note. It needs an astrometric solution from ImageSolver, flux calibration with SpectrophotometricFluxCalibration, and the Gaia and MARS databases installed. Because it compares your image with real reference data rather than guessing what the background should be, it can keep large faint structures that sample-based methods remove. MARS coverage and filter support are still growing, so check whether your field is covered.

Narrowband, mosaics and Milky Way images

  • Narrowband: gradients are much weaker but rarely zero, and they differ between filters (OIII is more sensitive to moonlight than Ha). Remove gradients on each channel separately, before combining, as in our Siril narrowband processing walkthrough.
  • Mosaics: each panel has its own gradient. Remove them panel by panel (lightly) before assembly so the backgrounds match, then do a final gentle pass on the full mosaic.
  • Landscape images and panoramas: automatic tools treat the horizon as a gradient. Mask the foreground or work on the sky only. Our Milky Way panorama guide covers stitching first and correcting second.
  • Fields full of nebula: Cygnus, Cepheus, Orion and similar regions have almost no true background. Use fewer, carefully placed samples, a smoother model, or a reference-based method like MGC.

Troubleshooting gradient removal

  • Dark halos around the target: samples too close to faint outer structure. Delete those samples or increase smoothing.
  • The nebula looks weaker after correction: the model absorbed real signal. Inspect the background model; if you can see the target’s shape in it, remove samples and try again.
  • Gradient still visible after correction: model too stiff. Add samples in the remaining area, lower smoothing, or raise the polynomial degree by one.
  • Blotchy or wavy background: model too flexible, or too few clean samples. Increase smoothing or use a simpler model.
  • Rings, donuts or dark corners remain: a calibration problem, not a gradient. Revisit your flats and darks before processing further.
  • Color cast returns after color calibration: you calibrated color before removing the gradient. Remove the gradient first, then calibrate.

Frequently asked questions

When should I remove gradients in my astrophotography workflow?

Remove gradients on the linear image after calibration, stacking and cropping, and before color calibration and stretching. A light extra pass on stretched data can help with residual blotches, but heavy correction after stretching tends to create artifacts.

Should I use subtraction or division for gradient removal?

Use subtraction for light pollution, moonlight and airglow, which add light on top of the image. Division is for multiplicative effects such as vignetting, which should be fixed with flat frames rather than a background tool.

Is GraXpert better than Siril background extraction?

Neither is always better. GraXpert's AI model is fast and needs no samples, which helps on busy fields. Siril's RBF and polynomial models give more control when you know exactly where the true background is.

Why does gradient removal erase my nebula?

The tool treats faint nebulosity as background if samples sit on it or the model is too flexible. Delete samples on the target, increase smoothing, or use a reference-based method such as PixInsight's MultiscaleGradientCorrection for fields full of faint signal.

Can flats remove light pollution gradients?

No. Flats correct vignetting, dust and uneven illumination in your optical train. Light pollution changes with sky position and conditions, so it needs background extraction after stacking.

Do narrowband images need gradient removal?

Usually a little. Narrowband filters reject most light pollution, but moonlight and residual skyglow still leave weak gradients, especially in OIII. Correct each channel separately before combining.

Summary

Diagnose first, then correct. Fix multiplicative problems with flats and sensor-fixed glow with darks; fix sky gradients with subtraction on linear, cropped data; protect the target by sampling true background; and always look at the model. For processing software beyond gradient removal, see our comparison of the best astrophotography stacking software.