Visual Servoing Platform  version 3.6.1 under development (2024-11-21)
vpRGBf Class Reference

#include <visp3/core/vpRGBf.h>

Public Member Functions

 vpRGBf ()
 
 vpRGBf (float r, float g, float b)
 
VP_EXPLICIT vpRGBf (float v)
 
VP_EXPLICIT vpRGBf (int v)
 
 vpRGBf (const vpRGBf &v)
 
VP_EXPLICIT vpRGBf (const vpColVector &v)
 
vpRGBfoperator= (float v)
 
vpRGBfoperator= (int v)
 
vpRGBfoperator= (const vpRGBf &v)
 
vpRGBfoperator= (const vpRGBf &&v)
 
vpRGBfoperator= (const vpColVector &v)
 
bool operator== (const vpRGBf &v) const
 
bool operator!= (const vpRGBf &v) const
 
vpColVector operator- (const vpRGBf &v) const
 
vpRGBf operator+ (const vpRGBf &v) const
 
vpColVector operator- (const vpColVector &v) const
 
vpColVector operator+ (const vpColVector &v) const
 
vpColVector operator* (float v) const
 
vpColVector operator* (double v) const
 
bool operator< (const vpRGBf &v) const
 
bool operator> (const vpRGBf &v) const
 

Public Attributes

float R
 
float G
 
float B
 

Friends

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

Related Functions

(Note that these are not member functions.)

VISP_EXPORT std::ostream & operator<< (std::ostream &os, const vpRGBf &rgb)
 

Detailed Description

Class that defines a RGB 32-bit floating point structure that is used to build color images. RGB stands for red green blue color space.

See also
vpRGBa
vpImage
Examples
testImageDifference.cpp, and tutorial-panda3d-renderer.cpp.

Definition at line 59 of file vpRGBf.h.

Constructor & Destructor Documentation

◆ vpRGBf() [1/6]

vpRGBf::vpRGBf ( )
inline

Basic constructor.

Build a black value.

Definition at line 67 of file vpRGBf.h.

◆ vpRGBf() [2/6]

vpRGBf::vpRGBf ( float  r,
float  g,
float  b 
)
inline

Constructor.

Initialize the color with R, G, B values.

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

Definition at line 78 of file vpRGBf.h.

◆ vpRGBf() [3/6]

VP_EXPLICIT vpRGBf::vpRGBf ( float  v)
inline

Constructor.

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

Parameters
v: Value to set.

Definition at line 89 of file vpRGBf.h.

◆ vpRGBf() [4/6]

VP_EXPLICIT vpRGBf::vpRGBf ( int  v)
inline

Constructor.

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

Parameters
v: Value to set.

Definition at line 98 of file vpRGBf.h.

◆ vpRGBf() [5/6]

vpRGBf::vpRGBf ( const vpRGBf v)
inline

Copy constructor.

Definition at line 106 of file vpRGBf.h.

◆ vpRGBf() [6/6]

VP_EXPLICIT vpRGBf::vpRGBf ( const vpColVector v)
inline

Create a RGB value from a 3 dimensional column vector.

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

Definition at line 115 of file vpRGBf.h.

Member Function Documentation

◆ operator!=()

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

Compare two color pixels.

Returns
true if the values are different, false if they are exactly the same.

Definition at line 144 of file vpRGBf.cpp.

References B, G, and R.

◆ operator*() [1/2]

vpColVector vpRGBf::operator* ( double  v) const

Multiplication operator : v * "this".

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

Definition at line 239 of file vpRGBf.cpp.

References B, G, and R.

◆ operator*() [2/2]

vpColVector vpRGBf::operator* ( float  v) const

Multiplication operator : v * "this".

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

Definition at line 222 of file vpRGBf.cpp.

References B, G, and R.

◆ operator+() [1/2]

vpColVector vpRGBf::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 205 of file vpRGBf.cpp.

References B, G, and R.

◆ operator+() [2/2]

vpRGBf vpRGBf::operator+ ( const vpRGBf 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 174 of file vpRGBf.cpp.

References B, G, and R.

◆ operator-() [1/2]

vpColVector vpRGBf::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 188 of file vpRGBf.cpp.

References B, G, and R.

◆ operator-() [2/2]

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

subtraction operator : "this" - v.

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

Definition at line 156 of file vpRGBf.cpp.

References B, G, and R.

◆ operator<()

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

Definition at line 251 of file vpRGBf.cpp.

References B, G, and R.

◆ operator=() [1/5]

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

Cast a vpColVector in a vpRGBf

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

Definition at line 104 of file vpRGBf.cpp.

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

◆ operator=() [2/5]

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

Move operator.

Definition at line 87 of file vpRGBf.cpp.

References B, G, and R.

◆ operator=() [3/5]

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

Copy operator.

Definition at line 75 of file vpRGBf.cpp.

References B, G, and R.

◆ operator=() [4/5]

BEGIN_VISP_NAMESPACE vpRGBf & vpRGBf::operator= ( float  v)

Copy operator (from a floating-point value).

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

Definition at line 51 of file vpRGBf.cpp.

References B, G, and R.

◆ operator=() [5/5]

vpRGBf & vpRGBf::operator= ( int  v)

Copy operator.

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

Definition at line 64 of file vpRGBf.cpp.

References B, G, and R.

◆ operator==()

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

Compare two RGB values.

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

Definition at line 125 of file vpRGBf.cpp.

References B, G, and R.

◆ operator>()

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

Definition at line 259 of file vpRGBf.cpp.

References B, G, and R.

Friends And Related Function Documentation

◆ operator* [1/2]

VISP_EXPORT vpRGBf operator* ( double  x,
const vpRGBf rgb 
)
friend

Scale RGB components by x.

Parameters
x: Value used to scale RGB color components.
rgb: RGB color components to rescale.
Returns
Rescaled components with RGB * x.

Definition at line 274 of file vpRGBf.cpp.

◆ operator* [2/2]

VISP_EXPORT vpRGBf operator* ( float  x,
const vpRGBf rgb 
)
friend

Scale RGB components by x.

Parameters
x: Value used to scale RGB color components.
rgb: RGB color components to rescale.
Returns
Rescaled components with RGB * x.

Definition at line 290 of file vpRGBf.cpp.

◆ operator<< [1/2]

VISP_EXPORT std::ostream & operator<< ( std::ostream &  os,
const vpRGBf rgb 
)
friend

Writes the RGB 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>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpImage<vpRGBf> I(480,640);
std::cout << "RGB: " << I[240][320] << std::endl;
return 0;
}
Definition of the vpImage class member functions.
Definition: vpImage.h:131

Definition at line 324 of file vpRGBf.cpp.

◆ operator<<() [2/2]

VISP_EXPORT std::ostream & operator<< ( std::ostream &  os,
const vpRGBf rgb 
)
related

Writes the RGB 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>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpImage<vpRGBf> I(480,640);
std::cout << "RGB: " << I[240][320] << std::endl;
return 0;
}

Definition at line 324 of file vpRGBf.cpp.

Member Data Documentation

◆ B

◆ G

◆ R