Skip to content

Fix skimage.io.imread returns incorrect dimensions - #1498

Merged
blink1073 merged 4 commits into
scikit-image:masterfrom
cgohlke:patch-2
May 9, 2015
Merged

blink1073 merged 4 commits into
scikit-image:masterfrom
cgohlke:patch-2

Conversation

@cgohlke

@cgohlke cgohlke commented May 7, 2015

Copy link
Copy Markdown
Contributor

Fixes #1496

Note that since imread does not have access to metadata, such as the TIFF PlanarConfiguration tag, this patch uses a heuristic approach based on the image shape. Also, the returned ndimage array might be non-contiguous.

@cgohlke cgohlke changed the title Fix skimage.io.imread returns incorrect dimensions WIP Fix skimage.io.imread returns incorrect dimensions May 8, 2015
@cgohlke cgohlke changed the title WIP Fix skimage.io.imread returns incorrect dimensions Fix skimage.io.imread returns incorrect dimensions May 8, 2015
@stefanv

stefanv commented May 9, 2015

Copy link
Copy Markdown
Member

/cc @blink1073

Comment thread skimage/io/_io.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why img.shape[-3] and not img.shape[0]?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is based on the convention in tifffile.py for multi-page TIFFs, where the first dimension may be the number of pages.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@JavierClearImageAI JavierClearImageAI Mar 19, 2020 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got this error still in python 3.6. Is it fixed in any new version?

"io" needs to access the metadata. Otherwise some labeling annotations might get it wrong when doing the segmentation for object detection applications. The labels where rotated 90º when having vertical images. It took me a while to find out where was the bug :( ... That's what the metadata is for. Why should we assume anything when we can get certainty?

I would suggest to use exiftool.

Regards

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JavierClearImageAI wow, this issue is a blast from the past! And yet, as you noted, very much still an issue.

The main problem with metadata is that it is inconsistent between different file formats, or even different variants of the same format. We don't have enough person-hours to pursue all the possible formats and metadata tags, and the lack of clarity over where to start has prevented real efforts from getting started here. See the following issues in imageio for more context:

https://github.com/imageio/imageio/issues?q=is%3Aissue+is%3Aopen+metadata

imageio is the right place to start thinking about and contributing to a solution.

Thank you for the ping!

@blink1073

Copy link
Copy Markdown
Contributor

I think we need a test with a multi-page RGB TIFF to really iron this out.

@blink1073

Copy link
Copy Markdown
Contributor

I can add the multi-page TIFF in another PR, I am fine with this one as-is, once @emmanuelle concurs.

@emmanuelle

Copy link
Copy Markdown
Member

👍

@blink1073

Copy link
Copy Markdown
Contributor

Thanks @cgohlke!

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 this pull request may close these issues.

skimage.io.imread returns incorrect dimensions (according to docs)

6 participants