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

void Impala::Core::Feature::InterestPointFeature::ProjectUNC ( Mat matrixDescriptors,
int  imageWidth,
int  imageHeight,
std::vector< int > &  X,
std::vector< int > &  Y,
std::vector< int > &  regionCounts 
) [inline, private]

Definition at line 539 of file InterestPointFeature.h.

References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::GetColumn2(), Impala::CmdOptions::GetInstance(), ILOG_DEBUG, ILOG_INFO, Impala::Core::Matrix::MatE(), Impala::Core::Matrix::MatMul(), Impala::Core::Matrix::MatNorm2DistTransposed(), Impala::Core::Matrix::MatNrCol(), Impala::Core::Matrix::MatNrRow(), Impala::Core::Matrix::MatSumAxis1(), mCodebook, mDescriptorReduce, mLastCodebookVectors, mPointSelector, Impala::Application::DemoCamera2d::sigma, Impala::Core::Table::Table::Size(), and Impala::Timer::SplitTimeStr().

Referenced by ProjectOntoCodebook().

00542     {
00543         using namespace Matrix;
00544         Timer timerProjection;
00545         if(mDescriptorReduce)
00546         {
00547             matrixDescriptors = MatMul(matrixDescriptors, mDescriptorReduce);
00548         }
00549         Mat* matrixCodebook = mCodebook->GetColumn2()->GetStorage();
00550         ILOG_DEBUG(MatNrRow(matrixDescriptors) << " " <<
00551                    MatNrCol(matrixDescriptors));
00552         ILOG_DEBUG(MatNrRow(matrixCodebook) << " " <<
00553                    MatNrCol(matrixCodebook));
00554         ILOG_DEBUG("Codebook projection (init) took: " <<
00555                    timerProjection.SplitTimeStr());
00556 
00557         int step = 10000;
00558         for(int k = 0; k < MatNrRow(matrixDescriptors); k += step)
00559         {
00560             int s = MatNrRow(matrixDescriptors) - k;
00561             if(step < s) s = step;
00562     
00563             Mat* partial = MatCreate<Mat>(s, MatNrCol(matrixDescriptors),
00564                                           MatE(matrixDescriptors, k, 0), true);
00565 
00566             // result will be a (#partial-descriptors, codebook size) matrix
00567             Mat* distances = MatNorm2DistTransposed(partial,
00568                                                     matrixCodebook);
00569             delete partial;
00570             
00571             ILOG_DEBUG("Codebook projection (matrix) took: " <<
00572                        timerProjection.SplitTimeStr());
00573             CmdOptions& options = CmdOptions::GetInstance();
00574             Real64 sigma = options.GetDouble("codebookSigma");
00575 
00576             // pull a Gaussian kernel over the Euclidian distances
00577             for(int vj = 0; vj < s; vj++)
00578             {
00579                 for(int i = 0; i < mCodebook->Size(); i++)
00580                 {
00581                     Real64 value = *MatE(distances, vj, i);
00582                     *MatE(distances, vj, i) = exp((-0.5 * value * value) /
00583                                                   (sigma * sigma));
00584                 }
00585             }
00586 
00587             // sum over axis 0 for the normalization factor
00588             // expected size is (#descriptors, 1)
00589             Mat* normalizationFactor = MatSumAxis1(distances);
00590             ILOG_DEBUG("normalizationFactor: " << MatNrRow(normalizationFactor)
00591                        << " " << MatNrCol(normalizationFactor));
00592 
00593             // perform normalization
00594             for(int vj = 0; vj < s; vj++)
00595             {
00596                 for(int i = 0; i < mCodebook->Size(); i++)
00597                 {
00598                     *MatE(distances, vj, i) = *MatE(distances, vj, i) /
00599                         *MatE(normalizationFactor, vj, 0);
00600                 }
00601             }
00602             delete normalizationFactor;
00603 
00604             // remains: sum over the *right* descriptors
00605             for(int vj = 0; vj < s; vj++)
00606             {
00607                 for(int ps = 0; ps < mPointSelector.size(); ps++)
00608                 {
00609                     if(mPointSelector[ps]->Accept(X[k+vj], Y[k+vj],
00610                                                   imageWidth, imageHeight))
00611                     {
00612                         for(int i = 0; i < mCodebook->Size(); i++)
00613                         {
00614                             mLastCodebookVectors[ps]->Elem(i) =
00615                                 mLastCodebookVectors[ps]->Elem(i) +
00616                                 *MatE(distances, vj, i);
00617                         }
00618                         regionCounts[ps] = regionCounts[ps] + 1;
00619                     }
00620                 }
00621             }
00622             delete distances;
00623             ILOG_DEBUG("Codebook projection (piece) took: " <<
00624                        timerProjection.SplitTimeStr() << " " << mPointSelector.size());
00625         }
00626         ILOG_INFO("Codebook projection (UNC/" << MatNrRow(matrixDescriptors) <<
00627                   ") took: " << timerProjection.SplitTimeStr());
00628         if(mDescriptorReduce)
00629         {
00630             delete matrixDescriptors;
00631         }
00632     }

Here is the call graph for this function:


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