Skip to content

matplotlib.pyplot.imread silently fails on uint16 images. #3616

@jni

Description

@jni

It assumes the image is uint8 and incorrectly wraps the input at 255:

In [1]: from skimage import io

In [15]: io.imsave('io3.png', np.array([[0, 1], [0, 4196]], dtype=np.uint16),
            plugin='pil')

In [19]: from matplotlib.pyplot import imread

In [20]: imread('io3.png')
Out[20]: 
array([[ 0.        ,  0.00392157],
       [ 0.        ,  0.39215687]], dtype=float32)

In [21]: import matplotlib as mpl

In [22]: mpl.__version__
Out[22]: '1.3.1'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions