MathToolKit  1.1.1
C++ maths framework
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Pixel Class Reference

Representation of a pixel. More...

Public Types

enum  Format { GScale, RGB }
 

Public Member Functions

 Pixel (Format format=GScale, bool limited=false)
 
 Pixel (int grey, bool limited=false)
 
 Pixel (int red, int green, int blue, bool limited=false)
 
int red () const
 
int green () const
 
int blue () const
 
int grey () const
 
bool limited () const
 
Format format () const
 
PixelsetRed (int red)
 
PixelsetGreen (int green)
 
PixelsetBlue (int blue)
 
PixelsetGrey (int grey)
 
PixelsetRGB (int red, int green, int blue)
 
PixelsetLimited (bool limited)
 
Pixeloperator+= (const Pixel &p)
 
Pixeloperator*= (const Pixel &p)
 
Pixeloperator-= (const Pixel &p)
 
Pixeloperator/= (const Pixel &p)
 

Friends

Pixel abs (const Pixel &p)
 
Pixel sqrt (const Pixel &p)
 
Pixel operator+ (Pixel p1, const Pixel &p2)
 
Pixel operator- (Pixel p1, const Pixel &p2)
 
Pixel operator- (Pixel p)
 
Pixel operator* (Pixel p1, const Pixel &p2)
 
Pixel operator/ (Pixel p1, const Pixel &p2)
 
bool operator== (const Pixel &p, int val)
 
bool operator== (const Pixel &p1, const Pixel &p2)
 
bool operator!= (const Pixel &p1, const Pixel &p2)
 
bool operator> (const Pixel &p1, const Pixel &p2)
 
bool operator< (const Pixel &p1, const Pixel &p2)
 
bool operator>= (const Pixel &p1, const Pixel &p2)
 
bool operator<= (const Pixel &p1, const Pixel &p2)
 
std::ostream & operator<< (std::ostream &os, const Pixel &p)
 

Detailed Description

Representation of a pixel.

Date
19/12/2018
Author
samiBendou

Providing multiple color scale and conversion between theses.

     The class provides an interface with char primitive
     type by converting a char value onto a grey scale pixel and vice versa if needed.

     A pixel can be in several states theses can be used for image processing computation :

        - `format`    : either Red, Green, Blue (RGB) or Grey Scale (GScale).
        - `limited`   : the value of each component can be limited to be between 0 and 255.
                        If the value of a component is set negative the result is 0. Else,
                        the if the value is greater than MAX_LIMIT_CMP than the set value
                        is the original value mod `MAX_LIMIT_CMP + 1`.

     The pixel is stored in memory as a RGB value even if the format is not RGB. Getting and
     setting components generally implies a constant time calculation to translate between RGB
     and other formats.

Member Enumeration Documentation

Enumerator
GScale 
RGB 

Constructor & Destructor Documentation

Pixel::Pixel ( Pixel::Format  format = GScale,
bool  limited = false 
)
explicit
Pixel::Pixel ( int  grey,
bool  limited = false 
)
Pixel::Pixel ( int  red,
int  green,
int  blue,
bool  limited = false 
)

Member Function Documentation

int Pixel::red ( ) const
inline
int Pixel::green ( ) const
inline
int Pixel::blue ( ) const
inline
int Pixel::grey ( ) const
inline
bool Pixel::limited ( ) const
inline
Format Pixel::format ( ) const
inline
Pixel& Pixel::setRed ( int  red)
inline
Pixel& Pixel::setGreen ( int  green)
inline
Pixel& Pixel::setBlue ( int  blue)
inline
Pixel& Pixel::setGrey ( int  grey)
inline
Pixel& Pixel::setRGB ( int  red,
int  green,
int  blue 
)
inline
Pixel & Pixel::setLimited ( bool  limited)
Pixel& Pixel::operator+= ( const Pixel p)
inline
Pixel& Pixel::operator*= ( const Pixel p)
inline
Pixel& Pixel::operator-= ( const Pixel p)
inline
Pixel& Pixel::operator/= ( const Pixel p)
inline

Friends And Related Function Documentation

Pixel abs ( const Pixel p)
friend
Pixel sqrt ( const Pixel p)
friend
Pixel operator+ ( Pixel  p1,
const Pixel p2 
)
friend
Pixel operator- ( Pixel  p1,
const Pixel p2 
)
friend
Pixel operator- ( Pixel  p)
friend
Pixel operator* ( Pixel  p1,
const Pixel p2 
)
friend
Pixel operator/ ( Pixel  p1,
const Pixel p2 
)
friend
bool operator== ( const Pixel p,
int  val 
)
friend
bool operator== ( const Pixel p1,
const Pixel p2 
)
friend
bool operator!= ( const Pixel p1,
const Pixel p2 
)
friend
bool operator> ( const Pixel p1,
const Pixel p2 
)
friend
bool operator< ( const Pixel p1,
const Pixel p2 
)
friend
bool operator>= ( const Pixel p1,
const Pixel p2 
)
friend
bool operator<= ( const Pixel p1,
const Pixel p2 
)
friend
std::ostream& operator<< ( std::ostream &  os,
const Pixel p 
)
friend