Skip to content

Commit

Permalink
Merge 9747c22 into 4c95d01
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuboudreau committed Jan 30, 2024
2 parents 4c95d01 + 9747c22 commit 9ed9a05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions ivadomed/loader/segmentation_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,19 @@ def convert_file_to_nifti(self, filename: str, extension: str, is_gt: bool = Fal
# Note: All of these are trivially true for JPEG and PNG due to limitations of these formats.

# make grayscale (treats binary as 1-bit grayscale)
colorspace_idx = 2 + int(props.is_batch)
colorspace_idx = 2
if _img.ndim <= colorspace_idx: # binary or gray
pass # nothing to do
elif _img.shape[colorspace_idx] == 2: # gray with alpha channel
_img = _img[:, :, 0]
elif _img.shape[colorspace_idx] == 3: # RGB
_img = np.sum(_img * (.299, .587, .114), axis=-1)
else: # RGBA
# discards alpha
_img = np.sum(_img * (.299, .587, .114, 0), axis=-1)
if len(_img.shape) < 3:
_img = np.expand_dims(_img, axis=-1)

img = imageio.core.image_as_uint(_img, bitdepth=8)

# Binarize ground-truth values (0-255) to 0 and 1 in uint8 with threshold 0.5
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# https://github.com/readthedocs/readthedocs.org/blob/ecac31de54bbb2c100f933e86eb22b0f4389ba84/requirements/pip.txt#L16
'sphinx',
'sphinx_rtd_theme',
'sphinx-tabs==3.2.0',
'sphinx-toolbox==2.15.2',
'sphinx-jsonschema~=1.16',
'sphinx-tabs',
'sphinx-toolbox',
'sphinx-jsonschema',
'pypandoc',
],
'tests': [
Expand Down

0 comments on commit 9ed9a05

Please sign in to comment.