title: Generating your own colormap in SciPy
body: <p>I'm using Python and Scipy to perform some basic image manipulation. I've made the image greyscale and subtracted it from a gaussian blur of itself as a form of edge detection. Now I'd like to make it look pretty when running the .imshow() command. If I use one of the default colormaps, for instance,</p>
  
  <pre><code>matplotlib.pyplot.imshow(lena, cmap='binary')
  </code></pre>
  
  <p>where lena is a matrix representing my image in question, the image appears washed out with a grey background. It looks quite a lot like <a href="http://homepages.inf.ed.ac.uk/rbf/HIPR2/images/fce2lap2.gif" rel="nofollow">this</a>.</p>
  
  <p>I would like the image to appear sharper, with only two real colors, white and black, and very little (or no) grey in between.</p>
  
  <p>Since none of the other default colormaps in SciPy can do this, I figured I should make my own. But I'm afraid I don't fully grasp the <a href="http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps" rel="nofollow">documentation</a> provided by scipy. </p>
  
  <p>So let's say I have the colormap from the tutorial:</p>
  
  <pre><code>cdict = {'red': ((0.0, 0.0, 0.0),
                   (0.5, 1.0, 0.7),
                   (1.0, 1.0, 1.0)),
           'green': ((0.0, 0.0, 0.0),
                     (0.5, 1.0, 0.0),
                     (1.0, 1.0, 1.0)),
           'blue': ((0.0, 0.0, 0.0),
                    (0.5, 1.0, 0.0),
                    (1.0, 0.5, 1.0))}
  
  my_cmap = matplotlib.colors.LinearSegmentedColormap('my_colormap', cdict, 256)
  matplotlib.pyplot.imshow(lena, cmap=my_cmap)
  </code></pre>
  
  <p>How should this look if I want the colormap to be exclusively white from range 0 to .5, and exclusively black from range .5 to 1? Thanks to everyone for the help!</p>