[ 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 >:
TinyVector< VALUETYPE, 3 > TinyVectorBase< VALUETYPE, SIZE, DATA, DERIVED >

Public Types

enum  
typedef Base::const_iterator const_iterator
typedef Base::iterator iterator
typedef Base::NormType NormType
typedef Base::SquaredNormType SquaredNormType
typedef Base::value_type value_type
Public Types inherited from TinyVectorBase< VALUETYPE, SIZE, DATA, DERIVED >
enum  
typedef value_type const * const_iterator
typedef VALUETYPE const * const_pointer
typedef VALUETYPE const & const_reference
typedef std::ptrdiff_t difference_type
typedef value_typeiterator
typedef SquareRootTraits< SquaredNormType >::SquareRootResult NormType
typedef VALUETYPE * pointer
typedef VALUETYPE & reference
typedef double scalar_multiplier
typedef unsigned int size_type
typedef NormTraits< VALUETYPE >::SquaredNormType SquaredNormType
typedef VALUETYPE value_type

Public Member Functions

value_typeblue ()
value_type const & blue () const
value_typegreen ()
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>
RGBValueoperator= (RGBValue< U, R, G, B > const &r)
RGBValueoperator= (TinyVector< value_type, 3 > const &r)
value_typered ()
value_type const & red () const
 RGBValue ()
 RGBValue (const_pointer i)
 RGBValue (const_pointer i, ReverseCopyTag reverse)
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)
 RGBValue (value_type first, value_type second, value_type third)
 RGBValue (value_type gray)
template<class V>
void setBlue (V value)
template<class V>
void setGreen (V value)
template<class V>
void setRed (V value)
SquaredNormType squaredMagnitude () const
Public Member Functions inherited from TinyVector< VALUETYPE, 3 >
TinyVectorcopy (TinyVectorBase< U, USIZE, DATA, DERIVED > const &r)
TinyVectoroperator= (Diff2D const &r)
TinyVectoroperator= (TinyVector const &r)
TinyVectoroperator= (TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
TinyVectoroperator= (value_type const &v)
 TinyVector ()
 TinyVector (const_pointer data, ReverseCopyTag)
 TinyVector (Diff2D const &initial)
 TinyVector (lemon::Invalid const &)
 TinyVector (SkipInitializationTag)
 TinyVector (TinyVector const &r)
 TinyVector (TinyVectorBase< U, SIZE, DATA, DERIVED > const &r)
 TinyVector (U const *data)
 TinyVector (value_type const &i1, value_type const &i2)
 TinyVector (value_type const &i1, value_type const &i2, value_type const &i3)
 TinyVector (value_type const &i1, value_type const &i2, value_type const &i3, value_type const &i4)
 TinyVector (value_type const &i1, value_type const &i2, value_type const &i3, value_type const &i4, value_type const &i5)
 TinyVector (value_type const &initial)
Public Member Functions inherited from TinyVectorBase< VALUETYPE, SIZE, DATA, DERIVED >
bool all () const
bool any () const
iterator begin ()
const_iterator begin () const
const_iterator cbegin () const
const_iterator cend () const
iterator end ()
const_iterator end () const
template<class Iterator>
void init (Iterator i, Iterator end)
void init (value_type initial)
NormType magnitude () const
VALUETYPE const & maximum () const
VALUETYPE const & minimum () const
template<class T1, class D1, class D2>
DERIVED & operator%= (TinyVectorBase< T1, SIZE, D1, D2 > const &r)
DERIVED & operator*= (double r)
template<class T1, class D1, class D2>
DERIVED & operator*= (TinyVectorBase< T1, SIZE, D1, D2 > const &r)
DERIVED & operator+= (double r)
template<class T1, class D1, class D2>
DERIVED & operator+= (TinyVectorBase< T1, SIZE, D1, D2 > const &r)
DERIVED & operator-= (double r)
template<class T1, class D1, class D2>
DERIVED & operator-= (TinyVectorBase< T1, SIZE, D1, D2 > const &r)
DERIVED & operator/= (double r)
template<class T1, class D1, class D2>
DERIVED & operator/= (TinyVectorBase< T1, SIZE, D1, D2 > const &r)
reference operator[] (difference_type i)
const_reference operator[] (difference_type i) const
size_type size () const
SquaredNormType squaredMagnitude () const
template<int FROM, int TO>
TinyVectorView< VALUETYPE, TO-FROM > subarray () const

Additional Inherited Members

Static Public Member Functions inherited from TinyVectorBase< VALUETYPE, SIZE, DATA, DERIVED >
static TinyVector< VALUETYPE, SIZE > linearSequence (VALUETYPE start=VALUETYPE(), VALUETYPE step=VALUETYPE(1))
 Factory function for a linear sequence.
static TinyVector< VALUETYPE, SIZE > unitVector (int k)
 Factory function for a unit vector for dimension k.

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

RGBValue(value_type first, value_type second, value_type third)
Definition rgbvalue.hxx:176

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
graph_agglomerative_clustering.cxx, invert.cxx, invert_explicitly.cxx, invert_tutorial.cxx, palette.cxx, resize.cxx, and smooth_explicitly.cxx.

Member Typedef Documentation

◆ value_type

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
typedef Base::value_type value_type

STL-compatible definition of valuetype

◆ iterator

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
typedef Base::iterator iterator

STL-compatible definition of iterator

◆ const_iterator

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
typedef Base::const_iterator const_iterator

STL-compatible definition of const iterator

◆ SquaredNormType

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
typedef Base::SquaredNormType SquaredNormType

squared norm type (result of squaredManitude())

◆ NormType

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
typedef Base::NormType NormType

norm type (result of magnitude())

Member Enumeration Documentation

◆ anonymous enum

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
anonymous enum

Color index positions

Constructor & Destructor Documentation

◆ RGBValue() [1/7]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
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() [2/7]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
RGBValue ( value_type gray)

Construct gray value.

◆ RGBValue() [3/7]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
RGBValue ( const_pointer i)
explicit

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

◆ RGBValue() [4/7]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
RGBValue ( const_pointer i,
ReverseCopyTag reverse )

Construct by reverse copying from raw memory.

◆ RGBValue() [5/7]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
RGBValue ( )

Default constructor (sets all components to 0)

◆ RGBValue() [6/7]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
template<class U, unsigned int R, unsigned int G, unsigned int B>
RGBValue ( RGBValue< U, R, G, B > const & r)

Copy constructor.

◆ RGBValue() [7/7]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
RGBValue ( TinyVector< value_type, 3 > const & r)

construct from TinyVector

Member Function Documentation

◆ operator=() [1/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
template<class U, unsigned int R, unsigned int G, unsigned int B>
RGBValue & operator= ( RGBValue< U, R, G, B > const & r)

Copy assignment.

◆ operator=() [2/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
RGBValue & operator= ( TinyVector< value_type, 3 > const & r)

assign TinyVector.

◆ operator-()

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
RGBValue operator- ( ) const

Unary negation (construct RGBValue with negative values)

◆ red() [1/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
value_type & red ( )

Access red component.

Examples
palette.cxx.

◆ green() [1/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
value_type & green ( )

Access green component.

Examples
palette.cxx.

◆ blue() [1/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
value_type & blue ( )

Access blue component.

Examples
palette.cxx.

◆ red() [2/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
value_type const & red ( ) const

Get red component.

◆ green() [2/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
value_type const & green ( ) const

Get green component.

◆ blue() [2/2]

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
value_type const & blue ( ) const

Get blue component.

◆ luminance()

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
value_type luminance ( ) const

Calculate luminance.

◆ magnitude()

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
NormType magnitude ( ) const

Calculate magnitude.

◆ squaredMagnitude()

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
SquaredNormType squaredMagnitude ( ) const

Calculate squared magnitude.

◆ setRed()

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
template<class V>
void setRed ( V value)

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

◆ setGreen()

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
template<class V>
void setGreen ( V value)

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

◆ setBlue()

template<class VALUETYPE, unsigned int RED_IDX = 0, unsigned int GREEN_IDX = 1, unsigned int BLUE_IDX = 2>
template<class V>
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 files:

© 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.12.3 ()