outlier_rejection_mad_adaptive¶
Replace pixels whose deviation from a local median exceeds threshold·MAD.
| Category | Preprocessing (2-D image) |
| Backend | numpy - implemented here on top of numpy primitives |
| Version | 1.0.1 |
| Reads | ctx.image (an ImageFrame) |
| Writes | image, metrics.n_replaced |
Vectorised with numpy.lib.stride_tricks.sliding_window_view, so the cost is one O(kernel · pixels) sort. Pixels within the band are replaced by the local median if their deviation exceeds threshold × MAD. The half-pixel border on each side is left untouched (window does not fit there). v1.0.1: rows are processed in chunks so the transient window copies stay around 64 MB regardless of frame size (a 4k² frame with k=5 needed ~6 GB before) — identical output.
Parameters¶
| Parameter | Default | Required | Description |
|---|---|---|---|
kernel_size |
3 |
- | Square neighbourhood size, odd integer ≥ 3. |
threshold |
3.0 |
- | Multiplier on the local MAD above which a pixel is replaced. |
row_lo |
0 |
- | First row (inclusive) where the filter applies; 0 = top. |
row_hi |
0 |
- | Last row (exclusive); 0 ⇒ bottom of the image. |
Use it¶
The CLI loads a single 1-D spectrum with --input; this algorithm needs
ctx.image (an ImageFrame). Run it from Python or as a step of a pipeline preset.
References¶
- Hwang & Haddad 1995, IEEE Trans. Image Processing 4(4):499 — adaptive median filter for impulsive noise.
- Hoaglin, Mosteller & Tukey 1983, Understanding Robust and Exploratory Data Analysis — Median Absolute Deviation properties.
Related algorithms¶
correct_slant_affine- Make monochromatic lines parallel to the rows by a horizontal shear.correct_smile_polynomial- Undo smile curvature via the Schroeder even-order expansion.correct_tilt_affine- Re-align the slit with the detector columns by a vertical shear.dark_subtract- Subtract a master dark fromctx.image.denoise_gaussian_2d- Separable isotropic Gaussian smoothing ofctx.image.denoise_median_2d- Square median filter overctx.image, optionally banded by rows.flat_normalize- Dividectx.imageby a master flat normalised to unity.flat_normalize_easyspec- Flat-field correct a science frame viacleaning.flatten.subtract_bias_easyspec- Subtract a master bias from a single science frame viacleaning.debias.subtract_dark_easyspec- Subtract a master dark from a science frame viacleaning.sub_dark.subtract_sky_2d- Subtract a per-column sky model fitted from off-trace rows ofctx.image.