tissue_components
tissue_components ¶
tissue_components(
img: ndarray,
label: ndarray | None = None,
device: str = "cpu",
) -> tuple[np.ndarray, np.ndarray]
Segment background and dark-component masks using RGB color clusters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
ndarray
|
RGB H&E image with shape (H, W, 3) and pixel values in [0, 255]. |
required |
label
|
ndarray | None
|
Optional nuclei labels with shape (H, W); positive labels are included in the dark-component mask. |
None
|
device
|
str
|
"cpu" or "cuda". CUDA clustering requires CuPy/cuML; mask cleanup checks its own CUDA dependencies. |
'cpu'
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
Background and dark-component NumPy boolean masks with shape (H, W). |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a required CUDA backend is unavailable. |
ValueError
|
If clustering rejects the inputs or device. |