Re: C : how to export raw YUV to a file ?
From: Arthur J. O'Dwyer (ajo_at_nospam.andrew.cmu.edu)
Date: 10/06/04
- Next message: Developwebsites: "Re: Beginner, Which language"
- Previous message: Developwebsites: "Re: Beginner, Which language"
- In reply to: DEMAINE Benoit-Pierre: "C : how to export raw YUV to a file ?"
- Next in thread: DEMAINE Benoit-Pierre: "Re: C : how to export raw YUV to a file ?"
- Reply: DEMAINE Benoit-Pierre: "Re: C : how to export raw YUV to a file ?"
- Reply: 187: "Re: C : how to export raw YUV to a file ?"
- Reply: Michael Wojcik: "Re: C : how to export raw YUV to a file ?"
- Reply: DEMAINE Benoit-Pierre: "Re: C : how to export raw YUV to a file ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 5 Oct 2004 20:32:15 -0400 (EDT)
On Tue, 5 Oct 2004, DEMAINE Benoit-Pierre wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
Here's a question for you: Why do PGP signatures always wind up in the
body text of Usenet posts? Hasn't someone written a PGP client that can
put the ugly stuff in headers where I don't have to look at it unless I
want to?
> Using C under Linux, I have an array containing row data about an YUV
> picture; how to store it on the hdd under bmp or better : png file ?
Okay, so you have two basic questions here: (1) How do I write an image
to disk as a PNG-format file? (2) How do I deal with YUV images, as
opposed to the more "canonical" (in most circles) RGB encoding?
(1) Use libpng, a free PNG library available on the Web. There's a
bare-bones example C source on my website:
http://www.contrib.andrew.cmu.edu/~ajo/free-software/simple_png.c
but depending on your level of expertise, it may be easier for you to
read the libpng documentation yourself than try to figure out what my C
routines are doing. ;)
(2) You have three options for dealing with YUV images:
(a) Convert the YUV data to RGB data and write it to the file as RGB.
You can find conversion formulas on the Web. This is a slightly lossy
procedure, which means you won't be able to get back exactly the YUV
values you started with. But that may not be a big deal.
(b) Just pretend YUV is RGB. For example, if you have a YUV triple
(200, 32, 32), just write out the RGB triple (200, 32, 32). Viewing
the resulting image file in a normal application will make that pixel
appear bright red, when really it's supposed to be... I dunno, bright
brown? I don't do YUV. Anyway, it'll make a funny-looking picture,
but you'll be able to read it back in and do processing on it as long
as you remember that R=Y, G=U, and B=V.
(c) Find an image format that supports YUV colorspace directly. AFAIK,
the PNG format does not do YUV. I bet TIFF does, but TIFF is kind of
cumbersome, in my opinion. Of course, you could also just dump the raw
YUV data, if you didn't need to be able to see the pretty pictures outside
of the application you're writing.
HTH,
-Arthur
- Next message: Developwebsites: "Re: Beginner, Which language"
- Previous message: Developwebsites: "Re: Beginner, Which language"
- In reply to: DEMAINE Benoit-Pierre: "C : how to export raw YUV to a file ?"
- Next in thread: DEMAINE Benoit-Pierre: "Re: C : how to export raw YUV to a file ?"
- Reply: DEMAINE Benoit-Pierre: "Re: C : how to export raw YUV to a file ?"
- Reply: 187: "Re: C : how to export raw YUV to a file ?"
- Reply: Michael Wojcik: "Re: C : how to export raw YUV to a file ?"
- Reply: DEMAINE Benoit-Pierre: "Re: C : how to export raw YUV to a file ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|