Population
Image processing library in C++
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
pop::RGB< ChannelType > Class Template Reference

Red Green Blue channel. More...

Public Types

enum  { DIM =3 }
 
typedef int E
 
typedef ChannelType F
 

Public Member Functions

ChannelType & operator() (int i)
 
const ChannelType & operator() (int i) const
 
ChannelType & r ()
 
ChannelType & g ()
 
ChannelType & b ()
 
const ChannelType & r () const
 
const ChannelType & g () const
 
const ChannelType & b () const
 
template<class U1 >
RGBoperator= (const RGB< U1 > &p)
 
template<typename Type1 >
RGBoperator+= (const RGB< Type1 > &p)
 
template<typename Scalar >
RGBoperator+= (Scalar value)
 
template<typename Type1 >
RGBoperator-= (const RGB< Type1 > &p)
 
template<typename Scalar >
RGBoperator-= (Scalar value)
 
RGBoperator- ()
 
template<typename Type1 >
RGBoperator*= (const RGB< Type1 > &p)
 
template<typename Scalar >
RGBoperator*= (Scalar value)
 
template<typename Type1 >
RGBoperator/= (const RGB< Type1 > &p)
 
template<typename Scalar >
RGBoperator/= (Scalar value)
 
template<typename Type1 >
bool operator== (const RGB< Type1 > &p) const
 
template<typename Type1 >
bool operator!= (const RGB< Type1 > &p) const
 
template<typename Type1 >
bool operator> (const RGB< Type1 > &x) const
 
template<typename Scalar >
bool operator> (const Scalar &x) const
 
template<typename Type1 >
bool operator< (const RGB< Type1 > &x) const
 
template<typename Scalar >
bool operator< (const Scalar &x) const
 
template<typename Type1 >
bool operator>= (const RGB< Type1 > &x) const
 
template<typename Scalar >
bool operator>= (const Scalar &x) const
 
template<typename Type1 >
bool operator<= (const RGB< Type1 > &x) const
 
template<typename Scalar >
bool operator<= (const Scalar &x) const
 
F32 lumi () const
 
template<typename Type1 >
void fromYUV (Type1 y, Type1 u, Type1 v)
 
template<typename Type1 >
void toYUV (Type1 &y, Type1 &u, Type1 &v) const
 
void fromYUV (F32 y, F32 u, F32 v)
 
template<typename Type1 >
void toHSL (Type1 &hh, Type1 &ss, Type1 &ll) const
 
void load (const char *file)
 
void save (const char *file) const
 
template<typename Type1 >
RGB operator+ (const RGB< Type1 > &rgb_value) const
 
RGB operator+ (ChannelType v) const
 
template<typename Type1 >
RGB operator- (const RGB< Type1 > &rgb_value) const
 
RGB operator- (ChannelType v) const
 
template<typename Type1 >
RGB operator* (const RGB< Type1 > &c) const
 
template<typename G >
RGB operator* (G v) const
 
template<typename Type1 >
RGB operator/ (const RGB< Type1 > &c) const
 
RGB operator/ (ChannelType v) const
 
F32 norm (int p=-1) const
 
F32 normPower (int p=-1) const
 
ChannelType * data ()
 
const ChannelType * data () const
 

Static Public Member Functions

static RGB< ChannelType > randomRGB ()
 

Public Attributes

 _data [1] =0
 

Detailed Description

template<class ChannelType>
class pop::RGB< ChannelType >

Red Green Blue channel.

Author
Tariel Vincent
Template Parameters
ChannelTypechannel type

This is an additive RGB model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors
To facilitate its utilisation, we use some typedef declarations to define the usual types to allow coding in C-style as these ones:

RGBUI8 c1(100,200,30);
c1.r()=10;
c1=c1+20;
std::cout<<c1<<std::endl;
std::cout<<c1.lumi()<<std::endl;
See also
http://en.wikipedia.org/wiki/RGB_color_model

Member Typedef Documentation

template<class ChannelType>
pop::RGB< ChannelType >::E

index type to access elements

template<class ChannelType>
pop::RGB< ChannelType >::F

type of the channel

Member Enumeration Documentation

template<class ChannelType>
anonymous enum
Enumerator
DIM 

Space dimension equal to 3

Member Function Documentation

template<class ChannelType>
ChannelType& pop::RGB< ChannelType >::b ( )
inline
Returns
blue element

Access to the blue element

template<class ChannelType>
template<typename Type1 >
void pop::RGB< ChannelType >::fromYUV ( Type1  y,
Type1  u,
Type1  v 
)
inline
Parameters
yluma
uchrominance
vchrominance

Convert Y'UV model defines a RGB space in terms of one luma (Y') and two chrominance (UV) to RGB model for this RGB object

See also
http://en.wikipedia.org/wiki/YUV
template<class ChannelType>
void pop::RGB< ChannelType >::fromYUV ( F32  y,
F32  u,
F32  v 
)
inline
Parameters
yluma
uchrominance
vchrominance

Convert YUV (Y' stands for the luma component and U and V are the chrominance ( components) model defines a RGB

See also
http://en.wikipedia.org/wiki/YUV
template<class ChannelType>
ChannelType& pop::RGB< ChannelType >::g ( )
inline
Returns
green element

Access to the green element

template<class ChannelType>
void pop::RGB< ChannelType >::load ( const char *  file)
inline
Parameters
fileinput file

load the RGB from the input file

template<class ChannelType>
F32 pop::RGB< ChannelType >::lumi ( ) const
inline
Returns
luminance

return the luminance of this RGB (0.299*this->r() + 0.587*this->g() + 0.114*this->b())

template<class ChannelType>
F32 pop::RGB< ChannelType >::norm ( int  p = -1) const
inline
Parameters
pp-norm (-1=lumi, 2=euclidean, 0=infinite,...)
Returns
norm of the color

return the norm as the luminance of the RGB colour by default

template<class ChannelType>
template<typename Type1 >
bool pop::RGB< ChannelType >::operator!= ( const RGB< Type1 > &  p) const
inline
Parameters
pother RGB
Returns
boolean

return true for at least one channel of this RGB is different to the channel of the other RGB, false otherwise

template<class ChannelType>
ChannelType& pop::RGB< ChannelType >::operator() ( int  i)
inline
Parameters
iindex
Returns
element

Access to the element at the given index i=0=red, i=1=green, i=2=blue

template<class ChannelType>
template<typename Type1 >
RGB pop::RGB< ChannelType >::operator* ( const RGB< Type1 > &  c) const
inline
Parameters
cRGB
Returns
output RGB

multiply all channels of this RGB by the RGB c

template<class ChannelType>
template<typename G >
RGB pop::RGB< ChannelType >::operator* ( v) const
inline
Parameters
vfactor
Returns
output RGB

multiply all channels of this RGB by the factor value

template<class ChannelType>
template<typename Type1 >
RGB& pop::RGB< ChannelType >::operator*= ( const RGB< Type1 > &  p)
inline
Parameters
pother RGB
Returns
this RGB

Multiply this RGB by the contents of other.

template<class ChannelType>
template<typename Scalar >
RGB& pop::RGB< ChannelType >::operator*= ( Scalar  value)
inline
Parameters
valuefactor
Returns
this RGB

Multiply all channels of this RGB by the factor

See also
value
template<class ChannelType>
template<typename Type1 >
RGB pop::RGB< ChannelType >::operator+ ( const RGB< Type1 > &  rgb_value) const
inline
Parameters
rgb_valueRGB
Returns
output RGB

addition of the RGB c with this RGB

template<class ChannelType>
RGB pop::RGB< ChannelType >::operator+ ( ChannelType  v) const
inline
Parameters
vfactor
Returns
output RGB

addition of the factor value to all channels of the RGB c1

template<class ChannelType>
template<typename Type1 >
RGB& pop::RGB< ChannelType >::operator+= ( const RGB< Type1 > &  p)
inline
Parameters
pother RGB
Returns
this RGB

Adds the contents of other to this RGB.

template<class ChannelType>
template<typename Scalar >
RGB& pop::RGB< ChannelType >::operator+= ( Scalar  value)
inline
Parameters
valuefactor
Returns
this RGB

Adds all channels of this RGB by the factor

See also
value
template<class ChannelType>
RGB& pop::RGB< ChannelType >::operator- ( )
inline
Returns
this RGB

opposite all channels of this RGB (the type of the channel must be signed)

template<class ChannelType>
template<typename Type1 >
RGB pop::RGB< ChannelType >::operator- ( const RGB< Type1 > &  rgb_value) const
inline
Parameters
rgb_valuefirst rgb valaue
Returns
output RGB

Subtraction of this RGB c1 by the RGB c

template<class ChannelType>
RGB pop::RGB< ChannelType >::operator- ( ChannelType  v) const
inline
Parameters
vfactor
Returns
output RGB

Subtraction of all channels of this RGB by the factor value

template<class ChannelType>
template<typename Type1 >
RGB& pop::RGB< ChannelType >::operator-= ( const RGB< Type1 > &  p)
inline
Parameters
pother RGB
Returns
this RGB

subtract this RGB by the contents of other.

template<class ChannelType>
template<typename Scalar >
RGB& pop::RGB< ChannelType >::operator-= ( Scalar  value)
inline
Parameters
valuefactor
Returns
this RGB

subtract all channels of this RGB by the factor

See also
value
template<class ChannelType>
template<typename Type1 >
RGB pop::RGB< ChannelType >::operator/ ( const RGB< Type1 > &  c) const
inline
Parameters
cfirst RGB
Returns
output RGB

divide all channels of this RGB by the RGB c

template<class ChannelType>
RGB pop::RGB< ChannelType >::operator/ ( ChannelType  v) const
inline
Parameters
vfactor
Returns
output RGB

divide all channels of this RGB by the factor value

template<class ChannelType>
template<typename Type1 >
RGB& pop::RGB< ChannelType >::operator/= ( const RGB< Type1 > &  p)
inline
Parameters
pother RGB
Returns
this RGB

Divide this RGB by the contents of other.

template<class ChannelType>
template<typename Scalar >
RGB& pop::RGB< ChannelType >::operator/= ( Scalar  value)
inline
Parameters
valuefactor
Returns
this RGB

Divide all channels of this RGB by the factor

See also
value
template<class ChannelType>
template<typename Type1 >
bool pop::RGB< ChannelType >::operator< ( const RGB< Type1 > &  x) const
inline
Parameters
xother RGB
Returns
boolean

return true for a luminance of this RGB is inferior to the luminance of the other RGB, false otherwise

template<class ChannelType>
template<typename Type1 >
bool pop::RGB< ChannelType >::operator<= ( const RGB< Type1 > &  x) const
inline
Parameters
xother RGB
Returns
boolean

return true for a luminance of this RGB is inferior to the luminance of the other RGB, false otherwise

template<class ChannelType>
template<class U1 >
RGB& pop::RGB< ChannelType >::operator= ( const RGB< U1 > &  p)
inline
Parameters
pother RGB
Returns
this RGB

Basic assignment of this RGB by other

template<class ChannelType>
template<typename Type1 >
bool pop::RGB< ChannelType >::operator== ( const RGB< Type1 > &  p) const
inline
Parameters
pother RGB
Returns
boolean

return true for each channel of this RGB is equal to the channel of the other RGB, false otherwise

template<class ChannelType>
template<typename Type1 >
bool pop::RGB< ChannelType >::operator> ( const RGB< Type1 > &  x) const
inline
Parameters
xother RGB
Returns
boolean

return true for a luminance of this RGB is superior to the luminance of the other RGB, false otherwise

template<class ChannelType>
template<typename Type1 >
bool pop::RGB< ChannelType >::operator>= ( const RGB< Type1 > &  x) const
inline
Parameters
xother RGB
Returns
boolean

return true for a luminance of this RGB is superior to the luminance of the other RGB, false otherwise

template<class ChannelType>
ChannelType& pop::RGB< ChannelType >::r ( )
inline
Returns
red element

Access to the red element

template<class ChannelType>
void pop::RGB< ChannelType >::save ( const char *  file) const
inline
Parameters
fileinput file

save the RGB to the input file

template<class ChannelType>
template<typename Type1 >
void pop::RGB< ChannelType >::toHSL ( Type1 &  hh,
Type1 &  ss,
Type1 &  ll 
) const
inline
Parameters
hhluma
sschrominance
llchrominance

Get Y'UV model defines a RGB space in terms of one luma (Y') and two chrominance (UV) to RGB model for this RGB object

See also
http://en.wikipedia.org/wiki/YUV
template<class ChannelType>
template<typename Type1 >
void pop::RGB< ChannelType >::toYUV ( Type1 &  y,
Type1 &  u,
Type1 &  v 
) const
inline
Parameters
yluma
uchrominance
vchrominance

Get Y'UV model defines a RGB space in terms of one luma (Y') and two chrominance (UV) to RGB model for this RGB object

See also
http://en.wikipedia.org/wiki/YUV

Member Data Documentation

template<class ChannelType>
pop::RGB< ChannelType >::_data[2] =0

default constructor

Parameters
r_valuered RGB
g_valuegreen RGB
b_valueblue RGB

constructor the RGB object with the RGB values

Parameters
valuescalar value

constructor the RGB object with the RGB values equal to value

Parameters
ccopied RGB

copy constructor


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