title: OpenCV unable to write Images using imwrite
body: <p>I am trying to write a Mat format which I have created into a jpeg file but all I'm getting is an unhandled exception. From the documentation it says that</p>
  
  <blockquote>
    <p>Only 8-bit (or 16-bit unsigned (CV_16U) in case of PNG, JPEG 2000, and TIFF) single-channel or 3-channel (with ‘BGR’ channel order) images can be saved using this function.</p>
  </blockquote>
  
  <p>So I created a Mat using the codes below:</p>
  
  <pre><code>Mat watermark(5,5,CV_16U);  
  imwrite("C:\\watermark.jpg",watermark);
  </code></pre>
  
  <p>However, I am unable to write the image into jpeg. It works fine with BMP formats, but just not JPG or any other formats. I was advised to convert it to CV_16U or 8U but it didn't work as well and I do have write permissions to the C:\ directory. </p>
  
  <p>Am I missing a step?  Or is there some other way I should go about saving an image into JPG using OpenCV?</p>