Collapse a spectral cube into a white-light image (robust, weighted)
Source:R/collapse.R
collapse_white_light.RdSteps:
subtract spatial median per-wavelength,
clip very negative outliers at -k * MAD,
(optional) inverse-variance weights 1/MAD^2,
weighted sum and reshape to a 2-D image,
force non-negative for visualization safety.