Transitioning from Scipy’s imread#

Scipy has depreciated their image I/O functionality.

This document is intended to help people coming from Scipy to adapt to ImageIO’s imread function. We recommend reading the user api and checking out some examples to get a feel of ImageIO.

ImageIO makes use of a variety of backends to support reading images (and volumes/movies) from many different formats. One of these backends is Pillow, which is the same library as used by Scipy’s imread. This means that all image formats that were supported by scipy are supported by ImageIO. At the same time, Pillow is not the only backend of ImageIO, and those other backends give you give you access to additional formats. To manage this, ImageIO automatically selects the right backend to use based on the source to read (which you can of course control manually, should you wish to do so).

In short terms: In most places where you used Scipy’s imread, ImageIO’s imread is a drop-in replacement and ImageIO provides the same functionality as Scipy in these cases. In some cases, you will need to update the keyword arguments used.

  • Instead of mode, use the pilmode keyword argument.

  • Instead of flatten, use the as_gray keyword argument.

  • The documentation for the above arguments is not on imread, but on the docs of the individual plugins, e.g. Pillow.

  • ImageIO’s functions all return numpy arrays, albeit as a subclass (so that meta data can be attached).