In [1]:
import matplotlib.image as mpim
In [2]:
img = mpim.imread('../data/fluid.png')
We end up with a 4-channel array with (R,G,B) values in the range [0, 1]:
In [3]:
img
Out[3]:
plt.imshow() interprets the multiple channels as (R,G,B) values, so don't bother passing a colourmap:
In [4]:
import matplotlib.pyplot as plt
%matplotlib inline
plt.imshow(img, cmap='gray')
plt.show()
In [5]:
from PIL import Image
In [6]:
img = Image.open('../data/fluid.png')
The repr() of a PIL Image object renders the actual image in the notebook:
In [7]:
img
Out[7]:
In [8]:
import numpy as np
i = np.array(img)
This time the array is represented as uint8 values, so [0,255].
In [9]:
i
Out[9]:
In [ ]: