[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| RGBValue< VALUETYPE, RED_IDX, GREEN_IDX, BLUE_IDX > Class Template Reference |

Class for a single RGB value. More...

`#include <vigra/rgbvalue.hxx>`

Inheritance diagram for RGBValue< VALUETYPE, RED_IDX, GREEN_IDX, BLUE_IDX >:

List of all members.

## Public Types
enum |
typedef Base::const_iterator | const_iterator
typedef Base::const_pointer | const_pointer
typedef Base::const_reference | const_reference
typedef Base::difference_type | difference_type
typedef Base::iterator | iterator
typedef Base::NormType | NormType
typedef Base::pointer | pointer
typedef Base::reference | reference
typedef Base::scalar_multiplier | scalar_multiplier
typedef Base::size_type | size_type
typedef Base::SquaredNormType | SquaredNormType
typedef Base::value_type | value_type
## Public Member Functions
value_type & | blue ()
value_type const & | blue () const
value_type & | green ()
value_type const & | green () const
value_type | luminance () const
NormType | magnitude () const
RGBValue | operator- () const
template<class U , unsigned int R, unsigned int G, unsigned int B>
RGBValue & | operator= (RGBValue< U, R, G, B > const &r)
RGBValue & | operator= (TinyVector< value_type, 3 > const &r)
value_type & | red ()
value_type const & | red () const
| RGBValue (value_type first, value_type second, value_type third)
| RGBValue (value_type gray)
| RGBValue (const_pointer i)
| RGBValue (const_pointer i, ReverseCopyTag reverse)
| RGBValue ()
template<class U , unsigned int R, unsigned int G, unsigned int B>
| RGBValue (RGBValue< U, R, G, B > const &r)
| RGBValue (TinyVector< value_type, 3 > const &r)
template<class V >
void | setBlue (V value)
template<class V >
void | setGreen (V value)
template<class V >
void | setRed (V value)
SquaredNormType | squaredMagnitude () const

## Detailed Description

### template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
class vigra::RGBValue< VALUETYPE, RED_IDX, GREEN_IDX, BLUE_IDX >

Class for a single RGB value.

This class contains three values (of the specified type) that represent red, green, and blue color channels. By means of the template parameters `RED_IDX, GREEN_IDX, BLUE_IDX`, the indices 0, 1, 2 can be assigned to the three colors arbitrarily, so that, for example, a BGR type can be created as

        typedef RGBValue<unsigned char, 2,1,0> BGRValue;

The standard order red=0, green=1, blue=2 is the default. There are three possibilities to access the color values: accessor functions (red(), green(), blue()), index operator (operator[](dx), where the `rgb[RED_IDX]` returns red etc.) and iterator (STL-compatible random access iterator that references the three colors in turn). The latter two methods, together with the necessary embedded typedefs, ensure compatibility of a RGBValue with a STL vector.

Arithmetic operations are defined as component-wise applications of these operations. Addition, subtraction, and multiplication of two RGBValues (+=, -=, *=, +, -, *, unary -), multiplication and division of an RGBValue with a double, and NumericTraits/PromoteTraits are defined, so that RGBValue fulfills the requirements of a Linear Algebra.

A number of accessors are provided that support access to RGBValues as a whole, to a selected color component, or to the luminance value.

#include <vigra/rgbvalue.hxx>
Namespace: vigra

Examples:
  invert.cxx, invert_explicitly.cxx, palette.cxx, and watershed.cxx.

## Member Typedef Documentation

typedef Base::value_type value_type

STL-compatible definition of valuetype

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::iterator iterator

STL-compatible definition of iterator

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::const_iterator const_iterator

STL-compatible definition of const iterator

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::SquaredNormType SquaredNormType

squared norm type (result of squaredManitude())

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::NormType NormType

norm type (result of magnitude())

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::reference reference

reference (return of operator[]).

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::const_reference const_reference

const reference (return of operator[] const).

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::pointer pointer

pointer (return of operator->).

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::const_pointer const_pointer

const pointer (return of operator-> const).

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::size_type size_type

STL-compatible definition of size_type

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::difference_type difference_type

STL-compatible definition of difference_type

Reimplemented from TinyVector< VALUETYPE, 3 >.

typedef Base::scalar_multiplier scalar_multiplier

the scalar type for the outer product

Reimplemented from TinyVector< VALUETYPE, 3 >.

## Member Enumeration Documentation

anonymous enum

Color index positions

## Constructor & Destructor Documentation

RGBValue | ( | value_type | first,
|  | value_type | second,
|  | value_type | third
| ) |  |

Construct from explicit color values. first, second, third are written in this order, irrespective of how the color indices are specified.

RGBValue | ( | value_type | gray | ) |

Construct gray value.

RGBValue | ( | const_pointer | i | ) | `[explicit]`

Copy from raw memory. The order is preserved, irrespective of how the color indices are specified.

RGBValue | ( | const_pointer | i,
|  | ReverseCopyTag | reverse
| ) |  |

Construct by reverse copying from raw memory.

RGBValue | ( |  | ) |

Default constructor (sets all components to 0)

RGBValue | ( | RGBValue< U, R, G, B > const & | r | ) |

Copy constructor.

RGBValue | ( | TinyVector< value_type, 3 > const & | r | ) |

construct from TinyVector

## Member Function Documentation

RGBValue& operator= | ( | RGBValue< U, R, G, B > const & | r | ) |

Copy assignment.

RGBValue& operator= | ( | TinyVector< value_type, 3 > const & | r | ) |

assign TinyVector.

RGBValue operator- | ( |  | ) | const

Unary negation (construct RGBValue with negative values)

value_type& red | ( |  | ) |

Access red component.

value_type& green | ( |  | ) |

Access green component.

value_type& blue | ( |  | ) |

Access blue component.

value_type const& red | ( |  | ) | const

Get red component.

value_type const& green | ( |  | ) | const

Get green component.

value_type const& blue | ( |  | ) | const

Get blue component.

value_type luminance | ( |  | ) | const

Calculate luminance.

NormType magnitude | ( |  | ) | const

Calculate magnitude.

Reimplemented from TinyVectorBase< VALUETYPE, SIZE, VALUETYPE[SIZE], TinyVector< VALUETYPE, SIZE > >.

SquaredNormType squaredMagnitude | ( |  | ) | const

Calculate squared magnitude.

Reimplemented from TinyVectorBase< VALUETYPE, SIZE, VALUETYPE[SIZE], TinyVector< VALUETYPE, SIZE > >.

void setRed | ( | V | value | ) |

Set red component. The type `V` of the passed in `value` is automatically converted to `VALUETYPE`.

void setGreen | ( | V | value | ) |

Set green component.The type `V` of the passed in `value` is automatically converted to `VALUETYPE`.

void setBlue | ( | V | value | ) |

Set blue component.The type `V` of the passed in `value` is automatically converted to `VALUETYPE`.

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

- vigra/rgbvalue.hxx

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.9.0 (Tue Nov 6 2012)