TIFFcolor.3tiff.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975
  1. <!-- Creator : groff version 1.18.1 -->
  2. <!-- CreationDate: Sat Feb 24 18:37:16 2007 -->
  3. <html>
  4. <head>
  5. <meta name="generator" content="groff -Thtml, see www.gnu.org">
  6. <meta name="Content-Style" content="text/css">
  7. <title>COLOR</title>
  8. </head>
  9. <body>
  10. <h1 align=center>COLOR</h1>
  11. <a href="#NAME">NAME</a><br>
  12. <a href="#SYNOPSIS">SYNOPSIS</a><br>
  13. <a href="#DESCRIPTION">DESCRIPTION</a><br>
  14. <a href="#SEE ALSO">SEE ALSO</a><br>
  15. <hr>
  16. <a name="NAME"></a>
  17. <h2>NAME</h2>
  18. <!-- INDENTATION -->
  19. <table width="100%" border=0 rules="none" frame="void"
  20. cols="2" cellspacing="0" cellpadding="0">
  21. <tr valign="top" align="left">
  22. <td width="8%"></td>
  23. <td width="91%">
  24. <p>TIFFYCbCrToRGBInit, TIFFYCbCrtoRGB, TIFFCIELabToRGBInit,
  25. TIFFCIELabToXYZ, TIFFXYZToRGB &minus; color conversion
  26. routines.</p>
  27. </td>
  28. </table>
  29. <a name="SYNOPSIS"></a>
  30. <h2>SYNOPSIS</h2>
  31. <!-- INDENTATION -->
  32. <table width="100%" border=0 rules="none" frame="void"
  33. cols="2" cellspacing="0" cellpadding="0">
  34. <tr valign="top" align="left">
  35. <td width="8%"></td>
  36. <td width="91%">
  37. <p><b>#include &lt;tiffio.h&gt;</b></p>
  38. <!-- INDENTATION -->
  39. <p><b>int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB
  40. *</b><i>ycbcr</i><b>, float *</b><i>luma</i><b>, float
  41. *</b><i>refBlackWhite&quot;</i><b>);&quot;<br>
  42. void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *</b><i>ycbcr</i><b>,
  43. uint32</b> <i>Y</i><b>, int32</b> <i>Cb</i><b>, int32</b>
  44. <i>Cr</i><b>, uint32 *</b><i>R</i><b>, uint32
  45. *</b><i>G</i><b>, uint32 *</b><i>B</i> <b>);</b></p>
  46. <!-- INDENTATION -->
  47. <p><b>int TIFFCIELabToRGBInit(TIFFCIELabToRGB
  48. *</b><i>cielab</i><b>, TIFFDisplay *</b><i>display</i><b>,
  49. float *</b><i>refWhite</i><b>);<br>
  50. void TIFFCIELabToXYZ(TIFFCIELabToRGB *</b><i>cielab</i><b>,
  51. uint32</b> <i>L</i><b>, int32</b> <i>a</i><b>, int32</b>
  52. <i>b</i><b>, float *</b><i>X</i><b>, float *</b><i>Y</i><b>,
  53. float *</b><i>Z</i><b>);<br>
  54. void TIFFXYZToRGB(TIFFCIELabToRGB *</b><i>cielab</i><b>,
  55. float</b> <i>X</i><b>, float</b> <i>Y</i><b>, float</b>
  56. <i>Z&quot;</i><b>,</b><i>uint32</i><b>*&quot;</b><i>R</i><b>,
  57. uint32 *</b><i>G</i><b>, uint32 *</b><i>B</i><b>);</b></p>
  58. </td>
  59. </table>
  60. <a name="DESCRIPTION"></a>
  61. <h2>DESCRIPTION</h2>
  62. <!-- INDENTATION -->
  63. <table width="100%" border=0 rules="none" frame="void"
  64. cols="2" cellspacing="0" cellpadding="0">
  65. <tr valign="top" align="left">
  66. <td width="8%"></td>
  67. <td width="91%">
  68. <p>TIFF supports several color spaces for images stored in
  69. that format. There is usually a problem of application to
  70. handle the data properly and convert between different
  71. colorspaces for displaying and printing purposes. To
  72. simplify this task libtiff implements several color
  73. conversion routines itself. In particular, these routines
  74. used in <b>TIFFRGBAImage(3TIFF)</b> interface.</p>
  75. <!-- INDENTATION -->
  76. <p><b>TIFFYCbCrToRGBInit()</b> used to initialize
  77. <i>YCbCr</i> to <i>RGB</i> conversion state. Allocating and
  78. freeing of the <i>ycbcr</i> structure belongs to programmer.
  79. <i>TIFFYCbCrToRGB</i> defined in <b>tiffio.h</b> as</p>
  80. </td>
  81. </table>
  82. <!-- INDENTATION -->
  83. <table width="100%" border=0 rules="none" frame="void"
  84. cols="2" cellspacing="0" cellpadding="0">
  85. <tr valign="top" align="left">
  86. <td width="17%"></td>
  87. <td width="82%">
  88. <pre>typedef struct { /* YCbCr-&gt;RGB support */
  89. TIFFRGBValue* clamptab; /* range clamping table */
  90. </pre>
  91. </td>
  92. </table>
  93. <!-- TABS -->
  94. <table width="100%" border=0 rules="none" frame="void"
  95. cols="5" cellspacing="0" cellpadding="0">
  96. <tr valign="top" align="left">
  97. <p>int*</p>
  98. <td width="28%"></td>
  99. <td width="-3%"></td>
  100. <td width="12%"></td>
  101. <td width="6%">
  102. <p>Cr_r_tab;<br>
  103. int*</p>
  104. </td>
  105. <td width="56%">
  106. </td>
  107. <tr valign="top" align="left">
  108. <td width="28%"></td>
  109. <td width="-3%"></td>
  110. <td width="12%"></td>
  111. <td width="6%">
  112. <p>Cb_b_tab;<br>
  113. int32*</p>
  114. </td>
  115. <td width="56%">
  116. </td>
  117. <tr valign="top" align="left">
  118. <td width="28%"></td>
  119. <td width="-3%"></td>
  120. <td width="12%"></td>
  121. <td width="6%">
  122. <p>Cr_g_tab;<br>
  123. int32*</p>
  124. </td>
  125. <td width="56%">
  126. </td>
  127. <tr valign="top" align="left">
  128. <td width="28%"></td>
  129. <td width="-3%"></td>
  130. <td width="12%"></td>
  131. <td width="6%">
  132. <p>Cb_g_tab;</p>
  133. </td>
  134. <td width="56%">
  135. </td>
  136. </table>
  137. <!-- INDENTATION -->
  138. <table width="100%" border=0 rules="none" frame="void"
  139. cols="2" cellspacing="0" cellpadding="0">
  140. <tr valign="top" align="left">
  141. <td width="17%"></td>
  142. <td width="82%">
  143. <p>int32* Y_tab;<br>
  144. } TIFFYCbCrToRGB;</p></td>
  145. </table>
  146. <!-- INDENTATION -->
  147. <table width="100%" border=0 rules="none" frame="void"
  148. cols="2" cellspacing="0" cellpadding="0">
  149. <tr valign="top" align="left">
  150. <td width="8%"></td>
  151. <td width="91%">
  152. <p><i>luma</i> is a float array of three values representing
  153. proportions of the red, green and blue in luminance, Y (see
  154. section 21 of the TIFF 6.0 specification, where the YCbCr
  155. images discussed). <i>TIFFTAG_YCBCRCOEFFICIENTS</i> holds
  156. that values in TIFF file. <i>refBlackWhite</i> is a float
  157. array of 6 values which specifies a pair of headroom and
  158. footroom image data values (codes) for each image component
  159. (see section 20 of the TIFF 6.0 specification where the
  160. colorinmetry fields discussed).
  161. <i>TIFFTAG_REFERENCEBLACKWHITE</i> is responsible for
  162. storing these values in TIFF file. Following code snippet
  163. should helps to understand the the technique:</p>
  164. </td>
  165. </table>
  166. <!-- INDENTATION -->
  167. <table width="100%" border=0 rules="none" frame="void"
  168. cols="2" cellspacing="0" cellpadding="0">
  169. <tr valign="top" align="left">
  170. <td width="17%"></td>
  171. <td width="82%">
  172. <pre>float *luma, *refBlackWhite;
  173. uint16 hs, vs;
  174. /* Initialize structures */
  175. ycbcr = (TIFFYCbCrToRGB*)
  176. </pre>
  177. </td>
  178. </table>
  179. <!-- TABS -->
  180. <table width="100%" border=0 rules="none" frame="void"
  181. cols="2" cellspacing="0" cellpadding="0">
  182. <tr valign="top" align="left">
  183. <td width="24%"></td>
  184. <td width="75%">
  185. <p>_TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB),
  186. sizeof(long))</p>
  187. </td>
  188. <tr valign="top" align="left">
  189. <td width="24%"></td>
  190. <td width="75%">
  191. <p>+ 4*256*sizeof(TIFFRGBValue)</p>
  192. </td>
  193. <tr valign="top" align="left">
  194. <td width="24%"></td>
  195. <td width="75%">
  196. <p>+ 2*256*sizeof(int)</p>
  197. </td>
  198. <tr valign="top" align="left">
  199. <td width="24%"></td>
  200. <td width="75%">
  201. <p>+ 3*256*sizeof(int32));</p>
  202. </td>
  203. </table>
  204. <!-- INDENTATION -->
  205. <table width="100%" border=0 rules="none" frame="void"
  206. cols="2" cellspacing="0" cellpadding="0">
  207. <tr valign="top" align="left">
  208. <td width="17%"></td>
  209. <td width="82%">
  210. <p>if (ycbcr == NULL) {<br>
  211. TIFFError(&quot;YCbCr-&gt;RGB&quot;,</p></td>
  212. </table>
  213. <!-- TABS -->
  214. <table width="100%" border=0 rules="none" frame="void"
  215. cols="4" cellspacing="0" cellpadding="0">
  216. <tr valign="top" align="left">
  217. <td width="24%"></td>
  218. <td width="6%">
  219. </td>
  220. <td width="6%">
  221. <p>&quot;No space for YCbCr-&gt;RGB conversion
  222. state&quot;);</p>
  223. </td>
  224. <td width="62%">
  225. </td>
  226. </table>
  227. <!-- INDENTATION -->
  228. <table width="100%" border=0 rules="none" frame="void"
  229. cols="2" cellspacing="0" cellpadding="0">
  230. <tr valign="top" align="left">
  231. <td width="17%"></td>
  232. <td width="82%">
  233. <p>exit(0);<br>
  234. }</p>
  235. <!-- INDENTATION -->
  236. <p>TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS,
  237. &amp;luma);<br>
  238. TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE,
  239. &amp;refBlackWhite);<br>
  240. if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) &lt;
  241. 0)</p></td>
  242. </table>
  243. <!-- TABS -->
  244. <table width="100%" border=0 rules="none" frame="void"
  245. cols="2" cellspacing="0" cellpadding="0">
  246. <tr valign="top" align="left">
  247. <td width="24%"></td>
  248. <td width="75%">
  249. <p>exit(0);</p>
  250. </td>
  251. </table>
  252. <!-- INDENTATION -->
  253. <table width="100%" border=0 rules="none" frame="void"
  254. cols="2" cellspacing="0" cellpadding="0">
  255. <tr valign="top" align="left">
  256. <td width="17%"></td>
  257. <td width="82%">
  258. <p>/* Start conversion */<br>
  259. uint32 r, g, b;<br>
  260. uint32 Y;<br>
  261. int32 Cb, Cr;</p>
  262. <!-- INDENTATION -->
  263. <p>for each pixel in image</p></td>
  264. </table>
  265. <!-- TABS -->
  266. <table width="100%" border=0 rules="none" frame="void"
  267. cols="2" cellspacing="0" cellpadding="0">
  268. <tr valign="top" align="left">
  269. <td width="24%"></td>
  270. <td width="75%">
  271. <p>TIFFYCbCrtoRGB(img-&gt;ycbcr, Y, Cb, Cr, &amp;r, &amp;g,
  272. &amp;b);</p>
  273. </td>
  274. </table>
  275. <!-- INDENTATION -->
  276. <table width="100%" border=0 rules="none" frame="void"
  277. cols="2" cellspacing="0" cellpadding="0">
  278. <tr valign="top" align="left">
  279. <td width="17%"></td>
  280. <td width="82%">
  281. <p>/* Free state structure */<br>
  282. _TIFFfree(ycbcr);</p></td>
  283. </table>
  284. <!-- INDENTATION -->
  285. <table width="100%" border=0 rules="none" frame="void"
  286. cols="2" cellspacing="0" cellpadding="0">
  287. <tr valign="top" align="left">
  288. <td width="8%"></td>
  289. <td width="91%">
  290. <p><b>TIFFCIELabToRGBInit()</b> initializes the <i>CIE
  291. L*a*b* 1976</i> to <i>RGB</i> conversion state.
  292. <b>TIFFCIELabToRGB</b> defined as</p>
  293. </td>
  294. </table>
  295. <!-- INDENTATION -->
  296. <table width="100%" border=0 rules="none" frame="void"
  297. cols="2" cellspacing="0" cellpadding="0">
  298. <tr valign="top" align="left">
  299. <td width="17%"></td>
  300. <td width="82%">
  301. <pre>#define CIELABTORGB_TABLE_RANGE 1500
  302. </pre>
  303. </td>
  304. </table>
  305. <!-- TABS -->
  306. <table width="100%" border=0 rules="none" frame="void"
  307. cols="9" cellspacing="0" cellpadding="0">
  308. <tr valign="top" align="left">
  309. <td width="17%"></td>
  310. <td width="6%">
  311. <p>typedef struct {</p>
  312. </td>
  313. <td width="6%"></td>
  314. <td width="6%"></td>
  315. <td width="6%"></td>
  316. <td width="6%">
  317. </td>
  318. <td width="6%">
  319. <p>/* CIE Lab 1976-&gt;RGB support */</p>
  320. </td>
  321. <td width="6%"></td>
  322. <td width="37%">
  323. </td>
  324. <tr valign="top" align="left">
  325. <td width="17%"></td>
  326. <td width="6%">
  327. </td>
  328. <td width="6%">
  329. <p>int</p>
  330. </td>
  331. <td width="6%">
  332. <p>range;</p>
  333. </td>
  334. <td width="6%"></td>
  335. <td width="6%">
  336. </td>
  337. <td width="6%">
  338. <p>/* Size of conversion table */</p>
  339. </td>
  340. <td width="6%"></td>
  341. <td width="37%">
  342. </td>
  343. <tr valign="top" align="left">
  344. <td width="17%"></td>
  345. <td width="6%">
  346. </td>
  347. <td width="6%">
  348. <p>float</p>
  349. </td>
  350. <td width="6%"></td>
  351. <td width="6%">
  352. <p>rstep, gstep, bstep;</p>
  353. </td>
  354. <td width="6%"></td>
  355. <td width="6%"></td>
  356. <td width="6%"></td>
  357. <td width="37%">
  358. </td>
  359. <tr valign="top" align="left">
  360. <td width="17%"></td>
  361. <td width="6%">
  362. </td>
  363. <td width="6%">
  364. <p>float</p>
  365. </td>
  366. <td width="6%"></td>
  367. <td width="6%">
  368. <p>X0, Y0, Z0;</p>
  369. </td>
  370. <td width="6%"></td>
  371. <td width="6%"></td>
  372. <td width="6%">
  373. <p>/* Reference white point */</p>
  374. </td>
  375. <td width="37%">
  376. </td>
  377. <tr valign="top" align="left">
  378. <td width="17%"></td>
  379. <td width="6%"></td>
  380. <td width="6%">
  381. <p>TIFFDisplay display;</p>
  382. </td>
  383. <td width="6%"></td>
  384. <td width="6%"></td>
  385. <td width="6%"></td>
  386. <td width="6%"></td>
  387. <td width="6%"></td>
  388. <td width="37%">
  389. </td>
  390. <tr valign="top" align="left">
  391. <td width="17%"></td>
  392. <td width="6%">
  393. </td>
  394. <td width="6%">
  395. <p>float</p>
  396. </td>
  397. <td width="6%"></td>
  398. <td width="6%">
  399. <p>Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr
  400. to r */</p>
  401. </td>
  402. <td width="6%"></td>
  403. <td width="6%"></td>
  404. <td width="6%"></td>
  405. <td width="37%">
  406. </td>
  407. <tr valign="top" align="left">
  408. <td width="17%"></td>
  409. <td width="6%">
  410. </td>
  411. <td width="6%">
  412. <p>float</p>
  413. </td>
  414. <td width="6%"></td>
  415. <td width="6%">
  416. <p>Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg
  417. to g */</p>
  418. </td>
  419. <td width="6%"></td>
  420. <td width="6%"></td>
  421. <td width="6%"></td>
  422. <td width="37%">
  423. </td>
  424. <tr valign="top" align="left">
  425. <td width="17%"></td>
  426. <td width="6%">
  427. </td>
  428. <td width="6%">
  429. <p>float</p>
  430. </td>
  431. <td width="6%"></td>
  432. <td width="6%">
  433. <p>Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb
  434. to b */</p>
  435. </td>
  436. <td width="6%"></td>
  437. <td width="6%"></td>
  438. <td width="6%"></td>
  439. <td width="37%">
  440. </td>
  441. </table>
  442. <!-- INDENTATION -->
  443. <table width="100%" border=0 rules="none" frame="void"
  444. cols="2" cellspacing="0" cellpadding="0">
  445. <tr valign="top" align="left">
  446. <td width="17%"></td>
  447. <td width="82%">
  448. <p>} TIFFCIELabToRGB;</p></td>
  449. </table>
  450. <!-- INDENTATION -->
  451. <table width="100%" border=0 rules="none" frame="void"
  452. cols="2" cellspacing="0" cellpadding="0">
  453. <tr valign="top" align="left">
  454. <td width="8%"></td>
  455. <td width="91%">
  456. <p><i>display</i> is a display device description, declared
  457. as</p>
  458. </td>
  459. </table>
  460. <!-- INDENTATION -->
  461. <table width="100%" border=0 rules="none" frame="void"
  462. cols="2" cellspacing="0" cellpadding="0">
  463. <tr valign="top" align="left">
  464. <td width="17%"></td>
  465. <td width="82%">
  466. <pre>typedef struct {
  467. </pre>
  468. </td>
  469. </table>
  470. <!-- TABS -->
  471. <table width="100%" border=0 rules="none" frame="void"
  472. cols="2" cellspacing="0" cellpadding="0">
  473. <tr valign="top" align="left">
  474. <td width="24%"></td>
  475. <td width="75%">
  476. <p>float d_mat[3][3]; /* XYZ -&gt; luminance matrix */</p>
  477. </td>
  478. <tr valign="top" align="left">
  479. <td width="24%"></td>
  480. <td width="75%">
  481. <p>float d_YCR; /* Light o/p for reference white */</p>
  482. </td>
  483. <tr valign="top" align="left">
  484. <td width="24%"></td>
  485. <td width="75%">
  486. <p>float d_YCG;</p>
  487. </td>
  488. <tr valign="top" align="left">
  489. <td width="24%"></td>
  490. <td width="75%">
  491. <p>float d_YCB;</p>
  492. </td>
  493. <tr valign="top" align="left">
  494. <td width="24%"></td>
  495. <td width="75%">
  496. <p>uint32 d_Vrwr; /* Pixel values for ref. white */</p>
  497. </td>
  498. <tr valign="top" align="left">
  499. <td width="24%"></td>
  500. <td width="75%">
  501. <p>uint32 d_Vrwg;</p>
  502. </td>
  503. <tr valign="top" align="left">
  504. <td width="24%"></td>
  505. <td width="75%">
  506. <p>uint32 d_Vrwb;</p>
  507. </td>
  508. <tr valign="top" align="left">
  509. <td width="24%"></td>
  510. <td width="75%">
  511. <p>float d_Y0R; /* Residual light for black pixel */</p>
  512. </td>
  513. <tr valign="top" align="left">
  514. <td width="24%"></td>
  515. <td width="75%">
  516. <p>float d_Y0G;</p>
  517. </td>
  518. <tr valign="top" align="left">
  519. <td width="24%"></td>
  520. <td width="75%">
  521. <p>float d_Y0B;</p>
  522. </td>
  523. <tr valign="top" align="left">
  524. <td width="24%"></td>
  525. <td width="75%">
  526. <p>float d_gammaR; /* Gamma values for the three guns
  527. */</p>
  528. </td>
  529. <tr valign="top" align="left">
  530. <td width="24%"></td>
  531. <td width="75%">
  532. <p>float d_gammaG;</p>
  533. </td>
  534. <tr valign="top" align="left">
  535. <td width="24%"></td>
  536. <td width="75%">
  537. <p>float d_gammaB;</p>
  538. </td>
  539. </table>
  540. <!-- INDENTATION -->
  541. <table width="100%" border=0 rules="none" frame="void"
  542. cols="2" cellspacing="0" cellpadding="0">
  543. <tr valign="top" align="left">
  544. <td width="17%"></td>
  545. <td width="82%">
  546. <p>} TIFFDisplay;</p></td>
  547. </table>
  548. <!-- INDENTATION -->
  549. <table width="100%" border=0 rules="none" frame="void"
  550. cols="2" cellspacing="0" cellpadding="0">
  551. <tr valign="top" align="left">
  552. <td width="8%"></td>
  553. <td width="91%">
  554. <p>For example, the one can use sRGB device, which has the
  555. following parameters:</p>
  556. </td>
  557. </table>
  558. <!-- INDENTATION -->
  559. <table width="100%" border=0 rules="none" frame="void"
  560. cols="2" cellspacing="0" cellpadding="0">
  561. <tr valign="top" align="left">
  562. <td width="17%"></td>
  563. <td width="82%">
  564. <pre>TIFFDisplay display_sRGB = {
  565. </pre>
  566. </td>
  567. </table>
  568. <!-- TABS -->
  569. <table width="100%" border=0 rules="none" frame="void"
  570. cols="5" cellspacing="0" cellpadding="0">
  571. <tr valign="top" align="left">
  572. <td width="24%"></td>
  573. <td width="0%"></td>
  574. <td width="6%">
  575. <p>{ /* XYZ -&gt; luminance matrix */</p>
  576. </td>
  577. <td width="6%"></td>
  578. <td width="62%">
  579. </td>
  580. <tr valign="top" align="left">
  581. <td width="24%"></td>
  582. <td width="0%"></td>
  583. <td width="6%">
  584. </td>
  585. <td width="6%">
  586. <p>{ 3.2410F, -1.5374F, -0.4986F },</p>
  587. </td>
  588. <td width="62%">
  589. </td>
  590. <tr valign="top" align="left">
  591. <td width="24%"></td>
  592. <td width="0%"></td>
  593. <td width="6%">
  594. </td>
  595. <td width="6%">
  596. <p>{ -0.9692F, 1.8760F, 0.0416F },</p>
  597. </td>
  598. <td width="62%">
  599. </td>
  600. <tr valign="top" align="left">
  601. <td width="24%"></td>
  602. <td width="0%"></td>
  603. <td width="6%">
  604. </td>
  605. <td width="6%">
  606. <p>{ 0.0556F, -0.2040F, 1.0570F }</p>
  607. </td>
  608. <td width="62%">
  609. </td>
  610. <tr valign="top" align="left">
  611. <td width="24%"></td>
  612. <td width="0%"></td>
  613. <td width="6%">
  614. <p>},</p>
  615. </td>
  616. <td width="6%">
  617. </td>
  618. <td width="62%">
  619. </td>
  620. <tr valign="top" align="left">
  621. <td width="24%"></td>
  622. <td width="0%"></td>
  623. <td width="6%">
  624. <p>100.0F, 100.0F, 100.0F, /* Light o/p for reference white
  625. */</p>
  626. </td>
  627. <td width="6%"></td>
  628. <td width="62%">
  629. </td>
  630. <tr valign="top" align="left">
  631. <td width="24%"></td>
  632. <td width="0%"></td>
  633. <td width="6%">
  634. <p>255, 255, 255, /* Pixel values for ref. white */</p>
  635. </td>
  636. <td width="6%"></td>
  637. <td width="62%">
  638. </td>
  639. <tr valign="top" align="left">
  640. <td width="24%"></td>
  641. <td width="0%"></td>
  642. <td width="6%">
  643. <p>1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel
  644. */</p>
  645. </td>
  646. <td width="6%"></td>
  647. <td width="62%">
  648. </td>
  649. <tr valign="top" align="left">
  650. <td width="24%"></td>
  651. <td width="0%"></td>
  652. <td width="6%">
  653. <p>2.4F, 2.4F, 2.4F, /* Gamma values for the three guns
  654. */</p>
  655. </td>
  656. <td width="6%"></td>
  657. <td width="62%">
  658. </td>
  659. </table>
  660. <!-- INDENTATION -->
  661. <table width="100%" border=0 rules="none" frame="void"
  662. cols="2" cellspacing="0" cellpadding="0">
  663. <tr valign="top" align="left">
  664. <td width="17%"></td>
  665. <td width="82%">
  666. <p>};</p></td>
  667. </table>
  668. <!-- INDENTATION -->
  669. <table width="100%" border=0 rules="none" frame="void"
  670. cols="2" cellspacing="0" cellpadding="0">
  671. <tr valign="top" align="left">
  672. <td width="8%"></td>
  673. <td width="91%">
  674. <p><i>refWhite</i> is a color temperature of the reference
  675. white. The <i>TIFFTAG_WHITEPOINT</i> contains the
  676. chromaticity of the white point of the image from where the
  677. reference white can be calculated using following
  678. formulae:</p>
  679. </td>
  680. </table>
  681. <!-- INDENTATION -->
  682. <table width="100%" border=0 rules="none" frame="void"
  683. cols="2" cellspacing="0" cellpadding="0">
  684. <tr valign="top" align="left">
  685. <td width="17%"></td>
  686. <td width="82%">
  687. <p>refWhite_Y = 100.0<br>
  688. refWhite_X = whitePoint_x / whitePoint_y * refWhite_Y<br>
  689. refWhite_Z = (1.0 - whitePoint_x - whitePoint_y) /
  690. whitePoint_y * refWhite_X</p></td>
  691. </table>
  692. <!-- INDENTATION -->
  693. <table width="100%" border=0 rules="none" frame="void"
  694. cols="2" cellspacing="0" cellpadding="0">
  695. <tr valign="top" align="left">
  696. <td width="8%"></td>
  697. <td width="91%">
  698. <p>The conversion itself performed in two steps: at the
  699. first one we will convert <i>CIE L*a*b* 1976</i> to <i>CIE
  700. XYZ</i> using <b>TIFFCIELabToXYZ()</b> routine, and at the
  701. second step we will convert <i>CIE XYZ</i> to <i>RGB</i>
  702. using <b>TIFFXYZToRGB().</b> Look at the code sample
  703. below:</p>
  704. </td>
  705. </table>
  706. <!-- INDENTATION -->
  707. <table width="100%" border=0 rules="none" frame="void"
  708. cols="2" cellspacing="0" cellpadding="0">
  709. <tr valign="top" align="left">
  710. <td width="17%"></td>
  711. <td width="82%">
  712. <pre>float *whitePoint;
  713. float refWhite[3];
  714. /* Initialize structures */
  715. img-&gt;cielab = (TIFFCIELabToRGB *)
  716. </pre>
  717. </td>
  718. </table>
  719. <!-- TABS -->
  720. <table width="100%" border=0 rules="none" frame="void"
  721. cols="2" cellspacing="0" cellpadding="0">
  722. <tr valign="top" align="left">
  723. <td width="24%"></td>
  724. <td width="75%">
  725. <p>_TIFFmalloc(sizeof(TIFFCIELabToRGB));</p>
  726. </td>
  727. </table>
  728. <!-- INDENTATION -->
  729. <table width="100%" border=0 rules="none" frame="void"
  730. cols="2" cellspacing="0" cellpadding="0">
  731. <tr valign="top" align="left">
  732. <td width="17%"></td>
  733. <td width="82%">
  734. <p>if (!cielab) {</p></td>
  735. </table>
  736. <!-- TABS -->
  737. <table width="100%" border=0 rules="none" frame="void"
  738. cols="5" cellspacing="0" cellpadding="0">
  739. <tr valign="top" align="left">
  740. <td width="24%"></td>
  741. <td width="0%"></td>
  742. <td width="6%">
  743. <p>TIFFError(&quot;CIE L*a*b*-&gt;RGB&quot;,</p>
  744. </td>
  745. <td width="6%"></td>
  746. <td width="62%">
  747. </td>
  748. <tr valign="top" align="left">
  749. <td width="24%"></td>
  750. <td width="0%"></td>
  751. <td width="6%">
  752. </td>
  753. <td width="6%">
  754. <p>&quot;No space for CIE L*a*b*-&gt;RGB conversion
  755. state.&quot;);</p>
  756. </td>
  757. <td width="62%">
  758. </td>
  759. <tr valign="top" align="left">
  760. <td width="24%"></td>
  761. <td width="0%"></td>
  762. <td width="6%">
  763. <p>exit(0);</p>
  764. </td>
  765. <td width="6%"></td>
  766. <td width="62%">
  767. </td>
  768. </table>
  769. <!-- INDENTATION -->
  770. <table width="100%" border=0 rules="none" frame="void"
  771. cols="2" cellspacing="0" cellpadding="0">
  772. <tr valign="top" align="left">
  773. <td width="17%"></td>
  774. <td width="82%">
  775. <p>}</p>
  776. <!-- INDENTATION -->
  777. <p>TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT,
  778. &amp;whitePoint);<br>
  779. refWhite[1] = 100.0F;<br>
  780. refWhite[0] = whitePoint[0] / whitePoint[1] *
  781. refWhite[1];<br>
  782. refWhite[2] = (1.0F - whitePoint[0] -
  783. whitePoint[1])</p></td>
  784. </table>
  785. <!-- TABS -->
  786. <table width="100%" border=0 rules="none" frame="void"
  787. cols="2" cellspacing="0" cellpadding="0">
  788. <tr valign="top" align="left">
  789. <td width="24%"></td>
  790. <td width="75%">
  791. <p>/ whitePoint[1] * refWhite[1];</p>
  792. </td>
  793. </table>
  794. <!-- INDENTATION -->
  795. <table width="100%" border=0 rules="none" frame="void"
  796. cols="2" cellspacing="0" cellpadding="0">
  797. <tr valign="top" align="left">
  798. <td width="17%"></td>
  799. <td width="82%">
  800. <p>if (TIFFCIELabToRGBInit(cielab, &amp;display_sRGB,
  801. refWhite) &lt; 0) {</p></td>
  802. </table>
  803. <!-- TABS -->
  804. <table width="100%" border=0 rules="none" frame="void"
  805. cols="5" cellspacing="0" cellpadding="0">
  806. <tr valign="top" align="left">
  807. <td width="24%"></td>
  808. <td width="0%"></td>
  809. <td width="6%">
  810. <p>TIFFError(&quot;CIE L*a*b*-&gt;RGB&quot;,</p>
  811. </td>
  812. <td width="6%"></td>
  813. <td width="62%">
  814. </td>
  815. <tr valign="top" align="left">
  816. <td width="24%"></td>
  817. <td width="0%"></td>
  818. <td width="6%">
  819. </td>
  820. <td width="6%">
  821. <p>&quot;Failed to initialize CIE L*a*b*-&gt;RGB conversion
  822. state.&quot;);</p>
  823. </td>
  824. <td width="62%">
  825. </td>
  826. <tr valign="top" align="left">
  827. <td width="24%"></td>
  828. <td width="0%"></td>
  829. <td width="6%">
  830. <p>_TIFFfree(cielab);</p>
  831. </td>
  832. <td width="6%"></td>
  833. <td width="62%">
  834. </td>
  835. <tr valign="top" align="left">
  836. <td width="24%"></td>
  837. <td width="0%"></td>
  838. <td width="6%">
  839. <p>exit(0);</p>
  840. </td>
  841. <td width="6%"></td>
  842. <td width="62%">
  843. </td>
  844. </table>
  845. <!-- INDENTATION -->
  846. <table width="100%" border=0 rules="none" frame="void"
  847. cols="2" cellspacing="0" cellpadding="0">
  848. <tr valign="top" align="left">
  849. <td width="17%"></td>
  850. <td width="82%">
  851. <p>}</p>
  852. <!-- INDENTATION -->
  853. <p>/* Now we can start to convert */<br>
  854. uint32 r, g, b;<br>
  855. uint32 L;<br>
  856. int32 a, b;<br>
  857. float X, Y, Z;</p>
  858. <!-- INDENTATION -->
  859. <p>for each pixel in image</p></td>
  860. </table>
  861. <!-- TABS -->
  862. <table width="100%" border=0 rules="none" frame="void"
  863. cols="2" cellspacing="0" cellpadding="0">
  864. <tr valign="top" align="left">
  865. <td width="24%"></td>
  866. <td width="75%">
  867. <p>TIFFCIELabToXYZ(cielab, L, a, b, &amp;X, &amp;Y,
  868. &amp;Z);</p>
  869. </td>
  870. <tr valign="top" align="left">
  871. <td width="24%"></td>
  872. <td width="75%">
  873. <p>TIFFXYZToRGB(cielab, X, Y, Z, &amp;r, &amp;g,
  874. &amp;b);</p>
  875. </td>
  876. </table>
  877. <!-- INDENTATION -->
  878. <table width="100%" border=0 rules="none" frame="void"
  879. cols="2" cellspacing="0" cellpadding="0">
  880. <tr valign="top" align="left">
  881. <td width="17%"></td>
  882. <td width="82%">
  883. <p>/* Don&rsquo;t forget to free the state structure */<br>
  884. _TIFFfree(cielab);</p></td>
  885. </table>
  886. <a name="SEE ALSO"></a>
  887. <h2>SEE ALSO</h2>
  888. <!-- INDENTATION -->
  889. <table width="100%" border=0 rules="none" frame="void"
  890. cols="2" cellspacing="0" cellpadding="0">
  891. <tr valign="top" align="left">
  892. <td width="8%"></td>
  893. <td width="91%">
  894. <p><b>TIFFRGBAImage</b>(3TIFF) <b>libtiff</b>(3TIFF),</p>
  895. <!-- INDENTATION -->
  896. <p>Libtiff library home page:
  897. <b>http://www.remotesensing.org/libtiff/</b></p>
  898. </td>
  899. </table>
  900. <hr>
  901. </body>
  902. </html>