title: Python OpenCV - apply colored mask to image
body: <p>I got the following things:</p>
  
  <ul>
  <li>an Image read with OpenCV (numpy array) </li>
  <li>a binary mask of the same size as the image </li>
  <li>a color string like <code>'red'</code>,<code>'blue'</code>, etc</li>
  </ul>
  
  <p><strong>Q</strong>: how do i color the mask before i add it to the image?
  explicitly: how do i add color channels to a binary mask given a color string</p>
  
  <p>I know how to add the mask (for example with <code>cv2.addWeighted(mask,alpha,image,1-alpha,0,image)</code> ) , but i dont know how to convert the binary mask to color space with a simple color 'string' as input. I know this works in PIL with <code>rgb = PIL.ImageColor.getrgb(color)</code>, but i dont know how to do this with OpenCV!</p>
  
  <p><strong>EDIT</strong>:
  i managed to get the colors in channel tuples (0,0,0) and currently my workaround is:</p>
  
  <pre><code>mask = cv2.cvtColor(mask, cv2.COLOR_GRAY2RGB)
  mask[np.where((mask == [1,1,1]).all(axis = 2))] = color
  cv2.addWeighted(mask,alpha,image,1-alpha,0,image)
  </code></pre>
  
  <p>but the problem is, now the image is greyscale with a colored map...
  So the first line needs to be exchanged</p>