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

histogram3d Class Template Reference

#include <histogram3d.h>

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 ()
histogram3dcopy (histogram3d &hist)
const double * end ()
double & get_prob (const RGBTRIPLE &rgb)
 histogram3d ()
void load_from_file (ifstream &is)
void normalize ()
double & operator[] (HISTBIN &bin)
void print_values (ofstream &os)
void save_to_file (ofstream &os)
double sum ()
void weighted_add (histogram3d &hist, const double &weight)

Private Member Functions

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

Private Attributes

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

template<int BINSIZE>
class histogram3d< BINSIZE >


Constructor & Destructor Documentation

histogram3d  )  [inline]
 

Definition at line 71 of file histogram3d.h.

00071                       {
00072                 m_numBins = BINSIZE*BINSIZE*BINSIZE;
00073                 m_totalMemSize = m_numBins * sizeof(double);
00074                 m_numColors = 256;
00075                 clear();
00076         }


Member Function Documentation

void add_uniform double  weight = 1.0  )  [inline]
 

Definition at line 126 of file histogram3d.h.

References end.

00126                                                {
00127                 const double uniform = weight*(1.0/static_cast<double>(m_numBins));
00128                 for (double *it = begin(); it != end(); it++)
00129                         *it = uniform + *it*(1-weight);
00130         }

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

Definition at line 90 of file histogram3d.h.

References HISTBIN.

00090                                                                         {
00091                 HISTBIN bin;
00092                 rgb2bin(rgb, bin);
00093                 addtobin(bin, value);
00094         }

void addtobin HISTBIN bin,
double  value = 1.0
[inline, private]
 

Definition at line 66 of file histogram3d.h.

References HISTBIN.

00066                                                           {
00067                 (*this)[bin] += value;
00068         }

double* begin  )  [inline]
 

Definition at line 78 of file histogram3d.h.

Referenced by weighted_add().

00078                                 {
00079                 return (&(m_hist[0][0][0]));
00080         }

void bin2rgb const HISTBIN bin,
RGBTRIPLE &  rgb
[inline, private]
 

Definition at line 58 of file histogram3d.h.

References tagHISTBIN::b1, tagHISTBIN::b2, and HISTBIN.

00058                                                                   {
00059                 const double alpha = 0.0;       // -0.5 left edge of distribution
00060                 const double binwidth = static_cast<double>(m_numColors)/static_cast<double>(BINSIZE);
00061                 rgb.rgbtRed = (bin.b1 - alpha)*binwidth + alpha;
00062                 rgb.rgbtGreen = (bin.b2 - alpha)*binwidth + alpha;
00063                 rgb.rgbtBlue = (bin.b2 - alpha)*binwidth + alpha;
00064         }

void clear  )  [inline]
 

Definition at line 102 of file histogram3d.h.

00102                       {
00103                 memset(m_hist, 0, m_totalMemSize);
00104         }

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

Definition at line 106 of file histogram3d.h.

References m_hist.

00106                                                {
00107                 memcpy(hist.m_hist, m_hist, m_totalMemSize);
00108                 return(hist);
00109         }

const double* end  )  [inline]
 

Definition at line 82 of file histogram3d.h.

00082                                     {
00083                 return(&(m_hist[BINSIZE-1][BINSIZE-1][BINSIZE-1])+1);
00084         }

double& get_prob const RGBTRIPLE &  rgb  )  [inline]
 

Definition at line 96 of file histogram3d.h.

References HISTBIN.

00096                                                         {
00097                 HISTBIN bin;
00098                 rgb2bin(rgb, bin);
00099                 return(get_prob(bin));
00100         }

double& get_prob HISTBIN bin  )  [inline, private]
 

Definition at line 45 of file histogram3d.h.

References HISTBIN.

00045                                                 {
00046                 return((*this)[bin]);
00047         }

void load_from_file ifstream &  is  )  [inline]
 

Definition at line 142 of file histogram3d.h.

References end.

00142                                            {
00143                 clear();
00144                 for (double *it = begin(); it != end(); it++)
00145                         is >> *it;
00146         }

void normalize  )  [inline]
 

Definition at line 111 of file histogram3d.h.

References end, and s.

00111                          {
00112                 double s = sum();
00113                 for (double *it = begin(); it != end(); it++) {
00114                         if (*it)
00115                                 *it /= s;
00116                 }
00117         }

double& operator[] HISTBIN bin  )  [inline]
 

Definition at line 86 of file histogram3d.h.

References tagHISTBIN::b1, tagHISTBIN::b2, tagHISTBIN::b3, and HISTBIN.

00086                                                    {
00087                 return(m_hist[bin.b1][bin.b2][bin.b3]);
00088         }

void print_values ofstream &  os  )  [inline]
 

Definition at line 137 of file histogram3d.h.

References end.

00137                                          {
00138                 for (double *it = begin(); it != end(); it++)
00139                         os << *it << endl;
00140         }

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

Definition at line 49 of file histogram3d.h.

References HISTBIN, r, and tagHISTBIN::set_bin().

00049                                                                   {
00050                 const double alpha = 0.0;       // -0.5 left edge of distribution
00051                 const double binwidth = static_cast<double>(m_numColors)/static_cast<double>(BINSIZE);
00052                 int r = floor( static_cast<double>(rgb.rgbtRed-alpha)/binwidth );
00053                 int g = floor( static_cast<double>(rgb.rgbtGreen-alpha)/binwidth );
00054                 int b = floor( static_cast<double>(rgb.rgbtBlue-alpha)/binwidth );
00055                 bin.set_bin(r, g, b);
00056         }

Here is the call graph for this function:

void save_to_file ofstream &  os  )  [inline]
 

Definition at line 148 of file histogram3d.h.

00148                                          {
00149                 print_values (os);
00150         }

double sum  )  [inline]
 

Definition at line 119 of file histogram3d.h.

References end, and s.

00119                      {
00120                 double s = 0.0;
00121                 for (double *it = begin(); it != end(); it++)
00122                         s += *it;
00123                 return (s);
00124         }

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

Definition at line 132 of file histogram3d.h.

References begin(), and end.

00132                                                                       {
00133                 for (double *toptr = begin(), *fromptr = hist.begin(); toptr != end(); toptr++, fromptr++)
00134                         *toptr = *toptr*weight + *fromptr*(1-weight);
00135         }

Here is the call graph for this function:


Member Data Documentation

double m_hist[BINSIZE][BINSIZE][BINSIZE] [private]
 

Definition at line 40 of file histogram3d.h.

Referenced by copy().

int m_numBins [private]
 

Definition at line 42 of file histogram3d.h.

int m_numColors [private]
 

Definition at line 43 of file histogram3d.h.

int m_totalMemSize [private]
 

Definition at line 41 of file histogram3d.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