Skip to content
Snippets Groups Projects
Verified Commit 2f84e019 authored by Yannick DAYER's avatar Yannick DAYER
Browse files

fix: gray PNG loading with new version of imageio.

Loading a PNG image with imageio now returns a 2-channel image instead
of 4 channels with the first three repeated.
parent 704ee82a
No related branches found
No related tags found
No related merge requests found
......@@ -104,11 +104,13 @@ def open_file(filename) -> np.ndarray:
img = imageio.imread(filename)
# PNGs have a 4th channel, which we don't want
# PNGs have an additional channel, which we don't want
# Alpha channels for instance have to be ignored
if img.ndim > 2:
if extension.lower() == ".png":
img = img[:, :, 0:3]
if extension.lower() == ".png" and img.shape[-1] in (2, 4):
img = img[:, :, :-1]
if img.shape[-1] == 1:
img = img.squeeze(-1)
img = check_gray(img)
return img if img.ndim == 2 else to_bob(img)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment