Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imread() for tiff file returns wrong dimensions #5545

Closed
r0f1 opened this issue Aug 27, 2021 · 6 comments · Fixed by #5546
Closed

imread() for tiff file returns wrong dimensions #5545

r0f1 opened this issue Aug 27, 2021 · 6 comments · Fixed by #5546

Comments

@r0f1
Copy link

r0f1 commented Aug 27, 2021

Consider this following code:

from pathlib import Path
from skimage.io import imread

a = sorted(Path(input_dir).glob("*.tiff"))[0]

imread(a).shape
imread(str(a)).shape

Output:

(64, 6)     # wrong
(64, 64, 6) # correct

I am trying to read a tiff file with 6 color channels. Why do I get different image dimension depending on whether I pass a PosixPath or a string to imread()? If PosixPaths are not supported by imread(), which is totally fine, could you please throw a ValueError?

@grlee77
Copy link
Contributor

grlee77 commented Aug 27, 2021

Thanks for reporting this! I can reproduce this issue with a tiff file bundled with the repository as well:

from pathlib import Path

io.imread(Path('skimage/data/multipage.tif')).shape
# (15, 10)

io.imread(str(Path('skimage/data/multipage.tif'))).shape
# (2, 15, 10)

@grlee77
Copy link
Contributor

grlee77 commented Aug 27, 2021

See #5546 for an explanation of why this was happening (basically a check for the file extension did not work properly when the input was a Path)

@r0f1
Copy link
Author

r0f1 commented Aug 28, 2021

Thanks, that's awesome!

@om-mishra-it
Copy link

Is this issue still open for a fix?

@grlee77
Copy link
Contributor

grlee77 commented Aug 30, 2021

@oreo2107, this one has a fix already proposed in #5546

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/magic-gui-not-reading-image-stack/63284/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants