TLIB documentation
 

tlColor Class Reference

List of all members.


Detailed Description

Color format description class.

Color values of different color formats (described here) are stored in tlColor objects. They are used as arguments to color filtering and color extraction routines.

Public Member Functions

 tlColor ()
 tlColor (tlColor *src)
 tlColor (tlPixel r, tlPixel g, tlPixel b)
 tlColor (tlPixel h1, tlPixel h2, tlPixel s, tlPixel i)
 tlColor (tlPixel nr, tlPixel ng)
 tlColor (tlPixel intensity)
virtual ~tlColor ()
int copy (tlColor *color)
int copyTo (tlColor *color)
int setChannel (int channel, tlPixel val)
int swapChannels (int channel1, int channel2)
int set (tlPixelArray *pixelArray, tlPoint *point)
int set (tlPixelArray *pixelArray, int x, int y)
int setRgb (tlPixel r, tlPixel g, tlPixel b)
int setYuv (tlPixel y, tlPixel u, tlPixel v)
int setNrg (tlPixel nr, tlPixel ng)
int setHsi (tlPixel h1, tlPixel h2, tlPixel s, tlPixel i)
int setGray (tlPixel intensity)
int setMin (tlPixelArray *pixelArray, tlRect *rect)
int setMax (tlPixelArray *pixelArray, tlRect *rect)
int setVar (tlPixelArray *pixelArray, tlRect *rect)
int toRgb ()
int toNrg ()
int toHsi ()
int toGray ()
int toBin (int threshold)
int add (tlColor *color)
int add (tlColor *color, tlColor *dest)
int sub (tlColor *color)
int sub (tlColor *color, tlColor *dest)

Public Attributes

tl_format format
tlPixel raw [TL_MAX_CHANNEL]
tlPixel intensity
tlPixel r
tlPixel g
tlPixel b
tlPixel y
tlPixel u
tlPixel v
tlPixel nr
tlPixel ng
tlPixel h1
tlPixel h2
tlPixel s
tlPixel i


Constructor & Destructor Documentation

tlColor::tlColor (  ) 

Constructor, initializes color format to RGB.

Note:
See error management for details.

tlColor::tlColor ( tlColor src  ) 

Constructor, creates a copy of an existing color.

Parameters:
src color to copy
Note:
See error management for details.

tlColor::tlColor ( tlPixel  r,
tlPixel  g,
tlPixel  b 
)

Constructor, initializes color format to RGB.

Parameters:
r R color values [0..255]
g G color values [0..255]
b B color values [0..255]
Note:
See error management for details.

tlColor::tlColor ( tlPixel  h1,
tlPixel  h2,
tlPixel  s,
tlPixel  i 
)

Constructor, initialises color format to HSI.

Parameters:
h1 H1 (coarse) color values [0..255]
h2 H2 (fine) color values [0..255]
s S color values [0..255]
i I color values [0..255]
Note:
See error management for details.

tlColor::tlColor ( tlPixel  nr,
tlPixel  ng 
)

Constructor, initializes color format to NRG.

Parameters:
nr NR color value [0..255]
ng NG color value [0..255]
Note:
See error management for details.

tlColor::tlColor ( tlPixel  intensity  ) 

Constructor, initializes color format to GRAY.

Parameters:
intensity GRAY color values [0..255]
Note:
See error management for details.

tlColor::~tlColor (  )  [virtual]

Destructor.

Note:
See error management for details.


Member Function Documentation

int tlColor::copy ( tlColor color  ) 

Copy data from another color.

Parameters:
color color to copy
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::copyTo ( tlColor color  ) 

Copy data to another color.

Parameters:
color [out] color to copy to
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setChannel ( int  channel,
tlPixel  val 
)

Set color value for a particular channel.

Parameters:
channel channel to be affected
val new channel value
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::swapChannels ( int  channel1,
int  channel2 
)

Swap two channel values.

Parameters:
channel1 channel to be swapped
channel2 channel to be swapped
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::set ( tlPixelArray pixelArray,
tlPoint point 
)

Set the color argument to the pixel value of a given pixel array.

Parameters:
pixelArray source pixel array to get color from
point pixel to consider in the pixel array
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::set ( tlPixelArray pixelArray,
int  x,
int  y 
)

Set the color argument to the pixel value of a given pixel array.

Parameters:
pixelArray source pixel array to get color from
x X coord of the pixel to consider
y Y coord of the pixel to consider
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setRgb ( tlPixel  r,
tlPixel  g,
tlPixel  b 
)

Set the RGB color value.

Parameters:
r R color value [0..255]
g G color value [0..255]
b B color value [0..255]
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setYuv ( tlPixel  y,
tlPixel  u,
tlPixel  v 
)

Set the YUV color value.

Parameters:
y Y color value [0..255]
u U color value [0..255]
v V color value [0..255]
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setNrg ( tlPixel  nr,
tlPixel  ng 
)

Set NRG color value.

Parameters:
nr NR color value [0..255]
ng NG color value [0..255];
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setHsi ( tlPixel  h1,
tlPixel  h2,
tlPixel  s,
tlPixel  i 
)

Set HSI color value.

Parameters:
h1 H (coarse) color values [0..255]
h2 H (fine) color values [0..255]
s S color values [0..255]
i I color values [0..255]
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setGray ( tlPixel  intensity  ) 

Set GRAY color value.

Parameters:
intensity GRAY color value [0..255]
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setMin ( tlPixelArray pixelArray,
tlRect rect 
)

Set color to the lowest value in a portion of a given pixel array; color takes the format of the input pixel array.

Parameters:
pixelArray the pixel array to extract the color from
rect the portion of the pixel array to consider
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setMax ( tlPixelArray pixelArray,
tlRect rect 
)

Set color to the highest value in a portion of a given pixel array; color takes the format of the input pixel array.

Parameters:
pixelArray the pixel array to extract the color from
rect the portion of the pixel array to consider
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::setVar ( tlPixelArray pixelArray,
tlRect rect 
)

Set color to the maximum variation in a portion of a given pixel array; color takes the format of the input pixel array.

Parameters:
pixelArray the pixel array to extract the color from
rect the portion of the pixel array to consider
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::toRgb (  ) 

Convert color to RGB format (if possible).

Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::toNrg (  ) 

Convert color to NRG format (if possible).

Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::toHsi (  ) 

Convert color to HSI format (if possible).

Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::toGray (  ) 

Convert color to GRAY format if (possible).

Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::toBin ( int  threshold  ) 

Convert color to BIN format if (possible).

Parameters:
threshold threshold value for pixel (de)activation
Returns:
0 on success, -1 otherwise.
See error management for details.

int tlColor::add ( tlColor color  ) 

Perform color addition.

Parameters:
color color to add to current color
Returns:
0 on success, -1 otherwise.
See error management for details.
Remarks:
Result is cast to TL_MAX_PIXEL_VAL in case of an overflow.

int tlColor::add ( tlColor color,
tlColor dest 
)

Perform color addition; the result is placed in another color object.

Parameters:
color color to add to current color
dest [out] destination color
Returns:
0 on success, -1 otherwise.
See error management for details.
Remarks:
dest must be allocated. Result is cast to TL_MAX_PIXEL_VAL in case of an overflow.

int tlColor::sub ( tlColor color  ) 

Perform color subtraction.

Parameters:
color color to sub from current color
Returns:
0 on success, -1 otherwise.
See error management for details.
Remarks:
Result is the absolute value of the difference.

int tlColor::sub ( tlColor color,
tlColor dest 
)

Perform color subtraction; the result is placed in another color object.

Parameters:
color color to sub from current color
dest destination color
Returns:
0 on success, -1 otherwise.
See error management for details.
Remarks:
dest must be allocated.
Result is the absolute value of the difference.


Member Data Documentation

tl_format tlColor::format

Color format.

See also:
tl_format

tlPixel tlColor::raw[TL_MAX_CHANNEL]

Raw (unspecified) format.

See also:
CUSTOM

tlPixel tlColor::intensity

GRAY (intensity) component.

See also:
GRAY

tlPixel tlColor::r

R (red) component.

See also:
RGB

tlPixel tlColor::g

G (green) component.

See also:
RGB

tlPixel tlColor::b

B (blue) component.

See also:
RGB

tlPixel tlColor::y

Y (luma) component.

See also:
YUV

tlPixel tlColor::u

U (R-Y) component.

See also:
YUV

tlPixel tlColor::v

V (B-Y) component.

See also:
YUV

tlPixel tlColor::nr

NR (normalized red) component.

See also:
NRG

tlPixel tlColor::ng

NG (normalized green) component.

See also:
NRG

tlPixel tlColor::h1

H1 (hue, coarse) component.

See also:
HSI

tlPixel tlColor::h2

H2 (hue, fine) component.

See also:
HSI

tlPixel tlColor::s

S (saturation) component.

See also:
HSI

tlPixel tlColor::i

I (intensity) component.

See also:
HSI


The documentation for this class was generated from the following files:

TLIB documentation - generated on 7 May 2008
Please address any questions to seb@tuyphon.com
(C) 2001-2008 - S. Grange
(C) 2001-2007 - VRAI Group, EPFL
All Rights Reserved.