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

TIntegral Class Template Reference

#include <integralimage.h>

Inheritance diagram for TIntegral:

Inheritance graph
[legend]
Collaboration diagram for TIntegral:

Collaboration graph
[legend]
List of all members.

Public Member Functions

const int getImHeight () const
const int getImNumPix () const
T getImPixel (int x, int y) const
const int getImWidth () const
const int getIntHeight () const
const int getIntNumPix () const
T getIntPixel (int x, int y) const
const int getIntWidth () const
void integrate ()
void printIm (const char *filename)
void printImBin (const char *filename, bool flag)
void printInt (const char *filename)
void printIntBin (const char *filename, bool flag)
void setImPixel (const int x, const int y, const T &value)
void setIntPixel (const int x, const int y, const T &value)
void setSize (const int width, const int height)
void setToMinLog ()
 TIntegral ()
 TIntegral (const int width, const int height)

template<class T>
class TIntegral< T >


Constructor & Destructor Documentation

TIntegral (  const int  width,
const int  height
)  [inline]
 

Definition at line 142 of file integralimage.h.

00142                                                     {
00143                 setSize(width,height);
00144         }

TIntegral (   )  [inline]
 

Definition at line 148 of file integralimage.h.

00148                     : TImage<T>() {
00149         }


Member Function Documentation

const int getImHeight (   )  const [inline]
 

Definition at line 134 of file integralimage.h.

Referenced by ScalePyramid::add_hypothesesPerScale(), MPColorFeatSearch::addBoxCorners(), drawBack(), drawROI(), TIntegral< double >::getImNumPix(), main(), TIntegral< double >::printIm(), TIntegral< double >::printImBin(), MPColorFeatSearch::searchFeature(), and HypothesesPerScale::setParams().

00134 {return height -1;      }

const int getImNumPix (   )  const [inline]
 

Definition at line 138 of file integralimage.h.

00138 { return getImWidth()*getImHeight();}

T getImPixel (  int  x,
int  y
)  const [inline]
 

Definition at line 207 of file integralimage.h.

Referenced by TIntegral< double >::printIm(), TIntegral< double >::printImBin(), and MPColorFeatSearch::searchFeature().

00207                                                  {
00208                 return getIntPixel(x+1,y+1);
00209         };

const int getImWidth (   )  const [inline]
 

Definition at line 133 of file integralimage.h.

Referenced by ScalePyramid::add_hypothesesPerScale(), MPColorFeatSearch::addBoxCorners(), drawBack(), drawROI(), TIntegral< double >::getImNumPix(), main(), TIntegral< double >::printIm(), TIntegral< double >::printImBin(), MPColorFeatSearch::searchFeature(), and HypothesesPerScale::setParams().

00133 {return width -1;       }

const int getIntHeight (   )  const [inline]
 

Definition at line 136 of file integralimage.h.

Referenced by MPColorFeatSearch::getBoxSum(), TIntegral< double >::getIntNumPix(), main(), TIntegral< double >::printInt(), TIntegral< double >::printIntBin(), and TIntegral< double >::setToMinLog().

00136 {return height; }

const int getIntNumPix (   )  const [inline]
 

Definition at line 139 of file integralimage.h.

Referenced by HypothesesPerScale::makezero(), MPColorFeatSearch::searchFeature(), and TIntegral< double >::setToMinLog().

00139 { return getIntWidth()*getIntHeight();}

T getIntPixel (  int  x,
int  y
)  const [inline]
 

Definition at line 179 of file integralimage.h.

Referenced by MPColorFeatSearch::addBoxCorners(), MPColorFeatSearch::getBoxSum(), TIntegral< double >::getImPixel(), TIntegral< double >::integrate(), main(), TIntegral< double >::printInt(), TIntegral< double >::printIntBin(), and MPColorFeatSearch::searchFeature().

00179                                                   {
00180                 int lx = x, ly = y;
00181                 if(lx < 0 || ly < 0) return 0;
00182                 
00183                 if(lx >= width) lx = width - 1;
00184                 if(ly >= height) ly = height - 1;
00185                 
00186                 int index = width * ly + lx;
00187                 ASSERT (index >= 0 && index < numpixels);
00188                 return array[index];
00189         };

const int getIntWidth (   )  const [inline]
 

Definition at line 135 of file integralimage.h.

Referenced by MPColorFeatSearch::getBoxSum(), TIntegral< double >::getIntNumPix(), main(), TIntegral< double >::printInt(), TIntegral< double >::printIntBin(), and TIntegral< double >::setToMinLog().

00135 {return width;  }

void integrate (   )  [inline]
 

Definition at line 152 of file integralimage.h.

Referenced by main(), MPColorFeatSearch::searchFeature(), and HypothesesPerScale::setParams().

00152                          { 
00153                 int x, y;
00154                 T * p = array;
00155 //              for(int x = 0; x < width; ++x) setIntPixel(x,0,0);   /* create top row of zeros */
00156 //              for(int y = 0; y < width; ++y) setIntPixel(0,y,0);   /* create left column of zeros */
00157 
00158                 for(x = 1; x < width; ++x) {
00159                         double v0 = getIntPixel(x-1,0);
00160                         double v1 = getIntPixel(x,0);
00161                         setIntPixel(x,0,v0+v1);   /* integrate top row */
00162                 }
00163 
00164                 for(y = 1; y < height; ++y) {
00165                         double v0 = getIntPixel(0,y-1);
00166                         double v1 = getIntPixel(0,y);
00167                         setIntPixel(0,y,v0+v1);   /* create left column of zeros */
00168     }
00169 
00170                 for(y = 1; y < height; ++y){
00171                         for(x = 1; x < width; ++x){
00172                                 T val = getIntPixel(x,y) + getIntPixel(x-1, y) +
00173                                         getIntPixel(x, y-1) - getIntPixel(x-1, y-1);
00174                           setIntPixel(x,y,val);
00175                         }
00176                 }
00177         }

void printIm (  const char *  filename  )  [inline]
 

Definition at line 217 of file integralimage.h.

00217                                            {
00218                 FILE *fid = fopen(filename, "w");
00219                 int z= 12003;
00220                 for (int y = 0; y < getImHeight(); y++) {
00221                         for (int x = 0; x < getImWidth(); x++)
00222                                 fprintf(fid, "%g\t", getImPixel(x, y));
00223                         fprintf(fid, "\n");
00224                 }
00225                 fclose(fid);
00226         }

void printImBin (  const char *  filename,
bool  flag
)  [inline]
 

Definition at line 238 of file integralimage.h.

Referenced by main().

00238                                                          {
00239                 std::ofstream os(filename, ios::binary | ios::app);
00240                 if (flag) {
00241                         os.flags(ios::binary);
00242                         int width = getImWidth();
00243                         int height = getImHeight();
00244                         os.write((char *)&width, sizeof(width));
00245                         os.write((char *)&height, sizeof(height));
00246                 }
00247                 for (int y = 0; y < getImHeight(); y++) {
00248                         for (int x = 0; x < getImWidth(); x++) {
00249                                 T val = (T)(getImPixel(x, y));
00250                                 os.write((char *)&val, sizeof(val));
00251                         }
00252                 }
00253                 os.close();
00254         }

void printInt (  const char *  filename  )  [inline]
 

Definition at line 228 of file integralimage.h.

00228                                             {
00229                 FILE *fid = fopen(filename, "w");
00230                 for (int y = 0; y < getIntHeight(); y++) {
00231                         for (int x = 0; x < getIntWidth(); x++)
00232                                 fprintf(fid, "%g\t", getIntPixel(x, y));
00233                         fprintf(fid, "\n");
00234                 }
00235                 fclose(fid);
00236         }

void printIntBin (  const char *  filename,
bool  flag
)  [inline]
 

Definition at line 256 of file integralimage.h.

Referenced by MPColorFeatSearch::searchFeature().

00256                                                           {
00257                 std::ofstream os(filename, ios::binary | ios::app);
00258                 if (flag) {
00259                         os.flags(ios::binary);
00260                         int width = getIntWidth();
00261                         int height = getIntHeight();
00262                         os.write((char *)&width, sizeof(width));
00263                         os.write((char *)&height, sizeof(height));
00264                 }
00265                 for (int y = 0; y < getIntHeight(); y++) {
00266                         for (int x = 0; x < getIntWidth(); x++) {
00267                                 T val = (T)(getIntPixel(x, y));
00268                                 os.write((char *)&val, sizeof(val));
00269                         }
00270                 }
00271                 os.close();
00272         }

void setImPixel (  const int  x,
const int  y,
const T &  value
)  [inline]
 

Definition at line 212 of file integralimage.h.

Referenced by ScalePyramid::add_hypothesesPerScale(), drawBack(), drawROI(), main(), and HypothesesPerScale::setParams().

00213         {
00214                 setIntPixel(x+1,y+1,value);
00215         };

void setIntPixel (  const int  x,
const int  y,
const T &  value
)  [inline]
 

Definition at line 192 of file integralimage.h.

Referenced by MPColorFeatSearch::addBoxCorners(), TIntegral< double >::integrate(), main(), and TIntegral< double >::setImPixel().

00193         {
00194                 int lx = x, ly = y;
00195                 
00196                 ASSERT( lx >= 0 && ly >=0 && lx < width && ly < height); 
00197                 if (lx < 0) lx = 0;
00198                 if (ly < 0) ly = 0;
00199                 if(lx >= width) lx = width - 1;
00200                 if(ly >= height) ly = height - 1;
00201 
00202                 int index = width * ly + lx;
00203                 ASSERT (index >= 0 && index < numpixels);
00204                 array[index] = value;
00205                 
00206         }

void setSize (  const int  width,
const int  height
)  [inline]
 

Reimplemented from TImage.

Definition at line 145 of file integralimage.h.

Referenced by main(), and TIntegral< double >::TIntegral().

00145                                                  {
00146     TImage<T>::setSize(width+1,height+1);
00147         }

void setToMinLog (   )  [inline]
 

Definition at line 274 of file integralimage.h.

00274                             {
00275           static TImage<T> cache(getIntWidth(), getIntHeight(), -1000);
00276                 T *ptr = array;
00277                 memcpy(ptr, cache.getArray(), sizeof(T)*getIntNumPix());
00278         }


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