Cosmic Clarity

The complete in-house AI processing suite for SASpro. Four modes in one dialog — stellar aberration correction, stellar and non-stellar sharpening, luminance and color denoise, and super-resolution upscaling — all powered by SetiAstro's own trained neural network models. Add in sister tool Satellite Removal for frame-by-frame trail cleanup, and you have a full AI pipeline that runs entirely locally on your machine, with no cloud, no subscription, no licensing phone-home. Supports GPU acceleration across Windows (CUDA/DirectML), macOS (CPU and MPS where available), and Linux (CUDA); gracefully falls back to CPU when the GPU path breaks. Includes mask-aware blending, new-view output, preset drag-and-drop, and automatic chunk/overlap tiling for images of any size.
SetiAstro Cosmic Clarity — original neural network models by Franklin Marek (setiastro.com). Every network in this dialog — the stellar aberration correction (V1 and V2), the stellar sharpening model, the non-stellar sharpening model, the standard denoise, the Lite denoise, the Walking Noise specialist, the super-resolution upscaler, and the satellite-trail segmenter — was architected, trained, and optimized in-house by SetiAstro, on datasets curated from real deep-sky integration data. The weights ship with SASpro; nothing talks to a remote server at inference time.

1. The four modes

The Mode dropdown selects the pipeline for this run:

The dialog's left column holds the Sharpen and Denoise groups; the right column holds Super Resolution and Advanced (chunk, overlap, temporary-stretch assist). Only the controls relevant to the current Mode are visible; the others are hidden to keep the dialog compact.

2. Sharpen mode

The Sharpen group bundles two independent capabilities — stellar aberration correction and sharpening itself — behind a single Execute. The Stellar Correction radio row at the top of the group decides which:

V1 vs V2 correction model. The Correction Model dropdown appears when a correction option is selected. V2 is the latest-generation model with updated weights and improved correction quality — it's the default when installed. V1 is the original release, kept available because some users prefer its slightly milder behavior on already-good data. V2 is marked disabled in the dropdown if its weights aren't installed; use Preferences → AI Models → Download/Update to pull it. The Conservative White Compression checkbox below applies to correction only — it reduces tiling seams on images with extreme contrast within a single tile (bright core + black background) by compressing white points more aggressively before inference.

Once correction is handled (or skipped), the sharpening controls take over:

3. Denoise mode

The Denoise group has three distinct model options behind a single dropdown:

Independent of model choice, three sliders tune the output:

Denoise RGB channels separately runs the mono denoise model on each of R, G, B independently. When this is enabled, Color Denoise and the full/luminance mode selector are disabled — the mono model has no concept of chroma, so those controls would do nothing. The tooltip on the greyed-out controls explains why.

GPU Compatibility Mode. The checkbox at the bottom of the Denoise group forces conservative GPU inference: batch size 1, no tensor-cores, no half-precision autocast. Significantly slower, but survives on older GPUs, GPUs with low VRAM, and the handful of Windows laptops where the normal path crashes with cryptic kernel errors. Enable this if sharpen or denoise fails, hangs, or produces visibly corrupted output on your hardware. Compatibility Mode applies to all AI stages in this dialog, not just denoise.

4. Super Resolution mode

Super Resolution upscales the image by 2×, 3×, or 4× using a learned prior. The output size is exactly the input size multiplied by the scale:

\mathrm{out} \in \mathbb{R}^{(s H) \times (s W) \times C}

Unlike interpolation (bilinear, bicubic, Lanczos), the model invents plausible high-frequency detail based on patterns it learned during training. On stars this produces tight, round cores at the new resolution. On extended structure (nebulosity, galaxy arms, dust lanes) it produces plausible texture that reads correctly at the new scale but is not literally what a longer-focal-length scope would have captured. Use with the understanding that this is upscaling with invention, not resolution recovery — it's for printing larger, for cropping into small objects, and for making web-sized versions of large captures look pin-sharp.

GPU is used unconditionally for Super Resolution (the models are heavy enough that CPU inference would be prohibitively slow); the GPU dropdown is hidden when this mode is selected. The sharpen and denoise sub-controls are also hidden — super-resolution runs in isolation.

5. Tile chunk, overlap, and temporary stretch

All AI networks process images in tiles rather than all at once (memory, mostly, and because the training patch size doesn't match arbitrary image sizes). The Advanced group exposes the two knobs that control tiling behavior:

Temporary Stretch for AI (linear assist) is the second major Advanced control. All of these networks were trained on data that's already been visually stretched — because that's what humans look at. If you hand the model raw linear integration data (median pixel value ~0.001, nothing above 0.05) it has nothing to work with and the output looks almost identical to the input. The temporary stretch applies an MTF stretch to the image before inference, runs the network, then reverses the stretch on the output so the result lands in your original linear space.

The Target Median slider (0.01-0.50) sets what median value the stretched image should land at. 0.25 is a good default for most data. If your linear data is already somewhat stretched (bright nebulosity, little background), use a smaller target like 0.15; for very dim linear data (narrowband, short-exposure LRGB), 0.30 may give the model more to work with. The relationship between the median after stretch and the MTF stretch parameter m is:

M(x) = \frac{(m - 1) \cdot x}{(2m - 1) \cdot x - m}

where M is the stretch function, x is the input value, and m is solved to make M(median) = T. The reverse applies M⁻¹ with the same m.

6. GPU use and provider fallback

The Use GPU dropdown is a simple Yes/No. "Yes" means SASpro picks the best available GPU backend (CUDA on NVIDIA, DirectML on any Windows DX12 GPU including Intel/AMD, MPS on Apple Silicon where available, otherwise CPU). "No" forces CPU for the whole run — useful when the GPU is busy with something else or when you want deterministic output for comparing results across machines.

If GPU inference fails mid-run with a recognizable hardware error (kernel mismatch, missing library, CUDA driver mismatch), SASpro catches the exception and reports it with the exact underlying message — not a generic "please install drivers" dialog. This matters because the real error is often "torch and torchvision built against different releases" (which surfaces as operator torchvision::nms does not exist) or "the installed torch expects a HIP/CUDA library the driver doesn't actually support" (which surfaces as an undefined-symbol or load failure). Those are searchable strings; a generic message is not.

7. Mask-aware application and output targets

If the active document has a mask active when you Execute, SASpro blends the AI output with the original using the mask as alpha:

\mathrm{out} = m \cdot \mathrm{processed} + (1 - m) \cdot \mathrm{src}

Mask values are normalized to [0, 1] regardless of their stored dtype (uint8, uint16, float32). White areas get full AI effect; black areas keep their original pixels; grays blend smoothly. Mask size is reconciled to the output size by nearest-neighbor subsampling if different (relevant when super-resolution is active — the mask gets upsampled to the output's larger dimensions). If the mask is identically zero everywhere, the blend is skipped and the original is returned unchanged (prevents a blank mask from silently discarding the processing).

The Apply to dropdown picks the output target:

The mono preservation behavior deserves a note: Cosmic Clarity's networks are RGB-only (they expect 3-channel input). If the active image is mono, SASpro expands it to RGB before inference and collapses the output back to a single channel at the end (by averaging the three channels, which are near-identical for mono input). Your mono image stays mono.

8. Clear AI Cache

The Clear AI Cache button in the bottom-left of the dialog flushes the model weights SASpro has loaded into RAM/VRAM during the current session. The next AI run will take longer because models must reload from disk, but you free up (sometimes substantial) memory. Use when:

The button is disabled during an active run to prevent clearing cache while a model is in use.

9. Preset drag and Replay Last

The grip handle at the bottom-left of the dialog captures the current UI state as a preset. Drag it onto the SASpro canvas to create a shortcut button for one-click reuse. Drop it directly onto an image to apply the current settings headlessly — no dialog, no further clicks. The preset captures every control: mode, GPU setting, sharpening amounts, denoise strengths, model variants, chunk size, overlap percentage, temporary stretch settings, super-resolution scale, mask application, and target (overwrite vs new view).

SASpro also registers each run as the "Replay Last Action" command, so your bound shortcut (default varies by platform) re-runs Cosmic Clarity with your most recent settings against the current view.

10. Sister dialog — Satellite Removal

The Cosmic Clarity Satellite dialog is a separate tool with its own icon and menu entry, built for batch processing frame-by-frame satellite trail removal from individual subs before stacking. Key features:

The Satellite dialog has its own ❔ button and its own doc entry; this doc covers the main Sharpen/Denoise/Super Resolution dialog.

11. Workflow recipes

First-light AI pass on a stacked integration. Open your master stack. Open Cosmic Clarity. Mode = Both. Stellar Correction = Correct + Sharpen (V2). Stellar Amount 0.5, Non-Stellar Amount 0.3. Denoise Luma 0.4, Color 0.5, Mode = full. Temp Stretch on, Target Median 0.25. Execute. One-click AI cleanup of a linear stack.
Fix soft stars without touching nebulosity. Mode = Sharpen. Stellar Correction = Sharpen Only (skip correction). Sharpening Mode = Stellar Only. Stellar Amount 0.6. Non-stellar controls hide automatically. Execute. Only star cores change; the galaxy or nebula underneath is untouched.
Fix elongated stars from a tilt or collimation issue. Mode = Sharpen. Stellar Correction = Correct Only (no sharpening pre-pass). Correction Model = V2. Execute. Stars snap into round. Then run a second pass with Sharpen Only if you want deconvolution lift on top.
Walking-noise cleanup on untracked data. Mode = Denoise. Denoise Model = Walking Noise. Luminance 0.6, Color 0.4, Mode = luminance (preserves chroma on the drift streaks). Execute. The diagonal striping is cut without flattening real nebula structure.
Super-res a crop for printing. Crop your image to the object of interest at native resolution. Open Cosmic Clarity. Mode = Super Resolution. Scale = 2x (3x and 4x work but take proportionally longer and invent more). Target = Create new view (keep the native-resolution original intact for reference). Execute. Compare the two side by side; use the super-res version for the print.
Difficult color data (nebulae with narrowband mapping). Mode = Sharpen. Correct + Sharpen (V2). Enable "Sharpen RGB channels separately" so each channel gets its own mono-model pass. Longer run, but channels that need different treatment (e.g., SII with low SNR vs Hα with strong signal) get appropriate individual sharpening.
Localized correction with a mask. Paint or generate a mask that's white only on the corners (a radial gradient inverted). Enable the mask on the document. Open Cosmic Clarity. Correct Only. Execute. Only the corner stars get touched by the correction model; the center of the frame — where stars were already clean — stays untouched.
Troubleshooting pass on a difficult GPU. First run failed with a kernel error. Enable GPU Compatibility Mode. Execute again. The slower, safer path usually survives — batch size drops to 1, half-precision autocast is off, tensor-cores are bypassed. If it still fails, switch GPU dropdown to No and re-run on CPU; the error dialog will show the underlying issue so you can fix the environment.

12. Credits

Models and training. Franklin Marek, SetiAstro — all neural network architectures, training pipelines, datasets, and weights for stellar aberration correction (V1, V2), stellar sharpening, non-stellar sharpening, standard denoise (deep_denoise_mono_AI4, deep_denoise_color_AI4), Lite denoise, Walking Noise denoise (deep_denoise_*_AI4.1w), super-resolution, and satellite segmentation (satelliteRemovalAI4). All models are developed and trained in-house at SetiAstro; the suite is marketed as SetiAstro Cosmic Clarity and distributed as part of SetiAstro Suite Pro.

SASpro integration. Dialog UI, preset system, mask blending, mono-preservation, undo-aware history, Hann-blended tiled inference wrappers, GPU provider selection with fallback, temporary-stretch linear assist, Compatibility Mode plumbing, Satellite Removal batch/live-monitor engine, and cache management — all Franklin Marek as part of SetiAstro Suite Pro.

Techniques. Tiled inference with Hann-windowed overlap-add synthesis is standard practice for processing large images with fixed-input-size networks. MTF (midtone transfer function) stretch for the temporary-stretch assist follows the PixInsight-style formulation with boundary conditions M(0)=0, M(m)=0.5, M(1)=1. Mask blending uses standard alpha composition.

Runtime. PyTorch (pytorch.org) for all neural network inference; the GPU acceleration path selects CUDA (NVIDIA) or DirectML / MPS as available on the host system, with transparent CPU fallback.

Technical details

13.1. Mode pipeline composition

Each mode is a stage sequence. "Both" chains Sharpen then Denoise with equal progress weighting; "Sharpen", "Denoise", and "Super Resolution" are single-stage. Progress is reported as:

\mathrm{frac} = (\mathrm{stage}\_i + \mathrm{sub}\_\mathrm{frac}) / N_{\mathrm{stages}}

where stage_i is the current stage index, sub_frac is the current stage's own 0-1 progress, and N_stages is the total count. The wait dialog's bar updates smoothly across the entire run even when it crosses stage boundaries.

13.2. Tiled inference with Hann overlap-add

All networks process the image in overlapping tiles blended with a 2D Hann window:

w(n) = 0.5 \cdot (1 - \cos(2\pi n / (N - 1)))
w_{2D}(i,j) = w(i) \cdot w(j)

Tile positions along each image axis start at 0 and advance by stride = chunk − overlap pixels:

\mathrm{stride} = C - O_{\mathrm{px}}

with the final tile anchored at N - C so the last tile always ends at the image edge. The output is reconstructed as the pixelwise weighted mean:

\mathrm{out}[i,j] = \frac{\sum_k \mathrm{tile}_k[i,j] \cdot w_{2D}[i_k,j_k]}{\sum_k w_{2D}[i_k,j_k]}

Hann windows sum to a near-constant across the overlap region, so this is a true overlap-add synthesis — no seams, no hot spots, no edge dimming. Weight values that happen to be zero (shouldn't occur with Hann + non-zero overlap, but defensively) are replaced with 1 before the divide.

13.3. Overlap percentage and cap

The UI stores overlap as a percentage of chunk size for scale-invariance (so changing chunk size doesn't invisibly change the effective overlap). The pixel count is computed per run:

O_{\mathrm{px}} = \min(C/2,\; \lfloor C \cdot \mathrm{pct}/100 \rfloor)

The C/2 cap exists because overlap above 50% would mean adjacent tiles overlap by more than half their area — the number of tiles explodes and the Hann windows produce diminishing returns in seam suppression. Pre-cap percentages up to 50% are allowed; higher values clamp silently. A legacy pixel-count setting from older SASpro versions is auto-migrated to a percentage at first load.

13.4. Temporary MTF stretch

The networks were trained on visually-stretched data. The temporary-stretch option applies a PixInsight-style midtone transfer function:

M(x) = \frac{(m - 1) \cdot x}{(2m - 1) \cdot x - m}

with boundary conditions M(0)=0, M(m)=0.5, M(1)=1. Given a target median T (the Target Median slider value), the midtone parameter m is solved to satisfy:

m = \mathrm{solve}\{M(\mathrm{median}(x)) = T\}

M is applied to the input, the network runs, and the output is unstretched with M⁻¹ using the same m. The round-trip is numerically stable as long as the input median is above zero (which real integration data always is).

13.5. Sharpening blend

Both stellar and non-stellar sharpening use a linear blend between the network output and the input, controlled by the Amount slider:

\mathrm{out} = (1 - a_s) \cdot \mathrm{src} + a_s \cdot \mathrm{sharpen}(\mathrm{src})

At a=0 the input is unchanged (the model still runs, but its output is discarded). At a=1 you get the full model output. The linear interpolation is pixelwise, so you can also mask the result after the fact if the global amount isn't quite right in some regions.

13.6. Mask-aware blending

When a mask is active, the pixelwise alpha composition:

\mathrm{out} = m \cdot \mathrm{processed} + (1 - m) \cdot \mathrm{src}

runs after all stages (including super-resolution). Mask values are normalized to [0, 1]: uint masks divide by np.iinfo(dtype).max, floats above 1 divide by their max, zero-valued masks skip the blend entirely to prevent silent discard. The mask is resampled to the output size via nearest-neighbor index arrays when sizes differ (relevant for super-resolution, where the output is 2-4× the mask dimensions). A final np.isfinite check guards against NaN propagation; a non-finite result causes the processed-only output to be returned instead.

13.7. Mono preservation

Cosmic Clarity's networks are RGB-only — they expect (H, W, 3) float32 input in [0, 1]. If the active image is mono (shape (H, W) or (H, W, 1)):

  1. The input is expanded to 3-channel by repeating the single channel.
  2. The network processes it as RGB.
  3. The output is collapsed back to mono by averaging the three channels (which are near-identical for mono input but may differ slightly due to network stochasticity).

The _orig_was_mono flag records the input state at Execute time so the result handler can collapse correctly, even if the user changes the active view mid-run.

13.8. Compatibility Mode plumbing

GPU Compatibility Mode sets three downstream flags on the engine presets:

The cost is substantial — Compatibility Mode runs can be 3-10× slower than normal — but the safety is real: this is the path that survives on older GPUs, low-VRAM GPUs, and some problematic Windows laptops where the normal path fails cryptically.

13.9. Settings persistence

Every control's value is saved to QSettings on change (under the cc/ prefix) and restored on dialog open. The load path blocks signals on every widget during setValue/setChecked to prevent a save-during-load cascade — otherwise the first widget would fire its save, which would overwrite the just-loaded values of all later widgets. Chunk size and overlap percentage have their own key pair (cc/chunk_size, cc/overlap_pct) with legacy-pixel-overlap migration on first load from older versions. Dialog geometry is saved to cc/dialog_geometry and restored on open, with a deferred resize via QTimer.singleShot(0, ...) so the restore wins over the layout engine's own sizing pass.

13.10. Satellite removal mechanics (summary)

The satellite segmenter is a separate network from the sharpen/denoise models. Its output is a trail mask; the dialog's Sensitivity slider sets the threshold below which mask values are treated as background:

\mathrm{dst}[\mathrm{mask} < s] = 0

Lower sensitivity = more aggressive segmentation (catches dim trails but may false-positive on bright stars). Default 0.10. "Clip Trail to 0.000" replaces segmented trail pixels with pure black (otherwise the AI-interpolated replacement is used, which gives smoother blending into the surrounding sky). The batch and live-monitor paths run through a dedicated QThread (SatelliteEngineThread) that loads models once and processes files one at a time, emitting per-file progress to the wait dialog.

13.11. Super-resolution output shape

For scale factor s and input shape (H, W, C):

\mathrm{out} \in \mathbb{R}^{(s H) \times (s W) \times C}

The channel count is preserved (RGB stays RGB; mono — after the usual expand/collapse round-trip — stays mono). Memory footprint scales as s² for the output buffer; a 4× pass on a 6000×4000 input needs ~1.1 GB just for the output float32 buffer, so the Compatibility Mode batch=1 path is often the only viable option on consumer GPUs at 4×.