panoptica.utils
panoptica.utils.constants
- class panoptica.utils.constants.CCABackend(value)
Bases:
_Enum_Compare
Enumeration representing different connected component analysis (CCA) backends.
This enumeration defines options for CCA backends, which are used for labeling connected components in segmentation masks.
- Members:
cc3d: Represents the Connected Components in 3D (CC3D) backend for CCA. [CC3D Website](https://github.com/seung-lab/connected-components-3d)
scipy: Represents the SciPy backend for CCA. [SciPy Website](https://www.scipy.org/)
- cc3d = 1
- scipy = 2
- class panoptica.utils.constants._Enum_Compare(value)
Bases:
Enum
An enumeration.
panoptica.utils.datatypes
panoptica.util.numpy_utils
- panoptica.utils.numpy_utils._count_unique_without_zeros(arr: ndarray) int
Count the number of unique elements in the input NumPy array, excluding zeros.
- Parameters:
arr (np.ndarray) – Input array.
- Returns:
Number of unique elements excluding zeros.
- Return type:
int
- panoptica.utils.numpy_utils._get_bbox_nd(img: ndarray, px_dist: int | tuple[int, ...] = 0) tuple[slice, ...]
calculates a bounding box in n dimensions given a image (factor ~2 times faster than compute_crop_slice)
- Parameters:
img – input array
px_dist – int | tuple[int]: dist (int): The amount of padding to be added to the cropped image. If int, will apply the same padding to each dim. Default value is 0.
- Returns:
list of boundary coordinates [x_min, x_max, y_min, y_max, z_min, z_max]
- panoptica.utils.numpy_utils._get_smallest_fitting_uint(max_value: int) type
Determine the smallest unsigned integer type that can accommodate the given maximum value.
- Parameters:
max_value (int) – The maximum value to be accommodated.
- Returns:
The NumPy data type (e.g., np.uint8, np.uint16, np.uint32, np.uint64).
- Return type:
type
Example: >>> _get_smallest_fitting_uint(255) <class ‘numpy.uint8’>
- panoptica.utils.numpy_utils._unique_without_zeros(arr: ndarray) ndarray
Get unique non-zero values from a NumPy array.
- Parameters:
arr (np.ndarray) – Input NumPy array.
- Returns:
Unique non-zero values from the input array.
- Return type:
np.ndarray
Issues a warning if negative values are present.