title: convert image (np.array) to binary image
body: <p>Thank you for reading my question. </p>
  
  <p>I am new to python and became interested in scipy. I am trying to figure out how I can make the image of the Racoon (in scipy misc) to a binary one (black, white). This is not taught in the scipy-lecture tutorial.  </p>
  
  <p>This is so far my code:</p>
  
  <pre><code>%matplotlib inline
  import matplotlib.pyplot as plt
  import numpy as np 
  from scipy import misc  #here is how you get the racoon image
  
  face = misc.face()
  image = misc.face(gray=True)
  plt.imshow(image, cmap=plt.cm.gray)
  print image.shape 
  
  def binary_racoon(image, lowerthreshold, upperthreshold):
      img = image.copy()
      shape = np.shape(img)
  
      for i in range(shape[1]):
          for j in range(shape[0]): 
               if img[i,j] &lt; lowerthreshold and img[i,j] &gt; upperthreshold:
                   #then assign black to the pixel
               else:
                   #then assign white to the pixel
  
      return img
  
      convertedpicture = binary_racoon(image, 80, 100) 
      plt.imshow(convertedpicture, cmap=plt.cm.gist_gray)
  </code></pre>
  
  <p>I have seen other people using OpenCV to make a picture binary, but I am wondering how I can do it in this way by looping over the pixels? I have no idea what value to give to the upper and lower threshold, so I made a guess of 80 and 100. Is there also a way to determine this? </p>