This is documentation for an old release of SciPy (version 0.10.1). Read this page in the documentation of the latest stable release (version 1.15.1).
Save an array as an image.
Parameters : | filename : str
image : ndarray, MxN or MxNx3 or MxNx4
|
---|
Examples
Construct an array of gradient intensity values and save to file:
>>> x = np.zeros((255, 255))
>>> x = np.zeros((255, 255), dtype=np.uint8)
>>> x[:] = np.arange(255)
>>> imsave('/tmp/gradient.png', x)
Construct an array with three colour bands (R, G, B) and store to file:
>>> rgb = np.zeros((255, 255, 3), dtype=np.uint8)
>>> rgb[..., 0] = np.arange(255)
>>> rgb[..., 1] = 55
>>> rgb[..., 2] = 1 - np.arange(255)
>>> imsave('/tmp/rgb_gradient.png', rgb)