title: OpenCV: read matrix value
body: <p>I want to count the number of white points in a background image which is only black and white. I have a code like this:</p>
  
  <pre><code>int count = 0; 
  for ( int j = 0; j &lt; Image.rows; j ++ )
      {
      for ( int i = 0; i &lt; Image.cols; i ++ )
          {
              if ( Image.at&lt;int&gt;(i,j) &gt;= 150 )
              {
                  count ++ ;
              }
          }
      }
  </code></pre>
  
  <p>For some reason, the above code doesn't work, it just stops reacting. I checked, and the line" if ( Image.at(i,j) >= 150 ) " causes the problem. My "Image" is a "cv::Mat", with "CV_8UC3" type. Is there someone can help me? Thank you. </p>