Definition at line 551 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, Impala::Min(), mPointSelector, Impala::Application::DemoCamera2d::sigma, Impala::Core::Table::Table::Size(), and Impala::Timer::SplitTimeStr(). Referenced by ProjectOntoCodebook(). 00554 { 00555 using namespace Matrix; 00556 Timer timerProjection; 00557 if(mDescriptorReduce) 00558 { 00559 matrixDescriptors = MatMul(matrixDescriptors, mDescriptorReduce); 00560 } 00561 Mat* matrixCodebook = mCodebook->GetColumn2()->GetStorage(); 00562 ILOG_DEBUG(MatNrRow(matrixDescriptors) << " " << 00563 MatNrCol(matrixDescriptors)); 00564 ILOG_DEBUG(MatNrRow(matrixCodebook) << " " << 00565 MatNrCol(matrixCodebook)); 00566 ILOG_DEBUG("Codebook projection (init) took: " << 00567 timerProjection.SplitTimeStr()); 00568 00569 int step = Min(Int64(10000), Int64(20000000 / mCodebook->Size())); 00570 for(int k = 0; k < MatNrRow(matrixDescriptors); k += step) 00571 { 00572 int s = MatNrRow(matrixDescriptors) - k; 00573 if(step < s) s = step; 00574 00575 Mat* partial = MatCreate<Mat>(s, MatNrCol(matrixDescriptors), 00576 MatE(matrixDescriptors, k, 0), true); 00577 00578 // result will be a (#partial-descriptors, codebook size) matrix 00579 Mat* distances = MatNorm2DistTransposed(partial, 00580 matrixCodebook); 00581 delete partial; 00582 00583 ILOG_DEBUG("Codebook projection (matrix) took: " << 00584 timerProjection.SplitTimeStr()); 00585 CmdOptions& options = CmdOptions::GetInstance(); 00586 Real64 sigma = options.GetDouble("codebookSigma"); 00587 00588 // pull a Gaussian kernel over the Euclidian distances 00589 for(int vj = 0; vj < s; vj++) 00590 { 00591 for(int i = 0; i < mCodebook->Size(); i++) 00592 { 00593 Real64 value = *MatE(distances, vj, i); 00594 *MatE(distances, vj, i) = exp((-0.5 * value * value) / 00595 (sigma * sigma)); 00596 } 00597 } 00598 00599 // sum over axis 0 for the normalization factor 00600 // expected size is (#descriptors, 1) 00601 Mat* normalizationFactor = MatSumAxis1(distances); 00602 ILOG_DEBUG("normalizationFactor: " << MatNrRow(normalizationFactor) 00603 << " " << MatNrCol(normalizationFactor)); 00604 00605 // perform normalization 00606 for(int vj = 0; vj < s; vj++) 00607 { 00608 for(int i = 0; i < mCodebook->Size(); i++) 00609 { 00610 *MatE(distances, vj, i) = *MatE(distances, vj, i) / 00611 *MatE(normalizationFactor, vj, 0); 00612 } 00613 } 00614 delete normalizationFactor; 00615 00616 // remains: sum over the *right* descriptors 00617 for(int vj = 0; vj < s; vj++) 00618 { 00619 for(int ps = 0; ps < mPointSelector.size(); ps++) 00620 { 00621 if(mPointSelector[ps]->Accept(X[k+vj], Y[k+vj], 00622 imageWidth, imageHeight)) 00623 { 00624 for(int i = 0; i < mCodebook->Size(); i++) 00625 { 00626 codebookVectors[ps]->Elem(i) = 00627 codebookVectors[ps]->Elem(i) + 00628 *MatE(distances, vj, i); 00629 } 00630 regionCounts[ps] = regionCounts[ps] + 1; 00631 } 00632 } 00633 } 00634 delete distances; 00635 ILOG_DEBUG("Codebook projection (piece) took: " << 00636 timerProjection.SplitTimeStr() << " " << mPointSelector.size()); 00637 } 00638 ILOG_INFO("Codebook projection (UNC/" << MatNrRow(matrixDescriptors) << 00639 ") took: " << timerProjection.SplitTimeStr()); 00640 if(mDescriptorReduce) 00641 { 00642 delete matrixDescriptors; 00643 } 00644 }
Here is the call graph for this function:
|