Reading and writing an elephant

Read and write images

import numpy as np
import matplotlib.pyplot as plt

original figure

plt.figure()
img = plt.imread('../../../data/elephant.png')
plt.imshow(img)
../../../_images/sphx_glr_plot_elephant_001.png

red channel displayed in grey

plt.figure()
img_red = img[:, :, 0]
plt.imshow(img_red, cmap=plt.cm.gray)
../../../_images/sphx_glr_plot_elephant_002.png

lower resolution

plt.figure()
img_tiny = img[::6, ::6]
plt.imshow(img_tiny, interpolation='nearest')
plt.show()
../../../_images/sphx_glr_plot_elephant_003.png

Total running time of the script: ( 0 minutes 0.038 seconds)

Gallery generated by Sphinx-Gallery