title: Match two images almost pixel-perfectly, but be able to match only slightly darker brightness values with OpenCV?
body: <p>I am trying to compare two images with cv2, <code>tile</code> and <code>tlcropped</code>. It works, but as long as the two images are pixel-perfect and color value-perfect.</p>
  
  <p>I want it to be pixel-perfect, but thing is... I don't want it to have to be the exact same color value, but the closest one. I am trying to compare tiles in these two images:</p>
  
  <p><strong>The screenshot</strong></p>
  
  <p><a href="https://i.stack.imgur.com/OV5JJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OV5JJ.png" alt="The screenshot"></a></p>
  
  <p><strong>The tile itself</strong></p>
  
  <p><a href="https://i.stack.imgur.com/YYDvU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YYDvU.png" alt="The tile itself"></a></p>
  
  <p>But, the screenshots have very slightly darker RGB values compared to the stand-alone tile picture. How would I get it to stay pixel-perfect but match at least slightly different brightness values, but not enough to get the wrong tile? Been thinking about this for a while now and haven't been able to come up with a good solution yet.</p>
  
  <p>(I'm using cv2, not cv.)
  Here's my comparison code right now, by the way, if you want it:</p>
  
  <pre><code>for tileN in range(1, tilecount):
      tilePosY = tileN*h;
  
      tlcropped = tlset[ tilePosY: tilePosY+16,   0: w]
  
      if ((tile==tlcropped).all()):
          match_found = True
          break;
  </code></pre>