Search code examples
pythonnumpypython-imageio

Why does imageio.imread sometimes return an `imageio.core.util.Array` instead of a numpy array?


In the docs for imageio it says that imageio.imread returns a numpy array. This has been my experience most of the time, but sometimes it returns an imageio.core.util.Array object. imageio.core.util.array is only mentioned once in the imageio documentation, and just noted that imageio.core.Image is an alias of it. I don't have a small example to provide because I only see it when I'm loading certain images, but I found that it happens in the scipy image processing guide.


Solution

  • imageio.core.util.Array is a subclass of the NumPy array, so it is correct to say that imread returns a NumPy array. You can find the source code for Array at https://github.com/imageio/imageio/blob/efc560c514409e6425e2d7a839b4904b3d918fcf/imageio/core/util.py#L111.