Representing a dominant color of a surface patch. More...
#include <dominant_color.h>
Public Member Functions | |
void | addColor (uint8_t r, uint8_t g, uint8_t b, int weight=1) |
Add the color value of a pixel in RGB. | |
DominantColor () | |
void | getColor (uint8_t &r, uint8_t &g, uint8_t &b) const |
Get the dominant color in RGB. | |
int | getMaxBin () const |
Get the index of the bin with the maximum value. | |
void | hsv2rgb (int h, int s, int v, uint8_t &r, uint8_t &g, uint8_t &b) const |
Convert from HSV to RGB color space. | |
int | incrBin (int h) |
Find the correct bin in the hue histogram and increment. | |
void | reset () |
Reset all internal variables. | |
void | rgb2hsv (uint8_t r, uint8_t g, uint8_t b, int &h, int &s, int &v) const |
Convert from RGB to HSV color space. | |
~DominantColor () | |
Private Types | |
enum | { HIST_SIZE = 180 } |
Definition of the histogram size. More... | |
Private Attributes | |
std::vector< int > | hue_histogram_ |
The histogram for the hue value. | |
int | sum_b_ |
Sum of R, G and B channels from all added points. | |
int | sum_colors_ |
Number of added color points. | |
int | sum_g_ |
int | sum_r_ |
Static Private Attributes | |
static const float | inv_bin_size = 1.0f / 360.0f * HIST_SIZE |
Representing a dominant color of a surface patch.
Definition at line 105 of file dominant_color.h.
anonymous enum [private] |
Definition of the histogram size.
Definition at line 192 of file dominant_color.h.
cob_3d_mapping::DominantColor::DominantColor | ( | ) | [inline] |
Definition at line 108 of file dominant_color.h.
cob_3d_mapping::DominantColor::~DominantColor | ( | ) | [inline] |
Definition at line 113 of file dominant_color.h.
void cob_3d_mapping::DominantColor::addColor | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b, | ||
int | weight = 1 |
||
) |
Add the color value of a pixel in RGB.
[in] | r | The red channel. |
[in] | g | The green channel. |
[in] | b | The blue channel. |
[in] | weight | The weight of this pixel. |
Definition at line 65 of file dominant_color.cpp.
void cob_3d_mapping::DominantColor::getColor | ( | uint8_t & | r, |
uint8_t & | g, | ||
uint8_t & | b | ||
) | const |
Get the dominant color in RGB.
[out] | r | The red channel. |
[out] | g | The green channel. |
[out] | b | The blue channel. |
Definition at line 86 of file dominant_color.cpp.
int cob_3d_mapping::DominantColor::getMaxBin | ( | ) | const |
Get the index of the bin with the maximum value.
Definition at line 113 of file dominant_color.cpp.
void cob_3d_mapping::DominantColor::hsv2rgb | ( | int | h, |
int | s, | ||
int | v, | ||
uint8_t & | r, | ||
uint8_t & | g, | ||
uint8_t & | b | ||
) | const |
Convert from HSV to RGB color space.
[in] | h | The hue channel. |
[in] | s | The saturation channel. |
[in] | v | The value channel. |
[out] | r | The red channel. |
[out] | g | The green channel. |
[out] | b | The blue channel. |
Definition at line 161 of file dominant_color.cpp.
int cob_3d_mapping::DominantColor::incrBin | ( | int | h | ) |
Find the correct bin in the hue histogram and increment.
[in] | The | hue value. |
Definition at line 105 of file dominant_color.cpp.
void cob_3d_mapping::DominantColor::reset | ( | ) |
Reset all internal variables.
Definition at line 227 of file dominant_color.cpp.
void cob_3d_mapping::DominantColor::rgb2hsv | ( | uint8_t | r, |
uint8_t | g, | ||
uint8_t | b, | ||
int & | h, | ||
int & | s, | ||
int & | v | ||
) | const |
Convert from RGB to HSV color space.
[in] | r | The red channel. |
[in] | g | The green channel. |
[in] | b | The blue channel. |
[out] | h | The hue channel. |
[out] | s | The saturation channel. |
[out] | v | The value channel. |
Definition at line 129 of file dominant_color.cpp.
std::vector<int> cob_3d_mapping::DominantColor::hue_histogram_ [private] |
The histogram for the hue value.
Definition at line 200 of file dominant_color.h.
const float cob_3d_mapping::DominantColor::inv_bin_size = 1.0f / 360.0f * HIST_SIZE [static, private] |
Definition at line 203 of file dominant_color.h.
int cob_3d_mapping::DominantColor::sum_b_ [private] |
Sum of R, G and B channels from all added points.
Definition at line 199 of file dominant_color.h.
int cob_3d_mapping::DominantColor::sum_colors_ [private] |
Number of added color points.
Definition at line 196 of file dominant_color.h.
int cob_3d_mapping::DominantColor::sum_g_ [private] |
Definition at line 199 of file dominant_color.h.
int cob_3d_mapping::DominantColor::sum_r_ [private] |
Definition at line 199 of file dominant_color.h.