LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::rgbPixel Class Reference
[Color Analysis]

Color pixel representation in RGB color space. More...

#include <ltiRGBPixel.h>

Inheritance diagram for lti::rgbPixel:
Inheritance graph
[legend]
Collaboration diagram for lti::rgbPixel:
Collaboration graph
[legend]

List of all members.

Classes

union  rgbPixelType
 this union allows to share the memory of a 32 bit integer with the three ubytes of RGB and a alpha byte. More...

Public Types

typedef ubyte value_type
typedef int size_type

Public Member Functions

 rgbPixel ()
 rgbPixel (const uint32 val)
 rgbPixel (const ubyte r, const ubyte g, const ubyte b, const ubyte d=0)
template<class U >
 rgbPixel (const trgbPixel< U > &p)
void set (const ubyte red, const ubyte green, const ubyte blue, const ubyte alpha)
void set (const ubyte red, const ubyte green, const ubyte blue)
void setRed (const ubyte r)
void setGreen (const ubyte g)
void setBlue (const ubyte b)
void setDummy (const ubyte d)
void setAlpha (const ubyte alpha)
void setValue (const uint32 &v)
void get (ubyte &red, ubyte &green, ubyte &blue) const
void get (int &red, int &green, int &blue) const
void get (ubyte &red, ubyte &green, ubyte &blue, ubyte &alpha) const
void get (int &red, int &green, int &blue, int &alpha) const
const ubyte & getRed () const
const ubyte & getGreen () const
const ubyte & getBlue () const
const ubyte & getDummy () const
const ubyte & getAlpha () const
const uint32 & getValue () const
uint32 & getValue ()
ubyte & at (const int x)
const ubyte & at (const int x) const
ubyte & operator[] (const int x)
const ubyte & operator[] (const int x) const
int size () const
rgbPixel & copy (const rgbPixel &other)
rgbPixel & operator= (const rgbPixel &other)
bool isEqual (const rgbPixel &other) const
bool isEqualColor (const rgbPixel &other) const
bool operator== (const rgbPixel &other) const
bool operator!= (const rgbPixel &other) const
bool operator< (const rgbPixel &other) const
bool operator> (const rgbPixel &other) const
rgbPixel & add (const rgbPixel &other)
rgbPixel & operator+= (const rgbPixel &other)
rgbPixel operator+ (const rgbPixel &other) const
rgbPixel & subtract (const rgbPixel &other)
rgbPixel & operator-= (const rgbPixel &other)
rgbPixel operator- (const rgbPixel &other) const
rgbPixel & multiply (const rgbPixel &other)
rgbPixel & operator*= (const rgbPixel &other)
rgbPixel operator* (const rgbPixel &other) const
rgbPixel & multiply (const int &other)
rgbPixel & multiply (const float &other)
rgbPixel & multiply (const double &other)
rgbPixel & operator*= (const int &other)
rgbPixel & operator*= (const float &other)
rgbPixel & operator*= (const double &other)
rgbPixel operator* (const int &other) const
rgbPixel operator* (const float &other) const
rgbPixel operator* (const double &other) const
rgbPixel & divide (const rgbPixel &other)
rgbPixel & operator/= (const rgbPixel &other)
rgbPixel operator/ (const rgbPixel &other) const
rgbPixel & divide (const int &other)
rgbPixel & operator/= (const int &other)
rgbPixel operator/ (const int &other) const
int absSqr () const
int dot (const rgbPixel &other) const
int distanceSqr (const rgbPixel &other) const

Protected Attributes

rgbPixelType data

Detailed Description

Color pixel representation in RGB color space.

This type ensures that a size of 32-bits. Each channel use values between 0 and 255, and a fourth "alpha" channel is used to complete the 32-bits.

If you need to use pixel values for the RGB channels of other types you can use lti::trgbPixel.


Member Typedef Documentation

return type of the size() member

used for the template-based interface for pixels as vectors.


Constructor & Destructor Documentation

lti::rgbPixel::rgbPixel (  )  [inline]

Default constructor.

This constructor does not initialize the contents of a pixel. The reason is that a default initialization would cost too much time while creating temporary images, required in many image processing algorithms.

You should take special care while initializing your pixels: do not forget to initialize the alpha channel too.

lti::rgbPixel::rgbPixel ( const uint32  val  )  [inline]

constructor with member initialization

Per default a new rgbPixel will be initialized with the given value.

Parameters:
val a 4 byte value to be assign to the three channels + alpha. Note that the order depends on the system endianness:

  • If you use little endian (for example: Intel Processor) a value of 0x00010203 means red=01,green=02 and blue=03
  • If you use big endian (for example: PowerPC Processor) a value of 0x00010203 means red=02,green=01 and blue=00 Avoid the use of this constructor if you want to maintain platform compatibility.

References data, and lti::rgbPixel::rgbPixelType::value.

lti::rgbPixel::rgbPixel ( const ubyte  r,
const ubyte  g,
const ubyte  b,
const ubyte  d = 0 
) [inline]

rgb constructor

Parameters:
r 8 bit value for the red component
g 8 bit value for the green component
b 8 bit value for the blue component
d 8 bit value for the alpha byte (default value 0)

References lti::rgbPixel::rgbPixelType::channels, and data.

template<class U >
lti::rgbPixel::rgbPixel ( const trgbPixel< U > &  p  )  [inline]

Member Function Documentation

int lti::rgbPixel::absSqr (  )  const [inline]

obtain the square of the magnitud of this pixel $red^2+green^2+blue^2 $.

References getBlue(), getGreen(), and getRed().

rgbPixel& lti::rgbPixel::add ( const rgbPixel &  other  )  [inline]

add this pixel with another one

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

Referenced by operator+(), and operator+=().

const ubyte& lti::rgbPixel::at ( const int  x  )  const [inline]

Used to simulate read-only vector access.

The correspondence between the elements of the vector and the color components still depents on the endianness of the system, but is usually at(0) for red, at(1) for green and at(2) for blue.

References data, and lti::rgbPixel::rgbPixelType::value.

ubyte& lti::rgbPixel::at ( const int  x  )  [inline]

Used to simulate vector access.

The correspondence between the elements of the vector and the color components is at(0) for red, at(1) for green and at(2) for blue.

References data, and lti::rgbPixel::rgbPixelType::value.

rgbPixel& lti::rgbPixel::copy ( const rgbPixel &  other  )  [inline]

copy the "other" pixel

References getValue(), and setValue().

Referenced by operator=().

int lti::rgbPixel::distanceSqr ( const rgbPixel &  other  )  const [inline]

returns the square of the distance of this pixel to the other one defined as $(red-other.red)^2+(green-other.green)^2+(blue-other.blue)^2$.

References lti::rgbPixel::rgbPixelType::channels, data, getBlue(), getGreen(), and getRed().

Referenced by lti::distanceSqr().

rgbPixel& lti::rgbPixel::divide ( const int &  other  )  [inline]

divide this pixel with an integer

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

rgbPixel& lti::rgbPixel::divide ( const rgbPixel &  other  )  [inline]

divide this pixel with another one the pixel division divides elementwise the elements of the pixel!

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

Referenced by operator/(), and operator/=().

int lti::rgbPixel::dot ( const rgbPixel &  other  )  const [inline]

get the scalar product of this pixel with another one, considering them as a 3D vector.

The dot product will be the sum of the red*other.red + green*other.green + blue*other.blue

References getBlue(), getGreen(), and getRed().

void lti::rgbPixel::get ( int &  red,
int &  green,
int &  blue,
int &  alpha 
) const [inline]

Get the four components and write them in the given arguments.

References lti::rgbPixel::rgbPixelType::channels, and data.

void lti::rgbPixel::get ( ubyte &  red,
ubyte &  green,
ubyte &  blue,
ubyte &  alpha 
) const [inline]

Get the four components and write them in the given arguments.

References lti::rgbPixel::rgbPixelType::channels, and data.

void lti::rgbPixel::get ( int &  red,
int &  green,
int &  blue 
) const [inline]

Get the three color components and write them in the given arguments.

References lti::rgbPixel::rgbPixelType::channels, and data.

void lti::rgbPixel::get ( ubyte &  red,
ubyte &  green,
ubyte &  blue 
) const [inline]

Get the three color components and write them in the given arguments.

References lti::rgbPixel::rgbPixelType::channels, and data.

const ubyte& lti::rgbPixel::getAlpha (  )  const [inline]

returns alpha component

References lti::rgbPixel::rgbPixelType::channels, and data.

Referenced by lti::write().

const ubyte& lti::rgbPixel::getBlue (  )  const [inline]
const ubyte& lti::rgbPixel::getDummy (  )  const [inline]

returns alpha component

*

Deprecated:
use getAlpha() instead!

References lti::rgbPixel::rgbPixelType::channels, and data.

const ubyte& lti::rgbPixel::getGreen (  )  const [inline]
const ubyte& lti::rgbPixel::getRed (  )  const [inline]
uint32& lti::rgbPixel::getValue (  )  [inline]

returns 4 byte component with RGB value

References data, and lti::rgbPixel::rgbPixelType::value.

const uint32& lti::rgbPixel::getValue (  )  const [inline]

returns 4 byte component with RGB value

References data, and lti::rgbPixel::rgbPixelType::value.

Referenced by copy(), isEqual(), operator<(), and operator>().

bool lti::rgbPixel::isEqual ( const rgbPixel &  other  )  const [inline]

Compares this pixel with the specified other pixel.

Two pixels are considered equal if all four (!) channels, i.e. R, G, B, and alpha, are equal. A call to this method is equivalent to this->getValue() == other.getValue().

References getValue().

Referenced by operator!=(), and operator==().

bool lti::rgbPixel::isEqualColor ( const rgbPixel &  other  )  const [inline]

Compares the color of this pixel with the specified other pixel.

Only the three RGB channels are considered; the alpha value is ignored.

References getBlue(), getGreen(), and getRed().

rgbPixel& lti::rgbPixel::multiply ( const double &  other  )  [inline]

multiply this pixel with a float.

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

rgbPixel& lti::rgbPixel::multiply ( const float &  other  )  [inline]

multiply this pixel with a float.

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

rgbPixel& lti::rgbPixel::multiply ( const int &  other  )  [inline]

multiply this pixel with an integer

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

rgbPixel& lti::rgbPixel::multiply ( const rgbPixel &  other  )  [inline]

multiply this pixel with another one the pixel multiplication multiplies elementwise the elements of the pixel!

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

Referenced by operator*(), and operator*=().

bool lti::rgbPixel::operator!= ( const rgbPixel &  other  )  const [inline]

alias for !compare()

References isEqual().

rgbPixel lti::rgbPixel::operator* ( const double &  other  )  const [inline]

multiply this pixel with a float an return a new one.

References multiply().

rgbPixel lti::rgbPixel::operator* ( const float &  other  )  const [inline]

multiply this pixel with a float an return a new one.

References multiply().

rgbPixel lti::rgbPixel::operator* ( const int &  other  )  const [inline]

multiply this pixel with another one without altering anything.

..

References multiply().

rgbPixel lti::rgbPixel::operator* ( const rgbPixel &  other  )  const [inline]

multiply this pixel with another one without altering anything.

..

References multiply().

rgbPixel& lti::rgbPixel::operator*= ( const double &  other  )  [inline]

alias for multiply

References multiply().

rgbPixel& lti::rgbPixel::operator*= ( const float &  other  )  [inline]

alias for multiply

References multiply().

rgbPixel& lti::rgbPixel::operator*= ( const int &  other  )  [inline]

alias for multiply

References multiply().

rgbPixel& lti::rgbPixel::operator*= ( const rgbPixel &  other  )  [inline]

alias for multiply()

References multiply().

rgbPixel lti::rgbPixel::operator+ ( const rgbPixel &  other  )  const [inline]

add this pixel with the otherone without altering anything.

..

References add().

rgbPixel& lti::rgbPixel::operator+= ( const rgbPixel &  other  )  [inline]

alias for add

References add().

rgbPixel lti::rgbPixel::operator- ( const rgbPixel &  other  )  const [inline]

subtract 'other' from this pixel without altering anything.

..

References subtract().

rgbPixel& lti::rgbPixel::operator-= ( const rgbPixel &  other  )  [inline]

alias for subtract

References subtract().

rgbPixel lti::rgbPixel::operator/ ( const int &  other  )  const [inline]

divide this pixel with another one without altering anything.

..

References divide().

rgbPixel lti::rgbPixel::operator/ ( const rgbPixel &  other  )  const [inline]

divide this pixel with another one without altering anything.

..

References divide().

rgbPixel& lti::rgbPixel::operator/= ( const int &  other  )  [inline]

alias for divide

References divide().

rgbPixel& lti::rgbPixel::operator/= ( const rgbPixel &  other  )  [inline]

alias for divide()

References divide().

bool lti::rgbPixel::operator< ( const rgbPixel &  other  )  const [inline]

An rgbPixel is said to be "smaller" than another one, if getValue() < other.getValue().

References getValue().

rgbPixel& lti::rgbPixel::operator= ( const rgbPixel &  other  )  [inline]

alias for copy

References copy().

bool lti::rgbPixel::operator== ( const rgbPixel &  other  )  const [inline]

Alias for isEqual().

Please note the difference between isEqual() and isEqualColor()!

References isEqual().

bool lti::rgbPixel::operator> ( const rgbPixel &  other  )  const [inline]

An rgbPixel is said to be "bigger" than another one, if getValue() > other.getValue().

References getValue().

const ubyte& lti::rgbPixel::operator[] ( const int  x  )  const [inline]

Used to simulate read-only vector access.

The correspondence between the elements of the vector and the color components still depents on the endianness of the system, but is usually [0] for red, [1] for green and [2] for blue.

References lti::rgbPixel::rgbPixelType::channels, and data.

ubyte& lti::rgbPixel::operator[] ( const int  x  )  [inline]

Used to simulate vector access.

The correspondence between the elements of the vector and the color components is [0] for red, [1] for green and [2] for blue.

References lti::rgbPixel::rgbPixelType::channels, and data.

void lti::rgbPixel::set ( const ubyte  red,
const ubyte  green,
const ubyte  blue 
) [inline]

set the red, green, blue values for the pixel

References lti::rgbPixel::rgbPixelType::channels, and data.

void lti::rgbPixel::set ( const ubyte  red,
const ubyte  green,
const ubyte  blue,
const ubyte  alpha 
) [inline]

set the red, green, blue and alpha values for the pixel

References lti::rgbPixel::rgbPixelType::channels, and data.

Referenced by lti::mergeYUVToImage::apply(), lti::mergeYPbPrToImage::apply(), and lti::mergeYCbCrToImage::apply().

void lti::rgbPixel::setAlpha ( const ubyte  alpha  )  [inline]

sets the alpha components to the given value

References lti::rgbPixel::rgbPixelType::channels, and data.

Referenced by lti::read().

void lti::rgbPixel::setBlue ( const ubyte  b  )  [inline]

sets the blue component to given value

References lti::rgbPixel::rgbPixelType::channels, and data.

Referenced by add(), divide(), lti::SOFM2DVisualizer::drawClasses(), multiply(), lti::read(), and subtract().

void lti::rgbPixel::setDummy ( const ubyte  d  )  [inline]

sets the alpha component to given value

Deprecated:
use setAlpha(const ubyte alpha) instead!

References lti::rgbPixel::rgbPixelType::channels, and data.

void lti::rgbPixel::setGreen ( const ubyte  g  )  [inline]

sets the green component to given value

References lti::rgbPixel::rgbPixelType::channels, and data.

Referenced by add(), divide(), lti::SOFM2DVisualizer::drawClasses(), multiply(), lti::read(), and subtract().

void lti::rgbPixel::setRed ( const ubyte  r  )  [inline]

sets the red component to given value

References lti::rgbPixel::rgbPixelType::channels, and data.

Referenced by add(), divide(), lti::SOFM2DVisualizer::drawClasses(), multiply(), lti::read(), and subtract().

void lti::rgbPixel::setValue ( const uint32 &  v  )  [inline]

sets the value component (all components together) to given value

References data, and lti::rgbPixel::rgbPixelType::value.

Referenced by copy().

int lti::rgbPixel::size (  )  const [inline]

Used to simulate the vector size.

rgbPixel& lti::rgbPixel::subtract ( const rgbPixel &  other  )  [inline]

subtract 'other' from this pixel

References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().

Referenced by operator-(), and operator-=().


Member Data Documentation


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

Generated on Sat Apr 10 15:26:44 2010 for LTI-Lib by Doxygen 1.6.1