Extraction de gradient
The sky background often has an unwanted gradient caused by light pollution, the moon, or simply the orientation of the camera relative to the ground. This tool models that gradient and removes it, following a smooth function so that nebulae and other real signal are preserved.
Siril offers two methods to build the background model, selected with the Method drop-down at the top of the dialog:
Sample-based (the classic method): the background is sampled at many places of the image, either on a regular grid or at manually placed points, and a smooth surface is interpolated through those samples.
Automatic (sample-free): no samples are placed. The background is fitted directly on every pixel that survives an iterative robust rejection of structures (stars, nebulae), which makes it convenient when placing a good sample grid is difficult.
The Correction mode, the Compute Background button and the View selector (see General settings) are common to both methods. All the other options are specific to the method selected.
Sample-based method
Boite de dialogue extraction du gradient. Sur la gauche la version polynomiale, sur la droite la version RBF.
Les échantillons peuvent être placés automatiquement en fournissant une densité (Echantillons par ligne) et en cliquant sur Générer. Si des zones de l'image sont plus lumineuses que la médiane d'un facteur Tolérance de la grille multiplié par sigma, alors aucun échantillon ne sera placé à cet endroit.
There are some options regarding how to place samples.
The default is a regular grid, however you can select random sample locations to achieve the same sample positioning as SetiAstro's AutoDBE process.
You can select sample optimization. If this is enabled, the position of each sample will be optimized by seeking a local minimum sample median. This may result in an irregular grid. Note that this setting also affects manually placed samples, so don't be surprised if your samples move! If you wish to place a sample precisely then disable this.
You can also limit the area in which samples are placed. If a sample lands too close to the image edge it may include black border areas, or areas of uneven coverage, resulting in a poor background model. By making a selection a little in from the image edge, you can restrict the sample placement to inside the selection thus eliminating the problem with edge samples.
Astuce
Si vous avez des gradients très forts, par exemple lorsque vous photographiez dans un ciel urbain à fort Bortle, même la tolérance maximale de la grille peut s'avérer insuffisante. Dans ce cas, vous pouvez cocher la case Gardez tous les échantillons et la grille d'échantillons complète sera remplie. Vous devrez alors retirer manuellement les échantillons posés sur des objets astronomiques réels.
Après la génération, les échantillons peuvent également être ajoutés manuellement (clic gauche) ou retirés manuellement (clic droit).
Add dither: check this option when color banding is produced after background extraction. Dither is an intentionally applied form of noise used to randomize quantization error, preventing large-scale patterns such as color banding in images.
There are two algorithms to interpolate the background model through the samples:
RBF
Il s'agit de la méthode la plus moderne. Elle utilise la fonction de base radiale pour synthétiser un fond de ciel afin de supprimer le gradient avec une grande flexibilité. Elle nécessite un seul paramètre qui est présent sous la forme d'un curseur : Lissage. Cette valeur permet de déterminer la douceur ou la dureté de la transition entre les points d'échantillonnage. Un facteur de lissage élevé a du sens pour les gradients larges et uniformes, et une valeur correspondante plus faible pour de petits gradients locaux.
Astuce
Commencez par le réglage de base (50 %) et ajustez progressivement pour obtenir des résultats optimaux.
Théorie
Les fonctions de base radiales sont des fonctions de la forme \(\phi(\mathbf{x}) = \phi(\| \mathbf{x} \|)\), sachant que dans notre cas, nous utilisons la norme euclidienne \(\| \mathbf{x} \| = \sqrt{x_1^2 + x_2^2}\). La fonction \(f\), qui décrit le modèle d'arrière-plan, peut maintenant être exprimée comme une combinaison linéaire
où \(w_i\) correspond aux poids des différents points d'échantillonnage et \(o\) correspond à un décalage constant.
L'exigence selon laquelle la fonction \(f\) doit passer par les points d'échantillonnage se traduit par la condition suivante
qui ne peut être satisfaite que si la matrice du côté gauche est inversible. Avec le bon choix de la fonction \(\phi\), cela peut toujours être garanti [Wright2003].
En outre, la somme \(s \, I\) est ajoutée à la matrice du côté gauche, où \(s\) est un paramètre de lissage et \(I\) est la matrice unitaire. La somme entraîne une régularisation, qui donne un résultat d'autant plus lisse que le paramètre \(s\) est grand. Ce paramètre peut être modifié avec le paramètre Lissage de la boîte de dialogue.
Pour la fonction de base radiale, nous utilisons la spline mince \(\phi(|\mathbf{x}|) = |\mathbf{x}|^2 \log(|\mathbf{x}|)\).
Polynomiale
Il s'agit de l'algorithme original et le plus simple développé dans Siril. Un seul paramètre est utilisé dans le calcul polynomial : le bouton Ordre. Plus le degré de l'ordre est élevé, plus la correction est souple, mais un degré trop élevé peut donner des résultats étranges comme une surcorrection.
Astuce
Une correction de degré 1 peut s'avérer très utile lorsque vous souhaitez supprimer le gradient sur les images individuelles.
Avertissement
Background removal can be carried out on CFA images, but only if they have Bayer patterns. (It is not supported for X-TRANS patterns.) For Bayer patterned images, the image is treated as four spatially interleaved images, each corresponding to a CFA subchannel. Each subchannel is independently processed to remove its gradient and then the subchannels are recombined into the original interleaved pattern.
The intended use for this is to remove linear gradients from sequence frames prior to using Drizzle on a Bayer patterned sequence, and in that case it is strongly recommended to use linear (polynomial order 1) gradient removal as with other pre-stacking gradient removal.
Théorie
Les fonctions polynomiales sont des fonctions de la forme
Dans Siril, le degré maximum autorisé est \(n=4\) et peut être modifié en utilisant le menu déroulant Ordre. Au-delà, le modèle est généralement instable et donne de mauvais résultats.
Automatic (sample-free) method
When Automatic (sample-free) is selected in the Method drop-down, no samples are placed on the image. Instead, the background is fitted directly on the pixels: the tool iteratively rejects everything that does not look like background (stars, nebulae and other structures) and fits a smooth model on the pixels that remain. This is convenient when a good sample grid is hard to place, for example on densely populated fields.
Background extraction dialog with the automatic (sample-free) method selected, showing the Automatic Model panel.
Avertissement
The automatic method fits the background over the whole image, borders included. Stacked images very often have black or uneven edges (caused by dithering, field rotation or incomplete overlap between frames). These borders must be cropped away before running the automatic method, otherwise they are treated as extremely dark background and corrupt the model. Unlike the sample-based method, the edges cannot be excluded here by making a selection, so a clean crop of the stacked result is imperative.
The following parameters are available in the Automatic Model panel:
Scale: relative scale of the multiscale model, in the
[1, 10]range (default 5). A higher value keeps only large-scale gradients and gives a smoother model, while a lower value lets the model follow more complex or more local gradients.Smoothness: extra smoothing applied to the final model (default 1). A higher value gives a softer, more gradual background; a value of 0 leaves the fitted model untouched.
Structure protection: when enabled (the default), extended bright structures such as nebulae are masked so that they are not absorbed into the background model. Two sub-parameters control it:
Protection threshold: brightness above the model at which a pixel starts to be treated as a structure (default 0.05). A lower value protects more of the image.
Protection amount: how far the protection mask grows around the detected structures (default 0.5).
Simplified model: replaces the multiscale model with a stiff low-degree polynomial. Use it when a nebula fills most of the frame and the default model would hollow it out. Its degree is set with:
Model degree: polynomial degree of the simplified model, in the
[1, 6]range (default 2). A lower value is stiffer (degree 1 is a plane).
Downsample: internal working scale factor (1, 2, 4 or 8, default 4). A higher value makes the computation faster but coarser; it does not change the scale of the background itself.
Astuce
Start with the default settings. If real signal (a large nebula) is being eaten by the model, either lower the Protection threshold or switch to the Simplified model with a low Model degree.
Théorie
The automatic model is estimated independently on each channel and, for speed, on an internally downsampled copy of the image (the Downsample factor). It then alternates a fit step and a robust rejection step:
An initial background model \(B\) is fitted on every pixel.
The residual \(r = I - B\) between the image \(I\) and the current model is computed, and its robust location and scale are estimated from the pixels currently kept, using the median and the median absolute deviation (\(\sigma = 1.4826 \times \mathrm{MAD}\)).
Pixels are rejected by an asymmetric sigma clipping: a pixel is kept only if its residual lies within \([\,\mathrm{med} - k_\mathrm{lo}\,\sigma,\ \mathrm{med} + k_\mathrm{hi}\,\sigma\,]\), with a tighter upper bound than the lower one. Bright outliers (stars, nebula cores) are therefore discarded more aggressively than faint ones.
When Structure protection is enabled, a spatially-coherent mask of extended bright structures is additionally removed from the fitting set, so large nebulae are not mistaken for background.
The model is re-fitted on the surviving pixels and the process repeats until the kept set stabilises.
Two models are available. The default multiscale model rebuilds a smooth surface across the rejected regions by harmonic-style inpainting (repeated low-pass filtering that restores the kept pixels at each pass); the Scale parameter sets the width of that low-pass, i.e. the spatial scale below which variations are considered signal rather than background. The simplified model instead fits a single 2D polynomial of the chosen Model degree by least squares. In both cases a final, optional Gaussian smoothing is controlled by Smoothness.
The low-pass filtering relies on a fast separable Gaussian approximated by variance-matched box blurs, so its cost is independent of the smoothing radius.
Paramètres généraux
These controls sit below the method panels and apply whichever method is selected.
Correction :
Soustraction : ceci est principalement utilisé pour corriger les effets additifs, tels que les gradients causés par la pollution lumineuse ou par la lune.
Division : principalement utilisé pour corriger les phénomènes multiplicatifs tels que le vignettage ou l'absorption atmosphérique différentielle par exemple. Cependant, ce genre d'opération devrait être effectué à l'aide du master-flat.
Compute Background: This will compute the synthetic background and will apply the selected correction. The model is always computed from the original image kept in memory allowing the user to work iteratively. The result is only previewed at this stage; it is committed when you close the dialog with the Apply button.
View: once a background has been computed, this drop-down chooses what is shown in the main view without recomputing anything:
Processed image: the corrected result (the default).
Background model: the background that was removed, reconstructed from the original and the processed image.
Original image: the untouched image kept in memory.
This replaces the former Show original image button and works identically for both methods.
Le gradient du fond de l'image pré-traitée peut être complexe car le gradient peut avoir tourné avec la session d'acquisition. Il peut être difficile de le supprimer complètement car il est difficile de le représenter par une fonction polynomiale. Si c'est le cas, vous pouvez envisager de supprimer le gradient dans les images individuelles : dans une seule image, le gradient de fond est beaucoup plus simple et suit généralement une fonction linéaire simple (degré 1).
Astuce
Il arrive que des bandes de couleur disgracieuses apparaissent après l'extraction du gradient. Dans ce cas, il y a deux choses à vérifier. Tout d'abord, si l'image est en 16 bits, nous vous conseillons vivement de toujours utiliser le format 32 bits. Si, malgré tout, vous observez de tels artefacts, l'option Ajout de diffusion d'erreur (dither), expliquée ci-dessus, est la solution à votre problème.
Lorsqu'un tel effet de bande se produit après l'extraction du gradient, il peut être résolu par l'option Ajout de diffusion d'erreur (dither) (avec l'aimable autorisation de Nathan B.).
Astuce
Pour obtenir de bons résultats avec l'algorithme RBF, il suffit généralement de moins d'échantillons qu'avec l'algorithme polynomial.
Voir aussi
Pour plus d'explications, voir le tutoriel correspondant ici.
Ligne de commande Siril
subsky { -rbf | degree } [-dither] [-samples=20] [-tolerance=1.0] [-smooth=0.5] [-existing] [-random] [-gradient] [-border=<pixels|percent%>]
Astuce
The automatic (sample-free) method is available on the command line with the
-auto argument. In this mode the sample-related options are ignored and
the automatic-model parameters (-scale=, -smoothness=, -noprotect,
-protect_threshold=, -protect_amount=, -simplified, -degree=,
-downsample=) apply instead, together with -mode=subtract|divide for
the correction type. See the subsky reference above for the
full list.
Astuce
The -existing command argument forces use of existing background samples.
This option is primarily for use in conjunction with the Python module where
SirilInterface.set_bgsamples() can be used to set custom background
samples based on user-defined algorithms. If it is not provided, subsky
will automatically regenerate background samples. Note that the -existing
option is not available with the seqsubsky command, because sequence frames
are not necessarly registered at the time background subtraction is carried
out, so the samples for one frame do not necessarily apply to another.
Ligne de commande Siril
seqsubsky sequencename { -rbf | degree } [-nodither] [-samples=20] [-tolerance=1.0] [-smooth=0.5] [-prefix=] [-random] [-gradient] [-border=<pixels|percent%>]
Wright, Grady Barrett. Radial basis function interpolation : numerical and analytical developments. University of Colorado at Boulder, 2003.