title: What is wrong with this code to retrieve bgr values of an image using the step method
body: <p>Here is the code I got from a reputable source but its not working:</p>
  
  <pre><code>    Mat img = imread("/home/w/d1",CV_LOAD_IMAGE_COLOR);
          unsigned char *input = (unsigned char*)(img.data);
  
         int i,j,r,g,b;
          for(int i = 0;i &lt; img.rows ;i++){
                  for(int j = 0;j &lt; img.cols ;j++){
                      b = input[img.step * j + i ] ;
                      g = input[img.step * j + i + 1];
                      r = input[img.step * j + i + 2];
              cout &lt;&lt; b &lt;&lt; g &lt;&lt;r;
                  }
              }
  </code></pre>
  
  <p>When I run it the output isn't the same as when I do a cout &lt;&lt; img;
  I think it might be something to do with the new C++ interface. If that is so and I'm supposed to use the step1 method, can some one show me how to update my code to access BGR values with the step1 method. I couldn't find online doc. on how to use step1. Thanks in advance for any help.</p>