title: OpenCV vs Matlab : Different Values on pixels with imread
body: <p>I have encountered a problem with the function <code>imread()</code> in Matlab (2014) and OpenCV (3.0) on Windows 7 with jpg files.</p>
  
  <p>I don't have the same values by reading the same file jpg and the same pixel.</p>
  
  <p>Here are my 2 codes : (OpenCV code followed by the Matlab code) and the values I have (mode debug to see in OpenCV, keyboard in Matlab)</p>
  
  <pre><code>#include &lt;opencv2\opencv.hpp&gt;
  #include &lt;cstdio&gt;
  
  using namespace cv;
  using namespace std;
  
  int main()
  {
       Mat img = imread("test.jpg");
  
       uchar pb = img.at&lt;Vec3b&gt;(0, 0).val[0];
       uchar pg = img.at&lt;Vec3b&gt;(0, 0).val[1];
       uchar pr = img.at&lt;Vec3b&gt;(0, 0).val[2];
  
       int d = img.depth();
  
       int t = img.type();
  }
  </code></pre>
  
  <p>Values : </p>
  
  <pre><code>     pixel [0,0] = (147,174,204); // = index(1,1) in the image.
       d = 0;
       t = 16;
  </code></pre>
  
  <p>Code Matlab :</p>
  
  <pre><code>img = imread('test.jpg');
  
  img(1,1,:)
  
  whos img
  </code></pre>
  
  <p>Values :</p>
  
  <pre><code>ans(:,:,1) =
  148
  
  ans(:,:,2) =
  174
  
  ans(:,:,3) =
  201
  
  Name         Size                   Bytes  Class    Attributes
  img       1920x2560x3            14745600  uint8     
  </code></pre>
  
  <p>Have you any idea why values are different? </p>
  
  <p>I have seen on another post a problem like this but the person did not have the same depth by reading a tiff. Here as you can see I have the same depth !</p>
  
  <p>Thank you in advance and sorry for any English mistake.</p>
  
  <p>PS: I have test with other pixels too, same results : closed results but not exactly equals. </p>