Chris Oswald
commited on
Commit
•
b45106a
1
Parent(s):
3013e2b
debugging
Browse files
SPIDER.py
CHANGED
@@ -68,13 +68,16 @@ def standardize_3D_image(
|
|
68 |
image: np.ndarray,
|
69 |
resize_shape: Tuple[int, int, int]
|
70 |
) -> np.ndarray:
|
71 |
-
"""Aligns dimensions of image to be (height, width, channels)
|
72 |
-
images to values specified in resize_shape
|
|
|
73 |
# Align height, width, channel dims
|
74 |
if image.shape[0] < image.shape[2]:
|
75 |
image = np.transpose(image, axes=[1, 2, 0])
|
76 |
# Resize image
|
77 |
image = skimage.transform.resize(image, resize_shape)
|
|
|
|
|
78 |
return image
|
79 |
|
80 |
|
@@ -493,9 +496,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
493 |
resize_shape,
|
494 |
)
|
495 |
|
496 |
-
# Rescale to UInt8 type (required for PyArrow and PIL)
|
497 |
-
image_array_standardized = skimage.img_as_ubyte(image_array_standardized)
|
498 |
-
|
499 |
# Load .mha mask file
|
500 |
mask_path = os.path.join(paths_dict['masks'], 'masks', example)
|
501 |
mask = sitk.ReadImage(mask_path)
|
|
|
68 |
image: np.ndarray,
|
69 |
resize_shape: Tuple[int, int, int]
|
70 |
) -> np.ndarray:
|
71 |
+
"""Aligns dimensions of image to be (height, width, channels); resizes
|
72 |
+
images to values specified in resize_shape; and rescales pixel values
|
73 |
+
to Uint8."""
|
74 |
# Align height, width, channel dims
|
75 |
if image.shape[0] < image.shape[2]:
|
76 |
image = np.transpose(image, axes=[1, 2, 0])
|
77 |
# Resize image
|
78 |
image = skimage.transform.resize(image, resize_shape)
|
79 |
+
# Rescale to UInt8 type (required for PyArrow and PIL)
|
80 |
+
image = skimage.img_as_ubyte(image)
|
81 |
return image
|
82 |
|
83 |
|
|
|
496 |
resize_shape,
|
497 |
)
|
498 |
|
|
|
|
|
|
|
499 |
# Load .mha mask file
|
500 |
mask_path = os.path.join(paths_dict['masks'], 'masks', example)
|
501 |
mask = sitk.ReadImage(mask_path)
|