title: OpenCV & Python: How to decrease brightness using binary mask?
body: <p>I would like to darken one image based on the mask of an edge-detected second image.</p>
  
  <p><strong>Image 1: Original (greyscale) image</strong></p>
  
  <p><a href="https://i.stack.imgur.com/T1lHz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/T1lHz.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Image 2: Edge detected (to be used as mask)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/l1WMX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l1WMX.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Image 3: Failed example showing cv2.subtract processing</strong></p>
  
  <p><a href="https://i.stack.imgur.com/UYvqA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UYvqA.jpg" alt="enter image description here"></a></p>
  
  <p>In my <strong>failed</strong> example (Image 3), I subtracted the white pixels (255) from the original image but what I want to do is <strong>DARKEN</strong> the original image based on a mask of the edge detected image.</p>
  
  <p>In this article: <a href="https://stackoverflow.com/questions/32609098/how-to-fast-change-image-brightness-with-python-opencv">How to fast change image brightness with python + OpenCV?</a>, Bill Gates describes how he converts the image to HSV, splits out then modifies <em>Value</em>, and then finally merges back. This seems like a reasonable approach but I only want to modify the <em>Value</em> where the mask is white i.e. the edge exists.</p>
  
  <p>Ultimately, I am trying to <em>enhance</em> the edge of a low resolution thermal video stream in a similar way to the FLIR One VividIR technology.</p>
  
  <p>I believe that I've made it really far as a complete novice to image processing, OpenCV and Python but after days now of trying just about every function OpenCV offers, I've got myself stuck.</p>