In [16]:
from scipy import ndimage
import numpy as np

In [2]:
from scipy import misc

In [3]:
f = misc.face()

In [4]:
misc.imsave('face.png', f)

In [7]:
import matplotlib.pyplot as plt
%matplotlib inline

In [8]:
plt.imshow(f)


Out[8]:
<matplotlib.image.AxesImage at 0xb7600fa438>

In [9]:
face = misc.face()

In [10]:
misc.imsave('face.png', face)

In [11]:
face = misc.imread('face.png')

In [12]:
type(face)


Out[12]:
numpy.ndarray

In [13]:
face.shape, face.dtype


Out[13]:
((768, 1024, 3), dtype('uint8'))

In [14]:
face.tofile('face.raw')

In [18]:
face_from_raw = np.fromfile('face.raw', dtype=np.uint8)

In [19]:
face_from_raw.shape


Out[19]:
(2359296,)

In [20]:
face_from_raw.shape = (768, 1024,3)

In [21]:
face_memmap = np.memmap('face.raw', dtype=np.uint8, shape=(768, 1024, 3))

In [ ]: