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

template<class SrcArrayT>
void Impala::Core::Feature::HarrisLaplaceDetector::laplacianScaleSelection ( PointDescriptorTable output,
SrcArrayT *  imIntensity,
MyPointList pointList,
Real64  laplaceThreshold 
) [inline]

Definition at line 273 of file HarrisLaplaceDetector.h.

References Impala::Core::Array::Abs(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Add(), ILOG_DEBUG, ILOG_WARN, Impala::Core::Array::Laplacian(), mBackwardsCompatible, mPrecision, mUseRecGauss, and Impala::Application::DemoCamera2d::sigma.

Referenced by CHLDetector(), and HLDetector().

00274     {
00275         std::vector<Real64> precomputeScales;
00276         std::vector<Array2dScalarReal64*> cache;
00277         for(int i = 0; i < 21; i++) {
00278             Real64 sigma = pow(sqrt(sqrt(Real64(2))),i) * 0.75;
00279             precomputeScales.push_back(sigma);
00280             Array2dScalarReal64* tmp = 0;
00281             Laplacian(tmp, imIntensity, sigma, 2, mUseRecGauss, mPrecision);
00282             Abs(tmp, tmp);
00283             cache.push_back(tmp);
00284 
00285             ILOG_DEBUG("Computing Laplacian scale: " << sigma);
00286         }
00287         
00288         typedef std::pair<int, std::pair<int, int> > MyKey;
00289         std::map<MyKey, int> alreadyHavePoint;
00290 
00291         for(MyPointList::iterator iter = pointList.begin(); iter != pointList.end(); iter++)
00292         {
00293             MyPoint* point(*iter);
00294             Real64 sigmaN = point->mDetectionScale;
00295 
00296             // we must find the index of the nearest sigma in precomputeScales
00297             int nearestIndex = 0;
00298             Real64 smallestDifference = 999;
00299             for(int i = 0; i < precomputeScales.size(); i++) {
00300                 Real64 difference;
00301                 if(mBackwardsCompatible)
00302                 {
00303                     // make the current (wrong) behavior explicit
00304                     difference = static_cast<int>(abs(precomputeScales[i] - sigmaN));
00305                 }
00306                 else
00307                 {
00308                     difference = fabs(precomputeScales[i] - sigmaN);
00309                 }
00310                 if(difference < smallestDifference) 
00311                 {
00312                     smallestDifference = difference;
00313                     nearestIndex = i;
00314                 }
00315             }
00316             if(smallestDifference > 0.0001) {
00317                 ILOG_WARN("WARNING: scale mismatch");
00318             }
00319     
00320             std::vector<int> interestingScales;
00321             std::vector<Real64> laplacianValues;
00322             //std::cout << "LAP: ";
00323             for(int i = 0; i < precomputeScales.size(); i++) {
00324                 if((i >= nearestIndex - 4) && (i <= nearestIndex + 4)) {
00325                     interestingScales.push_back(i);
00326                     // lookup the Laplacian value for this cached scale
00327                     laplacianValues.push_back(cache[i]->Value(point->mX, point->mY));
00328                     //std::cout << cache[i]->Value(point.mX, point.mY) << " ";
00329                 }
00330             }
00331             //std::cout << std::endl;
00332     
00333             /*std::cout << "plot([";
00334             for(int i = 0; i < precomputeScales.size(); i++) {
00335                 std::cout << cache[i]->Value(point.mX, point.mY) << " ";
00336             }
00337             std::cout << "])" << std::endl;*/
00338             
00339             // laplacianValues now contains the values of the Laplacian at interestingScales
00340     
00341             // select the local maximum
00342             int nrFound = 0;
00343             for(int i = 1; i < interestingScales.size() - 1; i++) {
00344                 if((laplacianValues[i] > laplacianValues[i-1]) &&
00345                    (laplacianValues[i] > laplacianValues[i+1]))
00346                 {
00347                     if(laplacianValues[i] > laplaceThreshold) {
00348                         MyKey key(std::make_pair(point->mX, std::make_pair(point->mY, interestingScales[i])));
00349                         if(alreadyHavePoint.find(key) == alreadyHavePoint.end())
00350                         {
00351                             alreadyHavePoint[key] = 0;
00352                             output->Add(point->mX, point->mY, precomputeScales[interestingScales[i]], 0, point->mCornerness);
00353                             nrFound++;
00354                         }
00355                     }
00356                 }
00357             }
00358         }
00359         for(int i = 0; i < cache.size(); i++) {
00360             delete cache[i];
00361         }
00362     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:09:44 2010 for ImpalaSrc by  doxygen 1.5.1