⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tiffcolor.3t

📁 tiff文件开发库
💻 3T
字号:
.\" $Header: /cvsroot/osrs/libtiff/man/TIFFcolor.3t,v 1.2 2003/12/22 21:06:23 dron Exp $.\".\" Copyright (c) 2003, Andrey Kiselev <dron@remotesensing.org>.\".\" Permission to use, copy, modify, distribute, and sell this software and .\" its documentation for any purpose is hereby granted without fee, provided.\" that (i) the above copyright notices and this permission notice appear in.\" all copies of the software and related documentation, and (ii) the names of.\" Sam Leffler and Silicon Graphics may not be used in any advertising or.\" publicity relating to the software without the specific, prior written.\" permission of Sam Leffler and Silicon Graphics..\" .\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, .\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY .\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  .\" .\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF .\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE .\" OF THIS SOFTWARE..\".if n .po 0.TH COLOR 3T "December 21, 2003".SH NAMETIFFYCbCrToRGBInit, TIFFYCbCrtoRGB, TIFFCIELabToRGBInit, TIFFCIELabToXYZ,TIFFXYZToRGB \- color conversion routines..SH SYNOPSIS.B "#include <tiffio.h>".sp.BI "int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *" ycbcr ", float *" luma ", float *"refBlackWhite" );".br.BI "void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *" ycbcr ", uint32 " Y ", int32 " Cb ", int32 " Cr ", uint32 *" R ", uint32 *" G ", uint32 *" B " );".sp.BI "int TIFFCIELabToRGBInit(TIFFCIELabToRGB *" cielab ", TIFFDisplay *" display ", float *" refWhite ");".br.BI "void TIFFCIELabToXYZ(TIFFCIELabToRGB *" cielab ", uint32 " L ", int32 " a ", int32 " b ", float *" X ", float *" Y ", float *" Z ");".br.BI "void TIFFXYZToRGB(TIFFCIELabToRGB *" cielab ", float " X ", float " Y ", float " Z" , uint32 *" R ", uint32 *" G ", uint32 *" B ");".SH DESCRIPTIONTIFF supports several color spaces for images stored in that format. There isusually a problem of application to handle the data properly and convertbetween different colorspaces for displaying and printing purposes. Tosimplify this task libtiff implements several color conversion routinesitself. In particular, these routines used in.B TIFFRGBAImage(3T)interface..PP.B TIFFYCbCrToRGBInit()used to initialize.I YCbCrto.I RGBconversion state. Allocating and freeing of the.I ycbcrstructure belongs to programmer..I TIFFYCbCrToRGBdefined in.B tiffio.has.PP.RS.nftypedef struct {                /* YCbCr->RGB support */        TIFFRGBValue* clamptab; /* range clamping table */        int*	      Cr_r_tab;        int*	      Cb_b_tab;        int32*	      Cr_g_tab;        int32*	      Cb_g_tab;        int32*        Y_tab;} TIFFYCbCrToRGB;.fi.RE.PP.I lumais a float array of three values representing proportions of the red, greenand blue in luminance, Y (see section 21 of the TIFF 6.0 specification, wherethe YCbCr images discussed)..I TIFFTAG_YCBCRCOEFFICIENTSholds that values in TIFF file..I refBlackWhiteis a float array of 6 values which specifies a pair of headroom and footroomimage data values (codes) for each image component (see section 20 of theTIFF 6.0 specification where the colorinmetry fields discussed)..I TIFFTAG_REFERENCEBLACKWHITEis responsible for storing these values in TIFF file. Following code snippetshould helps to understand the the technique:.PP.RS.nffloat *luma, *refBlackWhite;uint16 hs, vs;/* Initialize structures */ycbcr = (TIFFYCbCrToRGB*)	_TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB), sizeof(long))        	+ 4*256*sizeof(TIFFRGBValue)        	+ 2*256*sizeof(int)        	+ 3*256*sizeof(int32));if (ycbcr == NULL) {        TIFFError("YCbCr->RGB",		"No space for YCbCr->RGB conversion state");        exit(0);}TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma);TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE, &refBlackWhite);if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) < 0)	exit(0);/* Start conversion */uint32 r, g, b;uint32 Y;int32 Cb, Cr;for each pixel in image	TIFFYCbCrtoRGB(img->ycbcr, Y, Cb, Cr, &r, &g, &b);/* Free state structure */_TIFFfree(ycbcr);.fi.RE.PP.PP.B TIFFCIELabToRGBInit()initializes the.I CIE L*a*b* 1976to.I RGBconversion state..B TIFFCIELabToRGBdefined as.PP.RS.nf#define CIELABTORGB_TABLE_RANGE 1500typedef struct {		     /* CIE Lab 1976->RGB support */	int	range;		     /* Size of conversion table */	float	rstep, gstep, bstep;	float	X0, Y0, Z0;	     /* Reference white point */	TIFFDisplay display;	float	Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */	float	Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */	float	Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */} TIFFCIELabToRGB;.fi.RE.PP.I displayis a display device description, declared as.PP.RS.nftypedef struct {	float d_mat[3][3]; /* XYZ -> luminance matrix */	float d_YCR;       /* Light o/p for reference white */	float d_YCG;	float d_YCB;	uint32 d_Vrwr;     /* Pixel values for ref. white */	uint32 d_Vrwg;	uint32 d_Vrwb;	float d_Y0R;       /* Residual light for black pixel */	float d_Y0G;	float d_Y0B;	float d_gammaR;    /* Gamma values for the three guns */	float d_gammaG;	float d_gammaB;} TIFFDisplay;.fi.RE.PPFor example, the one can use sRGB device, which has the following parameters:.PP.RS.nfTIFFDisplay display_sRGB = {	{       /* XYZ -> luminance matrix */		{  3.2410F, -1.5374F, -0.4986F },		{  -0.9692F, 1.8760F, 0.0416F },		{  0.0556F, -0.2040F, 1.0570F }	},		100.0F, 100.0F, 100.0F, /* Light o/p for reference white */	255, 255, 255,      /* Pixel values for ref. white */	1.0F, 1.0F, 1.0F,   /* Residual light o/p for black pixel */	2.4F, 2.4F, 2.4F,   /* Gamma values for the three guns */};.fi.RE.PP.I refWhiteis a color temperature of the reference white. The.I TIFFTAG_WHITEPOINTcontains the chromaticity of the white point of the image from where thereference white can be calculated using following formulae:.PP.RSrefWhite_Y = 100.0.brrefWhite_X = whitePoint_x / whitePoint_y * refWhite_Y.brrefWhite_Z = (1.0 - whitePoint_x - whitePoint_y) / whitePoint_y * refWhite_X.br.RE.PPThe conversion itself performed in two steps: at the first one we will convert.I CIE L*a*b* 1976to.I CIE XYZusing.B TIFFCIELabToXYZ()routine, and at the second step we will convert.I CIE XYZto.I RGBusing.B TIFFXYZToRGB().Look at the code sample below:.PP.RS.nffloat   *whitePoint;float   refWhite[3];/* Initialize structures */img->cielab = (TIFFCIELabToRGB *)	_TIFFmalloc(sizeof(TIFFCIELabToRGB));if (!cielab) {	TIFFError("CIE L*a*b*->RGB",		"No space for CIE L*a*b*->RGB conversion state.");	exit(0);}TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT, &whitePoint);refWhite[1] = 100.0F;refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1];refWhite[2] = (1.0F - whitePoint[0] - whitePoint[1])	      / whitePoint[1] * refWhite[1];if (TIFFCIELabToRGBInit(cielab, &display_sRGB, refWhite) < 0) {	TIFFError("CIE L*a*b*->RGB",		"Failed to initialize CIE L*a*b*->RGB conversion state.");	_TIFFfree(cielab);	exit(0);}/* Now we can start to convert */uint32 r, g, b;uint32 L;int32 a, b;float X, Y, Z;for each pixel in image	TIFFCIELabToXYZ(cielab, L, a, b, &X, &Y, &Z);	TIFFXYZToRGB(cielab, X, Y, Z, &r, &g, &b);/* Don't forget to free the state structure */_TIFFfree(cielab);.fi.RE.PP.SH "SEE ALSO".IR libtiff (3T), TIFFRGBAImage(3T)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -