Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpRGBa Class Reference

#include <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)
VP_EXPLICIT vpRGBa (unsigned char v)
VP_EXPLICIT vpRGBa (unsigned int v)
VP_EXPLICIT vpRGBa (int v)
template<typename T, bool useFullScale, typename std::enable_if< std::is_same< T, unsigned char >::value, int >::type = 0>
VP_EXPLICIT vpRGBa (const vpHSV< T, useFullScale > &hsv)
template<typename T, bool useFullScale, typename std::enable_if< std::is_floating_point< T >::value, int >::type = 0>
VP_EXPLICIT vpRGBa (const vpHSV< T, useFullScale > &hsv)
template<typename T, bool useFullScale, typename U = float>
std::enable_if< std::is_same< U, float >::value &&std::is_same< T, unsignedchar >::value, vpRGBa & >::type buildFrom (const vpHSV< T, useFullScale > &other)
template<typename T, bool useFullScale>
std::enable_if< std::is_floating_point< T >::value, vpRGBa & >::type buildFrom (const vpHSV< T, useFullScale > &hsv)
 vpRGBa (const vpRGBa &v)=default
VP_EXPLICIT vpRGBa (const vpColVector &v)
vpRGBaoperator= (const unsigned char &v)
vpRGBaoperator= (const unsigned int &v)
vpRGBaoperator= (const int &v)
vpRGBaoperator= (vpRGBa &&v)=default
vpRGBaoperator= (const vpRGBa &v)=default
vpRGBaoperator= (const vpColVector &v)
bool operator== (const vpRGBa &v) const
bool operator!= (const vpRGBa &v) const
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

Static Public Attributes

static constexpr unsigned char nbChannels = 4

Friends

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

Detailed Description

Member Enumeration Documentation

◆ AlphaDefault

Enumerator
alpha_default 

Definition at line 76 of file vpRGBa.h.

Constructor & Destructor Documentation

◆ vpRGBa() [1/9]

◆ vpRGBa() [2/9]

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 95 of file vpRGBa.h.

References A, alpha_default, B, G, and R.

◆ vpRGBa() [3/9]

VP_EXPLICIT 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 106 of file vpRGBa.h.

References A, B, G, and R.

◆ vpRGBa() [4/9]

VP_EXPLICIT vpRGBa::vpRGBa ( unsigned int v)
inline

Constructor.

Initialize all the R, G, B, A components to v that should be in 0 - 255 range.

Parameters
v: Value to set.

Definition at line 115 of file vpRGBa.h.

References A, B, G, and R.

◆ vpRGBa() [5/9]

VP_EXPLICIT vpRGBa::vpRGBa ( int v)
inline

Constructor.

Initialize all the R, G, B, A components to v that should be in 0 - 255 range.

Parameters
v: Value to set.

Definition at line 132 of file vpRGBa.h.

References A, B, G, and R.

◆ vpRGBa() [6/9]

template<typename T, bool useFullScale, typename std::enable_if< std::is_same< T, unsigned char >::value, int >::type = 0>
VP_EXPLICIT vpRGBa::vpRGBa ( const vpHSV< T, useFullScale > & hsv)
inline

Construct a new vpRGBa object from an vpHSV pbject.

Template Parameters
TThe type of the channels of the vpHSV pixels.
useFullScaleTrue if vpHSV uses unsigned char and the full range [0; 255], false if vpHSV uses unsigned char and the limited range [0; 180].
Parameters
[in]hsvThe vpHSV object for which we want to have the corresponding vpRGBa object.

Definition at line 152 of file vpRGBa.h.

References buildFrom().

◆ vpRGBa() [7/9]

template<typename T, bool useFullScale, typename std::enable_if< std::is_floating_point< T >::value, int >::type = 0>
VP_EXPLICIT vpRGBa::vpRGBa ( const vpHSV< T, useFullScale > & hsv)
inline

Definition at line 158 of file vpRGBa.h.

References buildFrom().

◆ vpRGBa() [8/9]

vpRGBa::vpRGBa ( const vpRGBa & v)
inlinedefault

Copy constructor.

References A, B, G, R, and vpRGBa().

◆ vpRGBa() [9/9]

VP_EXPLICIT 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 279 of file vpRGBa.h.

References A, alpha_default, B, G, R, and vpRGBa().

Member Function Documentation

◆ buildFrom() [1/2]

template<typename T, bool useFullScale>
std::enable_if< std::is_floating_point< T >::value, vpRGBa & >::type vpRGBa::buildFrom ( const vpHSV< T, useFullScale > & hsv)
inline

Build a vpRGBa object from a vpHSV<double> or vpHSV<float> object.

Template Parameters
TThe type of the channels of the vpHSV pixels.
useFullScaleTrue if vpHSV uses unsigned char and the full range [0; 255], false if vpHSV uses unsigned char and the limited range [0; 180].
std::enable_if<std::is_floating_point<T>::value,int>::typeEnable the method only if T is a floating point number. The "int" is here because we cannot use a floating point type, otherwise we get "{float/double} is not a valid type for a template non-type parameter".
Parameters
[in]hsvThe vpHSV from which we want to build our object.
Returns
vpRGBa& The current object after conversion.

Definition at line 197 of file vpRGBa.h.

References A, alpha_default, B, vpMath::equal(), G, vpHSV< T, useFullScale >::H, R, vpMath::round(), vpHSV< T, useFullScale >::S, and vpHSV< T, useFullScale >::V.

◆ buildFrom() [2/2]

template<typename T, bool useFullScale, typename U = float>
std::enable_if< std::is_same< U, float >::value &&std::is_same< T, unsignedchar >::value, vpRGBa & >::type vpRGBa::buildFrom ( const vpHSV< T, useFullScale > & other)
inline

Build a vpRGBa object from a vpHSV<unsigned char> object.

Template Parameters
TThe type of the channels of the vpHSV pixels.
useFullScaleTrue if vpHSV uses unsigned char and the full range [0; 255], false if vpHSV uses unsigned char and the limited range [0; 180].
typeEnable the method only if T is unsigned char.
Parameters
[in]otherThe vpHSV from which we want to build our object.
Returns
vpRGBa& The current object after conversion.

Definition at line 176 of file vpRGBa.h.

References buildFrom().

Referenced by buildFrom(), and vpRGBa().

◆ operator!=()

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

Compare two color pixels.

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

Definition at line 132 of file vpRGBa.cpp.

References A, B, G, R, and vpRGBa().

◆ operator*() [1/2]

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

Multiplication operator : v * "this".

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

Definition at line 231 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator*() [2/2]

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

Multiplication operator : v * "this".

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

Definition at line 212 of file vpRGBa.cpp.

References A, B, G, and R.

Referenced by operator*.

◆ operator+() [1/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 193 of file vpRGBa.cpp.

References A, B, G, and R.

◆ operator+() [2/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, R, and vpRGBa().

◆ operator-() [1/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-() [2/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 139 of file vpRGBa.cpp.

References A, B, G, R, and vpRGBa().

◆ operator<()

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

Definition at line 245 of file vpRGBa.cpp.

References B, G, R, and vpRGBa().

◆ operator=() [1/6]

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

Copy operator that initializes all the components to v.

Parameters
v: Value used to initialize the object ( R = G = B = v ).

Definition at line 82 of file vpRGBa.cpp.

References A, B, G, R, and vpRGBa().

◆ operator=() [2/6]

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

Copy operator that initializes all the components to v.

Parameters
v: Value used to initialize the object ( R = G = B = v ).

Definition at line 53 of file vpRGBa.cpp.

References A, B, G, R, and vpRGBa().

Referenced by operator=().

◆ operator=() [3/6]

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

Copy operator that initializes all the components to v.

Parameters
v: Value used to initialize the object ( R = G = B = v ).

Definition at line 67 of file vpRGBa.cpp.

References A, B, G, R, and vpRGBa().

◆ operator=() [4/6]

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 dimension vector.

Definition at line 101 of file vpRGBa.cpp.

References A, B, vpException::dimensionError, G, R, and vpRGBa().

◆ operator=() [5/6]

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

References A, B, G, operator=(), R, and vpRGBa().

◆ operator=() [6/6]

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

References vpRGBa().

◆ operator==()

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

Compare two RGBa values.

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

Definition at line 123 of file vpRGBa.cpp.

References A, B, G, R, and vpRGBa().

◆ operator>()

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

Definition at line 253 of file vpRGBa.cpp.

References B, G, R, and vpRGBa().

◆ operator*

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

Scale RGB components by x. Alpha component remain unchanged.

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

Definition at line 268 of file vpRGBa.cpp.

References A, B, G, operator*(), R, and vpRGBa().

◆ 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>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpImage<vpRGBa> 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 303 of file vpRGBa.cpp.

References A, B, G, operator<<, R, and vpRGBa().

Referenced by operator<<.

Member Data Documentation

◆ A

◆ B

◆ G

◆ nbChannels

unsigned char vpRGBa::nbChannels = 4
staticconstexpr

Number of channels a vpRGBa object is made of.

Definition at line 322 of file vpRGBa.h.

◆ R