rgb_intensity
Computes the mean, std, and quantiles of RGB intensity of the labelled objects in
img
, separately for each channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img
|
ndarray
|
Image to compute properties from. Shape (H, W, 3). |
required |
label
|
ndarray
|
Label image. Shape (H, W). |
None
|
quantiles
|
Tuple[float, ...]
|
Quantiles to compute for each object. |
(0.25, 0.5, 0.75)
|
Returns:
Name | Type | Description |
---|---|---|
means |
Tuple[ndarray, ndarray, ndarray]
|
Mean intensity of each object for each channel (RGB). Each array shape (N,). |
std |
Tuple[ndarray, ndarray, ndarray]
|
Standard deviation of each object for each channel (RGB). Each array shape (N,). |
quantile_vals |
Tuple[ndarray, ndarray, ndarray]
|
Quantile values for each object for each channel (RGB). Each array shape (N, len(quantiles)). |
Examples:
>>> from histolytics.data import hgsc_cancer_he, hgsc_cancer_nuclei
>>> from histolytics.utils.raster import gdf2inst
>>> from histolytics.nuc_feats.intensity import rgb_intensity
>>>
>>> he_image = hgsc_cancer_he()
>>> nuclei = hgsc_cancer_nuclei()
>>> neoplastic_nuclei = nuclei[nuclei["class_name"] == "neoplastic"]
>>> inst_mask = gdf2inst(
... neoplastic_nuclei, width=he_image.shape[1], height=he_image.shape[0]
... )
>>> # Extract RGB intensity features from the neoplastic nuclei
>>> means, stds, quantiles = rgb_intensity(he_image, inst_mask)
>>> # RED channel mean intensity
>>> print(means[0].mean())
0.3659444588664546