title: read pixel value in C++ (OpenCV)
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4742251/pixel-access-in-opencv-2-2">Pixel access in OpenCV 2.2</a>  </p>
  </blockquote>
  
  
  
  <p>I was wondering how would I read a pixel value (in integer/float format) in C++ using Mat class?</p>
  
  <p>Lots of people have asked the same question, but there are no specific WORKING answers for this.</p>
  
  <p>I have the following code which compiles but gives NO proper result.</p>
  
  <pre><code>void Block(cv::Mat &amp;image)
  {
      for(int row = 0; row &lt; image.rows; ++row)
      {
  
          for (int col = 0; col &lt; image.cols; ++col)
       {
              cout&lt;&lt;image.at&lt;int&gt;(row, col)&lt;&lt;endl ;
  
          }
      }
  
  }
  </code></pre>
  
  <p>The above code prints garbage values.</p>