delta.utilities.label_seg

delta.utilities.label_seg(seg: ndarray[Any, dtype[uint8]], cellnumbers: Optional[List[int]] = None, return_contours: bool = False, background: int = 0) Union[ndarray[Any, dtype[uint16]], Tuple[ndarray[Any, dtype[uint16]], List[ndarray]]]

Label cells in segmentation mask

Parameters
segnumpy 2D array of float/uint8/uint16/bool

Cells segmentation mask. Values >0.5 will be considered cell pixels

cellnumberslist of ints, optional

Numbers to attribute to each cell mask, from top to bottom of image. Because we are using uint16s, maximum cell number is 65535. If None is provided, the cells will be labeled 1,2,3,… Background is 0 The default is None.

Returns
label2D numpy array of uint16

Labelled image. Each cell in the image is marked by adjacent pixels with values given by cellnumbers

contourslist

List of cv2 contours for each cell. Returned if return_contours==True.