StellarPix
← Back to Learn
ProcessingPublic tutorial · No membership required17 min read

Gradient Correction with MultiscaleGradientCorrection and MARS DR2

Correct gradients in individual monochrome filter masters before combining RGB, SHO, or HOO, or work on an existing one-shot-color RGB integration. Match each MGC trial to its actual filter, flux calibration, and available MARS reference.

Sources reviewed October 25, 2026

What is a gradient?

A gradient is an unwanted change in background brightness or color across an image, often associated with sky glow, moonlight, or residual illumination problems. It can look like a bright corner, a broad color wash, or a brightness slope across the frame.

Faint dust, diffuse emission, and galaxy halos are also large-scale structures. A smooth-looking patch is not automatically pollution. The goal is to reduce unwanted variation while keeping real sky signal, rather than making every part of the background equally dark.

MultiscaleGradientCorrection (MGC) uses an external sky reference to help distinguish the two. MARS means Multiscale All-Sky Reference Survey. Its DR2 database replaces DR1; it is reference data, not a preset that guarantees a correct result on every target.

1. Start with suitable data

For monochrome data, begin with calibrated, registered, integrated grayscale filter masters from WBPP: R/G/B for broadband, S II/Hα/O III for SHO, or Hα/O III for HOO. Assess and correct gradients on these individual masters before channel combination. Each filter can contain a different unwanted background pattern. Work on duplicates and retain the untouched integrations.

For one-shot-color broadband data, begin with the already debayered RGB integration. It has no separate acquired R/G/B filter masters to combine, so use the RGB route below. An existing combined monochrome RGB image can also use that route; do not automatically repeat a correction already accepted on its component masters.

Keep the image linear: no permanent stretch, star removal, or creative color mixing. ScreenTransferFunction (STF) can brighten its display without changing its pixel values. Finish trimming unwanted stacking borders before checking the astrometry and running flux calibration.

The monochrome route is: solve each master if needed → SPFC for that filter → MGC with a matching, supported reference → inspect and save → combine channels. For broadband RGB, check the new combination’s astrometry and run SPCC afterward. The one-shot-color route is ImageSolver if needed → SPFC → MGC → SPCC. Keep mapped SHO/HOO on the narrowband workflow instead of applying a broadband SPCC recipe.

MGC is a different process from GradientCorrection. Do not stack several background-removal tools on the same image just to make it look flatter. Compare alternatives on separate copies of the same starting image.

2. Confirm MARS DR2 and Gaia are available

Use the installation guide linked under Continue learning to download and register the databases. For this workflow, Gaia DR3 supports local plate solving, Gaia DR3/SP supplies stellar spectra for SPFC and SPCC, and MARS DR2 supplies the sky reference for MGC.

Open Process → All Processes → MultiscaleGradientCorrection, also listed under GradientCorrection in some versions. Open its wrench-shaped Preferences dialog and check the default XMARS file paths. Keep the database files in a permanent folder outside the application directory.

Inspect the active process’s XMARS list too. A saved process instance can retain older paths: use Default Files, or replace the active list with the registered DR2 files as appropriate for your version. A downloaded DR2 file is not in use until the process points to it.

Check the current release notes and process help for coverage of the entire field and the required reference bands. Do not assume that all sky positions or filter combinations are covered simply because the database is named an all-sky survey. Use the portal’s current files and sizes rather than an old DR1 download list.

Monochrome preparation: keep the filter identities clear

Use a common registration grid and crop across masters intended for combination. Keep stars present and the pixels linear. Save clearly named working copies such as Target_R_linear, Target_Ha_linear, and Target_OIII_linear. Do not stretch the channels independently to make their backgrounds look equally bright.

The acquisition filter determines the calibration and reference choice, not the RGB slot it will occupy later. A grayscale S II master is still sulfur data when assigned to the red display channel of SHO. Likewise, an Hα master assigned to HOO red does not call for a broadband red reference.

Master being correctedSPFC setupMGC reference to verify
Broadband R, G, or BGrayscale/Gray response for the actual acquired filter and sensorCorresponding broadband band, with field coverage
HαActual Hα response or documented narrowband configurationMatching Hα reference and coverage
O IIIActual O III response or documented narrowband configurationMatching O III reference and coverage
S IIActual S II response or documented narrowband configurationA genuine matching S II reference; if unavailable, use another method

3. Give the image a valid sky solution

ImageSolver adds a mapping between pixels and sky coordinates. MGC needs that mapping to find the corresponding reference field. If WBPP already produced a valid solution for this image at its current geometry, you can reuse it.

Otherwise, run Script → Image Analysis → ImageSolver on the active image. Verify the approximate field center, UTC observation information, and effective image scale, accounting for reducers, binning, and drizzle. Confirm a successful astrometric report before proceeding.

For the monochrome route, verify a valid solution on every master you will correct. Shared dimensions and registration do not by themselves establish valid metadata. Save solved checkpoints such as Target_R_solved.xisf or Target_Ha_solved.xisf; the color route can use Target_RGB_solved.xisf. If you crop or resample after solving, recheck the solution.

4. Run SPFC before gradient correction

SPFC and SPCC have different jobs. SPFC measures stars against catalog spectra and writes flux-calibration metadata that MGC uses. SPCC performs color calibration. Completing SPCC alone is not a substitute for the SPFC prerequisite.

Run SPFC on the actual current image that will go into MGC. It may look unchanged afterward because this operation supplies calibration information rather than a permanent display stretch or visible color correction.

  1. Open Process → Flux → SpectrophotometricFluxCalibration, or find it under All Processes. Reset a reused instance before entering this image’s configuration.
  2. Select the sensor QE appropriate to the acquisition. For an individual grayscale master, use the Gray filter response for its actual filter: R for an R master, for example. For an RGB image, configure the red, green, and blue responses instead; for a color camera include the relevant Bayer and additional filter responses as described in the installed help.
  3. Use Gaia DR3/SP and automatic limit magnitude for the initial attempt. Leave narrowband mode off for broadband data. For an emission-line master, use its actual supported response or the documented narrowband configuration, including the measured or manufacturer-specified wavelength and bandwidth where requested. Do not invent a bandwidth or mix unrelated response presets; check the installed help for your version’s entry method.
  4. Enable diagnostic graphs if available and apply SPFC to the active solved master. Read the console for completed measurements and calibration factors; do not continue past an actual error. Repeat with the correct response on each monochrome master rather than copying another filter’s metadata.
  5. Inspect the reported measurements for a usable, consistent calibration, rather than adopting a universal star-count or dispersion threshold. Save separate checkpoints such as Target_R_SPFC.xisf, Target_Ha_SPFC.xisf, or Target_RGB_SPFC.xisf as the starting points for MGC trials.

5. Make one MGC trial

Start from a fresh duplicate of the SPFC checkpoint. Use the installed process help for version-specific defaults and controls; the linked developer masterclass predates DR2 and is useful for concepts, not current download filenames or coverage.

  1. Open MultiscaleGradientCorrection and reset a reused instance. Confirm that its active database list still points to DR2.
  2. Check the reference-band mapping. For a grayscale master, configure the grayscale reference for the actual acquired filter, using only a matching band available in the installed DR2 data. For broadband RGB, use the corresponding R, G, and B references. These MGC reference bands are distinct from the detailed response curves entered in SPFC. Recheck the mapping every time you switch filters.
  3. Begin with the process’s default gradient-model parameters and scale factors. Enable Show gradient model if available, so you can inspect the estimated correction as well as the corrected image.
  4. Apply MGC to the flux-calibrated image and wait for completion. Keep the generated model and the pre-correction image open for comparison.
  5. Read any coverage or metadata messages before judging the picture. Save a filter-specific trial such as Target_Ha_MGC_trial01.xisf or Target_RGB_MGC_trial01.xisf, rather than overwriting the checkpoint. Repeat from the appropriate SPFC checkpoint for the next master.

If a monochrome filter has no matching MARS reference

Check both band availability and coverage of the entire field before committing to MGC. In particular, do not assume that S II is available because Hα or O III is listed. If no genuine matching reference is supplied, leave that master out of the MGC route. Do not substitute Hα, O III, or broadband R just because the resulting background looks smoother.

For that master, test another gradient method on a separate duplicate of the original linear integration. For example, DBE lets you place background samples deliberately: avoid stars, nebulosity, dust, and galaxy halos; inspect the proposed background model; use subtraction for an additive sky gradient and create a separate corrected output. Check the installed DBE help for controls and do not default to division to repair poor flats.

In a field filled with real emission, apparently empty background samples may not be trustworthy. Use a conservative model, compare it with the uncorrected source, and keep the source if the correction removes real structure. Missing reference data is a reason to change method, not to force an unrelated reference to work.

Different channels may need different model settings or methods. The goal is preserved sky structure with reduced unwanted gradients, not identical backgrounds, histograms, or pixel values across filters. Save the chosen method and parameters for each master.

6. Decide whether the correction is helpful

Compare source and result at the same zoom and framing with the same display stretch. Independently auto-stretching each image can hide a brightness change or exaggerate a small residual. You can refresh STF afterward to inspect how the corrected image will display on its own.

Look across the whole frame for the original unwanted slope or wash, then inspect faint dust, outer nebular emission, galaxy halos, edges, and bright-star surroundings at 1:1. A darker background alone is not evidence of a better correction.

Inspect the gradient model with a display stretch. It represents the estimated component being removed, not the desired finished image. Recognizable subject-shaped structure in the model is a reason to investigate signal loss; broad bright and dark regions need comparison with the source and reference, not automatic acceptance or rejection.

Reject a trial that creates dark bowls, ripples, new color patches, conspicuous star halos, or weakened faint structures. Also check whether an apparently uneven patch might be genuine emission rather than a remaining gradient.

7. Adjust one control at a time

For every comparison, return to a fresh copy of the same SPFC checkpoint. Applying a second correction to the previous trial is not a controlled test of a new setting.

Gradient scale controls the spatial scale of the correction. Smaller settings can fit finer variation and risk treating real structure as a mismatch; larger settings concentrate on broader variation and may leave gradients behind. The same pixel setting represents a different sky angle after resampling, so there is no universal value for all images.

Model smoothness changes how smooth the estimated correction is. Structure separation also affects the model. Read their tooltips, change one control, and inspect both result and model. Smoothness should not be increased merely to conceal a wrong reference-band choice or poor calibration.

Leave channel scale-factor adjustments for a deliberate, documented refinement after verifying astrometry, SPFC, reference bands, and coverage. Treat them as calibration adjustments rather than color-saturation sliders. Keep the first trial if later changes do not provide a clear improvement.

8. Calibrate color and keep a clean checkpoint

For monochrome data, save each accepted corrected master separately, for example Target_R_gradient_corrected.xisf, Target_Ha_gradient_corrected.xisf, and Target_OIII_gradient_corrected.xisf. Use a neutral filename if a different gradient method was retained. Keep the original and accepted trial for every channel.

Combine the corrected broadband R/G/B masters using ChannelCombination, then check the resulting RGB image’s astrometry and continue to SPCC with the actual camera/filter responses and appropriate white reference. Do not assume the separate masters’ SPFC metadata is valid for the newly created RGB image. For the existing RGB route, save Target_RGB_MGC.xisf and continue to SPCC directly with valid prerequisites.

Do not treat a residual color cast before SPCC as proof that the gradient correction failed. Conversely, color calibration cannot repair missing faint structures or a badly fitted gradient model. Assess spatial problems separately from overall color balance.

If you return to MGC after later operations change pixel values or geometry, return to an appropriate linear checkpoint and regenerate the prerequisites as needed. Do not assume old flux-calibration metadata remains valid after arbitrary processing.

Record the PixInsight version, exact DR2 database filenames, SPFC response choices, MGC reference bands and parameters, and why you retained the result. These notes make comparisons useful across future projects without turning one target’s settings into a prescription.

Combine the corrected narrowband masters into SHO or HOO

After accepting the correction on each channel, confirm that the masters still share dimensions, orientation, registration, and crop. Keep them linear. For SHO, assign S II to red, Hα to green, and O III to blue. For HOO, assign Hα to red and the same corrected O III master to both green and blue.

Correct O III once for the HOO source and reuse that accepted master; do not create independent green and blue correction trials for the same acquired O III data. Check the combined image with a linked RGB STF for new color slopes, edge mismatches, or star fringes. If a problem appears, inspect the individual masters and assignments first.

Continue with the narrowband lesson for stretching and NarrowbandNormalization. Palette balancing is separate from gradient correction and does not replace it. Do not apply broadband SPCC to the mapped SHO/HOO composite as though its display channels were broadband filter measurements.

Do not automatically apply another gradient removal after combination. Revisit the preserved linear inputs if a genuine residual remains, and compare a new trial rather than accumulating corrections. Save the combined linear image before any creative color or stretch operation.

Common problems and when to use another method

Missing flux-calibration metadata: run SPFC successfully on the same image, then rerun MGC from that checkpoint. Renaming the file or running SPCC does not supply the missing step.

No astrometric solution or reference field mismatch: verify the current image’s sky solution and image scale before changing model settings.

No reference data or incomplete coverage: check the active DR2 paths, available bands, and the whole field’s coverage. Missing coverage is different from a disconnected database drive. Another gradient method, such as DBE or GradientCorrection, may be more suitable; test it on a separate copy.

Wrong filter or reference: check the acquisition identity of the individual master and its SPFC Gray response and MGC reference. The eventual SHO/HOO display channel is not a filter specification. A dual-band color integration is also not an ordinary broadband RGB input; use an appropriate, separately validated extraction and calibration workflow.

Halos, ripples, or lost dust: return to the source, check the prerequisites and reference mapping, then compare a more conservative model. Do not keep correcting until every faint variation disappears.

Persistent rings, dust shadows, or strong illumination problems may need attention in calibration or acquisition. MGC does not replace good flats or fix every optical reflection.

Your completion checklist and further reading

For every MGC-corrected master, you have intact stars, linear pixels, valid astrometry, fresh filter-appropriate SPFC metadata, and a matching DR2 band with field coverage. If another method was required, its model and result were checked separately. Accepted masters retain common geometry and are saved alongside their sources before channel combination.

The public DR2 announcement confirms the database replacement. The developer masterclass provides background on MARS, prerequisites, and application but predates DR2. Current account downloads and installed process documentation take precedence for coverage, settings, and version-specific behavior. This guide does not claim a hands-on test of every control in the latest PixInsight build.

See the technique in practice

This lesson is public. Detailed project workflows and dataset downloads require an active membership. Dataset selections follow your membership allowance; reading a workflow does not use a selection.

  • Let the shell stand alone

    See this technique in the recorded Crescent Nebula - NGC6888 workflow. Use that project’s documented order, retained settings, and limitations.

    Public overview · Member-only detailed workflow

    Explore story and member workflow →
  • Finding the Pelican in blue and gold

    See this technique in the recorded Pelican Nebula - IC5070 workflow. Use that project’s documented order, retained settings, and limitations.

    Public overview · Member-only detailed workflow

    Explore story and member workflow →