title: Convert all white pixels in the image into black pixels
body: <p>I have this image <code>rand-walk-2.png</code></p>
  
  <p><img src="https://i.imgur.com/6xrMPSs.png" alt="rand-walk-2.png"></p>
  
  <p>I would like to convert all the white pixels to black pixels, so that there is a picture of a <em>red random walk</em> over a black background, this means I cannot just invert the colors of image. My current code simply finds the white pixels and set them to black:</p>
  
  <pre><code>from PIL import Image
  import PIL.ImageOps    
  import numpy as np
  from skimage.io import imsave
  import cv2
  
  
  in_path  = 'rand-walk-2.png'
  out_path = 'rand-walk-trial.png'
  
  
  Image = cv2.imread(in_path)
  Image2 = np.array(Image, copy=True)
  
  white_px = np.asarray([255, 255, 255])
  black_px = np.asarray([0  , 0  , 0  ])
  
  (row, col, _) = Image.shape
  
  for r in xrange(row):
      for c in xrange(col):
          px = Image[r][c]
          if all(px == white_px):
              Image2[r][c] = black_px
  
  imsave(out_path, Image2)
  </code></pre>
  
  <p>But it produces this:</p>
  
  <p><img src="https://i.imgur.com/brp4kZL.png" alt="rand-walk-trial.png"></p>
  
  <p>for some reason I cannot explain. </p>