multicolorfits.make_transparent_cutout#

multicolorfits.make_transparent_cutout(rgb, size=None, alpha_lo=55.0, alpha_hi=99.3, alpha_gamma=0.5, alpha_source='luma', layer=None, alpha_smooth=0.0, sky_color='black', crop='auto', pad=0.05, matte='none', soft_edge=0.0, invert=False, existing_alpha='replace', wcs=None, sky_box=None)[source]#

Build a transparent-sky RGBA cutout from an RGB (or RGBA) composite.

Parameters:
  • rgb (array) – (ny, nx, 3) or (ny, nx, 4) in [0, 1] (values outside are clipped).

  • size (int or None) – If set, downsample so the longest side is at most this many pixels (after cropping). None keeps native resolution.

  • alpha_lo (float) – Percentiles of the intensity map mapped to fully transparent / opaque. alpha_hi acts as the opacity threshold: pixels at or above it are fully opaque, with alpha ramping down to zero at alpha_lo.

  • alpha_hi (float) – Percentiles of the intensity map mapped to fully transparent / opaque. alpha_hi acts as the opacity threshold: pixels at or above it are fully opaque, with alpha ramping down to zero at alpha_lo.

  • alpha_gamma (float) – Fade shape, any value > 0 (< 1 = bolder object body, > 1 = tighter matte around the brightest structure; default 0.5 matches the skyplothelper M74 recipe).

  • alpha_source ({'luma', 'max', 'mean', 'sat', 'dist', 'layer'}) – How to derive the intensity map for the matte. 'dist' uses the color distance from sky_color (use for non-black skies, e.g. white-background or deblended composites); 'sat' uses HSV saturation.

  • layer (array or int or None) – Extra band (2D) or channel index when alpha_source='layer'.

  • alpha_smooth (float) – Gaussian sigma (pixels) applied to the intensity map before the percentile ramp. A few px makes the matte trace coherent structure (whole spiral arms opaque) instead of pixel noise; the RGB data itself is untouched.

  • sky_color (color) – Background color for alpha_source='dist' (any matplotlib color).

  • crop ({'auto', 'none'} or False) – 'auto' trims to the non-transparent bbox (+ pad).

  • pad (float) – Fractional padding around the auto-crop bbox (0.05 = 5%).

  • matte ({'none', 'circle', 'ellipse'}) – Optional geometric window on top of the luminance matte.

  • soft_edge (float) – Gaussian sigma (pixels) applied to alpha after the matte (0 = off).

  • invert (bool) – Treat dark pixels as signal (white-background composites).

  • existing_alpha ({'replace', 'multiply', 'keep'}) – If rgb already has an alpha channel: replace it, multiply into the new matte, or keep the original and only apply size/crop/matte.

  • wcs – Optional WCS-aware pre-crop. sky_box=(ra0, dec0, ra1, dec1) in degrees; requires an WCS matching rgb.

  • sky_box – Optional WCS-aware pre-crop. sky_box=(ra0, dec0, ra1, dec1) in degrees; requires an WCS matching rgb.

Returns:

array – Float RGBA (ny, nx, 4) in [0, 1].