title: Best way to indexing a matrix in opencv
body: <p>Let say, <code>A</code> and <code>B</code> are matrices of the same size.
  In <code>Matlab</code>, I could use simple indexing as below.</p>
  
  <pre><code>idx = A&gt;0;
  B(idx) = 0
  </code></pre>
  
  <p>How can I do this in <code>OpenCV</code>? Should I just use </p>
  
  <pre><code>for (i=0; ... rows)
      for(j=0; ... cols)
          if (A.at&lt;double&gt;(i,j)&gt;0) B.at&lt;double&gt;(i,j) = 0;
  </code></pre>
  
  <p>something like this? Is there a better (faster and more efficient) way?</p>
  
  <p>Moreover, in <code>OpenCV</code>, when I try</p>
  
  <pre><code>Mat idx = A&gt;0;
  </code></pre>
  
  <p>the variable <code>idx</code> seems to be a <code>CV_8U</code> matrix (not boolean but integer). </p>