textural_feats
Compute GLCM texture features from a grayscale image.
Note
Uses skimage.feature.graycomatrix
and skimage.feature.graycoprops
See scikit-image docs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im_gray
|
ndarray
|
Grayscale image. Shape (H, W), Dtype: uint8. |
required |
label
|
ndarray
|
Instance label map. Shape (H, W), Dtype: int. |
required |
metrics
|
Sequence[str]
|
Texture metrics to compute. Allowed values are:
|
('contrast', 'dissimilarity')
|
distances
|
Sequence[int]
|
Specifies the pixel distances at which the relationships are computed. A distance of 1 compares adjacent pixels, while larger distances allow for the analysis of texture at different scales, capturing relationships between pixels that are further apart. |
(1,)
|
angles
|
Sequence[float]
|
Defines the direction of the pixel relationships for GLCM computation. Angles of 0, π/4, π/2, and 3π/4 radians correspond to horizontal, diagonal, vertical, and anti-diagonal directions, respectively. This parameter allows you to analyze textures that may be directionally dependent or anisotropic. |
(0,)
|
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. "cpu" or "cuda". If cuda, the pre-processing is done on the GPU. The CLCM computation is performed on the CPU. |
'cpu'
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: DataFrame containing the computed texture features for each nucleus. |
Examples:
>>> from histolytics.data import hgsc_cancer_he, hgsc_cancer_inst_mask
>>> from histolytics.nuc_feats.texture import textural_feats
>>> # Load data
>>> img = hgsc_cancer_he()
>>> inst_label = hgsc_cancer_inst_mask()
>>>
>>> metrics = ["contrast", "dissimilarity"]
>>> distances = (1,)
>>> angles = (0,)
>>> feats = textural_feats(
... img,
... inst_label,
... distances=distances,
... metrics=metrics,
... angles=angles,
... device="cuda",
... )
>>>
>>> print(feats.head(3))
contrast_d-1_a-0.00 dissimilarity_d-1_a-0.00
1 172.885714 6.247619
2 535.854839 10.635484
3 881.203704 13.500000
Source code in src/histolytics/nuc_feats/texture.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|