title: Overlay an image segmentation with numpy and matplotlib
body: <p>I am trying to overlay two images. The first one is a 512x512 NumPy array (from a CT image). The second one is also a 512x512 NumPy array but I am just interested in the pixels where the value is larger than 0 (a functional image).</p>
  
  <p>To do that I am trying to create a masked array.  </p>
  
  <pre><code>import numpy as np 
  import numpy.ma as ma
  import matplotlib.pyplot as plt
  
  # Both images are loaded from a dicom. Both are numpy arrays of (512,512) 
  Image1 = readimage(path)
  Image2 = readimage(path)
  # Create image 2 mask
  mask = ma.masked_where(Image2&gt;0, Image2)
  Image2_mask = ma.masked_array(Image2,mask)
  
  # Plot images
  plt.figure(dpi=300)
  y, x = np.mgrid[1:513,1:513]
  plt.axes().set_aspect('equal', 'datalim')
  plt.set_cmap(plt.gray())
  plt.pcolormesh(x, y, Image1,cmap='gray')
  plt.pcolormesh(x, y, Image2_mask,cmap='jet')
  plt.axis([x.min(), x.max(), y.min(), y.max()])
  plt.colorbar()
  plt.show()
  </code></pre>
  
  <p>This code does not show any overlay. What I am doing wrong? Is there any straight way? I am coming from a Matlab environment and I am quite new to Python.</p>