CVR-Lib last update 20 Sep 2009

cvr::rgbPixel< T > Class Template Reference
[Color Analysis]

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

#include <cvrRGBPixel.h>

Inheritance diagram for cvr::rgbPixel< T >:

Inheritance graph
[legend]

List of all members.

Public Types

typedef T value_type
typedef int size_type

Public Member Functions

 rgbPixel ()
 rgbPixel (const T r, const T g, const T b)
 rgbPixel (const rgbaPixel &other)
template<class U >
 rgbPixel (const rgbPixel< U > &other)
template<class U >
void set (const U r, const U g, const U blue)
void setRed (const T r)
void setGreen (const T g)
void setBlue (const T b)
template<class U >
void get (U &r, U &g, U &b) const
const T & getRed () const
const T & getGreen () const
const T & getBlue () const
T & getRed ()
T & getGreen ()
T & getBlue ()
T & at (const int x)
const T & at (const int x) const
T & operator[] (const int x)
const T & operator[] (const int x) const
size_type size () const
rgbPixel< T > & copy (const rgbPixel< T > &other)
rgbPixel< T > & operator= (const rgbPixel< T > &other)
rgbPixel< T > & copy (const rgbaPixel &other)
rgbPixel< T > & operator= (const rgbaPixel &other)
void castTo (rgbaPixel &other) const
rgbaPixel getRGBAPixel () const
rgbaPixel getClippedRGBAPixel () const
bool isEqual (const rgbPixel< T > &other) const
bool operator== (const rgbPixel< T > &other) const
bool operator!= (const rgbPixel< T > &other) const
bool operator< (const rgbPixel< T > &other) const
bool operator> (const rgbPixel< T > &other) const
rgbPixel< T > & add (const rgbPixel< T > &other)
rgbPixel< T > & operator+= (const rgbPixel< T > &other)
rgbPixel< T > operator+ (const rgbPixel< T > &other) const
rgbPixel< T > & subtract (const rgbPixel< T > &other)
rgbPixel< T > & operator-= (const rgbPixel< T > &other)
rgbPixel< T > operator- (const rgbPixel< T > &other) const
rgbPixel< T > & multiply (const rgbPixel< T > &other)
rgbPixel< T > & operator*= (const rgbPixel< T > &other)
rgbPixel< T > operator* (const rgbPixel< T > &other) const
rgbPixel< T > & multiply (const int other)
rgbPixel< T > & multiply (const float &other)
rgbPixel< T > & multiply (const double &other)
rgbPixel< T > & operator*= (const int other)
rgbPixel< T > & operator*= (const float &other)
rgbPixel< T > & operator*= (const double &other)
rgbPixel< T > operator* (const int other) const
rgbPixel< T > operator* (const float &other) const
rgbPixel< T > operator* (const double &other) const
rgbPixel< T > & divide (const rgbPixel< T > &other)
rgbPixel< T > & operator/= (const rgbPixel< T > &other)
rgbPixel< T > operator/ (const rgbPixel< T > &other) const
rgbPixel< T > & divide (const int other)
rgbPixel< T > & divide (const float &other)
rgbPixel< T > & divide (const double &other)
rgbPixel< T > & operator/= (const int other)
rgbPixel< T > & operator/= (const float &other)
rgbPixel< T > & operator/= (const double &other)
rgbPixel< T > operator/ (const int other) const
rgbPixel< T > operator/ (const float &other) const
rgbPixel< T > operator/ (const double &other) const
typeInfo< T >
::square_accumulation_type 
absSqr () const
typeInfo< T >
::square_accumulation_type 
dot (const rgbPixel< T > &other) const
typeInfo< T >
::square_accumulation_type 
distanceSqr (const rgbPixel< T > &other) const

Public Attributes

union {
   struct {
      T   red
      T   green
      T   blue
   } 
   T   data [3]
}; 


Detailed Description

template<typename T>
class cvr::rgbPixel< T >

Color pixel representation in RGB color space.

This is a more general type than cvr::rgbaPixel, which is used to represent points in the RGB color space with arbitrary precision, specified through the template type of the class.

The types supported for T are byte, ubyte, int16, uint16, int32, uint32, float and double.


Member Typedef Documentation

template<typename T>
typedef int cvr::rgbPixel< T >::size_type

Return type of the size() member.

template<typename T>
typedef T cvr::rgbPixel< T >::value_type

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


Constructor & Destructor Documentation

template<typename T>
cvr::rgbPixel< T >::rgbPixel (  ) 

Default constructor.

The default constructor of the rgbPixel<T> does not initialize anything, in order to allow the creation of uninitialized images in a more efficient way.

template<typename T>
cvr::rgbPixel< T >::rgbPixel ( const T  r,
const T  g,
const T  b 
)

RGB constructor.

Parameters:
r value for the red component
g value for the green component
b value for the blue component

template<typename T>
cvr::rgbPixel< T >::rgbPixel ( const rgbaPixel other  ) 

Copy constructor.

template<typename T>
template<class U >
cvr::rgbPixel< T >::rgbPixel ( const rgbPixel< U > &  other  )  [inline]

Copy constructor.


Member Function Documentation

template<typename T>
typeInfo<T>::square_accumulation_type cvr::rgbPixel< T >::absSqr (  )  const [inline]

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

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::add ( const rgbPixel< T > &  other  )  [inline]

Add this pixel with another one.

The alpha channel is kept unchanged.

template<typename T>
const T& cvr::rgbPixel< T >::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.

template<typename T>
T& cvr::rgbPixel< T >::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.

template<typename T>
void cvr::rgbPixel< T >::castTo ( rgbaPixel other  )  const [inline]

Cast To an cvr::rgbaPixel.

The alpha value of the rgbaPixel is always set to zero

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::copy ( const rgbaPixel other  )  [inline]

Copy the "other" pixel.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::copy ( const rgbPixel< T > &  other  )  [inline]

Copy the "other" pixel.

template<typename T>
typeInfo<T>::square_accumulation_type cvr::rgbPixel< T >::distanceSqr ( const rgbPixel< T > &  other  )  const [inline]

Square of the distance between this pixel and the other one.

$(red-other.red)^2+(green-other.green)^2+(blue-other.blue)^2$.

Referenced by cvr::euclideanDistance(), and cvr::euclideanDistanceSqr().

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::divide ( const double &  other  )  [inline]

Divide all components of this pixel with an integer.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::divide ( const float &  other  )  [inline]

Divide all components of this pixel with an integer.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::divide ( const int  other  )  [inline]

Divide all components of this pixel with an integer.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::divide ( const rgbPixel< T > &  other  )  [inline]

Divide this pixel with another one.

The pixel division divides elementwise the elements of the pixel except the alpha channel, which is kept unchanged.

template<typename T>
typeInfo<T>::square_accumulation_type cvr::rgbPixel< T >::dot ( const rgbPixel< T > &  other  )  const [inline]

Scalar product in the 3D RGB color space.

Get the scalar product of this pixel with another one, considering them as a 3D point in the RGB color space.

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

template<typename T>
template<class U >
void cvr::rgbPixel< T >::get ( U &  r,
U &  g,
U &  b 
) const [inline]

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

template<typename T>
T& cvr::rgbPixel< T >::getBlue (  )  [inline]

Returns blue component.

template<typename T>
const T& cvr::rgbPixel< T >::getBlue (  )  const [inline]

Returns blue component.

template<typename T>
rgbaPixel cvr::rgbPixel< T >::getClippedRGBAPixel (  )  const [inline]

Get a new cvr::rgbaPixel with the contents of this pixel.

Just a static_cast of the attributes will be made and the alpha is set to zero. In case of under/overflow, the values are set to zero or 255.

template<typename T>
T& cvr::rgbPixel< T >::getGreen (  )  [inline]

Returns green component.

template<typename T>
const T& cvr::rgbPixel< T >::getGreen (  )  const [inline]

Returns green component.

template<typename T>
T& cvr::rgbPixel< T >::getRed (  )  [inline]

Returns red component.

template<typename T>
const T& cvr::rgbPixel< T >::getRed (  )  const [inline]

Returns red component.

template<typename T>
rgbaPixel cvr::rgbPixel< T >::getRGBAPixel (  )  const [inline]

Get a new cvr::rgbaPixel with the contents of this pixel.

Just a static_cast of the attributes will be made and the alpha is set to zero. No clipping of the values is made in case of under or overflow.

template<typename T>
bool cvr::rgbPixel< T >::isEqual ( const rgbPixel< T > &  other  )  const [inline]

Compare two pixels (true if equal!).

Two pixels are equal if all four components (red, green, blue, and alpha) are equal. It is an usual error to leave the alpha channel uninizalized and then compare for equalilty.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::multiply ( const double &  other  )  [inline]

Multiply all components of this pixel with a float, except the alpha channel, which is kept unchanged.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::multiply ( const float &  other  )  [inline]

Multiply all components of this pixel with a float, except the alpha channel, which is kept unchanged.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::multiply ( const int  other  )  [inline]

Multiply all components of this pixel with an integer, except the alpha channel, which is kept unchanged.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::multiply ( const rgbPixel< T > &  other  )  [inline]

Multiply this pixel with another one.

The pixel multiplication multiplies elementwise the elements of the pixel, except the alpha channel, which is kept unchanged.

template<typename T>
bool cvr::rgbPixel< T >::operator!= ( const rgbPixel< T > &  other  )  const [inline]

Alias for !compare().

Two pixels are equal if all four components (red, green, blue, and alpha) are equal. It is an usual error to leave the alpha channel uninizalized and then compare for equalilty.

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator* ( const double &  other  )  const [inline]

Multiply all components of this pixel with a a double, except the alpha channel.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator* ( const float &  other  )  const [inline]

Multiply all components of this pixel with a a float, except the alpha channel.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator* ( const int  other  )  const [inline]

Multiply all components of this pixel with a an integer, except the alpha channel.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator* ( const rgbPixel< T > &  other  )  const [inline]

Multiply this pixel with another one without altering anything.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator*= ( const double &  other  )  [inline]

Multiply all components of this pixel with a a double, except the alpha channel, which is kept unchanged.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator*= ( const float &  other  )  [inline]

Multiply all components of this pixel with a a float, except the alpha channel, which is kept unchanged.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator*= ( const int  other  )  [inline]

Multiply all components of this pixel with a an integer, except the alpha channel, which is kept unchanged.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator*= ( const rgbPixel< T > &  other  )  [inline]

Multiply this pixel with another one.

The pixel multiplication multiplies elementwise the elements of the pixel, except the alpha channel, which is kept unchanged.

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator+ ( const rgbPixel< T > &  other  )  const [inline]

Add this pixel with the other one without altering anything.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator+= ( const rgbPixel< T > &  other  )  [inline]

Add this pixel with another one.

The alpha channel is kept unchanged.

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator- ( const rgbPixel< T > &  other  )  const [inline]

Subtract 'other' from this pixel without altering anything.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator-= ( const rgbPixel< T > &  other  )  [inline]

Subtract 'other' from this pixel.

The alpha channel is kept unchanged.

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator/ ( const double &  other  )  const [inline]

Divide all components of this pixel with an integer without altering anything.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator/ ( const float &  other  )  const [inline]

Divide all components of this pixel with an integer without altering anything.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator/ ( const int  other  )  const [inline]

Divide all components of this pixel with an integer without altering anything.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T> cvr::rgbPixel< T >::operator/ ( const rgbPixel< T > &  other  )  const [inline]

Divide this pixel with another one.

The pixel division divides elementwise the elements of the pixel except the alpha channel.

The alpha channel of the resulting pixel is equal to the one of this pixel (the first operand in the binary expression)

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator/= ( const double &  other  )  [inline]

Divide all components of this pixel with an integer.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator/= ( const float &  other  )  [inline]

Divide all components of this pixel with an integer.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator/= ( const int  other  )  [inline]

Divide all components of this pixel with an integer.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator/= ( const rgbPixel< T > &  other  )  [inline]

Divide this pixel with another one.

The pixel division divides elementwise the elements of the pixel except the alpha channel, which is kept unchanged.

template<typename T>
bool cvr::rgbPixel< T >::operator< ( const rgbPixel< T > &  other  )  const [inline]

Less than operator.

An rgbPixel<T> is said to be "smaller" than another one, if its red component its smaller, or (if both red components are equal) if the green component if smaller, or (if both green components are equal) if the blue component is smaller.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator= ( const rgbaPixel other  )  [inline]

Alias for copy.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::operator= ( const rgbPixel< T > &  other  )  [inline]

Alias for copy.

template<typename T>
bool cvr::rgbPixel< T >::operator== ( const rgbPixel< T > &  other  )  const [inline]

Alias for compare().

Two pixels are equal if all four components (red, green, blue, and alpha) are equal. It is an usual error to leave the alpha channel uninizalized and then compare for equalilty.

template<typename T>
bool cvr::rgbPixel< T >::operator> ( const rgbPixel< T > &  other  )  const [inline]

Greater than operator.

An rgbPixel<T> is said to be "greater" than another one, if its red component its greater, or (if both red components are equal) if the green component if greater, or (if both green components are equal) if the blue component is greater.

template<typename T>
const T& cvr::rgbPixel< T >::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.

template<typename T>
T& cvr::rgbPixel< T >::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.

template<typename T>
template<class U >
void cvr::rgbPixel< T >::set ( const U  r,
const U  g,
const U  blue 
) [inline]

Set the red, green, blue values for the pixel.

template<typename T>
void cvr::rgbPixel< T >::setBlue ( const T  b  )  [inline]

Sets the blue component to given value.

template<typename T>
void cvr::rgbPixel< T >::setGreen ( const T  g  )  [inline]

Sets the green component to given value.

template<typename T>
void cvr::rgbPixel< T >::setRed ( const T  r  )  [inline]

Sets the red component to given value.

template<typename T>
size_type cvr::rgbPixel< T >::size (  )  const [inline]

Used to simulate the vector size.

It returns always 3.

template<typename T>
rgbPixel<T>& cvr::rgbPixel< T >::subtract ( const rgbPixel< T > &  other  )  [inline]

Subtract 'other' from this pixel.

The alpha channel is kept unchanged.


Member Data Documentation

union { ... }

Anonymous union to provide efficient access through three different mechanism to the pixel components.

The order of the data in this union assumes little endianness.

template<typename T>
T cvr::rgbPixel< T >::blue

Blue channel.

template<typename T>
T cvr::rgbPixel< T >::data[3]

The four values as array.

template<typename T>
T cvr::rgbPixel< T >::green

Green channel.

template<typename T>
T cvr::rgbPixel< T >::red

Red channel.


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

Generated on Sun Sep 20 22:09:08 2009 for CVR-Lib by Doxygen 1.5.8