grayscale_intensity
Computes the mean, std, & quantiles of grayscale intensity of objects in img
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img
|
ndarray
|
Image to compute properties from. Shape (H, W). |
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 |
ndarray
|
Mean intensity of each object. Shape (N,). |
std |
ndarray
|
Standard deviation of each object. Shape (N,). |
quantile_vals |
ndarray
|
Quantile values for each object. 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 grayscale_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 grayscale intensity features from the neoplastic nuclei
>>> means, stds, quantiles = grayscale_intensity(he_image, inst_mask)
>>> print(means.mean())
0.21791865214466258