Skip to content

Commit 7b81bb7

Browse files
Use normalized glcm and add intensity image
1 parent 048e7c0 commit 7b81bb7

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/scip/features/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def features_partition(
8080
if "shape" in types:
8181
out[i, c:c + lengths["shape"]] = shape_features(
8282
mask=p["mask"],
83-
combined_mask=p["combined_mask"]
83+
combined_mask=p["combined_mask"],
84+
image=p["pixels"]
8485
)
8586
c += lengths["shape"]
8687
if "raw" in types:

src/scip/features/shape.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,21 @@ def _shape_features_meta(channel_names: List[str]) -> Mapping[str, type]:
112112
return out
113113

114114

115-
def _row(mask: numpy.ndarray) -> numpy.ndarray:
115+
def _row(mask: numpy.ndarray, image: numpy.ndarray = None) -> numpy.ndarray:
116116
label_img = label(mask)
117-
props = regionprops_table(label_image=label_img, properties=prop_ids, cache=False)
117+
props = regionprops_table(
118+
label_image=label_img,
119+
properties=prop_ids,
120+
intensity_image=image,
121+
cache=False
122+
)
118123
return [numpy.mean(props[k]) for k in prop_names]
119124

120125

121126
def shape_features(
122127
mask: numpy.ndarray,
123-
combined_mask: numpy.ndarray
128+
combined_mask: numpy.ndarray,
129+
image: numpy.ndarray
124130
) -> numpy.ndarray:
125131
"""Extracts shape features from image.
126132
@@ -139,7 +145,7 @@ def shape_features(
139145

140146
for i in range(len(mask)):
141147
if numpy.any(mask[i]):
142-
out[(i + 1) * len(prop_names):(i + 2) * len(prop_names)] = _row(mask[i])
148+
out[(i + 1) * len(prop_names):(i + 2) * len(prop_names)] = _row(mask[i], image[i])
143149
else:
144150
# setting proper default values if possible when the mask is empty
145151
out[(i + 1) * len(prop_names):(i + 2) * len(prop_names)] = [

src/scip/features/texture.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def _row(pixels, num_features):
6464
distances=distances,
6565
angles=angles,
6666
levels=bins + 2,
67-
symmetric=True
67+
symmetric=True,
68+
normed=True
6869
)[:-1, :-1]
6970

7071
out = numpy.full(shape=(num_features,), fill_value=None, dtype=float)

0 commit comments

Comments
 (0)