title: finding colors in Image and redraw on second image(using numpy)
body: <p>I am trying to find specific colors(or more likely ranges of colors) in a picture and redraw the coordinates on a second picture for further investigation. Since I read a lot about how great numpy is, I started using that(I am pretty new with python and especially numpy).
  So, I wrote something, that works good with one color, but has it's (performance-)problems with a lot of color and I am pretty sure, I can solve that, by using more functions that numpy provides. Basically, I want to kill the for-loops. That's my code(I have to add more ranges of colors later):</p>
  
  <pre><code>import PIL, numpy
  from PIL import Image
  
  def add_color_range(p_a_c, r,r1,g,g1,b,b1):
      for ir in range(r, r1+1):
          for ig in range(g, g1+1):
              for ib in range(b, b1+1):
                  p_a_c.extend([[ir,ig,ib]])
      return p_a_c
  
  for i in range(1):
      im = Image.open('%*s.bmp'% (1, i))
      n_test = numpy.asarray(im)
      ni_test = numpy.zeros([1050,1680,3],dtype=numpy.uint8)
      ni_test.fill(255)
      c=[]
      c=add_color_range(c,5,10,5,10,5,10)
  
      for ic in range(len(c)):
          ind=numpy.where(numpy.all(n_test==c[ic],  axis=-1))
          for ii in range(len(ind[0])):
              ni_test[ind[0][ii],ind[1][ii]]=[0,0,0]
      im_test = Image.fromarray(ni_test, 'RGB')
      im_test.save('test_%*s.bmp'% (1, i))
  </code></pre>