Description
Two detail-enhancement tools: a multi-scale HDR compression of bright areas (hdr) and local sharpening of the luminance (sharpen, CLAHE or unsharp mask), with the sky background protected and colours preserved.
What it does
The plugin provides two stages: hdr and sharpen.
hdr — multi-scale compression of bright areas
Some objects have a huge dynamic range: the core of M42, the bulge of a galaxy or a globular cluster are "burnt out" as soon as you stretch enough to reveal the faint outer parts. The hdr stage:
- computes the luminance (mean of the channels) and moves to the logarithmic domain;
- separates a large-scale background (blur at a scale of 2^
layerspx, Gaussian, or guided filter ifedge_aware) from the details (everything else); - compresses only the background above a threshold (
threshold× background maximum) with a slope of 1 −amount, through a soft knee (softplus function) to avoid any break; the details are added back untouched; - applies the new / old luminance ratio to all three channels: colours are preserved;
rescaleoption: linearly stretches the values above the threshold to bring the maximum (99.99th percentile) back to its original level, without touching the background.
Result: the bright core becomes readable again (structures visible) while faint areas do not move. In the application's reduced preview, layers is adapted to the scale automatically.
sharpen — local sharpening
Works on the luminance (Rec. 709 weighting) of a stretched image (values brought into 0–1), then replaces the luminance while keeping the R:G:B ratios.
unsharp(default): unsharp mask. Details (luminance − Gaussian blur ofsigmapx) are added, multiplied byamount. A weight protects the background: it is 0 below thethreshold(by default median + 3 × MAD of the background, computed automatically) and rises gradually to 1 above it, so sky noise is not enhanced.clahe: CLAHE (contrast-limited adaptive histogram equalisation, OpenCV) on a grid oftile×tiletiles, limited byclip_limit, then blended with the original according toamount. Increases the local contrast of nebulae (medium-scale structures) rather than fine sharpness.
When to use it
hdr: M42, M31, M8, globular clusters, galaxy cores, and more generally any object whose centre saturates after stretching. Especially useful on smart-telescope images (Vespera, Seestar) of M42, where the Trapezium vanishes into white.sharpenwithunsharp: bring out a galaxy's arms or a nebula's filaments after stretching; smallsigma(1–2 px) for fine detail, larger for structures.sharpenwithclahe: extended, low-contrast nebulae (emission or dark nebulae).
When not to use them:
hdron an object without a bright area (star field, faint nebula): no useful effect;sharpenon a linear (unstretched) image: the stage works in 0–1 and assumes a stretched image;sharpenon a still noisy image: denoise first (plugin "denoise"), otherwise noise in signal areas will be enhanced too;- high strengths: dark halos around stars and sharp edges (unsharp mask), artificial look (CLAHE).
Recommended order: hdr after a first stretch (when the core looks burnt out), possibly followed by a second light stretch; sharpen near the end of the chain, after stretch and denoise, before saturation and export.
Installation
astrostack plugin install details
or from the Plugins view of the CelestiaX application, then add "Multi-scale HDR" (Tones group) or "Local sharpening" (Details group) to the recipe.
Python dependencies: none beyond the core (python_deps is empty); NumPy and OpenCV are provided by astrostack.
Optional: hdr with edge_aware: true uses OpenCV's guided filter (cv2.ximgproc), which is only available in the "contrib" modules (package opencv-contrib-python-headless, which then replaces opencv-python-headless). Without these modules, the stage silently falls back to a Gaussian blur.
Parameters
Stage hdr
| Parameter | Type | Default | Description |
|---|---|---|---|
layers |
int | 5 |
Scale of the compressed background: 2^layers px (2 to 9). Larger = more global compression. |
amount |
float | 0.7 |
Compression strength (0–1). |
threshold |
float | 0.3 |
Brightness (fraction of the maximum) above which compression starts (0.01 to 1). |
edge_aware |
bool | false |
Guided filter: fewer halos at sharp edges (requires OpenCV contrib). |
rescale |
bool | false |
Bring the maximum back to its original level. |
mask |
text | empty | Optional post-processing mask (see below). |
Stage sharpen
| Parameter | Type | Default | Description |
|---|---|---|---|
method |
choice | unsharp |
clahe: local contrast; unsharp: detail enhancement. |
amount |
float | 0.7 |
Strength (blend for clahe, detail gain for unsharp), 0 to 3. |
clip_limit |
float | 2.0 |
CLAHE contrast limit (0.5 to 10). |
tile |
int | 8 |
Number of CLAHE tiles per side (2 to 32). |
sigma |
float | 2.0 |
Detail scale for unsharp, in px (0.3 to 20). |
threshold |
float | empty | Luminance below which the background is protected (unsharp), 0 to 1; empty = automatic (optional). |
mask |
text | empty | Optional post-processing mask (see below). |
The mask parameter. Both stages accept astrostack's post-processing masks. The mask is computed on the image before the stage, then result = before × (1 − m) + after × m. Short form: mask: "stars invert" (do not sharpen stars), mask: "object feather=8" (limit to the nebula or galaxy); dictionary form: mask: {type: luminance, low: 0.1, high: 0.4}. Types: luminance, color, stars, object, range, file, combine; common options invert, blur (σ in px), strength (0–1).
YAML examples
M42: core compressed after stretching, then sharpening:
pipeline:
- gradient: {}
- color: {method: stars}
- stretch: {method: auto, target_background: 0.2}
- hdr: {layers: 5, amount: 0.7, threshold: 0.3, rescale: true}
- sharpen: {method: unsharp, amount: 0.5, sigma: 1.5, mask: "stars invert"}
- export: {formats: [tiff16, png]}
Galaxy: sharpening limited to the object, stars untouched:
pipeline:
- denoise: {}
- stretch: {method: ghs}
- sharpen:
amount: 0.8
sigma: 2.0
mask: {type: combine, op: min, masks: [{type: object, feather: 8}, {type: stars, invert: true}]}
Extended nebula: CLAHE local contrast, reduced effect:
pipeline:
- stretch: {method: auto}
- sharpen: {method: clahe, clip_limit: 2.0, tile: 8, amount: 0.4}
Outputs
hdr: the current image is replaced (float32, same scale as the input); console message with the strength and threshold.sharpen: the current image is replaced by an image in 0–1 (float32).- Out-of-field pixels (NaN) are kept by both stages. No file is written.
Limitations
hdracts on luminance only: an area saturated in a single channel (burnt-out coloured star) does not recover its colour.hdrwithoutedge_awarecan produce a slight dark halo around a very contrasted core;edge_aware(guided filter) reduces it.sharpenbrings the image into 0–1: values above are clipped (without hue change).claheworks in 16 bits and can enhance background noise: use a moderateamountor a mask.
Licences
- Plugin: MIT licence, © Erwan Sturzenegger.
- Dependencies (installed with astrostack): NumPy (BSD), OpenCV (Apache 2.0), including the optional contrib modules (Apache 2.0).
Steps provided
This plugin adds 2 steps to the pipeline.
| Step | Type | Role |
|---|---|---|
hdr Multiscale HDR | Post-processing | Compresses bright areas (M42 core, galaxies) without losing detail. |
sharpen Local sharpening | Post-processing | CLAHE or unsharp mask on luminance, background protected. |
- 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.0.0 current
Initial release (extracted from the astrostack core)