title: Image erosion and dilation with Scipy
body: <p>I am trying to use scipy to do <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.morphology.binary_erosion.html" rel="noreferrer">erosion</a> and <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.morphology.binary_dilation.html" rel="noreferrer">dilation</a> of an image. It seems pretty straightforward using scipy -> <code>binary_erosion / dialation</code>. However, the output is not at all what is expected.</p>
  
  <p>Here is my basic code:</p>
  
  <pre><code>import scipy
  from scipy import ndimage
  import matplotlib.pyplot as plt
  import numpy as np
  import Image
  
  #im = Image.open('flower.png')
  im = ndimage.imread('flower.png')
  im = ndimage.binary_erosion(im).astype(np.float32)
  scipy.misc.imsave('erosion.png', im)
  
  
  im2 = Image.open('flower.png')
  im2 = ndimage.binary_dilation(im2)
  scipy.misc.imsave('dilation.png', im2)
  </code></pre>
  
  <p>This is the output:</p>
  
  <p><img src="https://i.stack.imgur.com/8qlqi.png" alt="enter image description here"></p>
  
  <p>The output for dilation is just a completely white image for the original "flower.png"</p>
  
  <p>I believe that I must specify a better kernel or mask but am not really sure why I am getting a green output for erosion and completely white output for dilation. </p>