Noise reduction

Noise reduction with noise-map driven wavelets, NLM (OpenCV) or BM3D (optional), maskable.

Version
1.0.0
Licence
MIT
Author
Erwan Sturzenegger
astrostack
≥ 0.1.0
Downloads
0
Size
10.6 KB

Description

Reduces image noise with wavelets driven by the local noise map, with NLM (OpenCV) or with BM3D (optional), denoising chrominance harder than luminance, with an optional mask.

What it does

The plugin provides one stage: denoise.

Luminance / chrominance split. On a colour image (3 channels), the stage computes the luminance Y (mean of the channels) and two chrominance components (u = R − Y, v = B − Y). Luminance is denoised at the requested strength; chrominance with a strength multiplied by chroma_strength (1.5 by default), because colour noise (the red, green and blue "confetti" of colour sensors) is more distracting and carries less detail. The R, G, B channels are then rebuilt. With luminance_only: true, chrominance is left untouched. A monochrome image (or one with a different number of channels) is processed channel by channel.

Methods:

  • wavelets (default): "à trous" wavelet transform (B3 starlet), which splits the image into layers detail layers of increasing scale (1, 2, 4, 8… px) plus a residual. Each layer is soft-thresholded: coefficients below k_j × σ are set to zero, the others shrunk by the same amount. The threshold is k on the first layer and then decreases with scale (k / (1 + 0.5 j)), taking into account how noise is distributed across layers. With noise_map: true, σ is not a single value but a local noise map (robust RMS of the first layer, computed by SEP on 64 px cells with stars rejected): the noisy background is smoothed more than areas of strong signal, and a stack whose depth varies across the field (edges, mosaic, field rotation) is treated evenly. strength blends the result, globally or layer by layer.
  • nlm: OpenCV Non-Local Means (fastNlMeansDenoising, image converted to 16 bits, 5 × 5 patches and 13 × 13 search window, L1 norm). Each pixel is replaced by an average of pixels whose neighbourhood looks similar. The strength is h × σ, where σ is the global noise estimated on the first wavelet layer.
  • bm3d: Block-Matching 3D, through the optional Python package bm3d (noise σ multiplied by h). Often the best result on fine textures, but much slower.

When to use it

  • Colour sensors and smart telescopes (Vespera, Seestar): strong colour noise with short exposures; the boosted chrominance setting removes it without smearing the luminance.
  • Light-polluted skies, short total integration: grainy background after stretching. Denoising before the stretch avoids stretching the noise.
  • Uneven stacks (poorly covered edges, alt-az field rotation): the noise map adapts the threshold locally.
  • After deconvolution, to calm the noise it amplified.

When not to use it (or sparingly):

  • on an already very clean image (long integration): the risk is erasing faint detail and getting a "plastic" look;
  • at full strength on stars and fine structures: use a mask to spare signal areas.

Recommended order: preferably on the linear image, after crop, background/gradient and deconv, before stretch. A light pass after stretching, restricted to the background with a luminance mask, is also possible.

Installation

astrostack plugin install denoise

or from the Plugins view of the CelestiaX application, then add the "Denoise" step (Details group) to the recipe.

Python dependencies: none required (python_deps is empty); NumPy, OpenCV and SEP are provided by astrostack.

Optional dependency, only for method: bm3d:

pip install bm3d

Without this package, the wavelets and nlm methods work normally; bm3d stops with the message "denoise : method bm3d nécessite le paquet bm3d (pip install bm3d)".

Parameters

Stage denoise

Parameter Type Default Description
method choice wavelets Method: wavelets, nlm or bm3d.
layers int 4 Wavelets: number of layers (1 to 7). More layers = large-scale noise (blotches) is also treated.
k float 3.0 Wavelets: threshold in σ on the 1st layer, decreasing afterwards (0.5 to 10).
strength float 1.0 Strength 0–1; in YAML a list is allowed (one value per layer, the last one is repeated).
h float 1.0 NLM / BM3D: strength relative to the noise (0.1 to 5).
noise_map bool true Wavelets: thresholds adapted to local noise (otherwise global σ).
luminance_only bool false Denoise only the luminance (colour image).
chroma_strength float 1.5 Strength multiplier for chrominance (0 to 4): multiplies k (wavelets) or h (NLM / BM3D).
mask text empty Optional post-processing mask (see below).

The mask parameter. Restricts denoising to an area: the mask is computed on the image before the stage, then result = before × (1 − m) + after × m. Examples: mask: {type: luminance, low: 0.1, high: 0.4, invert: true} (denoise mostly the dark background), mask: "stars invert" (spare the stars), mask: "object invert feather=8" (sky background only). Types: luminance, color, stars, object, range, file, combine; common options invert, blur (σ in px), strength (0–1).

YAML examples

Standard settings on the linear image:

pipeline:
  - crop: {}
  - gradient: {}
  - deconv: {}
  - denoise: {method: wavelets, layers: 4, k: 3.0, chroma_strength: 1.5}
  - color: {method: stars}
  - stretch: {method: auto}

Per-layer strength (fine noise strongly reduced, large scales preserved), background only:

pipeline:
  - denoise:
      method: wavelets
      layers: 5
      strength: [1.0, 0.8, 0.5, 0.3, 0.1]
      mask: {type: luminance, low: 0.1, high: 0.4, invert: true}
  - stretch: {method: auto}

BM3D (bm3d package installed), after stretching, stars spared:

pipeline:
  - stretch: {method: auto}
  - denoise: {method: bm3d, h: 0.8, mask: "stars invert"}

Outputs

  • The current image is replaced by the denoised image (float32); out-of-field pixels (NaN) are kept.
  • No file is written; console message "Débruitage terminé".

Limitations

  • Any denoising also removes some signal: the faintest nebulosity and small stars can fade if k or h is too high.
  • Wavelets: a high k with many layers can leave a "mottled" background; lower k or the strength of the large layers.
  • NLM works in 16 bits over a range limited by the 0.01 % – 99.99 % percentiles; its noise estimate is global (no local map).
  • BM3D is slow on large images and relies on an external package with a restrictive licence (see below).

Licences

  • Plugin: MIT licence, © Erwan Sturzenegger.
  • Dependencies installed with astrostack: NumPy and SciPy (BSD), OpenCV (Apache 2.0), SEP (LGPL v3 for code derived from SExtractor, BSD/MIT for the rest).
  • bm3d (optional, PyPI): distributed under its authors' own licence which, to our knowledge, restricts use to non-commercial purposes (research, evaluation, personal use). Check the package licence (pip show bm3d and the licence file it ships) before any use, especially commercial. The plugin does not bundle it and never installs it automatically.

Steps provided

This plugin adds one step to the pipeline.

StepTypeRole
denoise DenoisePost-processingWavelets driven by the noise map, NLM or BM3D.
  • Post-processing On the stacked image, replayable in the live preview.

Dependencies

No dependency beyond CelestiaX: the plugin works as soon as it is installed.

Versions

  1. 1.0.0 current

    Initial release (extracted from the astrostack core)