title: Reading pixels data values from a bitmap image file
body: <p>here is the code i have written in c++</p>
  
  <pre><code>  int main()
     {
      Mat im = imread("C:/santhu/bitmap.bmp");
  
  int rows = im.rows;
     int cols = im.cols;
  
  cout&lt;&lt;"rows\n"&lt;&lt;rows;
  cout&lt;&lt;"cols"&lt;&lt;cols;
  
  if (im.empty()) 
   {
       cout &lt;&lt; "Cannot load image!" &lt;&lt; endl;
      return -1;
  }
  
  
  cout&lt;&lt;"the output for matrix of pixels";
  
  for (int i = 0; i &lt;cols ; i++)
  {
      Vec3b *ptr = im.ptr&lt;Vec3b&gt;(i);
      for (int j = 0; j &lt; rows; j++)
      {   
          Vec3b pixel = ptr[j];
          cout&lt;&lt;pixel&lt;&lt;"\t";
      }
      cout&lt;&lt;"\n";
  }
  
  getchar();
   imshow("Image", im);
  waitKey(0);
  }
  </code></pre>
  
  <p>the code works fine until it shows every pixels values in terms of
  <code>Vec3b</code>,but at last the exception like "<code>Unhandled exception at 0x75afb9bc in san.exe: Microsoft C++ exception: cv::Exception at memory location 0x0043f9d0..</code>" will come up in prompting windows asks to break or continue the flow </p>
  
  <p>And in command console, where i m getting the pixels values to be displayed, in this it's showing me as <code>opencv error:assertion failed(y==0 ||(data &amp;&amp; dims)=1 &amp;&amp;(unsigned) y &lt;(unsigned)size.p[0] in cv::Mat::ptr,file c:\opencv\build\include\opencv2\core\mat.hpp,line 428</code>, after displaying pixels data.</p>
  
  <p>i checked whole web and the <code>mat.hpp</code> also it's inline function given, so i'm frustrated,  can anyone plz explain abt this error(exception) and help me out to get code run only until the data pixels is their in bitmap and execute nicely.plz</p>