Quantcast

Writing 16 bit images to disk

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Writing 16 bit images to disk

Brigit Schroeder
Hi there,

See this page with documentation on imwrite:

http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html


For 16-bit grayscale, you should also try using PNG format or Jpeg (only if
you just want to view it and don't care about retrieving disparity values
from it later on).

In the future, it would be helpful to post snippets of code, and also look
for examples online.

thanks,
brigit


[Non-text portions of this message have been removed]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Writing 16 bit images to disk

John McDonald
Hi Brigit,

Sorry, should have posted some code, however it's pretty straightforward:
cv::StereoBM _stereoBM;
...
this->_stereoBM(_leftRectifiedGrayFrame, _rightRectifiedGrayFrame,
_disparityMap);
int type = disp16.type(); // for debugging purposes...type==3==CV_16S
cv::imwrite("disp16.tiff",disp16);

I have tried tiff, pgm, and png. As I want to import the data into other
apps for computation I don't want lossy compression. All seem to save in
8 bit...or at least that's what octave/gimp tell me. I can always just
write out a raw binary file, but then I need to write some code to read
that back in, which screws up portability.

I did google this before posting, but none of what I found helped i.e.
most was simply a rehash of the docs which I interpreted to mean that
imwrite would hold the 16 bit nature of the data as long as I used the
prescribed formats. This doesn't seem to be the case.

Regards,
John.

brigit wrote:

>
> Hi there,
>
> See this page with documentation on imwrite:
>
> http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html 
> <http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html>
>
> For 16-bit grayscale, you should also try using PNG format or Jpeg
> (only if
> you just want to view it and don't care about retrieving disparity values
> from it later on).
>
> In the future, it would be helpful to post snippets of code, and also look
> for examples online.
>
> thanks,
> brigit
>
> [Non-text portions of this message have been removed]
>
>



------------------------------------

Change settings: http://www.yahoogroups.com/mygroups, select
   Get Emails (get all posts)
   Daily Digest (one summary email per day)
   Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email]
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/OpenCV/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/OpenCV/join
    (Yahoo! ID required)

<*> To change settings via email:
    [hidden email]
    [hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Writing 16 bit images to disk

Samuel Audet
On 2010-02-05 07:20, John McDonald wrote:

> I have tried tiff, pgm, and png. As I want to import the data into other
> apps for computation I don't want lossy compression. All seem to save in
> 8 bit...or at least that's what octave/gimp tell me. I can always just
> write out a raw binary file, but then I need to write some code to read
> that back in, which screws up portability.
>
> I did google this before posting, but none of what I found helped i.e.
> most was simply a rehash of the docs which I interpreted to mean that
> imwrite would hold the 16 bit nature of the data as long as I used the
> prescribed formats. This doesn't seem to be the case.

The OpenEXR format will work for that, but it is not enabled by default
in OpenCV 2.0. You have to manually enable it inside src/highgui/_highgui.h

Samuel


------------------------------------

Change settings: http://www.yahoogroups.com/mygroups, select
   Get Emails (get all posts)
   Daily Digest (one summary email per day)
   Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email]
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/OpenCV/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/OpenCV/join
    (Yahoo! ID required)

<*> To change settings via email:
    [hidden email]
    [hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Writing 16 bit images to disk

Brigit Schroeder
In reply to this post by John McDonald


When using OpenCV I have always used cvSaveImage(...) -  see the code  
snippet below.
In this application 'image' was a jpeg also.

cvShowImage(“mywindow”, image);
cvSaveImage(“c:\img1.jpg”,image);

Have you considered endianess? Png supports big endian format  -  
opposite of most PC's
which are little endian. In that case the pixel values would be  
inverted, although I am not sure
what the image would look like.

Your disparity map looks some of the maps I've seen examples of online  
for opencv. What is the
range of your disparity values? Areas of your scene which are closer  
should have a larger disparity
and therefore be brighter in color (e.g. white), and then fade  
gradually as the disparity gets smaller.  Here is an
example of a good disparity map done with matlab:

http://robots.stanford.edu/cs223b05/images/real7.disparity.jpg


Hope this helps -
brigit

On Feb 4, 2010, at 5:20 PM, John McDonald wrote:

> Hi Brigit,
>
> Sorry, should have posted some code, however it's pretty  
> straightforward:
> cv::StereoBM _stereoBM;
> ...
> this->_stereoBM(_leftRectifiedGrayFrame, _rightRectifiedGrayFrame,
> _disparityMap);
> int type = disp16.type(); // for debugging purposes...type==3==CV_16S
> cv::imwrite("disp16.tiff",disp16);
>
> I have tried tiff, pgm, and png. As I want to import the data into  
> other
> apps for computation I don't want lossy compression. All seem to  
> save in
> 8 bit...or at least that's what octave/gimp tell me. I can always just
> write out a raw binary file, but then I need to write some code to  
> read
> that back in, which screws up portability.
>
> I did google this before posting, but none of what I found helped i.e.
> most was simply a rehash of the docs which I interpreted to mean that
> imwrite would hold the 16 bit nature of the data as long as I used the
> prescribed formats. This doesn't seem to be the case.
>
> Regards,
> John.
>
> brigit wrote:
>>
>> Hi there,
>>
>> See this page with documentation on imwrite:
>>
>> http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html
>> <http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html 
>> >
>>
>> For 16-bit grayscale, you should also try using PNG format or Jpeg
>> (only if
>> you just want to view it and don't care about retrieving disparity  
>> values
>> from it later on).
>>
>> In the future, it would be helpful to post snippets of code, and  
>> also look
>> for examples online.
>>
>> thanks,
>> brigit
>>
>> [Non-text portions of this message have been removed]
>>
>>
>
>
>
> ------------------------------------
>
> Change settings: http://www.yahoogroups.com/mygroups, select
>   Get Emails (get all posts)
>   Daily Digest (one summary email per day)
>   Read on the web (read posts on the web only)Or Unsubscribe by  
> mailing [hidden email]
> Yahoo! Groups Links
>
>
>



------------------------------------

Change settings: http://www.yahoogroups.com/mygroups, select
   Get Emails (get all posts)
   Daily Digest (one summary email per day)
   Read on the web (read posts on the web only)Or Unsubscribe by mailing [hidden email]
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/OpenCV/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/OpenCV/join
    (Yahoo! ID required)

<*> To change settings via email:
    [hidden email]
    [hidden email]

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Loading...