rgb_intensity_feats
Computes rgb-intensity features of labeled objects in img
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
img
|
ndarray
|
Image to compute properties from. Shape (H, W, 3). |
required |
label
|
ndarray
|
Label image. Shape (H, W). |
required |
metrics
|
Tuple[str, ...]
|
Metrics to compute for each object. Options are:
|
('mean', 'std', 'quantiles')
|
quantiles
|
Tuple[float, ...]
|
Quantiles to compute for each object. Ignored if |
(0.25, 0.5, 0.75)
|
n_bins
|
int
|
Number of bins to use for histogram-based features. Ignored if |
32
|
hist_range
|
Tuple[float, float]
|
Range of pixel values to use for histogram-based features. Ignored if |
None
|
mask
|
ndarray
|
Optional binary mask to apply to the image to restrict the region of interest. Shape (H, W). For example, it can be used to mask out tissues that are not of interest. |
None
|
device
|
str
|
Device to use for computation. Options are 'cpu' or 'cuda'. If set to 'cuda', CuPy and cucim will be used for GPU acceleration. |
'cpu'
|
Raises:
Type | Description |
---|---|
ValueError
|
If the shape of |
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame containing the computed features for each RGB-channel for each object. |
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_feats
>>>
>>> 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
>>> feats = rgb_intensity_feats(he_image, inst_mask)
>>> print(feats.iloc[..., 0:3].head(3))
R_mean R_std R_quantile_0.25
292 0.390361 0.071453 0.349138
316 0.279746 0.032215 0.254310
340 0.319236 0.071267 0.267241
Source code in src/histolytics/nuc_feats/intensity.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|