8000 [Doc]: Suggestion to use PIL.image.open is not a 1:1 replacement for imread · Issue #21474 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content {"props":{"docsUrl":"https://docs.github.com/get-started/accessibility/keyboard-shortcuts"}}
[Doc]: Suggestion to use PIL.image.open is not a 1:1 replacement for imread #21474
Closed
@Debilski

Description

@Debilski

Documentation Link

https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imread.html

Problem

Following the deprecation message in matplotlib.pyplot.imread (when used with a URL) and trying to replace the code as suggested with PIL.Image.open(urllib.request.urlopen(url)), the resulting object is a PIL image object and not a numpy array as it used to be. As we are typically suggesting imread to create a numpy array from an image file (or URL) in some of our teaching materials, this is a bit confusing.

This is probably not a problem for matplotlib itself, as it can perfectly deal with the PIL object in eg. imshow, therefore I don’t know if it needs to be changed (it could be out of scope for the matplotlib documentation to clarify this).

Suggested improvement

Additionally present code that shows how to transform the PIL image object into an array.

Matplotlib Version

3.4.3

Matplotlib documentation version

3.4.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Proj 384A ects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0