title: in OpenCV is mask a bitwise and operation
body: <p>I'm starting with opencv in python and I have a questions about how mask is applied for </p>
  
  <p><code>bitwise_and(src1, src2, mask=mask)</code></p>
  
  <p>Which of these describes the implementation:</p>
  
  <ul>
  <li><p>A. all bitwise, mask first</p>
  
  <ol>
  <li>src1 is ANDed with mask</li>
  <li>src2 is ANDed with mask</li>
  <li>what's left of src1 and src2 are ANDed together</li>
  </ol></li>
  <li><p>B. all bitwise, images first</p>
  
  <ol>
  <li>src1 is ANDed with src2</li>
  <li>result is ANDed with mask</li>
  </ol></li>
  <li><p>C. conditional AND</p>
  
  <ol>
  <li>mask is "iterated" through (eg a loop)</li>
  <li>for each pixel in mask, if it's nonzero, then corresponding pixels in src1,src2 are ANDed and copied to output</li>
  </ol></li>
  </ul>
  
  <p>I would think the performance characteristics of each could vary slightly.</p>
  
  <p>Which of these (or how else) is the actual implementation?  (and why, if I may ask)</p>
  
  <p>I was trying to look at the source, but couldn't quite make out what they did:
  <a href="https://github.com/opencv/opencv/blob/ca0b6fbb952899a1c7de91b909d3acd8e682cedf/modules/core/src/arithm.cpp" rel="nofollow noreferrer">https://github.com/opencv/opencv/blob/ca0b6fbb952899a1c7de91b909d3acd8e682cedf/modules/core/src/arithm.cpp</a></p>