Skip to content

Deprecate (most of) skimage.io in favour of imageio #5036

Closed

Description

@jni

Description

This is meant to supersede the discussion in #1605, which contains a lot of outdated information.

In 2020, here are the pros for replacing skimage.io with imageio:

  • distributing wheels is easy now
  • imageio has feature parity with skimage.io. In fact, I would be surprised if 99% of our io.imread calls didn't go straight through to imageio — at least if we exclude tifffile.
  • this post by @danielballan, for those that haven't seen it, gives a rough outline for implementing a single protocol for lazy image reading in Python. imageio is a natural place to implement such work, and skimage.io is at best redundant, at worst, another place for things to fall out of sync.

Things that I think need to change in imageio for us to completely drop skimage.io:

  • imageio.imread does return a fancy array wrapper rather than a straight numpy array, which breaks the scikit-image API. However, this is somewhat necessary for imageio to provide metadata. Not sure where to meet on this one.
  • imageio.imread only gets a single plane out of a tiff file, preferring to leave volume loading to imageio.volread. imho we should aim to be dimension-agnostic. @almarklein is this something you foresee could change? See e.g. reading array of shape (512, 512, 30) with a pathlib path returns array of shape (512, 30) #4138.

In my opinion, the existence of both skimage.io and imageio is redundant, and it makes sense to separate the two functionalities (IO vs processing/analysis) into two separate packages.

@emmanuelle argues for keeping imread. I'm ok with that but I also would contemplate removing it for 1.0.


Definition of done: All external plugins and functionality in skimage.io, other than ImageCollection, MultiImage, load_sift, load_surf, and the imageio wrappers for imread, imsave are removed.

Activity

  1. added this to the 1.0 milestone on Oct 27, 2020
  2. sciunto commented on Oct 27, 2020

    @sciunto
    Member

    +1 with @emmanuelle I beleive it is important to keep wrappers of our io functions because it helps a lot beginners.

  3. rfezzani commented on Oct 27, 2020

    @rfezzani
    Member

    Thank you @jni for opening this, you can't imagine how enthusiastic I am about dropping skimage.io! 😃

    I already shared my feelings about this, and I am convinced that skimage can gain maturity and stability if it focuses on it's core functionality: image processing!

    There is plenty of excellent python packages dedicated to IO and viewing. We must advertise for them instead of proposing yet another implementation with all the induced maintenance...

    @sciunto, the skimage deprecation procedure takes 2 releases before completely removing the deprecated part from the package. I think that this is enough time to teach beginners how to properly read/write images without our skimage.io module 😉

  4. almarklein commented on Oct 27, 2020

    @almarklein
    Contributor

    this post by @danielballan, for those that haven't seen it, gives a rough outline for implementing a single protocol [...]

    I hadn't seen that one yet, but I find the idea of standards (over implementations) very interesting. Also the idea to use entrypoints for packages to advertise image/data reading capabilities without importing them is very interesting to scale supported formats without making a lib like imageio "heavy". This needs some more thought ...

    imageio.imread does return a fancy array wrapper rather than a straight numpy array, which breaks the scikit-image API. However, this is somewhat necessary for imageio to provide metadata.

    Perhaps it's finally time to finally fix this long-standing issue ;)

    imageio.imread only gets a single plane out of a tiff file, preferring to leave volume loading to imageio.volread. imho we should aim to be dimension-agnostic. @almarklein is this something you foresee could change? See e.g. #4138.

    There are some formats that are somewhat ambiguous about whether their data is a set of 2D images or one 3D image. Most notably Tiff and Dicom. In imageio I've made the choice to let the user decide what dimensionality is expected, and pass that hint to the reader. So there's imread() for single 2D images, mimread() for image series, volread() for volumes and mvolread() for series of volumes.

    I believe this approach works well. I think that if you'd want to keep an imread() function in skimage, I'd recommend adding (at least) volread() as well.

  5. jni commented on Oct 27, 2020

    @jni
    MemberAuthor

    There are some formats that are somewhat ambiguous about whether their data is a set of 2D images or one 3D image. Most notably Tiff and Dicom.

    Sure, but from a user perspective, we'd want a 3D array in either case, right? For users who work with anything from 2D to 3D+t+c images, having to remember which of the 4 functions to call today is annoying. (Not to mention that sometimes I get user-provided data or downloaded data from a paper and I actually don't know ahead of time the dimensionality.) I believe this is a problem for the metadata, but the data should be a NumPy (or Dask) array, in any case, and so in any case we should use the same function.

  6. almarklein commented on Oct 27, 2020

    @almarklein
    Contributor

    Sure, but from a user perspective, we'd want a 3D array in either case, right?

    I think it's not that simple. Both Tiff and Dicom can provide multiple images (or volumes) of different shapes, so they cannot be stacked into a single array.

    having to remember which of the 4 functions to call today is annoying.

    Well, you're going to do something with the data, and for that you're assuming a certain shape. I understand that for data exploration it would be nice to see what's actually inside ... which brings us full circle to meta data ;)

  7. jni commented on Oct 27, 2020

    @jni
    MemberAuthor

    Well, you're going to do something with the data, and for that you're assuming a certain shape.

    Nope — napari will happily display any shape array. ;)

    Both Tiff and Dicom can provide multiple images (or volumes) of different shapes, so they cannot be stacked into a single array.

    That is definitely a concern — but one that volread doesn't solve, does it? I would suggest imread (nD image) and mimread (iterator of nD images).

  8. almarklein commented on Oct 28, 2020

    @almarklein
    Contributor

    napari will happily display any shape array. ;)

    Nice! Ok, I see the use-case for an API to just "gimme the data". But I also think there is a need to be able to be more precise.

    Somewhere at the plugin level, there is a function _get_data(index). In a lot of cases the file contains one image, index is 0, and all is well. In some cases (e.g. video) it's clear that index represents the nth image. But for e.g. Tiff, the format needs a hint to know whether the user wants the whole thing or is iterating over the slices. Right now, this hint is provided by the user using imshow/mimshow/volshow.

    Maybe, we could do something along the lines of imread(hint="greedy"). By default this will try to simply ready all data, but the user can set the hint (or mode?) to '2d' or '3d' to specify a more precise intention if needed.

    edit: PS: this hint is also used in imageio to select the appropriate format. E.g. Pillow can read gif and Tiff, but not files with multiple frames.

  9. emmanuelle commented on Oct 29, 2020

    @emmanuelle
    Member

    My argument in favor of keeping io.imread: even if we do the deprecation properly etc., it would be a communication/public relations disaster to break 90% of users' scripts. People are going to complain a lot, heavily, and for a long time. We know that there is a long queue of people who upgrade their version only when they really need to, who have a lot of legacy code, etc. If we can help people improving their coding skills this is great, but this is not the right direction IMO. That said, we can have this discussion within the larger context of "what is going to break for users with 1.0" (but I hope that the answer is not 90% of scripts will have to be changed some way or another).

    Removing the most used function in scikit-image (from this Github crawling which was done a while ago) does not sound like a good idea.

    However, I'm very much in favour of making imread a wrapper as thin as possible around imageio, to discard the rest of the API, and to make any further developments in imageio.

  10. sciunto commented on Oct 29, 2020

    @sciunto
    Member

    @emmanuelle I have similar feelings as yours. I would like to add also that some newcomers are lost partly because of the tool segmentation across libraries, which is a natural effect in FLOSS. Thus, I see sometimes scripts mixing pil/scikit-image/opencv merely by ignorance and I'm afraid that some users will search "how to load image in python", and use a library returning a format inappropriate for scikit-image and being lost.

    Few wrappers can help the users until they fully understand the machinery. We can also imagine a strategy saying that we regularly reconsider (through web log analysis / forum inspection) if maintaining the wrappers are still relevant.

  11. rfezzani commented on Oct 29, 2020

    @rfezzani
    Member

    I had multiple discussions with other core team members (cc @jni, @hmaarrfk 😉) about breaking changes etc... But I am still not convinced...
    People needing their scripts to keep working simply doesn't have to update skimage! Python environment are made to manage this... Our deprecation strategy is gentle enough to give users time to update their script if needed...
    We can also rely on our doc to educate new comers to good practices...
    I use to think that things evolves naturally, particularly in computer science, and that we don't have to worry much about breaking things... Users usually learn/adapt pretty fast to new behaviors 🙂.

  12. emmanuelle commented on Oct 29, 2020

    @emmanuelle
    Member

    In the dev meeting, Almar made an interesting suggestion:

    • rewrite our documentation to teach people how to use imageio (gallery examples in particular)
    • but keep io.imread as a thin wrapper to avoid breaking people's code.

    I would be very happy about this trade-off. Thoughts?

  13. rfezzani commented on Oct 29, 2020

    @rfezzani
    Member

    Keeping skimage.io.imread is not a big deal. Defining it as

    skimage.io.imread = imageio.imread

    doesn't hurt. My main concern is to keep warning users that it is not the right way to go and to not maintain code in skimage.io!

  14. rfezzani commented on Oct 29, 2020

    @rfezzani
    Member

    In other words, we must say to scikit-image users that IO is no more a target, and that we delegate this to imageio because it is dedicated to IO and it manage it way better then we may do.

  15. 43 remaining items

  16. added this to the 0.20 milestone on Feb 20, 2023
  17. stefanv commented on Feb 22, 2023

    @stefanv
    Member

    skimage.io is currently a thin wrapper around imageio that ensures that a NumPy array is returned. We don't plan to change this for the forthcoming release, so I'm bumping the milestone to 0.21.

  18. modified the milestones: 0.20, 0.21 on Feb 22, 2023
  19. modified the milestones: 0.21, 0.22 on May 19, 2023
  20. removed this from the 0.22 milestone on Oct 3, 2023
  21. moved this to To Do in skimage2on Aug 5, 2024
  22. changed the title [-]Discussion: deprecating (most of) skimage.io in favour of imageio[/-] [+]Deprecate (most of) skimage.io in favour of imageio[/+] on Mar 1, 2025
  23. added
    🥾 Path to skimage2
    on Mar 4, 2025
  24. moved this from To Do to To Triage in skimage2on Apr 21, 2025
  25. mkcor commented on Sep 8, 2025

    @mkcor
    Member

    I'll close this issue as superseded by #7353 and the discussion in Long-term plan for skimage.io plugin infrastructure referenced therein.

  26. moved this from To Triage to Done in skimage2on Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🥾 Path to skimage2📜 type: API💬 Discussion

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions