Skip to content

Commit 643bff1

Browse files
authored
Update img_util.py
1 parent 0ed45c4 commit 643bff1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/segmentation_skeleton_metrics/utils/img_util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,22 +167,30 @@ class TiffReader(ImageReader):
167167
Class that reads an image with the Tifffile library.
168168
"""
169169

170-
def __init__(self, img_path):
170+
def __init__(self, img_path, swap_axes=True):
171171
"""
172172
Instantiates a TiffReader image reader.
173173
174174
Parameters
175175
----------
176176
img_path : str
177177
Path to a TIFF image.
178+
swap_axes : bool, optional
179+
Indication of whether to swap axes 0 and 2. Default is True.
178180
"""
181+
# Call parent class
179182
super().__init__(img_path)
180183

184+
# Instance attributes
185+
self.swap_axes = swap_axes
186+
181187
def _load_image(self):
182188
"""
183189
Loads image using the Tifffile library.
184190
"""
185191
self.img = imread(self.img_path)
192+
if self.swap_axes:
193+
self.img = np.swapaxes(self.img, 0, 2)
186194

187195

188196
# --- Miscellaneous ---

0 commit comments

Comments
 (0)