Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

Matrix::Mat* Impala::Core::Feature::DSurf ( Array::Array2dScalarReal64 *  image,
PointDescriptorTable *  pointData,
int  sampleRate,
int  numberHaarSum,
int  spatiality 
)

image in, descriptors are added to pointList

Definition at line 65 of file DSurf.h.

References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Add(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CH(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CW(), ExtractFeatureIntoVector(), HaarResponse(), ILOG_DEBUG, ILOG_VAR, Impala::Core::Array::IntegrateReduce(), Impala::Core::Array::IntegrateReduceWeighted(), Impala::Core::Matrix::MatE(), and Impala::Core::Table::Table::Size().

Referenced by CalculateSurfDescriptors().

00068 {
00069     using namespace Matrix;
00070 
00071     ILOG_VAR(Impala.Core.Feature.DSurf);
00072     ILOG_DEBUG("image w="<< image->CW() <<", h="<< image->CH());
00073     /* In order to speed up processing reduce the image so one pixel has the
00074        same 'energy' as a block of sampleRate^2 pixels. */
00075     Array::Array2dScalarReal64* reduced = 0;
00076     IntegrateReduce(reduced, image, sampleRate);
00077     // haar responses
00078     std::vector<Array::Array2dScalarReal64*> haar = HaarResponse(reduced);
00079     delete reduced;
00080     // sum the haar responses into component of the surf feature
00081     std::vector<Array::Array2dScalarReal64*> components;
00082     int w = haar[0]->CW() / numberHaarSum;
00083     int h = haar[0]->CH() / numberHaarSum;
00084     for(int i=0 ; i<haar.size() ; ++i)
00085     {
00086         Array::Array2dScalarReal64* comp =
00087             new Array::Array2dScalarReal64(w, h, 0, 0);
00088         IntegrateReduceWeighted(comp, haar[i], numberHaarSum);
00089         components.push_back(comp);
00090         delete haar[i];
00091     }
00092     w = components[0]->CW();
00093     h = components[0]->CH();
00094     //now combine the components into actual surf features
00095     int nrFeatures = w*h;
00096     int sampleSize = sampleRate * numberHaarSum;
00097     int featureSize = sampleSize * spatiality;
00098     /* because the DSurf implementation does it's own sampling we need this loop
00099        to create the interest points with correct dimensions (actually only the
00100        middle point is needed) */
00101     if(pointData->Size() == 0)
00102     {
00103         for(int y=0 ; y<=h-spatiality ; ++y)
00104         {
00105             for(int x=0 ; x<=w-spatiality ; ++x)
00106             {
00107                 int left=x*sampleSize;
00108                 int top =y*sampleSize;
00109                 int centerX = static_cast<int>(((featureSize) / 2.0 + left) + 0.5);
00110                 int centerY = static_cast<int>(((featureSize) / 2.0 + top) + 0.5);
00111                 // this gives the same output as the old way of doing things,
00112                 // though the featureSize entries are not needed *twice*
00113                 pointData->Add(centerX, centerY, featureSize+1, featureSize+1, 0);
00114                 //Geometry::Rectangle r(left, top, left+featureSize, top+featureSize);
00115             }
00116         }
00117     }
00118     // here comes the actual creation of surf features
00119     /* we might speed this up as follows:
00120        - first allocate a double array for all features.
00121        - then loop over the component images sepqrately and write into the buffer.
00122          This might be faster because the component images are are accessed once.
00123        - then normalize all features and copy vectors into the point list.
00124     */
00125     int it = 0;
00126     Mat* descriptors = MatCreate<Mat>(pointData->Size(), components.size() * spatiality * spatiality);
00127     for(int y=0 ; y<=h-spatiality ; ++y)
00128     {
00129         for(int x=0 ; x<=w-spatiality ; ++x)
00130         {
00131             ExtractFeatureIntoVector(MatE(descriptors, it, 0), components, x, y, spatiality);
00132             it++;
00133         }
00134     }
00135     for(int i=0 ; i<components.size() ; ++i)
00136         delete components[i];
00137     return descriptors;
00138 }

Here is the call graph for this function:


Generated on Thu Jan 13 09:19:00 2011 for ImpalaSrc by  doxygen 1.5.1