Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
vpRGBa Class Reference

#include <visp3/core/vpRGBa.h>

+ Inheritance diagram for vpRGBa:

Public Types

enum  AlphaDefault { alpha_default = 255 }
 

Public Member Functions

 vpRGBa ()
 
 vpRGBa (unsigned char r, unsigned char g, unsigned char b, unsigned char a=vpRGBa::alpha_default)
 
 vpRGBa (unsigned char v)
 
 vpRGBa (const vpRGBa &v)
 
 vpRGBa (const vpColVector &v)
 
vpRGBaoperator= (const unsigned char &v)
 
vpRGBaoperator= (const vpRGBa &v)
 
vpRGBaoperator= (const vpRGBa &&v)
 
vpRGBaoperator= (const vpColVector &v)
 
bool operator== (const vpRGBa &v)
 
bool operator!= (const vpRGBa &v)
 
vpColVector operator- (const vpRGBa &v) const
 
vpRGBa operator+ (const vpRGBa &v) const
 
vpColVector operator- (const vpColVector &v) const
 
vpColVector operator+ (const vpColVector &v) const
 
vpColVector operator* (const float &v) const
 
vpColVector operator* (const double &v) const
 
bool operator< (const vpRGBa &v) const
 
bool operator> (const vpRGBa &v) const
 

Public Attributes

unsigned char R
 
unsigned char G
 
unsigned char B
 
unsigned char A
 

Friends

VISP_EXPORT std::ostream & operator<< (std::ostream &os, const vpRGBa &rgba)
 
VISP_EXPORT vpRGBa operator* (const double &x, const vpRGBa &rgb)
 

Detailed Description

Class that defines a RGBa 32 bits structure that is used to build color images. RGBa stands for red green blue alpha color space.

The alpha channel is normally used as an opacity channel. If a pixel has a value of 0 in its alpha channel, it is fully transparent, whereas a value of 255 in the alpha channel gives a fully opaque pixel.

By default the alpha channel is set to vpRGBa::alpha_default.

See also
vpImage
Examples:
servoMomentImage.cpp, testColorConversion.cpp, testConnectedComponents.cpp, testContours.cpp, testDisplayRoi.cpp, testImageBinarise.cpp, testImageDifference.cpp, testImageDraw.cpp, testImageGetValue.cpp, testImagePrint.cpp, testImageWarp.cpp, testPerformanceLUT.cpp, testRealSense2_D435_align.cpp, tutorial-connected-components.cpp, tutorial-count-coins.cpp, tutorial-flood-fill.cpp, and tutorial-image-manipulation.cpp.

Definition at line 66 of file vpRGBa.h.

Member Enumeration Documentation

◆ AlphaDefault

Enumerator
alpha_default 

Definition at line 69 of file vpRGBa.h.

Constructor & Destructor Documentation

◆ vpRGBa() [1/5]

vpRGBa::vpRGBa ( )
inline

Basic constructor.

Build a black value.

Definition at line 77 of file vpRGBa.h.

◆ vpRGBa() [2/5]

vpRGBa::vpRGBa ( unsigned char  r,
unsigned char  g,
unsigned char  b,
unsigned char  a = vpRGBa::alpha_default 
)
inline

Constructor.

Initialize the color with R, G, B, A values.

Parameters
r: Red value.
g: Green value.
b: Blue value.
a: Additional value.

Definition at line 90 of file vpRGBa.h.

◆ vpRGBa() [3/5]

vpRGBa::vpRGBa ( unsigned char  v)
inline

Constructor.

Initialize all the R, G, B, A components to v.

Parameters
v: Value to set.

Definition at line 103 of file vpRGBa.h.

◆ vpRGBa() [4/5]

vpRGBa::vpRGBa ( const vpRGBa v)
inline

Copy constructor.

Definition at line 108 of file vpRGBa.h.

◆ vpRGBa() [5/5]

vpRGBa::vpRGBa ( const vpColVector v)
inline

Create a RGBa value from a 4 dimension column vector.

R=v[0] G=v[1] B=v[2] A=v[3]

Definition at line 119 of file vpRGBa.h.

References operator*().

Member Function Documentation

◆ operator!=()

bool vpRGBa::operator!= ( const vpRGBa v)

Compare two color pixels.

Returns
true if the images are different, false if they are the same.

Definition at line 136 of file vpRGBa.cpp.

References A, B, G, and R.

Referenced by vpColor::~vpColor().

◆ operator*() [1/2]

vpColVector vpRGBa::operator* ( const float &  v) const

Multiplication operator : v * "this".

Parameters
v: Value to multiply.
Returns
v * "this"

Definition at line 204 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator*() [2/2]

vpColVector vpRGBa::operator* ( const double &  v) const

Multiplication operator : v * "this".

Parameters
v: Value to multiply.
Returns
v * "this"

Definition at line 219 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator+() [1/2]

vpRGBa vpRGBa::operator+ ( const vpRGBa v) const

Addition operator : "this" + v.

Parameters
v: Color to add to the current object "this".
Returns
"this" + v
Warning
in case of overflow : e.g. 128+128 returns 0 for all 4 channels

Definition at line 159 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator+() [2/2]

vpColVector vpRGBa::operator+ ( const vpColVector v) const

Addition operator : "this" + v.

Parameters
v: Color to add to the current object "this".
Returns
"this" + v

Definition at line 189 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator-() [1/2]

vpColVector vpRGBa::operator- ( const vpRGBa v) const

subtraction operator : "this" - v.

Parameters
v: Color to subtract to the current object "this".
Returns
"this" - v

Definition at line 143 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator-() [2/2]

vpColVector vpRGBa::operator- ( const vpColVector v) const

subtraction operator : "this" - v.

Parameters
v: Color to subtract to the current object "this".
Returns
"this" - v

Definition at line 174 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator<()

bool vpRGBa::operator< ( const vpRGBa v) const

Definition at line 229 of file vpRGBa.cpp.

References B, G, and R.

◆ operator=() [1/4]

vpRGBa & vpRGBa::operator= ( const unsigned char &  v)

Copy operator (from an unsigned char value)

Parameters
v: Input color ( R = G = B = v )

Definition at line 56 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator=() [2/4]

vpRGBa & vpRGBa::operator= ( const vpRGBa v)

Copy operator.

Definition at line 68 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator=() [3/4]

vpRGBa & vpRGBa::operator= ( const vpRGBa &&  v)

Move operator.

Definition at line 81 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator=() [4/4]

vpRGBa & vpRGBa::operator= ( const vpColVector v)

Cast a vpColVector in a vpRGBa

Parameters
v: Input vector. v[0], v[1], v[2], v[3] are to make into relation with respectively R, G, B and A.
Exceptions
vpException::dimensionError: If v is not a 4 four dimention vector.

Definition at line 100 of file vpRGBa.cpp.

References A, B, vpException::dimensionError, G, vpArray2D< Type >::getRows(), R, and vpERROR_TRACE.

◆ operator==()

bool vpRGBa::operator== ( const vpRGBa v)

Compare two RGBa values.

Returns
true if the values are the same, false otherwise.

Definition at line 118 of file vpRGBa.cpp.

References A, B, G, and R.

Referenced by vpColor::~vpColor().

◆ operator>()

bool vpRGBa::operator> ( const vpRGBa v) const

Definition at line 237 of file vpRGBa.cpp.

References B, G, and R.

Friends And Related Function Documentation

◆ operator*

VISP_EXPORT vpRGBa operator* ( const double &  x,
const vpRGBa rgb 
)
friend

Definition at line 245 of file vpRGBa.cpp.

◆ operator<<

VISP_EXPORT std::ostream & operator<< ( std::ostream &  os,
const vpRGBa rgba 
)
friend

Writes the RGBA values to the stream os, and returns a reference to the stream. The coordinates are separated by a comma.

The following code prints the intensity of the pixel in the middle of the image:

#include <visp3/core/vpImage.h>
int main()
{
vpImage<vpRGBa> I(480,640);
std::cout << "RGB: " << I[240][320] << std::endl;
return 0;
}

Definition at line 269 of file vpRGBa.cpp.

Member Data Documentation

◆ A

◆ B

◆ G

◆ R