expand_mask#

mufasa.UltraCube.expand_mask(mask, expand)[source]#

Expand a 3D mask along the spectral axis by a specified buffer size.

This function applies a binary dilation to the input mask, increasing its coverage along the spectral axis by the specified expand value. The expansion is applied independently for each spatial pixel.

Parameters:
  • mask (numpy.ndarray) – A 3D boolean array representing the original mask. The first dimension corresponds to the spectral axis, while the remaining dimensions represent spatial axes.

  • expand (int) – The number of spectral channels to extend the mask along the spectral axis. Must be a non-negative integer.

Returns:

expanded_mask – A 3D boolean array of the same shape as the input mask, with the spectral regions expanded by the specified buffer size.

Return type:

numpy.ndarray

Notes

The binary dilation process enlarges the True regions in the mask along the spectral axis. The dilation does not affect spatial axes, but it creates a buffer around the original mask in the spectral dimension.

Raises:
  • ValueError – If expand is not a non-negative integer.

  • TypeError – If the input mask is not a boolean numpy array.