title: How to create a mask for all relatively white parts of an image using numpy?
body: <p>Say I have 2 white images (RGB 800x600 image) that is 'dirty' at some unknown positions, I want to create a final combined image that has all the dirty parts of both images.</p>
  <p>Just adding the images together reduces the 'dirtyness' of each blob, since I half the pixel values and then add them (to stay in the 0-&gt;255 rgb range), this is amplified when you have more than 2 images.</p>
  <p>What I want to do is create a mask for all relatively white pixels in the 3 channel image, I've seen that if all RGB values are within 10-15 of each other, a pixel is relatively white. How would I create this mask using numpy?</p>
  <p>Pseudo code for what I want to do:</p>
  <pre><code>img = cv2.imread(img) #BGR image
  mask = np.where( BGR within 10 of each other)
  </code></pre>
  <p>Then I can use the first image, and replace pixels on it where the second picture is not masked, keeping the 'dirtyness level' relatively dirty. (I know some dirtyness of the second image will replace that of the first, but that's okay)</p>
  <p>Edit:
  People asked for images so I created some sample images, the white would not always be so exactly white as in these samples which is why I need to use a 'within 10 BGR' range.</p>
  <p>Image 1
  <a href="https://i.stack.imgur.com/tEMNO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tEMNO.jpg" alt="Image 1" /></a></p>
  <p>Image 2
  <a href="https://i.stack.imgur.com/2fv2Q.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2fv2Q.jpg" alt="Image 2" /></a></p>
  <p>Image 3 (combined, ignore the difference in yellow blob from image 2 to here, they should be the same)
  <a href="https://i.stack.imgur.com/HbHjK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HbHjK.jpg" alt="Image 3" /></a></p>