| AWARE [SYSTEMS] | Imaging expertise for the Delphi developer | |||||||
![]() |
TIFF and LibTiff Mailing List Archive | |||||||
LibTiff Mailing List
TIFF and LibTiff Mailing List Archive Contact
The TIFF Mailing List Homepage |
Thread2005.09.20 10:59 "Re: Parse image into YCbCr data", by Joris Van Dammekatrina maramba wrote:
> What is the simplest way to parse a tiff image into
> YCbCr data? What is the API to call for this? What I
> found in the files was an API to convert YCbCr to RGB.
> Is there an API that has the same behavior as
> TIFFReadRGBAStrip but instead output YCbCr??
No, there is no such function.
You can, however, easilly convert the RGBA returned from
TIFFReadRGBAStrip into YCbCr. The relation between these color spaces is
documented in the TIFF spec, and in the LibJpeg jdcolor.c and jccolor.c
files. It's the same YCbCr.
R = Y + 1.40200 * Cr
G = Y - 0.34414 * Cb - 0.71414 * Cr
B = Y + 1.77200 * Cb
Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128
Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128
Note that these are floating point convertions. To optimize to integer
arithmatic, multiply all coëfficients with 65536, add 32767 to the
complete result, and shift right 16 bits. Or consult jccolor.c.
Also note that these aren't completely round trip. If you need 16bit or
floating point precision, and you want a convertion from RGB to YCbCr to
RGB to yield the exact values you started with, you'll have to do some
matrix convertion of your own with greater precision.
Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be/
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html
|
|||||||