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

lti::trgbPixel< T > Class Template Reference
[Color Analysis]

Template to use RGB pixel representations of types other than ubyte. More...

#include <ltiRGBPixel.h>

Inheritance diagram for lti::trgbPixel< T >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef T value_type
typedef int size_type

Public Member Functions

 trgbPixel ()
 trgbPixel (const T g)
 trgbPixel (const T r, const T g, const T b)
 trgbPixel (const trgbPixel< T > &p)
 trgbPixel (const rgbPixel &p)
void get (T &r, T &g, T &b) const
const T & getRed () const
const T & getGreen () const
const T & getBlue () const
void set (const T r, const T g, const T b)
void setRed (const T r)
void setGreen (const T g)
void setBlue (const T b)
T & at (const int x)
const T & at (const int x) const
T & operator[] (const int x)
const T & operator[] (const int x) const
int size () const
trgbPixel< T > & copy (const trgbPixel< T > &other)
trgbPixel< T > & copy (const rgbPixel &other)
trgbPixel< T > & operator= (const trgbPixel< T > &other)
trgbPixel< T > & operator= (const rgbPixel &other)
template<class U >
trgbPixel< T > & castFrom (const trgbPixel< U > &other)
bool isEqual (const trgbPixel< T > &other) const
bool operator== (const trgbPixel< T > &other) const
bool operator!= (const trgbPixel< T > &other) const
bool operator< (const trgbPixel< T > &other) const
bool operator> (const trgbPixel< T > &other) const
trgbPixel< T > & add (const trgbPixel< T > &other)
trgbPixel< T > & add (const trgbPixel< T > &a, const trgbPixel< T > &b)
trgbPixel< T > & add (const T val)
trgbPixel< T > & operator+= (const trgbPixel< T > &other)
trgbPixel< T > operator+ (const trgbPixel< T > &other) const
trgbPixel< T > addScaled (const T b, const trgbPixel< T > &other)
trgbPixel< T > addScaled (const T a, const trgbPixel< T > &pixa, const T b, const trgbPixel< T > &pixb)
trgbPixel< T > addScaled (const trgbPixel< T > &pixa, const T b, const trgbPixel< T > &pixb)
trgbPixel< T > addScaled (const T a, const T b, const trgbPixel< T > &pixb)
trgbPixel< T > & subtract (const trgbPixel< T > &other)
trgbPixel< T > & subtract (const trgbPixel< T > &a, const trgbPixel< T > &b)
trgbPixel< T > & subtract (const T val)
trgbPixel< T > & operator-= (const trgbPixel< T > &other)
trgbPixel< T > operator- (const trgbPixel< T > &other) const
trgbPixel< T > & multiply (const trgbPixel< T > &other)
trgbPixel< T > & multiply (const trgbPixel< T > &a, const trgbPixel< T > &b)
trgbPixel< T > & multiply (const T c)
trgbPixel< T > & multiply (const trgbPixel< T > &other, const T val)
trgbPixel< T > & operator*= (const trgbPixel< T > &other)
trgbPixel< T > operator* (const trgbPixel< T > &other) const
trgbPixel< T > operator*= (const T other)
trgbPixel< T > operator* (const T c) const
trgbPixel< T > & divide (const T c)
trgbPixel< T > operator/ (const T c) const
trgbPixel< T > & divide (const trgbPixel< T > &other, const T val)
trgbPixel< T > & operator/= (const T c)
trgbPixel< T > & divide (const trgbPixel< T > &c)
trgbPixel< T > & divide (const trgbPixel< T > &a, const trgbPixel< T > &b)
trgbPixel< T > operator/ (const trgbPixel< T > &c) const
trgbPixel< T > & operator/= (const trgbPixel< T > &c)
absSqr () const
distanceSqr (const trgbPixel< T > &other) const
dot (const trgbPixel< T > &other) const
rgbPixel getRGBPixel () const
rgbPixel getClippedRGBPixel () const
trgbPixel< T > & apply (T(*function)(T))
trgbPixel< T > & apply (T(*function)(const T &))

Public Attributes

red
green
blue

Detailed Description

template<class T>
class lti::trgbPixel< T >

Template to use RGB pixel representations of types other than ubyte.

The type rgbPixel optimize speed and memory use. If you need RGB integer values between 0 and 255, you should use rgbPixel instead (much more efficient!)

See also:
lti::drgbPixel, lti::frgbPixel, lti::irgbPixel

Member Typedef Documentation

template<class T>
typedef int lti::trgbPixel< T >::size_type

return type of the size() member

template<class T>
typedef T lti::trgbPixel< T >::value_type

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


Constructor & Destructor Documentation

template<class T>
lti::trgbPixel< T >::trgbPixel (  )  [inline]

default constructor

template<class T>
lti::trgbPixel< T >::trgbPixel ( const T  g  )  [inline, explicit]

gray value constructor

template<class T>
lti::trgbPixel< T >::trgbPixel ( const T  r,
const T  g,
const T  b 
) [inline]

default constructor

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

copy constructor

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

copy constructor


Member Function Documentation

template<class T>
T lti::trgbPixel< T >::absSqr (  )  const [inline]

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

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::add ( const T  val  )  [inline]

add a constant to each component of the pixel

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::add ( const trgbPixel< T > &  a,
const trgbPixel< T > &  b 
) [inline]

Add pixels a and b leave the result here.

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::add ( const trgbPixel< T > &  other  )  [inline]
template<class T>
trgbPixel<T> lti::trgbPixel< T >::addScaled ( const T  a,
const T  b,
const trgbPixel< T > &  pixb 
) [inline]

scale this pixel with a, and add to the result the scaled pixel pixb (scaling factor b), i.e.

*this = *this*a + pb*b

template<class T>
trgbPixel<T> lti::trgbPixel< T >::addScaled ( const trgbPixel< T > &  pixa,
const T  b,
const trgbPixel< T > &  pixb 
) [inline]

assign to this pixel the sum of the pixel pixa and the scaled pixel pixb (scaling factor b), i.e.

*this = pa + pb*b

template<class T>
trgbPixel<T> lti::trgbPixel< T >::addScaled ( const T  a,
const trgbPixel< T > &  pixa,
const T  b,
const trgbPixel< T > &  pixb 
) [inline]

assign to this pixel the sum of the scaled pixels with their respective scaling factors, i.e.

*this = pa*a + pb*b

template<class T>
trgbPixel<T> lti::trgbPixel< T >::addScaled ( const T  b,
const trgbPixel< T > &  other 
) [inline]

add to this pixel the other pixel scaled by the given constant

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::apply ( T(*)(const T &)  function  )  [inline]

apply a C-function to each component of the pixel

Returns:
a reference to the pixel
template<class T>
trgbPixel<T>& lti::trgbPixel< T >::apply ( T(*)(T)  function  )  [inline]

apply a C-function to each component of the pixel

Returns:
a reference to the pixel
template<class T>
const T& lti::trgbPixel< T >::at ( const int  x  )  const [inline]

Used to simulate read-only vector access.

It is slower than the normal access to the elements with getRed() or similar methods.

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

template<class T>
T& lti::trgbPixel< T >::at ( const int  x  )  [inline]

Used to simulate vector access.

It is slower than the normal access to the elements with getRed() or setRed() similar methods.

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

template<class T>
template<class U >
trgbPixel<T>& lti::trgbPixel< T >::castFrom ( const trgbPixel< U > &  other  )  [inline]

convert between pixels of different types

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::copy ( const rgbPixel other  )  [inline]

copy member

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::copy ( const trgbPixel< T > &  other  )  [inline]

copy member

Referenced by lti::trgbPixel< int >::operator=().

template<class T>
T lti::trgbPixel< T >::distanceSqr ( const trgbPixel< T > &  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$.

Referenced by lti::distanceSqr().

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::divide ( const trgbPixel< T > &  a,
const trgbPixel< T > &  b 
) [inline]

Elementwise divide between the elements of a and b.

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::divide ( const trgbPixel< T > &  c  )  [inline]

elementwise divide

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::divide ( const trgbPixel< T > &  other,
const T  val 
) [inline]

divide the elements of the other pixel with the given value, and leave the result here.

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::divide ( const T  c  )  [inline]
template<class T>
T lti::trgbPixel< T >::dot ( const trgbPixel< T > &  other  )  const [inline]

computes the dot product with another pixel, which is define as the sum of the products of all corresponding components, i.e.

p1.red*p2.red + p1.green*p2.green + p1.blue*p2.blue, where p1 is this pixel.

template<class T>
void lti::trgbPixel< T >::get ( T &  r,
T &  g,
T &  b 
) const [inline]

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

template<class T>
const T& lti::trgbPixel< T >::getBlue (  )  const [inline]
template<class T>
rgbPixel lti::trgbPixel< T >::getClippedRGBPixel (  )  const [inline]

return a normal lti::rgbPixel Values lower than 0 are set to 0 and values higher than 255 are set to 255.

This method is slower than getRGBPixel() due to the extra comparisons

See also:
getRGBPixel()
template<class T>
const T& lti::trgbPixel< T >::getGreen (  )  const [inline]
template<class T>
const T& lti::trgbPixel< T >::getRed (  )  const [inline]
template<class T>
rgbPixel lti::trgbPixel< T >::getRGBPixel (  )  const [inline]

return a normal lti::rgbPixel You should ensure that the values are all in a valid interval!

See also:
getClippedRGBPixel()
template<class T>
bool lti::trgbPixel< T >::isEqual ( const trgbPixel< T > &  other  )  const [inline]

compare member: returns true if this is equal to other

Referenced by lti::trgbPixel< int >::operator!=(), and lti::trgbPixel< int >::operator==().

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::multiply ( const trgbPixel< T > &  other,
const T  val 
) [inline]

multiply the elements of the other pixel with the given value, and leave the result here.

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::multiply ( const T  c  )  [inline]

multiply with a constant

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::multiply ( const trgbPixel< T > &  a,
const trgbPixel< T > &  b 
) [inline]

Elementwise multiplication of the elements of a and b.

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::multiply ( const trgbPixel< T > &  other  )  [inline]

multiply with another pixel.

The pixel multiplication is a elementwise multiplication

Referenced by lti::trgbPixel< int >::operator*(), and lti::trgbPixel< int >::operator*=().

template<class T>
bool lti::trgbPixel< T >::operator!= ( const trgbPixel< T > &  other  )  const [inline]

alias for !compare()

template<class T>
trgbPixel<T> lti::trgbPixel< T >::operator* ( const T  c  )  const [inline]

multiply this pixel with another one without altering anything.

..

template<class T>
trgbPixel<T> lti::trgbPixel< T >::operator* ( const trgbPixel< T > &  other  )  const [inline]

multiply this pixel with another one without altering anything.

..

template<class T>
trgbPixel<T> lti::trgbPixel< T >::operator*= ( const T  other  )  [inline]

alias for multiply

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::operator*= ( const trgbPixel< T > &  other  )  [inline]

alias for multiply The pixel multiplication is a elementwise multiplication

template<class T>
trgbPixel<T> lti::trgbPixel< T >::operator+ ( const trgbPixel< T > &  other  )  const [inline]

add this pixel with the otherone without altering anything.

..

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::operator+= ( const trgbPixel< T > &  other  )  [inline]

alias for add

template<class T>
trgbPixel<T> lti::trgbPixel< T >::operator- ( const trgbPixel< T > &  other  )  const [inline]

subtract 'other' from this pixel without altering anything.

..

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::operator-= ( const trgbPixel< T > &  other  )  [inline]

alias for subtract

template<class T>
trgbPixel<T> lti::trgbPixel< T >::operator/ ( const trgbPixel< T > &  c  )  const [inline]

elementwise divide

template<class T>
trgbPixel<T> lti::trgbPixel< T >::operator/ ( const T  c  )  const [inline]

divide by a constant

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::operator/= ( const trgbPixel< T > &  c  )  [inline]

alias for elementwise divide

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::operator/= ( const T  c  )  [inline]

alias for divide

template<class T>
bool lti::trgbPixel< T >::operator< ( const trgbPixel< T > &  other  )  const [inline]

returns true if the intensity of this color is smaller than the intensity of the other color

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::operator= ( const rgbPixel other  )  [inline]

alias for copy member

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::operator= ( const trgbPixel< T > &  other  )  [inline]

alias for copy member

template<class T>
bool lti::trgbPixel< T >::operator== ( const trgbPixel< T > &  other  )  const [inline]

alias for compare()

template<class T>
bool lti::trgbPixel< T >::operator> ( const trgbPixel< T > &  other  )  const [inline]

returns true if the intensity of this color is bigger than the intensity of the other color

template<class T>
const T& lti::trgbPixel< T >::operator[] ( const int  x  )  const [inline]

Used to simulate read-only vector access.

It is slower than the normal access to the elements with getRed() or similar methods.

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

template<class T>
T& lti::trgbPixel< T >::operator[] ( const int  x  )  [inline]

Used to simulate vector access.

It is slower than the normal access to the elements with getRed() or setRed() similar methods.

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

template<class T>
void lti::trgbPixel< T >::set ( const T  r,
const T  g,
const T  b 
) [inline]

set the red, green, blue values for the pixel

template<class T>
void lti::trgbPixel< T >::setBlue ( const T  b  )  [inline]

sets blue value

Referenced by lti::read().

template<class T>
void lti::trgbPixel< T >::setGreen ( const T  g  )  [inline]

sets green value

Referenced by lti::read().

template<class T>
void lti::trgbPixel< T >::setRed ( const T  r  )  [inline]

sets red value

Referenced by lti::read().

template<class T>
int lti::trgbPixel< T >::size (  )  const [inline]

Used to simulate the vector size.

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::subtract ( const T  val  )  [inline]

subtract the given value from each component of the pixel

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::subtract ( const trgbPixel< T > &  a,
const trgbPixel< T > &  b 
) [inline]

Subtract pixel b from pixel a and leave the result here.

template<class T>
trgbPixel<T>& lti::trgbPixel< T >::subtract ( const trgbPixel< T > &  other  )  [inline]

Subtract the other pixel from the current one and leave the result here.

Referenced by lti::trgbPixel< int >::operator-(), and lti::trgbPixel< int >::operator-=().


Member Data Documentation

template<class T>
T lti::trgbPixel< T >::blue
template<class T>
T lti::trgbPixel< T >::green
template<class T>
T lti::trgbPixel< T >::red

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