auto_stretch
Apply PixInsight's auto-stretch to a view, using STF-based clipping and midtones balance to enhance faint details. Adjusts per-channel or linked RGB with configurable target background and shadows clipping.
Instructions
Stretch a view in place with PixInsight's auto-stretch (the ScreenTransferFunction Auto Stretch computation), applied as a HistogramTransformation. Per channel, sigma = 1.4826 × MAD (the median absolute deviation from the median). A channel whose median is below 0.5 gets shadows clipping c0 = median + shadows_clipping × sigma, clamped to [0,1] (0 when sigma is 0), and midtones balance m = MTF(target_bg, median − c0), where MTF(m, x) = (m − 1)·x / ((2m − 1)·x − m); a channel whose median is above 0.5 is treated as inverted: highlights clipping c1 = median − shadows_clipping × sigma (1 when sigma is 0) and m = MTF(c1 − median, target_bg). linked: one transform for R, G and B, with c0 (or c1) the mean over channels of the per-channel clipping points (a channel with sigma 0 adds 0, or 1 for c1) and the mean median in place of the median; the image is treated as inverted only when every channel median is above 0.5. The defaults of shadows_clipping, target_bg and linked are PixInsight's auto-stretch defaults. Fails, changing nothing, when the clipping point leaves no range for a midtones balance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| linked | No | Colour images: true computes one transform for R, G and B; false computes one per channel. Ignored for mono images | |
| view_id | Yes | View ID to stretch | |
| target_bg | No | Target background level, strictly between 0 and 1 | |
| shadows_clipping | No | Clipping point relative to the median, in units of sigma = 1.4826 × MAD |