title: Sum a stack of images
body: <p>I have a stack of images and I am looking for a way to </p>
  
  <ul>
  <li>load the first ten images;</li>
  <li>sum the corresponding arrays;</li>
  <li>plot the result of the sum.</li>
  </ul>
  
  <p>With two images, the code looks like</p>
  
  <pre><code>import matplotlib
  from pylab import *
  import numpy as np
  import matplotlib.pyplot as plt
  import matplotlib.cm as cm
  from PIL import Image
  
  filename_1 = ('images/image_001.txt')
  filename_2 = ('images/image_002.txt')
  matrix_1 = np.loadtxt(filename_1)
  matrix_2 = np.loadtxt(filename_2)
  matrix = (matrix_1 + matrix_2)
  plt.imshow(matrix, cmap = cm.Greys_r, interpolation='none')
  plt.show()
  </code></pre>
  
  <p>How would you extend it to a loop?</p>