title: Python - Applying a color map to a grayscale numpy array and converting it to an image
body: <p>I want to achieve the gradient mapping effect that's available in Photoshop. <a href="https://stackoverflow.com/questions/10050344/opencv-how-to-apply-rainbow-gradient-map-on-an-image">There's already a post that explains the desired outcome.</a> Also, <a href="https://stackoverflow.com/a/10967471/1574632">this answer</a> covers exactly what I want to do, however </p>
  
  <pre><code>im = Image.fromarray(np.uint8(cm.gist_earth(myarray)*255))
  </code></pre>
  
  <p>is not working for me since I don't know how to normalize the array to values of 1.0.</p>
  
  <p>Below is my code as I intend for it to work.</p>
  
  <pre><code>im = Image.open(filename).convert('L') # Opening an Image as Grayscale
  im_arr = numpy.asarray(im)             # Converting the image to an Array 
  
  # TODO - Grayscale Color Mapping Operation on im_arr
  
  im = Image.fromarray(im_arr)
  </code></pre>
  
  <p>Can anyone indicate the possible options and ideal way to apply a color map to this array? I don't want to plot it as there doesn't seem to be a simple way to convert a pyplot figure to an image.</p>
  
  <p>Also, can you point out how to normalize the array since I'm unable to do so and can't find help anywhere. </p>