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

sampleGrabber Class Reference

Inheritance diagram for sampleGrabber:

Inheritance graph
[legend]
Collaboration diagram for sampleGrabber:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void grab (RImage< float > &pixels, const double *index_flags)
 sampleGrabber (const mxArray **ci, const int &max_num_patches_, mxArray *&patch_array)
 ~sampleGrabber ()

Constructor & Destructor Documentation

sampleGrabber const mxArray **  ci,
const int &  max_num_patches_,
mxArray *&  patch_array
[inline]
 

Definition at line 27 of file mp_grabSamples.cc.

00027                                                                                          :
00028     MPISearchMex(ci,max_num_patches_,patch_array) {};
  ~sampleGrabber() {}

~sampleGrabber  )  [inline]
 

Definition at line 29 of file mp_grabSamples.cc.

00029 {}


Member Function Documentation

void grab RImage< float > &  pixels,
const double *  index_flags
 

Definition at line 79 of file mp_grabSamples.cc.

References MPISearchStream::allocated, MPIImagePyramid::begin(), c, corner, MPISearchStream::corners, MPIImagePyramid::end(), MPISearchStream::fns, RImage::height, index_flags, MPISearchStream::init(), MPISearchObjectDetector< float >::integrateImages(), MPISearchStream::mpi, MPISearchStream::norm_window, MPISearchStream::nw_c, MPISearchStream::nw_fn, p, FeatureData::patchsize, r, sprintf(), FeatureData::stdAdjusts, Corner::value, RImage::width, and y.

00079                                                                         {
00080   if(!stream.allocated){
00081     //cout << "MPISearchObjectDetector::search: stream not allocated. Allocating data" << endl;
00082     stream.init(pixels.width, pixels.height, data, 1);
00083   }
00084   integrateImages(pixels, stream);
00085 
00086   double * p = patches;
00087   int numWindows = 0;
00088   int scale_index;
00089   float scale_factor;
00090   int ind, x, y;
00091   char errStr[256];
00092 
00093   MPIImagePyramid<float>::const_iterator scale = stream.mpi->begin();
00094   MPIImagePyramid<float>::const_iterator last_scale = stream.mpi->end();
00095   for( ; scale != last_scale; ++scale){
00096     // get pointers to cached values for this scale
00097     scale_index = scale.getScale(scale_factor);
00098     //cout << "Scale: " << scale_index << ", scale_factor = " << scale_factor << endl;
00099     float sf2 = scale_factor * scale_factor;
00100     CornerCache<float> **corners = stream.corners[scale_index];
00101     float *fns = stream.fns[scale_index];
00102     CornerCache<float> *nw_c = stream.nw_c[scale_index];
00103     float nw_fn = stream.nw_fn[scale_index];
00104     MPIScaledImage<float>::const_iterator window = (*scale).begin(), last_window = (*scale).end();
00105     //cout << "Index = " << ind << ", x = " << x << ", y = " << y << endl;
00106     for( ; window != last_window; ++window, ++numWindows){
00107       if(index_flags[numWindows] > 0){
00108         // cout << "Grabbing a Patch at index " << numWindows << endl;
00109           // calculate the statistics for this sub window
00110         window.getIndex(ind);
00111         window.getCoords(x,y);
00112         //cout << "Index = " << ind << ", x = " << x << ", y = " << y << endl;
00113           double mean = 0.0;
00114           double mean2 = 0.0;
00115           for(int corner = 0; corner < 4; corner++) {
00116             mean  += window.getPixel0 (nw_c[corner].scaledIndex) * stream.norm_window[corner].value;
00117             mean2 += window.getPixel1 (nw_c[corner].scaledIndex) * stream.norm_window[corner].value;
00118           }
00119           mean /= nw_fn;
00120           mean2 /= nw_fn;
00121           double standard_deviation = sqrt(mean2 - mean*mean);
00122           if(standard_deviation < 0.00001){
00123             sprintf(errStr,"mp_grabSamples: std = 0 at index %d",ind); 
00124             mexErrMsgTxt(errStr);
00125           }
00126 
00127           double top_left = static_cast<double>(window.getScalePixel(0,0,0));
00128           double top_row;
00129           double left_column;
00130           double divisor = 1.0/(sf2 * standard_deviation * data.stdAdjusts[static_cast<int>(scale_factor+0.5f)-1]);
00131           double * oldp = p;
00132           for(int c = 0; c < data.patchsize; ++c){
00133             top_row = static_cast<double>(window.getScalePixel(0,c,0));
00134             for(int r = 0; r < data.patchsize; ++r){
00135               left_column = static_cast<double>(window.getScalePixel(0,0,r));
00136               *(p++) = (static_cast<double>(window.getScalePixel(0,c,r))
00137                         - left_column - top_row + top_left - (r)*(c)*sf2*mean)
00138                 * divisor;
00139             }
00140           }
00141       }
00142     }
00143   }
00144 }

Here is the call graph for this function:


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