The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

histogram_hue Class Template Reference

#include <histogram_hue.h>

Collaboration diagram for histogram_hue:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void add_uniform (double weight=1.0)
void addtobin (const RGBTRIPLE &rgb, const double value=1.0)
double * begin ()
void clear ()
histogram_huecopy (histogram_hue &hist)
const double * end ()
double & get_prob (const RGBTRIPLE &rgb)
 histogram_hue ()
void load_from_file (ifstream &is)
void normalize ()
double & operator[] (const int &bin)
void print_values (std::ostream &os)
void save_to_file (ofstream &os)
double sum ()
void weighted_add (histogram_hue &hist, const double &weight)

Private Member Functions

void addtobin (const int &bin, double value=1.0)
double & get_prob (const int &bin)
void rgb2bin (const RGBTRIPLE &rgb, int &bin)

Private Attributes

MPColorTools m_color
double m_hist [BINSIZE]
int m_numBins
int m_numColors
int m_totalMemSize

template<int BINSIZE>
class histogram_hue< BINSIZE >


Constructor & Destructor Documentation

histogram_hue  )  [inline]
 

Definition at line 35 of file histogram_hue.h.

00035                         {
00036                 m_numBins = BINSIZE;
00037                 m_totalMemSize = m_numBins * sizeof(double);
00038                 m_numColors = 256;
00039                 clear();
00040         }


Member Function Documentation

void add_uniform double  weight = 1.0  )  [inline]
 

Definition at line 90 of file histogram_hue.h.

References end.

00090                                                {
00091                 const double uniform = weight*(1.0/static_cast<double>(m_numBins));
00092                 for (double *it = begin(); it != end(); it++)
00093                         *it = uniform + *it*(1-weight);
00094         }

void addtobin const RGBTRIPLE &  rgb,
const double  value = 1.0
[inline]
 

Definition at line 54 of file histogram_hue.h.

00054                                                                         {
00055                 int bin;
00056                 rgb2bin(rgb, bin);
00057                 addtobin(bin, value);
00058         }

void addtobin const int &  bin,
double  value = 1.0
[inline, private]
 

Definition at line 30 of file histogram_hue.h.

00030                                                             {
00031                 m_hist[bin] += value;
00032         }

double* begin  )  [inline]
 

Definition at line 42 of file histogram_hue.h.

Referenced by weighted_add().

00042                                 {
00043                 return (&(m_hist[0]));
00044         }

void clear  )  [inline]
 

Definition at line 66 of file histogram_hue.h.

00066                       {
00067                 memset(m_hist, 0, m_totalMemSize);
00068         }

histogram_hue& copy histogram_hue< BINSIZE > &  hist  )  [inline]
 

Definition at line 70 of file histogram_hue.h.

References m_hist.

00070                                                    {
00071                 memcpy(hist.m_hist, m_hist, m_totalMemSize);
00072                 return(hist);
00073         }

const double* end  )  [inline]
 

Definition at line 46 of file histogram_hue.h.

00046                                     {
00047                 return(&(m_hist[BINSIZE]));
00048         }

double& get_prob const RGBTRIPLE &  rgb  )  [inline]
 

Definition at line 60 of file histogram_hue.h.

00060                                                         {
00061                 int bin;
00062                 rgb2bin(rgb, bin);
00063                 return(get_prob(bin));
00064         }

double& get_prob const int &  bin  )  [inline, private]
 

Definition at line 18 of file histogram_hue.h.

00018                                                   {
00019                 return(m_hist[bin]);
00020         }

void load_from_file ifstream &  is  )  [inline]
 

Definition at line 110 of file histogram_hue.h.

References end.

00110                                            {
00111                 clear();
00112                 for (double *it = begin(); it != end(); it++)
00113                         is >> *it;
00114         }

void normalize  )  [inline]
 

Definition at line 75 of file histogram_hue.h.

References end, and s.

00075                          {
00076                 double s = sum();
00077                 for (double *it = begin(); it != end(); it++) {
00078                         if (*it)
00079                                 *it /= s;
00080                 }
00081         }

double& operator[] const int &  bin  )  [inline]
 

Definition at line 50 of file histogram_hue.h.

00050                                                      {
00051                 return(m_hist[bin]);
00052         }

void print_values std::ostream &  os  )  [inline]
 

Definition at line 101 of file histogram_hue.h.

References end.

00101                                            {
00102                 int count = 1;
00103                 for (double *it = begin(); it != end(); it++) {
00104                         count++;
00105                         os << *it << endl;
00106                 }
00107                 count;
00108         }

void rgb2bin const RGBTRIPLE &  rgb,
int &  bin
[inline, private]
 

Definition at line 22 of file histogram_hue.h.

References MPColorTools::RGBtoHSV(), s, and v.

00022                                                               {
00023                 const double alpha = 0.0;       // -0.5 left edge of distribution
00024                 const double binwidth = static_cast<double>(m_numColors)/static_cast<double>(BINSIZE);
00025                 float h = 0.0, s = 0.0, v = 0.0;
00026                 m_color.RGBtoHSV(&rgb, h, s, v);
00027                 bin = (int) (h*m_numBins/360.0);
00028         }

Here is the call graph for this function:

void save_to_file ofstream &  os  )  [inline]
 

Definition at line 116 of file histogram_hue.h.

00116                                          {
00117                 print_values (os);
00118         }

double sum  )  [inline]
 

Definition at line 83 of file histogram_hue.h.

References end, and s.

00083                      {
00084                 double s = 0.0;
00085                 for (double *it = begin(); it != end(); it++)
00086                         s += *it;
00087                 return (s);
00088         }

void weighted_add histogram_hue< BINSIZE > &  hist,
const double &  weight
[inline]
 

Definition at line 96 of file histogram_hue.h.

References begin(), and end.

00096                                                                         {
00097                 for (double *toptr = begin(), *fromptr = hist.begin(); toptr != end(); toptr++, fromptr++)
00098                         *toptr = *toptr*weight + *fromptr*(1-weight);
00099         }

Here is the call graph for this function:


Member Data Documentation

MPColorTools m_color [private]
 

Definition at line 16 of file histogram_hue.h.

double m_hist[BINSIZE] [private]
 

Definition at line 12 of file histogram_hue.h.

Referenced by copy().

int m_numBins [private]
 

Definition at line 14 of file histogram_hue.h.

int m_numColors [private]
 

Definition at line 15 of file histogram_hue.h.

int m_totalMemSize [private]
 

Definition at line 13 of file histogram_hue.h.


The documentation for this class was generated from the following file:
Generated on Mon Nov 8 17:08:32 2004 for MPT by  doxygen 1.3.9.1