Removes the part of your background that the real sky does not explain. SRGC fetches an image of your exact field from a published survey — or uses a frame from your own second scope — models both backgrounds on the same sample points, and subtracts only the residual. Real nebulosity survives because it is present in the reference too. Requires a plate solution; the survey path also needs a network connection. Non-destructive: nothing changes until Apply.
ADBE models your background and removes it. The problem it cannot solve is attribution. Your background is
where \(S\) is real diffuse sky structure — nebulosity, IFN, galactic cirrus — and \(G\) is your gradient: light pollution, airglow, a vignetting residual, moonlight. A self-contained model sees one surface and has no way to tell those apart, so it removes some of each. That is why large faint structure quietly flattens out, and it is the reason PixInsight funded an entire survey (MARS) to attack the same problem.
SRGC breaks the degeneracy with outside information. It fetches a reference image of the same patch of sky, models its background the same way, and fits
robustly across the frame. Whatever is left over,
is the part of your background the real sky does not account for. That is your gradient, and that is what gets subtracted. Nebulosity is in the reference too, so it is absorbed by the \(b\,B_r\) term and comes through untouched.
Linear data is the home ground, but a stretched image is not a write-off. SRGC models your gradient as something added to the sky and subtracts it, which is exactly true while the data is linear. It stays a good approximation after an ordinary stretch, because a stretch does almost nothing curved down where the background lives: the background occupies a sliver at the bottom of the histogram, and over a sliver any smooth curve is its own tangent — which is precisely what an additive model is. See §3.7 for the measurements. What does break it is anything spatially varying — masked stretching, local contrast, HDR compression — because that is no longer one transfer function, so there is no single tangent to stand in for it.
The image must be plate-solved: the reference is fetched and aligned by sky coordinates, so without a WCS there is nothing to look up. If the image has no solution SRGC offers to run the plate solver for you. With no pointing in the header that falls back to a blind solve, which searches the quad index and can take a few minutes — so it always asks first and never starts one on its own.
Reference source selects between a published survey and your own image.
Pick the survey whose content matches your data, not simply the deepest one. A narrowband frame should be matched against a narrowband reference: fitting an Hα image against a broadband continuum plane regresses your gradient against structure that is not in your channel.
| Survey | Use it for | Coverage |
|---|---|---|
| NSNS visual continuum — mono | General broadband work in the north. Linear intensity in Rayleighs, star-subtracted. The default. | dec ≥ −16° |
| NSNS SHO (Hα / [OIII] / [SII]) | SHO-mapped narrowband — each channel is matched to the line it was imaged in. | dec ≥ −16° |
| NSNS HOO / SOO | One-shot colour behind a dual narrowband filter. The Bayer matrix already sorted the passbands, so your frame is an HOO composite and the reference is built to be one too. | dec ≥ −16° |
| NSNS Hα / [OIII] / [SII] — mono | Single-line mono data. | dec ≥ −16° |
| NSNS OHS ([OIII] / Hα / [SII]) | Data mapped in the OHS palette, which the SHO entry cannot match — it pairs the channels the other way round. One download instead of three, at the cost of an 8-bit tonal curve. | dec ≥ −16° |
| NSNS HBR (Hα / blue cont / red cont) | Colour data where Hα dominates one channel. The only NSNS tree that separates the blue and red continuum — vc combines them. | dec ≥ −16° |
| NSNS RGB continuum — colour | Broadband colour in the north with a real three-colour reference — neither a photographic plate nor 36% of sky. 8-bit tonal curve and partial star subtraction. | dec ≥ −16° |
| SHASSA Hα — mono | Narrowband in the south. The Southern Hα Sky Survey Atlas, continuum subtracted, linear FITS at 0.8′ — a real survey, seven times finer than the Finkbeiner composite. | dec ≤ +15° |
| VTSS Hα — mono | Northern Hα at 1.6′, linear FITS in Rayleighs. Ten times coarser than NSNS, so reach for it when the non-commercial clause is a problem, or as a second opinion. | northern |
| DSS2 red + NSNS continuum — colour | Colour data in the north. Two genuinely different planes, so each of your channels gets its own reference. | dec ≥ −16° |
| DSS2 colour from 8-bit tiles — colour | Colour data anywhere, including the south. Real red/green/blue bands out of one download. | all sky |
| Finkbeiner Hα composite — mono | Narrowband in the south. WHAM + VTSS + SHASSA combined into one full-sky Hα map (Finkbeiner 2003), linear FITS in Rayleighs. Every other narrowband option stops at dec −16°. Native resolution is ~6′, so it constrains a gradient across a wide field and has little to say across half a degree — check the survey/yours split. | all sky |
| DSS2 red — mono | The dependable fallback. Photographic plates, all sky, always there. | all sky |
| HI4PI neutral hydrogen — mono | Not an optical survey. 21 cm HI column density as a cirrus template: the HI traces the galactic structure a gradient fit must not mistake for a gradient, and light pollution is not in it, so what the fit leaves behind is the gradient. The HI-to-optical ratio varies across the sky — read it as a prior, not a measurement. | all sky |
The note under the dropdown describes the selected survey and leads with a ⚠ warning when it cannot currently fetch. Availability is not decoration: survey hosting moves, and mirrors go down. SRGC re-checks the unavailable entries in the background each time you open the dialog, and tells you if one has come back.
If you run two scopes on one mount, the wide one is very likely a better reference than any survey: it saw the same sky, on the same night, through the same light pollution and the same airglow. A survey tells you where real nebulosity is. A simultaneous wide frame tells you that and what the sky was doing at the time.
Choose it from the list of open images, or load a file directly. Two requirements:
| Control | What it does |
|---|---|
| Work resolution | Long side of the grid the reference is fetched on and both backgrounds are modelled at. A gradient is low-frequency by definition, and NSNS resolves ~10″ anyway, so larger is slower without being better. 1024 is right. |
| Background degree (0–4) | Polynomial order for both background models. Keep it low. A high-degree model on the target absorbs real structure before the reference ever gets a chance to explain it, which defeats the whole method. 1–2. |
| Sample points | How many background samples are placed. One set is generated and used for both models — see §3.3. |
| Patch size (px) | Window whose statistic is taken at each sample point. Larger is more robust to stars, but blurs the line between sky and faint extended signal. |
| Exclude brightest | Percentage of the survey's brightest pixels that are off-limits to sampling. Raise it on a field dominated by a big object; lower it on sparse fields. |
| Protect k (MAD) | Signal protection on the reference, in MAD-sigma units — the same median + k·MAD threshold ADBE's multiscale stage uses. Lower protects more. Drop to 1.5–2 on a field with a large bright object. |
| RBF refinement | Radial-basis refinement on both background models, after the polynomial. |
| Strength (0–150%) | How much of the modelled gradient to subtract. 100% is the fit. Above it deliberately over-corrects — useful for telling a real gradient residual from something the reference never explained. |
Everything above is additive — sky added on top of your signal. Dust motes, internal reflections and vignetting are multiplicative: they scale what was already there, and no additive fit can take them out. Ticking this runs ADBE’s multiscale stage afterwards, as a second pass, dividing out a band of wavelet scales. The core is ADBE’s verbatim; what SRGC adds is the protection — see the last row.
| Control | What it does |
|---|---|
| Scales (1–12) | The wavelet band the defect is estimated from. 6–8 is where dust motes and reflections live: coarse enough to miss stars and noise, fine enough to keep their edges. Lower catches smaller, sharper defects; higher drifts toward the smooth gradient the additive stage has already dealt with. |
| Include coarsest residual | Folds everything coarser than that band into the correction as well. Leave it off unless a broad multiplicative falloff survives the additive stage — vignetting the flat missed, typically. Be more careful with it here than in ADBE: the smooth background has already been removed additively, and removed against a reference that says which large-scale structure is real sky. The coarsest residual is exactly where that structure lives, so folding it in can divide out nebulosity the survey just finished vouching for — on top of correcting the gradient twice. It also costs time: the full pyramid has to be built rather than stopping at the top of the band. |
| Refine strength | How much of the multiplicative correction to apply. 1.00 applies it fully; ease it down if the correction flattens real large-scale structure. |
| Protect k (MAD) | As above, but for this stage: what counts as signal that must not be divided out. Lower protects more. |
| Remove stars first (DarkStar) | Estimates the defect band on a starless copy while the protection mask is still built on the star-inclusive image. That pairing is what makes the band clean; leave it on unless DarkStar is unavailable. |
| Protect real structure using the survey | The one thing SRGC knows that ADBE cannot. ADBE builds its protection from the image itself, so a bright extended blob looks the same whether it is a nebula or an internal reflection; here the survey says which. Real structure is kept from the untouched source, and anything sharp sitting on sky the survey says is empty is treated as a defect. Hand-drawn exclusion zones protect unconditionally, whether or not this is ticked. |
Fetch & Model does the work; Apply commits it. The six view tabs are where the tool earns your trust:
| View | What to look for |
|---|---|
| Corrected | The result. Tick Before to flick back to the image as it was when the model was built — it stays a true "before" even after you Apply. |
| Gradient removed | What is being subtracted. It should look like a gradient: smooth, large-scale, no nebula in it. If you can see your target in here, the model is eating signal — lower the degree or the protect k. Carries the same scale control as the two background views, and under linear it gains a reading the others do not have: the gradient is already median-subtracted, so mid-grey is literally zero. Grey means nothing was removed at that pixel, brighter means subtracted, darker means added back. Under min/max that reading is lost, because the darkest pixel becomes black whatever its value. |
| Reference | The fetched cutout. Confirm it is the right piece of sky and the right way up. If it reports MONO, every channel resolved to the same plane — a colour survey degraded because only one of its channels could be fetched. |
| Reference / Target background | The two modelled surfaces.
These and Gradient removed each carry the same scale control at the
top of the tab — one setting shared by all three, since all three
draw a surface rather than a picture:
|
| Sample points | Green dots are the points used; red tint is vetoed by the survey. A point sitting on anything bright in this view is sampling structure. Your own gradient is deliberately invisible here — see §3.4. |
Run diagnostics probes every route for the selected survey with a tiny cutout and reports what each one returned. Use it when a fetch fails: it separates a dead host from a rejected request from a genuine footprint miss, which all look identical from the main error message.
Current view → new document, in the button column beside Run diagnostics, hands whatever you are looking at to the main window as a new image document — the way ADBE can write its background out separately. It acts on the tab you are on, and the tooltip changes with the tab to say exactly what you will get. It changes nothing here: the correction is still only committed by Apply.
Each view is a different kind of thing, so each one is handed over in the form that is actually usable, and the status bar says which:
| Tab | What you get |
|---|---|
| Target image | _SRGC_Corrected — the
corrected image at the current strength, full resolution, the same pixels
Apply would commit — except that this document is new, so the
original is left alone. With Before ticked you get
_SRGC_Before instead, the uncorrected snapshot the model was
built from, so you can keep both and blink them. |
| Survey reference | _SRGC_Reference — the
fetched cutout, at work resolution rather than yours, because that
is the grid it was reprojected onto and upscaling it would invent detail
it never had. If its values fall outside 0–1 — a DSS2 plate
arrives as 1130–20528 counts — it is rescaled by its own range
and the range is recorded in the metadata, so it behaves like every other
document in SASpro. Nothing the correction used is lost: the fit absorbs
any linear scale (§3.6). |
| Gradient removed | _SRGC_Gradient — the
surface being subtracted, full resolution, in your image’s units,
with your median added back. The gradient is median-subtracted, so
half of it sits below zero; shifted up to your sky level it is positive,
autostretch shows it, and nothing that clips at zero can eat half of it.
The amplitude is untouched — only a constant differs — so
subtract this document and restore the median and you have redone the
correction by hand. |
| Target background | _SRGC_Background —
your modelled background, full resolution, exactly as the model made it.
The one surface that needs no adjusting: it is already in your units and
at your own sky level. This is the direct equivalent of ADBE’s
background document. |
| Survey background | _SRGC_RefBackground
— \( b\,B_r \), the term the fit subtracts, full
resolution. Not the raw survey background, for the same reason the linear
view does not show it: that is in survey counts and means nothing beside a
0–1 frame. Its median is moved to yours, so it blinks against
_SRGC_Background — what the survey contributes, beside
what you started with. |
| Sample points | _SRGC_Points — the
point map as drawn, at work resolution. This one is a picture, not
data: the green dots and the red veto tint are painted into the display
render, so what you get is that render promoted to float. Good as a record
of what was sampled; not something to measure. |
The four full-resolution pushes sit on your pixel grid, so they inherit your
image’s header and its WCS and can be combined with it directly. The two
work-grid pushes deliberately do not — a header whose
NAXIS disagrees with the array it describes is a trap for whatever
saves the file later. Every pushed document records which view it came from,
the survey, the strength, the coverage and the fitted coefficients in its
metadata.
What follows is the method rather than the interface. None of it is needed to use the tool.
The reference is fetched and both backgrounds are modelled at reduced resolution, 1024 px on the long side by default. This is not a shortcut. A gradient is by definition a low-spatial-frequency field, and the degeneracy this tool exists to break lives only at large scales. Working small also keeps the fit well conditioned and the download small. The modelled gradient is upscaled back to full resolution before it is subtracted.
Every survey here is published as a HiPS (IVOA Hierarchical Progressive Survey) — the sky tiled into HEALPix cells at a pyramid of resolutions. SRGC reads the static tile trees directly: it maps each output pixel to a HEALPix index, fetches the tiles that cover the field in parallel, and samples them onto your WCS. It does not depend on a reprojection service.
Each survey carries several mirror URLs, tried in order, leading with a non-CDS host wherever one exists. A failed route is treated by kind: an HTTP 404 retires that one path, because a mirror may carry one band and not another; a connection timeout retires the whole host, because every further route on it would time out too. A TCP pre-flight settles an unreachable host in a couple of seconds rather than waiting out the operating system's connect timeout.
A fetched reference is cached for the session, keyed on the survey, the work resolution and your image's pointing and scale. Changing degree, samples, patch size, exclusion, protect k or strength and re-running therefore costs no download at all — those are exactly the knobs worth re-running.
This is the difference between a reference-based correction that works and one that quietly eats nebulosity.
Modelling the two backgrounds independently lets each chase structure in its own way — different noise, different resolution, different star content. Since the fit downstream is \(B_t \approx a + b\,B_r\), any structure one model follows and the other does not lands in the residual and is subtracted as "gradient". Sampling both at the same sky positions makes those errors common-mode, and common-mode error is precisely what the \(b\,B_r\) term exists to absorb.
Sample points are chosen on
The reference supplies the diffuse-structure veto, and your frame contributes only its high-pass: stars, trails, sharp artefacts.
Your own brightness deliberately gets no vote on whether a location is background. The target is the frame with the gradient in it — that is the entire premise — so treating a bright patch of light pollution as "not background" would starve the fit on the bright side of the gradient and bias the model toward the dim corner. It is also self-defeating: the gradient is the quantity being measured, so declining to sample where it is strong is declining to measure it. A high-pass is blind to a smooth gradient by construction, so a point sitting in the brightest corner of your light pollution is a perfectly good background sample, while a point on a star is not.
On top of that, two hard vetoes are applied to the reference: the
brightest exclude% of covered sky, and a median + k·MAD
signal mask, dilated and blurred. Both are smoothed at the patch scale first and
have their interior holes filled — a dust lane inside a galaxy is dimmer
than the sky outside it, so on a raw map it passes a brightness test and acts as
a local minimum that the sampler walks straight into. Filling holes is what stops
a point landing between M31's dust lanes. If structure dominates the frame the
thresholds are relaxed until enough sky is samplable, and the relaxation is
reported rather than hidden.
Per channel, sigma-clipped least squares for \(B_t \approx a + b\,B_r\), iterated with a MAD-based scale:
Clipping matters more than usual here. Anything your frame has that the reference does not — a satellite trail, a reflection, a processing artefact, a galaxy the survey is too shallow to show — would otherwise tilt the fit, and a tilted fit becomes a gradient that gets subtracted. Clipping removes those before they can.
The fit runs over the whole covered frame, including the vetoed region. Restricting it to sample-constrained pixels looks more principled and measures worse: on a controlled test \(b\) fell from 0.122 to 0.081 against a known truth of 0.129, and recovery correlation dropped from 0.983 to 0.936. Two reasons. The vetoed region is not invented data — both backgrounds there are smooth predictions from the same points through the same kernel, so their extrapolation errors are correlated and cancel in a linear fit. And excluding it throws away the high-\(B_r\) end of the range, which is the leverage that determines \(b\) at all.
Colour data is fitted per channel. Light pollution is strongly colour-selective, so a red sky and a blue sky need to be explained by red and blue structure rather than by one grey average. Against a mono reference each channel still solves its own \((a, b)\) — the structure is assumed to have the same shape in every channel and a different amplitude, which is an approximation, but a far better one than no reference at all.
A survey cutout and your frame are in completely unrelated units — a DSS2 plate arrives as roughly 1100–20000 counts against your 0–1 floats — which raises the obvious worry that the two sides of the fit are not comparable. They are, and the fit form is the reason. Because it solves \( B_t \approx a + b\,B_r \), any linear rescaling of either side is absorbed exactly:
The sigma clipping does not break this either, because its threshold is MAD-based and so scales with the data. Measured: a target or reference rescaled by \( 10^4 \) changes the recovered gradient by about \( 10^{-8} \), which is float32 round-off and not a difference. So matching the two images' scales before the fit, and undoing it afterwards, is provably a no-op — and it is worse than neutral if done carelessly: rescaling a small signal onto a large pedestal cost 0.18% of the gradient span to float32 cancellation in the same test.
What the fit cannot absorb is curvature — a reference that encodes brightness non-linearly, as a log-stretched 8-bit composite does. In practice this costs very little, for a structural reason: the fit runs on background models, not raw pixels, and a background spans a narrow range by construction. Any smooth monotone curve is close to its own tangent over a narrow range, and a tangent is exactly what \( a + b\,B_r \) fits. On a real DSS2 fetch the reference background spanned 2.2% of its own sky level, which puts the second-order term of a log at about 1.1% of the reference term — and that term explained 31% of the gradient, so roughly 0.35% of the correction. Swapping a linear reference for a log, asinh, gamma or 8-bit-quantised one changed recovery by 0.01 percentage points in a controlled test.
The tool therefore does not rescale anything. It reports instead: the Survey reference tab names the format it fetched, how that tree encodes brightness (linear, log, or high-passed) and whether it can resolve a gradient at all — see §3.8.
§3.6 is about a curved reference. This is the other half of the same question: a curved target. The answer is better than the additive model has any right to expect, and the reason is where the background sits.
A statistical stretch lifts the background enormously — measured local gain 30× at a 0.25 target median, 39× at 0.40 — but it lifts it almost uniformly. On a synthetic frame whose background occupied 0.0215–0.0259, the stretch departed from a straight line across that whole range by only 4.2% (6.9% at a 0.40 median) of what it did to the range. The knee is a feature of the curve somewhere else entirely; the background rides a nearly straight piece of it. That straight piece is a gain, and a gain is exactly what \( a + b\,B_r \) already solves for.
End to end, with the gradient recovered and scored against the truth in stretched space:
| Target | Recovery error | vs linear |
|---|---|---|
| linear (baseline) | 12.5% | — |
| statistical stretch, 0.25 median | 16.9% | +4.4 pts |
| statistical stretch, 0.40 median | 20.4% | +7.9 pts |
| statistical stretch applied twice | 16.9% | +4.4 pts |
| gamma 0.33 | 14.0% | +1.5 pts |
| log10 (deliberately unfair) | 14.8% | +2.3 pts |
A few points per cent, against a 12.5% floor that is inherent to the method rather than to the stretch. And the cost falls as the gradient grows: at a gradient equal to the sky level the stretched cases scored 5.2% against the linear baseline's 12.7%, because a bigger signal swamps the degeneracy between your gradient and real sky structure. Subtracting a sky-fitted surface does not damage the bright end either — error on the stars came out lower than error on the sky.
These are simulations. They establish that the shape of the problem is benign, not that any particular real image will come out well. Two caveats are real: a stretch that clipped the black point has destroyed part of the background outright, and nothing recovers that; and a spatially varying edit is not one transfer function, so the tangent argument above does not apply to it at all.
Separate question from §3.9, and not covered by it. A reference quantised so coarsely that the sky sits on one or two levels can still produce a perfectly healthy \( b \) — fitted to a staircase. FITS tiles are preferred wherever a tree publishes them, but some trees are 8-bit only, so the resolution is measured directly from the data: the quantisation step is found from the gaps between distinct values, and the modelled background is reported in units of that step.
Noise decides how much that costs. If the per-pixel scatter is wider than one step, sky pixels straddle several levels and averaging a sample patch recovers structure far finer than the step — the quantisation is dithered. If the scatter is narrower, every sky pixel reads the same integer and the structure is simply gone. Four verdicts follow:
| Verdict | Means |
|---|---|
| ample | 32+ steps, or 8+ steps with dithering. Nothing to think about. |
| coarse | 8 or more steps but undithered. The gradient's shape is described; its amplitude is described in that many discrete steps. Prefer a FITS tree if one covers the field. |
| coarse-dithered | Fewer than 8 steps, but noise wider than a step. Patch averaging recovers sub-step structure — shape usable, amplitude soft. |
| pinned | Fewer than 8 steps and undithered. The reference cannot resolve your gradient. Flagged with a warning on the run summary. |
Measured on M81 with a 256 px work grid: the DSS2 red FITS tree gave a background spanning 91 quantisation steps with noise 48× the step (ample), while CDS's 8-bit DSS2 colour composite gave 8.5 steps with noise 0.88× the step (coarse) on the same field. Both are usable; only one of them is comfortable.
This is measured from the pixels rather than inferred from the tile format, so it also covers a reference you supply yourself — which is the case where nobody knows what the data has been through.
The run summary splits the background structure between the two components that describe it. Write \( E \) for the amplitude the reference accounted for and \( R \) for what was left over — your gradient:
So the survey's share and yours sum to 100%, and neither can exceed it.
Earlier versions divided \( E \) by \( R \) alone, which could report a reference explaining 164% of the gradient. That was not a display bug but a real one, and the reason is worth knowing: spans do not add. \( \mathrm{span}(X + Y) \) equals \( \mathrm{span}(X) + \mathrm{span}(Y) \) only when \( X \) and \( Y \) are perfectly correlated, and a fitted component and its residual generally are not — so \( E \) can exceed \( R \) with both being correct measurements of their own component. The ratio of one to the other is then not a fraction of anything. For a least-squares fit the exact orthogonal decomposition is in quadrature, \( E^2/(E^2 + R^2) \); the linear form is used here because these spans are robust percentile measures rather than variances (so exact additivity is unavailable either way), and because in the small-\( E \) regime where the warning fires \( E/(E+R) \) tends to \( E/R \), which keeps the 5% trip point calibrated where it already was. Quadrature would have moved it by about a factor of four.
This is the honest self-check, and it is worth reading every time. With a strict veto the reference background can come out nearly flat, \(b\,B_r\) collapses toward a constant, and the method quietly degenerates into ADBE with a survey-derived exclusion mask. That is still a useful tool — but it is not reference-based correction, and the difference should be visible rather than assumed. A survey share near zero means one of:
The correction is additive, always. The premise is that what the reference fails to explain is additive sky, so dividing it out would be the wrong operator. The gradient is median-centred, scaled by Strength, subtracted, and the original median restored; the result is then rescaled if needed so nothing clips at either end.
Pixels outside the survey footprint come back non-finite and are carried through honestly. A pixel is usable only where every reference channel has data, so one channel's footprint edge cannot silently fit against a hole in another. Below 25% coverage the run stops, and the message distinguishes the cases, because they have very different fixes:
ctx.run_command('srgc', {'degree': 2, 'strength': 80}).
The headless path never starts a blind plate solve — solve the image
first, or use the dialog.