123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975 |
- <!-- Creator : groff version 1.18.1 -->
- <!-- CreationDate: Sat Feb 24 18:37:16 2007 -->
- <html>
- <head>
- <meta name="generator" content="groff -Thtml, see www.gnu.org">
- <meta name="Content-Style" content="text/css">
- <title>COLOR</title>
- </head>
- <body>
- <h1 align=center>COLOR</h1>
- <a href="#NAME">NAME</a><br>
- <a href="#SYNOPSIS">SYNOPSIS</a><br>
- <a href="#DESCRIPTION">DESCRIPTION</a><br>
- <a href="#SEE ALSO">SEE ALSO</a><br>
- <hr>
- <a name="NAME"></a>
- <h2>NAME</h2>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p>TIFFYCbCrToRGBInit, TIFFYCbCrtoRGB, TIFFCIELabToRGBInit,
- TIFFCIELabToXYZ, TIFFXYZToRGB − color conversion
- routines.</p>
- </td>
- </table>
- <a name="SYNOPSIS"></a>
- <h2>SYNOPSIS</h2>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p><b>#include <tiffio.h></b></p>
- <!-- INDENTATION -->
- <p><b>int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB
- *</b><i>ycbcr</i><b>, float *</b><i>luma</i><b>, float
- *</b><i>refBlackWhite"</i><b>);"<br>
- void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *</b><i>ycbcr</i><b>,
- uint32</b> <i>Y</i><b>, int32</b> <i>Cb</i><b>, int32</b>
- <i>Cr</i><b>, uint32 *</b><i>R</i><b>, uint32
- *</b><i>G</i><b>, uint32 *</b><i>B</i> <b>);</b></p>
- <!-- INDENTATION -->
- <p><b>int TIFFCIELabToRGBInit(TIFFCIELabToRGB
- *</b><i>cielab</i><b>, TIFFDisplay *</b><i>display</i><b>,
- float *</b><i>refWhite</i><b>);<br>
- void TIFFCIELabToXYZ(TIFFCIELabToRGB *</b><i>cielab</i><b>,
- uint32</b> <i>L</i><b>, int32</b> <i>a</i><b>, int32</b>
- <i>b</i><b>, float *</b><i>X</i><b>, float *</b><i>Y</i><b>,
- float *</b><i>Z</i><b>);<br>
- void TIFFXYZToRGB(TIFFCIELabToRGB *</b><i>cielab</i><b>,
- float</b> <i>X</i><b>, float</b> <i>Y</i><b>, float</b>
- <i>Z"</i><b>,</b><i>uint32</i><b>*"</b><i>R</i><b>,
- uint32 *</b><i>G</i><b>, uint32 *</b><i>B</i><b>);</b></p>
- </td>
- </table>
- <a name="DESCRIPTION"></a>
- <h2>DESCRIPTION</h2>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p>TIFF supports several color spaces for images stored in
- that format. There is usually a problem of application to
- handle the data properly and convert between different
- colorspaces for displaying and printing purposes. To
- simplify this task libtiff implements several color
- conversion routines itself. In particular, these routines
- used in <b>TIFFRGBAImage(3TIFF)</b> interface.</p>
- <!-- INDENTATION -->
- <p><b>TIFFYCbCrToRGBInit()</b> used to initialize
- <i>YCbCr</i> to <i>RGB</i> conversion state. Allocating and
- freeing of the <i>ycbcr</i> structure belongs to programmer.
- <i>TIFFYCbCrToRGB</i> defined in <b>tiffio.h</b> as</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <pre>typedef struct { /* YCbCr->RGB support */
- TIFFRGBValue* clamptab; /* range clamping table */
- </pre>
- </td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="5" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <p>int*</p>
- <td width="28%"></td>
- <td width="-3%"></td>
- <td width="12%"></td>
- <td width="6%">
- <p>Cr_r_tab;<br>
- int*</p>
- </td>
- <td width="56%">
- </td>
- <tr valign="top" align="left">
- <td width="28%"></td>
- <td width="-3%"></td>
- <td width="12%"></td>
- <td width="6%">
- <p>Cb_b_tab;<br>
- int32*</p>
- </td>
- <td width="56%">
- </td>
- <tr valign="top" align="left">
- <td width="28%"></td>
- <td width="-3%"></td>
- <td width="12%"></td>
- <td width="6%">
- <p>Cr_g_tab;<br>
- int32*</p>
- </td>
- <td width="56%">
- </td>
- <tr valign="top" align="left">
- <td width="28%"></td>
- <td width="-3%"></td>
- <td width="12%"></td>
- <td width="6%">
- <p>Cb_g_tab;</p>
- </td>
- <td width="56%">
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>int32* Y_tab;<br>
- } TIFFYCbCrToRGB;</p></td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p><i>luma</i> is a float array of three values representing
- proportions of the red, green and blue in luminance, Y (see
- section 21 of the TIFF 6.0 specification, where the YCbCr
- images discussed). <i>TIFFTAG_YCBCRCOEFFICIENTS</i> holds
- that values in TIFF file. <i>refBlackWhite</i> is a float
- array of 6 values which specifies a pair of headroom and
- footroom image data values (codes) for each image component
- (see section 20 of the TIFF 6.0 specification where the
- colorinmetry fields discussed).
- <i>TIFFTAG_REFERENCEBLACKWHITE</i> is responsible for
- storing these values in TIFF file. Following code snippet
- should helps to understand the the technique:</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <pre>float *luma, *refBlackWhite;
- uint16 hs, vs;
- /* Initialize structures */
- ycbcr = (TIFFYCbCrToRGB*)
- </pre>
- </td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>_TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB),
- sizeof(long))</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>+ 4*256*sizeof(TIFFRGBValue)</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>+ 2*256*sizeof(int)</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>+ 3*256*sizeof(int32));</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>if (ycbcr == NULL) {<br>
- TIFFError("YCbCr->RGB",</p></td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="4" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>"No space for YCbCr->RGB conversion
- state");</p>
- </td>
- <td width="62%">
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>exit(0);<br>
- }</p>
- <!-- INDENTATION -->
- <p>TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS,
- &luma);<br>
- TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE,
- &refBlackWhite);<br>
- if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) <
- 0)</p></td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>exit(0);</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>/* Start conversion */<br>
- uint32 r, g, b;<br>
- uint32 Y;<br>
- int32 Cb, Cr;</p>
- <!-- INDENTATION -->
- <p>for each pixel in image</p></td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>TIFFYCbCrtoRGB(img->ycbcr, Y, Cb, Cr, &r, &g,
- &b);</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>/* Free state structure */<br>
- _TIFFfree(ycbcr);</p></td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p><b>TIFFCIELabToRGBInit()</b> initializes the <i>CIE
- L*a*b* 1976</i> to <i>RGB</i> conversion state.
- <b>TIFFCIELabToRGB</b> defined as</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <pre>#define CIELABTORGB_TABLE_RANGE 1500
- </pre>
- </td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="9" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%">
- <p>typedef struct {</p>
- </td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>/* CIE Lab 1976->RGB support */</p>
- </td>
- <td width="6%"></td>
- <td width="37%">
- </td>
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>int</p>
- </td>
- <td width="6%">
- <p>range;</p>
- </td>
- <td width="6%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>/* Size of conversion table */</p>
- </td>
- <td width="6%"></td>
- <td width="37%">
- </td>
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>float</p>
- </td>
- <td width="6%"></td>
- <td width="6%">
- <p>rstep, gstep, bstep;</p>
- </td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="37%">
- </td>
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>float</p>
- </td>
- <td width="6%"></td>
- <td width="6%">
- <p>X0, Y0, Z0;</p>
- </td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%">
- <p>/* Reference white point */</p>
- </td>
- <td width="37%">
- </td>
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%"></td>
- <td width="6%">
- <p>TIFFDisplay display;</p>
- </td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="37%">
- </td>
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>float</p>
- </td>
- <td width="6%"></td>
- <td width="6%">
- <p>Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr
- to r */</p>
- </td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="37%">
- </td>
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>float</p>
- </td>
- <td width="6%"></td>
- <td width="6%">
- <p>Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg
- to g */</p>
- </td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="37%">
- </td>
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>float</p>
- </td>
- <td width="6%"></td>
- <td width="6%">
- <p>Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb
- to b */</p>
- </td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="6%"></td>
- <td width="37%">
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>} TIFFCIELabToRGB;</p></td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p><i>display</i> is a display device description, declared
- as</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <pre>typedef struct {
- </pre>
- </td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_mat[3][3]; /* XYZ -> luminance matrix */</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_YCR; /* Light o/p for reference white */</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_YCG;</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_YCB;</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>uint32 d_Vrwr; /* Pixel values for ref. white */</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>uint32 d_Vrwg;</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>uint32 d_Vrwb;</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_Y0R; /* Residual light for black pixel */</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_Y0G;</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_Y0B;</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_gammaR; /* Gamma values for the three guns
- */</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_gammaG;</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>float d_gammaB;</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>} TIFFDisplay;</p></td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p>For example, the one can use sRGB device, which has the
- following parameters:</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <pre>TIFFDisplay display_sRGB = {
- </pre>
- </td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="5" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>{ /* XYZ -> luminance matrix */</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>{ 3.2410F, -1.5374F, -0.4986F },</p>
- </td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>{ -0.9692F, 1.8760F, 0.0416F },</p>
- </td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>{ 0.0556F, -0.2040F, 1.0570F }</p>
- </td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>},</p>
- </td>
- <td width="6%">
- </td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>100.0F, 100.0F, 100.0F, /* Light o/p for reference white
- */</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>255, 255, 255, /* Pixel values for ref. white */</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel
- */</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>2.4F, 2.4F, 2.4F, /* Gamma values for the three guns
- */</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>};</p></td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p><i>refWhite</i> is a color temperature of the reference
- white. The <i>TIFFTAG_WHITEPOINT</i> contains the
- chromaticity of the white point of the image from where the
- reference white can be calculated using following
- formulae:</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>refWhite_Y = 100.0<br>
- refWhite_X = whitePoint_x / whitePoint_y * refWhite_Y<br>
- refWhite_Z = (1.0 - whitePoint_x - whitePoint_y) /
- whitePoint_y * refWhite_X</p></td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p>The conversion itself performed in two steps: at the
- first one we will convert <i>CIE L*a*b* 1976</i> to <i>CIE
- XYZ</i> using <b>TIFFCIELabToXYZ()</b> routine, and at the
- second step we will convert <i>CIE XYZ</i> to <i>RGB</i>
- using <b>TIFFXYZToRGB().</b> Look at the code sample
- below:</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <pre>float *whitePoint;
- float refWhite[3];
- /* Initialize structures */
- img->cielab = (TIFFCIELabToRGB *)
- </pre>
- </td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>_TIFFmalloc(sizeof(TIFFCIELabToRGB));</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>if (!cielab) {</p></td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="5" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>TIFFError("CIE L*a*b*->RGB",</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>"No space for CIE L*a*b*->RGB conversion
- state.");</p>
- </td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>exit(0);</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>}</p>
- <!-- INDENTATION -->
- <p>TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT,
- &whitePoint);<br>
- refWhite[1] = 100.0F;<br>
- refWhite[0] = whitePoint[0] / whitePoint[1] *
- refWhite[1];<br>
- refWhite[2] = (1.0F - whitePoint[0] -
- whitePoint[1])</p></td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>/ whitePoint[1] * refWhite[1];</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>if (TIFFCIELabToRGBInit(cielab, &display_sRGB,
- refWhite) < 0) {</p></td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="5" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>TIFFError("CIE L*a*b*->RGB",</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- </td>
- <td width="6%">
- <p>"Failed to initialize CIE L*a*b*->RGB conversion
- state.");</p>
- </td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>_TIFFfree(cielab);</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="0%"></td>
- <td width="6%">
- <p>exit(0);</p>
- </td>
- <td width="6%"></td>
- <td width="62%">
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>}</p>
- <!-- INDENTATION -->
- <p>/* Now we can start to convert */<br>
- uint32 r, g, b;<br>
- uint32 L;<br>
- int32 a, b;<br>
- float X, Y, Z;</p>
- <!-- INDENTATION -->
- <p>for each pixel in image</p></td>
- </table>
- <!-- TABS -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>TIFFCIELabToXYZ(cielab, L, a, b, &X, &Y,
- &Z);</p>
- </td>
- <tr valign="top" align="left">
- <td width="24%"></td>
- <td width="75%">
- <p>TIFFXYZToRGB(cielab, X, Y, Z, &r, &g,
- &b);</p>
- </td>
- </table>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="17%"></td>
- <td width="82%">
- <p>/* Don’t forget to free the state structure */<br>
- _TIFFfree(cielab);</p></td>
- </table>
- <a name="SEE ALSO"></a>
- <h2>SEE ALSO</h2>
- <!-- INDENTATION -->
- <table width="100%" border=0 rules="none" frame="void"
- cols="2" cellspacing="0" cellpadding="0">
- <tr valign="top" align="left">
- <td width="8%"></td>
- <td width="91%">
- <p><b>TIFFRGBAImage</b>(3TIFF) <b>libtiff</b>(3TIFF),</p>
- <!-- INDENTATION -->
- <p>Libtiff library home page:
- <b>http://www.remotesensing.org/libtiff/</b></p>
- </td>
- </table>
- <hr>
- </body>
- </html>
|