title: OpenCV (C++): how to save a 16bit image?
body: <p>I'm working with kinect, and I need to save RAW depth image. This means that I shouldn't save it with a conversion to 8 bit (that is what imwrite is doing!) but save it as 16 bit, without have any bit-depth reducing. I hope that this question will not be too trivial, but I'm new to OpenCV programming. I tried the following, but it doesn't work:</p>
  
  <pre><code>[...]
  
  Mat imageDepth ( 480, 640, CV_16UC1 );
  Mat imageRGB;
  
  // Video stream settings
  VideoCapture capture;
  capture.open( CAP_OPENNI );
  
  if ( !capture.isOpened() ) {
    cerr &lt;&lt; "Cannot get video stream!" &lt;&lt; endl;
    exit ( EXIT_WITH_ERROR );
  }
  
  if ( !capture.grab() ) {
    cerr &lt;&lt; "Cannot grab images!" &lt;&lt; endl;
    exit ( EXIT_WITH_ERROR );
  }
  
  // Getting frames
  if ( capture.retrieve( imageDepth, CAP_OPENNI_DISPARITY_MAP ) ) {
    imwrite( fileDepth, imageDepth );
  }
  if( capture.retrieve( imageRGB, CAP_OPENNI_BGR_IMAGE ) ) {
    imwrite( fileRGB, imageRGB );
  }
  
  return EXIT_WITH_SUCCESS;
  </code></pre>
  
  <p>Thanks in advance.</p>