latest version v1.9 - last update 10 Apr 2010 |
Color pixel representation in RGB color space. More...
#include <ltiRGBPixel.h>
Classes | |
union | rgbPixelType |
this union allows to share the memory of a 32 bit integer with the three ubytes of RGB and a alpha byte. More... | |
Public Types | |
typedef ubyte | value_type |
typedef int | size_type |
Public Member Functions | |
rgbPixel () | |
rgbPixel (const uint32 val) | |
rgbPixel (const ubyte r, const ubyte g, const ubyte b, const ubyte d=0) | |
template<class U > | |
rgbPixel (const trgbPixel< U > &p) | |
void | set (const ubyte red, const ubyte green, const ubyte blue, const ubyte alpha) |
void | set (const ubyte red, const ubyte green, const ubyte blue) |
void | setRed (const ubyte r) |
void | setGreen (const ubyte g) |
void | setBlue (const ubyte b) |
void | setDummy (const ubyte d) |
void | setAlpha (const ubyte alpha) |
void | setValue (const uint32 &v) |
void | get (ubyte &red, ubyte &green, ubyte &blue) const |
void | get (int &red, int &green, int &blue) const |
void | get (ubyte &red, ubyte &green, ubyte &blue, ubyte &alpha) const |
void | get (int &red, int &green, int &blue, int &alpha) const |
const ubyte & | getRed () const |
const ubyte & | getGreen () const |
const ubyte & | getBlue () const |
const ubyte & | getDummy () const |
const ubyte & | getAlpha () const |
const uint32 & | getValue () const |
uint32 & | getValue () |
ubyte & | at (const int x) |
const ubyte & | at (const int x) const |
ubyte & | operator[] (const int x) |
const ubyte & | operator[] (const int x) const |
int | size () const |
rgbPixel & | copy (const rgbPixel &other) |
rgbPixel & | operator= (const rgbPixel &other) |
bool | isEqual (const rgbPixel &other) const |
bool | isEqualColor (const rgbPixel &other) const |
bool | operator== (const rgbPixel &other) const |
bool | operator!= (const rgbPixel &other) const |
bool | operator< (const rgbPixel &other) const |
bool | operator> (const rgbPixel &other) const |
rgbPixel & | add (const rgbPixel &other) |
rgbPixel & | operator+= (const rgbPixel &other) |
rgbPixel | operator+ (const rgbPixel &other) const |
rgbPixel & | subtract (const rgbPixel &other) |
rgbPixel & | operator-= (const rgbPixel &other) |
rgbPixel | operator- (const rgbPixel &other) const |
rgbPixel & | multiply (const rgbPixel &other) |
rgbPixel & | operator*= (const rgbPixel &other) |
rgbPixel | operator* (const rgbPixel &other) const |
rgbPixel & | multiply (const int &other) |
rgbPixel & | multiply (const float &other) |
rgbPixel & | multiply (const double &other) |
rgbPixel & | operator*= (const int &other) |
rgbPixel & | operator*= (const float &other) |
rgbPixel & | operator*= (const double &other) |
rgbPixel | operator* (const int &other) const |
rgbPixel | operator* (const float &other) const |
rgbPixel | operator* (const double &other) const |
rgbPixel & | divide (const rgbPixel &other) |
rgbPixel & | operator/= (const rgbPixel &other) |
rgbPixel | operator/ (const rgbPixel &other) const |
rgbPixel & | divide (const int &other) |
rgbPixel & | operator/= (const int &other) |
rgbPixel | operator/ (const int &other) const |
int | absSqr () const |
int | dot (const rgbPixel &other) const |
int | distanceSqr (const rgbPixel &other) const |
Protected Attributes | |
rgbPixelType | data |
Color pixel representation in RGB color space.
This type ensures that a size of 32-bits. Each channel use values between 0 and 255, and a fourth "alpha" channel is used to complete the 32-bits.
If you need to use pixel values for the RGB channels of other types you can use lti::trgbPixel.
typedef int lti::rgbPixel::size_type |
return type of the size() member
typedef ubyte lti::rgbPixel::value_type |
used for the template-based interface for pixels as vectors.
lti::rgbPixel::rgbPixel | ( | ) | [inline] |
Default constructor.
This constructor does not initialize the contents of a pixel. The reason is that a default initialization would cost too much time while creating temporary images, required in many image processing algorithms.
You should take special care while initializing your pixels: do not forget to initialize the alpha channel too.
lti::rgbPixel::rgbPixel | ( | const uint32 | val | ) | [inline] |
constructor with member initialization
Per default a new rgbPixel will be initialized with the given value.
val | a 4 byte value to be assign to the three channels + alpha. Note that the order depends on the system endianness:
|
References data, and lti::rgbPixel::rgbPixelType::value.
rgb constructor
r | 8 bit value for the red component | |
g | 8 bit value for the green component | |
b | 8 bit value for the blue component | |
d | 8 bit value for the alpha byte (default value 0) |
References lti::rgbPixel::rgbPixelType::channels, and data.
lti::rgbPixel::rgbPixel | ( | const trgbPixel< U > & | p | ) | [inline] |
copy constructor
References lti::rgbPixel::rgbPixelType::channels, data, lti::trgbPixel< T >::getBlue(), lti::trgbPixel< T >::getGreen(), and lti::trgbPixel< T >::getRed().
int lti::rgbPixel::absSqr | ( | ) | const [inline] |
obtain the square of the magnitud of this pixel .
References getBlue(), getGreen(), and getRed().
add this pixel with another one
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
Referenced by operator+(), and operator+=().
const ubyte& lti::rgbPixel::at | ( | const int | x | ) | const [inline] |
Used to simulate read-only vector access.
The correspondence between the elements of the vector and the color components still depents on the endianness of the system, but is usually at(0) for red, at(1) for green and at(2) for blue.
References data, and lti::rgbPixel::rgbPixelType::value.
ubyte& lti::rgbPixel::at | ( | const int | x | ) | [inline] |
Used to simulate vector access.
The correspondence between the elements of the vector and the color components is at(0) for red, at(1) for green and at(2) for blue.
References data, and lti::rgbPixel::rgbPixelType::value.
int lti::rgbPixel::distanceSqr | ( | const rgbPixel & | other | ) | const [inline] |
returns the square of the distance of this pixel to the other one defined as .
References lti::rgbPixel::rgbPixelType::channels, data, getBlue(), getGreen(), and getRed().
Referenced by lti::distanceSqr().
rgbPixel& lti::rgbPixel::divide | ( | const int & | other | ) | [inline] |
divide this pixel with an integer
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
divide this pixel with another one the pixel division divides elementwise the elements of the pixel!
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
Referenced by operator/(), and operator/=().
int lti::rgbPixel::dot | ( | const rgbPixel & | other | ) | const [inline] |
get the scalar product of this pixel with another one, considering them as a 3D vector.
The dot product will be the sum of the red*other.red + green*other.green + blue*other.blue
References getBlue(), getGreen(), and getRed().
void lti::rgbPixel::get | ( | int & | red, | |
int & | green, | |||
int & | blue, | |||
int & | alpha | |||
) | const [inline] |
Get the four components and write them in the given arguments.
References lti::rgbPixel::rgbPixelType::channels, and data.
Get the four components and write them in the given arguments.
References lti::rgbPixel::rgbPixelType::channels, and data.
void lti::rgbPixel::get | ( | int & | red, | |
int & | green, | |||
int & | blue | |||
) | const [inline] |
Get the three color components and write them in the given arguments.
References lti::rgbPixel::rgbPixelType::channels, and data.
Get the three color components and write them in the given arguments.
References lti::rgbPixel::rgbPixelType::channels, and data.
const ubyte& lti::rgbPixel::getAlpha | ( | ) | const [inline] |
returns alpha component
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by lti::write().
const ubyte& lti::rgbPixel::getBlue | ( | ) | const [inline] |
returns blue component
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by absSqr(), add(), lti::splitImageToYUV::apply(), lti::splitImageToYPbPr::apply(), lti::splitImageToYCbCr::apply(), lti::cityBlockDistance(), lti::trgbPixel< int >::copy(), distanceSqr(), divide(), dot(), isEqualColor(), multiply(), lti::scale(), subtract(), and lti::write().
const ubyte& lti::rgbPixel::getDummy | ( | ) | const [inline] |
returns alpha component
*
References lti::rgbPixel::rgbPixelType::channels, and data.
const ubyte& lti::rgbPixel::getGreen | ( | ) | const [inline] |
returns green component
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by absSqr(), add(), lti::splitImageToYUV::apply(), lti::splitImageToYPbPr::apply(), lti::splitImageToYCbCr::apply(), lti::cityBlockDistance(), lti::trgbPixel< int >::copy(), distanceSqr(), divide(), dot(), isEqualColor(), multiply(), lti::scale(), subtract(), and lti::write().
const ubyte& lti::rgbPixel::getRed | ( | ) | const [inline] |
returns red component
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by absSqr(), add(), lti::splitImageToYUV::apply(), lti::splitImageToYPbPr::apply(), lti::splitImageToYCbCr::apply(), lti::cityBlockDistance(), lti::trgbPixel< int >::copy(), distanceSqr(), divide(), dot(), isEqualColor(), multiply(), lti::scale(), subtract(), and lti::write().
uint32& lti::rgbPixel::getValue | ( | ) | [inline] |
returns 4 byte component with RGB value
References data, and lti::rgbPixel::rgbPixelType::value.
const uint32& lti::rgbPixel::getValue | ( | ) | const [inline] |
returns 4 byte component with RGB value
References data, and lti::rgbPixel::rgbPixelType::value.
Referenced by copy(), isEqual(), operator<(), and operator>().
bool lti::rgbPixel::isEqual | ( | const rgbPixel & | other | ) | const [inline] |
Compares this pixel with the specified other pixel.
Two pixels are considered equal if all four (!) channels, i.e. R, G, B, and alpha, are equal. A call to this method is equivalent to this->getValue() == other.getValue().
References getValue().
Referenced by operator!=(), and operator==().
bool lti::rgbPixel::isEqualColor | ( | const rgbPixel & | other | ) | const [inline] |
Compares the color of this pixel with the specified other pixel.
Only the three RGB channels are considered; the alpha value is ignored.
References getBlue(), getGreen(), and getRed().
rgbPixel& lti::rgbPixel::multiply | ( | const double & | other | ) | [inline] |
multiply this pixel with a float.
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
rgbPixel& lti::rgbPixel::multiply | ( | const float & | other | ) | [inline] |
multiply this pixel with a float.
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
rgbPixel& lti::rgbPixel::multiply | ( | const int & | other | ) | [inline] |
multiply this pixel with an integer
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
multiply this pixel with another one the pixel multiplication multiplies elementwise the elements of the pixel!
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
Referenced by operator*(), and operator*=().
bool lti::rgbPixel::operator!= | ( | const rgbPixel & | other | ) | const [inline] |
alias for !compare()
References isEqual().
rgbPixel lti::rgbPixel::operator* | ( | const double & | other | ) | const [inline] |
multiply this pixel with a float an return a new one.
References multiply().
rgbPixel lti::rgbPixel::operator* | ( | const float & | other | ) | const [inline] |
multiply this pixel with a float an return a new one.
References multiply().
rgbPixel lti::rgbPixel::operator* | ( | const int & | other | ) | const [inline] |
rgbPixel& lti::rgbPixel::operator*= | ( | const double & | other | ) | [inline] |
alias for multiply
References multiply().
rgbPixel& lti::rgbPixel::operator*= | ( | const float & | other | ) | [inline] |
alias for multiply
References multiply().
rgbPixel& lti::rgbPixel::operator*= | ( | const int & | other | ) | [inline] |
alias for multiply
References multiply().
alias for multiply()
References multiply().
alias for add
References add().
alias for subtract
References subtract().
rgbPixel lti::rgbPixel::operator/ | ( | const int & | other | ) | const [inline] |
rgbPixel& lti::rgbPixel::operator/= | ( | const int & | other | ) | [inline] |
alias for divide
References divide().
bool lti::rgbPixel::operator< | ( | const rgbPixel & | other | ) | const [inline] |
An rgbPixel is said to be "smaller" than another one, if getValue() < other.getValue().
References getValue().
alias for copy
References copy().
bool lti::rgbPixel::operator== | ( | const rgbPixel & | other | ) | const [inline] |
Alias for isEqual().
Please note the difference between isEqual() and isEqualColor()!
References isEqual().
bool lti::rgbPixel::operator> | ( | const rgbPixel & | other | ) | const [inline] |
An rgbPixel is said to be "bigger" than another one, if getValue() > other.getValue().
References getValue().
const ubyte& lti::rgbPixel::operator[] | ( | const int | x | ) | const [inline] |
Used to simulate read-only vector access.
The correspondence between the elements of the vector and the color components still depents on the endianness of the system, but is usually [0] for red, [1] for green and [2] for blue.
References lti::rgbPixel::rgbPixelType::channels, and data.
ubyte& lti::rgbPixel::operator[] | ( | const int | x | ) | [inline] |
Used to simulate vector access.
The correspondence between the elements of the vector and the color components is [0] for red, [1] for green and [2] for blue.
References lti::rgbPixel::rgbPixelType::channels, and data.
set the red, green, blue values for the pixel
References lti::rgbPixel::rgbPixelType::channels, and data.
void lti::rgbPixel::set | ( | const ubyte | red, | |
const ubyte | green, | |||
const ubyte | blue, | |||
const ubyte | alpha | |||
) | [inline] |
set the red, green, blue and alpha values for the pixel
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by lti::mergeYUVToImage::apply(), lti::mergeYPbPrToImage::apply(), and lti::mergeYCbCrToImage::apply().
void lti::rgbPixel::setAlpha | ( | const ubyte | alpha | ) | [inline] |
sets the alpha components to the given value
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by lti::read().
void lti::rgbPixel::setBlue | ( | const ubyte | b | ) | [inline] |
sets the blue component to given value
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by add(), divide(), lti::SOFM2DVisualizer::drawClasses(), multiply(), lti::read(), and subtract().
void lti::rgbPixel::setDummy | ( | const ubyte | d | ) | [inline] |
sets the alpha component to given value
References lti::rgbPixel::rgbPixelType::channels, and data.
void lti::rgbPixel::setGreen | ( | const ubyte | g | ) | [inline] |
sets the green component to given value
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by add(), divide(), lti::SOFM2DVisualizer::drawClasses(), multiply(), lti::read(), and subtract().
void lti::rgbPixel::setRed | ( | const ubyte | r | ) | [inline] |
sets the red component to given value
References lti::rgbPixel::rgbPixelType::channels, and data.
Referenced by add(), divide(), lti::SOFM2DVisualizer::drawClasses(), multiply(), lti::read(), and subtract().
void lti::rgbPixel::setValue | ( | const uint32 & | v | ) | [inline] |
sets the value component (all components together) to given value
References data, and lti::rgbPixel::rgbPixelType::value.
Referenced by copy().
int lti::rgbPixel::size | ( | ) | const [inline] |
Used to simulate the vector size.
subtract 'other' from this pixel
References getBlue(), getGreen(), getRed(), setBlue(), setGreen(), and setRed().
Referenced by operator-(), and operator-=().
rgbPixelType lti::rgbPixel::data [protected] |
The data of the pixel.
Referenced by at(), distanceSqr(), get(), getAlpha(), getBlue(), getDummy(), getGreen(), getRed(), getValue(), operator[](), rgbPixel(), set(), setAlpha(), setBlue(), setDummy(), setGreen(), setRed(), and setValue().