multicolorfits.alpha_from_intensity#
- multicolorfits.alpha_from_intensity(intensity, lo=55.0, hi=99.3, gamma=0.5, invert=False, smooth=0.0)[source]#
Build a soft alpha matte from a 2D intensity map.
- Parameters:
intensity (array (ny, nx)) – Brightness map in arbitrary units (typically luma of an RGB composite).
lo (float) – Percentiles of intensity mapped to alpha 0 and 1. Defaults (~55 / 99.3) leave most sky transparent while keeping the bright object body opaque. Think of hi as the opacity threshold: everything at or above it is fully opaque; below it, alpha ramps down to 0 at the lo level.
hi (float) – Percentiles of intensity mapped to alpha 0 and 1. Defaults (~55 / 99.3) leave most sky transparent while keeping the bright object body opaque. Think of hi as the opacity threshold: everything at or above it is fully opaque; below it, alpha ramps down to 0 at the lo level.
gamma (float) – Shape of the fade below the hi threshold (any value > 0).
gamma < 1(e.g. 0.5) keeps more of the object body opaque — better over light slide backgrounds.gamma = 1is a linear ramp.gamma > 1(e.g. 1.4) tightens the matte, so only the brightest structure survives at high opacity.invert (bool) – If True, treat dark as signal (white-paper / emission-on-white look).
smooth (float) – Gaussian sigma (pixels) applied to the intensity map before the percentile ramp. A few pixels of smoothing makes the matte follow coherent structure (whole spiral arms) instead of per-pixel noise, so extended features stay opaque while the sky still cuts to zero. Requires scipy when > 0.
- Returns:
array (ny, nx) float in [0, 1]