Automatic (Dynamic) Background Extraction — ADBE

Models the sky background — gradients, vignetting, light pollution — with a polynomial plus an optional radial-basis refinement, and removes it while preserving star colour and linear photometry. An optional multiscale stage additionally removes sharp multiplicative defects (dust motes, reflections, filter-edge shadows) that smooth fits can't model. Non-destructive: nothing changes until Apply.

1. Using the tool

Set the model parameters, optionally guide the sampling (exclude regions or place points by hand), Preview, then Apply. The preview is fully interactive; the sampling behaviour depends on whether you're in Auto or Manual mode.

For RGB data, combine R/G/B into one colour image before running ADBE. Running it on separate mono channels can leave colour artefacts at saturated stars once they're recombined.

Model parameters

ControlWhat it does
Polynomial degree (0–6)Order of the smooth large-scale background surface. Higher fits more structure but risks absorbing real signal. 0 skips the polynomial entirely → RBF-only (and enables RBF automatically).
# sample pointsHow many background samples the automatic sampler places (Auto mode only — disabled in Manual).
Downsample factor (4–32)The background is fit on a shrunk copy for speed. Keep it ≥ 4; factor 1 with RBF on can exhaust memory.
Patch size (px)The window whose median is taken at each sample point — larger is more robust to noise and faint stars.
Sample modeAuto (ADBE chooses points) or Manual (you place them on the preview).
Random seedMakes the auto sampling reproducible; -1 = different every run.
RBF refinement + Smooth (×0.01)Enable a second multiquadric stage that models residual, irregular gradients the polynomial can't; Smooth sets how loosely it fits (higher = gentler).
Correction modeSubtract (standard additive removal) or Divide (for vignetting / multiplicative gradients).
Create background documentAlso open the extracted gradient as its own image.
Preview background instead of correctedShow the model itself rather than the result.

Sample points: Auto vs Manual

This is the key choice, and it changes what your mouse does in the preview:

Auto mode — drawing exclusion areas

Exclusion areas are regions where no sample points will be placed — draw them around bright nebulosity, a large galaxy, or anything that isn't sky background, so the gradient fit isn't contaminated.

Exclusion areas do double duty when Multiscale Gradient Refinement is on: the same polygons that keep the sampler off your galaxy also protect that galaxy from the multiscale correction (see below), so you can draw once and both stages respect it.

Manual mode — placing points by hand

In Manual mode you drop sample points exactly where you want the background measured:

Three helpers seed a starting set and switch you to Manual so you can refine by hand:

Multiscale Gradient Refinement (optional)

The polynomial and RBF stages model smooth background. They cannot represent sharp-edged, multiplicative defects in the imaging train — dust motes (soft dark donuts), internal reflections / ghosts, and filter-edge shadows (coarse frame darkening). These are throughput losses: light that should have landed is attenuated by some factor less than one. A smooth surface fit just slides underneath them; multiscale refinement is built to catch them.

When enabled, it runs after the normal background removal, on the already-flattened result:

ControlWhat it does
Enable multiscale refinementTurns the whole stage on. Off by default — existing ADBE behaviour is unchanged until you tick it.
Remove stars first (DarkStar)Runs CosmicClarity DarkStar to get a starless image for estimating the gradient, so stars don't pollute the model. Stars are kept in the final output — they just don't contaminate the estimate. Strongly recommended.
Gradient scale band (layers lo–hi)Which spatial scales to treat as gradient. Dust motes, reflections and filter edges live in the mid-to-coarse layers; 6–8 is a good starting band on a full-size frame. Lower the band for finer structure, raise the top toward 9–10 for very broad filter-edge darkening.
Include coarsest residualFolds the smoothest (coarsest) scale into the gradient too. Usually leave off — that smooth component is already handled by poly/RBF, and including it risks double-correcting.
Strength (%)Blend strength of the correction. 100% applies it fully; lower eases it in if the full correction over-flattens real large-scale structure.
Protect k (MAD)Signal-protection threshold in MAD units. Pixels brighter than median + k·MAD are treated as signal, masked out and interpolated across so they aren't modelled as gradient. k = 1–2 protects aggressively (safest for faint signal), k = 3 is balanced, k = 4–5 protects only the brightest cores and lets more extended structure into the estimate.
Protecting a galaxy or nebula. The MAD threshold alone can't both flatten the background and fully protect a faint extended halo — a high k flattens well but can eat the halo. So the drawn exclusion area is honoured at apply time: wherever you've excluded, the original pixels are kept unchanged, no matter what the gradient did there. Draw a polygon around M81/M82 (or your nebula), push k up for a dead-flat field everywhere else, and the object comes back pristine. The edge of the exclusion is feathered with a wide, image-scaled blur, so the protected object blends smoothly into the corrected background with no hard line.
Workflow: run ADBE once in Subtract mode with multiscale off and look at the result. If sharp mottling, donuts or a darkened frame edge remain, tick Enable multiscale refinement, draw exclusion areas around any bright objects, set the band to 6–8, and Preview. Adjust the band and k until the background is flat and the objects are untouched.

Navigating the preview

Running it

Preview computes the correction without touching the document; Apply commits an “ABE” step (and, if asked, the background document); Close dismisses. The grip (bottom-left) drags to the canvas to mint an ADBE shortcut with these settings, or drops on an image to apply headlessly.

2. Technical details

A two-stage background model is fit on a downsampled copy, in a stretched domain for sampling accuracy, then un-stretched and removed in linear space so photometry and star colour survive. An optional multiscale stage then removes sharp multiplicative defects in log space.

2.1 Two-stage background model

The smooth component is a 2-D polynomial of the chosen degree d, least-squares-fit to the sampled background values z:

B(x,y)=\sum_{p+q\leq d} c_{pq}\,x^{p}\,y^{q}\,,\qquad \min_{c}\;\|A\,c-z\|^{2}

If RBF refinement is on, a second surface is fit to what the polynomial left behind, using a multiquadric radial basis over the sample points:

\phi(r)=\sqrt{r^{2}+\epsilon^{2}}\,,\qquad B_{\mathrm{rbf}}(x)=\sum_i w_i\,\phi\!\left(\|x-x_i\|\right)

The RBF stage is capped at ~1 megapixel (downsampling further if needed) to bound memory, and its smoothing scales with the sample count so the control feels consistent regardless of how many points there are. The total model is B = B_poly + B_rbf.

2.2 Smart sample placement

In Auto mode the sampler seeds points at the corners, along the borders, and within each image quartile, then refines each one by gradient descent to the dimmest nearby spot — it repeatedly steps to whichever neighbour has the lowest local patch-median luminance, so samples land on background rather than on stars or nebulosity:

Y=0.2989\,R+0.5870\,G+0.1140\,B

Within each quartile the brightest ~50% of pixels are excluded before random selection (bright-region avoidance), and any user exclusion polygons remove their pixels from the candidate pool. At every chosen point the background value is the median of the surrounding patch, which rejects stars and hot pixels.

2.3 Fit stretched, remove linear

Gradients are easiest to sample on stretched data, but must be removed from linear data to keep photometry intact. ADBE does both: it fits the model on an auto-stretched copy, then un-stretches the background model back to linear and removes it from the original linear image. The fitting stretch is the same analytic midtones transfer used by Statistical Stretch (target median 0.25):

S(x)=\frac{(M-1)\,T\,x}{M\,(T+x-1)-T\,x}\qquad(T=0.25)

This “fit in stretched space, subtract in linear space” order is what preserves star colour and linear flux relationships — subtracting a stretched background directly would distort both.

2.4 Correction & rescale

With the linear background model B, the two correction modes are:

\mathrm{subtract:}\quad \mathrm{out}=I-B+\left(\mathrm{med}(I)-\mathrm{med}(I-B)\right)
\mathrm{divide:}\quad \mathrm{out}=\frac{I}{B/\mathrm{med}(B)}\ \ (\text{re-centred on }\mathrm{med}(I))

Both re-centre the result on the original median so overall brightness is preserved. A final clip-free, median-anchored rescale lifts any negatives and compresses the ceiling only if the data exceeds 1.0 — holding the median fixed — so no values are hard-clipped away.

2.5 Multiscale multiplicative refinement

Optical-train defects are multiplicative: the observed image is the true scene times a spatially-varying throughput factor.

I_{\mathrm{obs}} = I_{\mathrm{true}} \cdot G(x,y)

Taking logs turns that product into a sum, so an additive multiscale decomposition can separate the defect by spatial scale consistently with the multiplicative model — a linear decomposition would over- or under-correct depending on local brightness:

\log I_{\mathrm{obs}} = \log I_{\mathrm{true}} + \log G

The stage runs on the already-background-corrected image. First it builds a robust signal-protection mask on the (optionally starless) luminance, so real signal is interpolated across rather than modelled as gradient:

\mathrm{protect} = I > \mathrm{med}(I) + k \cdot \mathrm{MAD}\,,\qquad \mathrm{MAD} = 1.4826 \cdot \mathrm{median}(|I - \mathrm{med}(I)|)

It then decomposes the log-image with an à-trous-style pyramid (successive Gaussian blurs; each detail layer is the difference between consecutive blurs, with the blur scale doubling per layer):

d_k = c_k - \mathcal{B}_{\sigma_k}(c_k),\quad \sigma_k = \sigma_0 \cdot 2^{k}

The selected band of detail layers is summed into the log-gradient, then re-centred to zero mean (unit median in linear space) and exponentiated back:

G_{\log} = \sum_{k=k_{lo}}^{k_{hi}} d_k\,,\qquad G_{\log} \leftarrow G_{\log} - \mathrm{median}(G_{\log})
G = \exp(G_{\log}),\qquad \mathrm{median}(G) \approx 1

Finally the defect is divided out (optionally eased in by a strength blend), and the result is re-centred on the original median:

\mathrm{out} = (1-s)\,I + s\,(I / G)

2.6 Star removal & estimation

Point sources would otherwise dominate the mid-scale layers and be mistaken for structure, so with DarkStar enabled the gradient is estimated on a starless copy — CosmicClarity DarkStar removes the stars, the band is extracted from that, and the resulting gradient map is applied to the original (star-bearing) image. The luminance used for both the protection mask and the decomposition is the Rec. 709 weighting:

Y = 0.2126\,R + 0.7152\,G + 0.0722\,B

The gradient is estimated on luminance and applied to all channels, because these throughput defects are achromatic. The decomposition reuses the same GPU-capable (torch) Gaussian blur as the Multiscale Decomposition tool, and only the layers up to the band's top are computed when the coarse residual isn't needed.

2.7 Protecting excluded regions

The multiscale correction runs across the whole frame, but a hand-drawn exclusion area is honoured as a final composite: wherever the mask marks protection, the original pixels are kept.

\mathrm{out} = (1-m)\cdot\mathrm{corrected} + m\cdot I_{\mathrm{orig}}

To avoid a hard seam at the polygon edge, the mask m is first blurred with a large Gaussian so its 0→1 transition is spread over a wide, soft band. The blur radius scales with the image — by default about 10% of the frame's short side (roughly 300 px on a 4500×3000 image). This matters: a fixed small feather that looks fine on a screenshot is invisible at full resolution, leaving a visible diagonal line where the correction stops. Scaling the blur to the image makes the protected region dissolve gently into the corrected background at any resolution. A positive override can force an exact blur radius if a particular image wants a tighter or softer edge.

Because this is a straight composite from the untouched source, whatever the gradient did inside the excluded region is irrelevant — the galaxy or nebula returns exactly as it was, while the background everywhere else stays fully corrected. The same exclusion polygons drawn for the sampler are reused here, so one drawing protects both stages.

2.8 Masking & notes