Block
Stacking
- What it does
- It adds up the aligned frames of the night into one image, each frame counting by its quality, and leaves out satellite trails, planes and cosmic rays.
- What it shows
- In Inspect, the stack, its two half-stacks and the weight of every frame, with the frames stacked, the stacked exposure and the share of rejected pixels; in the Report, the stacking figures and the colour offset corrected.
- What can be set
- The Stacking method and the Drizzle scale, which FLOAT proposes with their reason, and the Rejection threshold (3 σ); the proposed values suit most nights.
The Stacking block combines the registered frames of a session into one image. It offers two methods: a Bayer drizzle, which drops every raw colour pixel at its registered position without debayering or interpolation, and a Classic stack, which debayers and interpolates each frame first. FLOAT measures the frames and proposes the method, the drizzle scale and the drop size, each with the reason for the choice; every value can still be set by hand.
- Calibration
- Registration
- Selection
- Stacking
- Astrometry
- Gradient
1What goes in, what comes out
The block receives the calibrated frames, the registration of each one (a cubic polynomial that maps its sensor pixels onto the reference frame), the size of its stars, and the weight the Selection block gave it.
It writes the stack, two half-stacks made of separate frames, the coverage map of each colour, and for every frame its weight or the reason it was left out. Inspect shows all of them.
2Bayer drizzle
A colour sensor records one colour per pixel: in each cell of 2 × 2 pixels, one red, two green, one blue. Debayering fills in the two missing colours of every pixel by interpolation. The Bayer drizzle skips that step. Each raw sample is dropped onto the output grid where the registration of its frame puts it, as a small square, and only into its own colour. The value of an output pixel is the weighted mean of the drops that touch it.[1]
The method depends on the frames being shifted against each other. Red and blue each hold a quarter of the samples: one frame alone leaves three output pixels in four empty in those colours. The shifts between frames, from dithering or from the drift of the mount, are what fills the grid.
The red and blue images of the stars are registered on the green one for the whole night, against lateral chromatic aberration and atmospheric dispersion. The offset of each colour is a quadratic surface over the field, fitted on the isolated, unsaturated stars of the first mean (at least 50, well above the noise and under half the saturation); the red and blue samples are then dropped where the green ones of the same star fall. The offsets at the centre and in the corners are given in the log and in the Report.
- Coverage variation (standard deviation / median)
- Output pixels left empty
3Scale and drop size
Before it stacks, FLOAT computes the map of figure 1 from the real registration of the frames the selection keeps, on a grid of small patches of the field. It then applies the rule of the DrizzlePac Handbook: the standard deviation of the weight map must stay under 20 % of its median. The variation is measured for each colour; red and blue decide.
- A scale of 1.5 or 2 is proposed only if the stars are undersampled (a width under 2 pixels) and the rule holds at that scale. Drizzle restores detail only in that case.[1]
- The drop size is then the smallest value, in steps of 0.05 from 1 / scale upwards, that keeps the rule.
- At scale 1, the drop size is 1.
The estimate takes about 0.5 s for 100 frames and 1.5 s for 300, on one processor core. After the stack, the same statistic is measured on the weight map actually obtained.
| Series | Proposed | Why |
|---|---|---|
| Colour sensor, fewer than 15 frames | Classic | Too few frames for the red and blue samples to cover the grid. |
| Colour sensor, red or blue coverage varying by 20 % or more at 1× | Classic | The 20 % rule does not hold.[2] |
| Colour sensor, enough well-shifted frames | Bayer drizzle, at the scale the rule gives | The rule holds. |
| Colour sensor, stars under 2 px, coverage holding at 1.5× or 2× | Bayer drizzle at 1.5× or 2× | Undersampled stars: the finer grid restores detail.[1] |
| Monochrome sensor | Classic; drizzle only with stars under 2 px, 15 frames and the coverage holding at 1.5× or 2× | No colour mosaic: drizzle only adds detail when the stars are undersampled. |
| Frames already in colour (JPEG, PNG, TIFF) | Classic | No mosaic of raw samples to drop. |
Figure 2 shows the weight map obtained on a real night: with stars of 2.1 px the scale stayed at 1, and the coverage of each colour varies by 1.5 to 3.1 %, far under the 20 % of the rule.
4Outlier rejection
Satellites, planes, cosmic rays and hot pixels are left out sample by sample. The Bayer drizzle has three ways of finding them.
On the raw pixels
A sigma clipping against the spread measured at each output point. A first pass keeps the weighted mean and standard deviation of the samples dropped there; a second leaves out the samples farther than the threshold (3 standard deviations) and measures both again; a third judges every sample against these values and deposits the ones kept. There is no noise model: the spread is the one the frames show at that point. This follows the principle of Siril’s sigma clipping, with the weighted mean as centre.[3]
Figure 3 shows what this rejection took from each frame of a long series: a few hundredths of a percent of the samples, most of them above the mean, with a few frames standing out.
By frame count
With N values, one outlier can reach at most (N − 1) / √N standard deviations: under 3 below 11 values. In a Bayer drizzle, red and blue hold about a quarter of the frames at a point, so a sigma clipping at 3 can run short of values. The values of every frame are then kept for each output point, and the rejection is chosen by their number: percentile clipping, winsorized sigma clipping, or linear fit clipping. FLOAT proposes this way when the colours hold too few values per point.
From the Classic stack’s rejection
The rejection of the Classic method runs on the debayered, registered frames, and what it rejects in a frame is left out of that frame’s drops on the same output pixels.
5Two half-stacks
The frames are dealt alternately, in blocks of 20, to two half-stacks A and B built the same way. Both show the same sky; the noise of their frames is independent. Their difference gives the noise of the stack: with equal weights, the noise of the stack is half the standard deviation of A − B (in general, that deviation times √(wA wB) / (wA + wB), w being the sum of the frame weights of each half). The Denoise block uses them as a pair: a network that predicts one half from the other keeps only what both contain.[5]
6The Classic method
Each frame is debayered with RCD,[6] the colours balanced before and the balance taken off after, as raw converters do. It is resampled onto the reference grid with Lanczos-4, clamped to hold back the dark rings Lanczos-4 draws around bright stars. The frames are then combined with a rejection chosen by their number: percentile clipping under 6 frames, winsorized sigma clipping from 6 to 15, linear fit clipping from 16. The combination itself can be chosen: the weighted mean of what the rejection keeps (the default), the median, the maximum (star trails, meteors and satellites are kept), the minimum, or the sum. The four last reject nothing and give every frame the same weight.
7Settings
| Setting | Value | Range | What it does |
|---|---|---|---|
| Stacking method | automatic | Bayer drizzle, Classic | Classic suits few or barely shifted frames, whose red and blue pixels leave holes in a drizzle. |
| Drizzle scale | automatic | 1 – 3 × | Output resolution relative to the sensor. Higher values cost memory and add noise. |
| Drop size | automatic | 0.3 – 1 | Size of the deposited drop relative to the input pixel. Smaller drops are sharper but noisier, with a risk of holes. |
| Rejection (drizzle) | automatic | On the raw pixels, By frame count, From the classic stack’s rejection | How outliers are found (section 4). |
| Rejection threshold | 3 σ | 2 – 20 | Higher keeps more samples; lower removes more trails but may eat star cores in poor seeing. |
| Half-stack block | 20 frames | 1 – 200 | The size of the blocks of frames dealt in turn to the half-stacks A and B. |
| Combination (Classic) | mean | mean, median, maximum, minimum, sum | With the Classic method: how the values of the frames at each pixel make the stack. |
| Pattern removal | off | on, off | Measures the sensor’s fixed pattern and subtracts it from every frame (section 8). |
8Limits, and what was tried
- Pattern removal is off by default. It measures the fixed pattern of the sensor as the median of the frames in sensor coordinates, and subtracts it, against the streaks known as walking noise. On some stacks the estimate also held the tracks of the faint stars across the sensor, and subtracting it drew the very streaks it was meant to remove.
- No Bayer drizzle for frames already in colour. A JPEG, PNG or TIFF frame has no mosaic of raw samples to drop: the Classic method is used (issue 57).
- Few frames at a point, no rejection. Where fewer than three frames cover a point, at the edges of the field, nothing is rejected.
References
- Fruchter, A. S. & Hook, R. N. 2002, Drizzle: A Method for the Linear Reconstruction of Undersampled Images, PASP 114, 144. arXiv:astro-ph/9808087
- The DrizzlePac Handbook, version 3, Space Telescope Science Institute, §7.3 “Inspecting Drizzled Products after User Reprocessing”. hst-docs.stsci.edu/drizzpac
- Siril documentation, Stacking, “Rejection algorithms”. siril.readthedocs.io
- Samuelson, P. A. 1968, How Deviant Can You Be?, JASA 63, 1522. doi:10.1080/01621459.1968.10480944
- Lehtinen, J. et al. 2018, Noise2Noise: Learning Image Restoration without Clean Data, ICML. arXiv:1803.04189
- Sanz Rodríguez, L., Ratio Corrected Demosaicing (RCD), release 2.3. github.com/LuisSR/RCD-Demosaicing