title: How can I read the RGB 10 bit raw image?
body: <p>I have read a <a href="https://stackoverflow.com/questions/39623001/how-can-i-read-10-bit-raw-image-which-contain-rgb-ir-data">post</a> with a similar question, but actually doesn't work for me. His image's resolution is 1280x720, file size is 1,843,200 bytes. The camera store 10 bits meta data into 16 bits space for each pixel. Although it is not containing true 16 bits data, but a linear stretching can do the job. What a real 10-bit format raw image is probably encoded like <a href="https://i.stack.imgur.com/bvfrY.png" rel="nofollow noreferrer">this</a>.</p>
  
  <p>My raw image is from OV5670 camera and output format is red in R1C2 (GRBG, not 100% sure, the driver is set in that way). Resolution is 1920x1080, size of the file: 2,592,000 bytes. Each pixel is exactly 10 bits.</p>
  
  <p>Question: How can I decode it with Matlab or Python? The main problem is I don't know how the pixels are arranged as the specification didn't mention the pixels are in 2d array or 1d array.</p>
  
  <p><a href="https://drive.google.com/file/d/0B-LYEo0KAmhET2JZNDQwa3NmWFRERHpOQVJZSjNhb3o2SVM4/view?usp=sharing" rel="nofollow noreferrer">Download the raw file</a>. (The driver doesn't have exposure control feature, the actual image might be over exposure)</p>
  
  <p>EDITED: Here is the correct image from imatest software<a href="https://i.stack.imgur.com/pU89h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pU89h.jpg" alt="enter image description here"></a></p>
  
  <p>The structure of the sensor pixel is:</p>
  
  <pre><code>╔═══════╦═══════╦═══════╦═══════╗
  ║  B G  ║  ...  ║       ║ 8 act ║
  ║  G R  ║  ...  ║       ║ dummy ║
  ╠═══════╬═══════╬═══════╬═══════╣
  ║  ...  ║       ║       ║ 1944  ║
  ║  ...  ║       ║       ║ active║
  ╠═══════╬═══════╬═══════╬═══════╣
  ║       ║       ║       ║ 8 act ║
  ║       ║       ║       ║ dummy ║
  ╠═══════╬═══════╬═══════╬═══════╣
  ║       ║       ║       ║  20   ║
  ║       ║       ║       ║  blk  ║
  ╠═══════╬═══════╬═══════╬═══════╣
  ║16 act ║ 2592  ║ 16    ║       ║
  ║ dummy ║active ║ dummy ║       ║
  ╚═══════╩═══════╩═══════╩═══════╝
  </code></pre>
  
  <p>I have the datasheet but it is confidential. The pixel is format like my graph above. Act means active lines, blk means black lines. The subsampling is using 2x2 binning.</p>
  
  <p>The datasheet is confidential and there is no public doc on internet. I posted a little portion about it hopefully</p>