mdsTriVertexDetector.hxx

Go to the documentation of this file.
00001 //==============================================================================
00015 #define LOG_VERTICES
00016 
00017 
00018 //==============================================================================
00019 /*
00020  * Methods templates.
00021  */
00022 
00023 //template <>
00024 bool CTriVertexDetector<CELL_MAX>::operator()(const mds::img::CDImage *pImage,
00025                                               vctl::MCVerticeS *pVertices
00026                                               )
00027 {
00028     MDS_ASSERT(pImage && pVertices);
00029 
00030     // Get image size
00031     mds::tSize XSize = pImage->getXSize();
00032     mds::tSize YSize = pImage->getYSize();
00033 
00034     // Estimate threshold
00035     double dThreshold = mds::img::getMean<double>(*pImage) + m_dThreshold * sqrt(mds::img::getVariance<double>(*pImage));
00036 
00037     // Minimal and maximal values
00038     double dMin = mds::img::getMin<double>(*pImage);
00039     double dMax = mds::img::getMax<double>(*pImage);
00040     double dTemp = 1.0 / (dMax - dMin + 0.001);
00041 
00042     // Helper values
00043     mds::tSize FullSize = m_CellSize + 2 * m_CellMargin;
00044     mds::tSize TempSize = m_CellSize + m_CellMargin;
00045 
00046     // Helper string stream used for logging
00047 #ifdef LOG_VERTICES
00048     std::stringstream ss;
00049     ss << "points = [";
00050 #endif //LOG_VERTICES
00051 
00052     // Insert all significant edge points to the list of vertices
00053     for( mds::tSize j = 0; (j + m_CellMargin) < YSize; j += FullSize )
00054     {
00055         mds::tSize MinJ = j + m_CellMargin;
00056         mds::tSize MaxJ = mds::math::getMin(j + TempSize, YSize);
00057 
00058         for( mds::tSize i = 0; (i + m_CellMargin) < XSize; i += FullSize )
00059         {
00060             mds::tSize MinI = i + m_CellMargin;
00061             mds::tSize MaxI = mds::math::getMin(i + TempSize, XSize);
00062 
00063             mds::tSize MaxX = MinI;
00064             mds::tSize MaxY = MinJ;
00065             double dMaxValue = (double)pImage->get(MaxX, MaxY);
00066 
00067             for( int wj = MinJ; wj < MaxJ; ++wj )
00068             {
00069                 for( int wi = MinI; wi < MaxI; ++wi )
00070                 {
00071                     double dValue = (double)pImage->get(wi, wj);
00072                     if( dValue > dMaxValue )
00073                     {
00074                         dMaxValue = dValue;
00075                         MaxX = wi;
00076                         MaxY = wj;
00077                     }
00078                 }
00079             }
00080             if( dMaxValue > dThreshold )
00081             {
00082                 vctl::MCVertex *pVertex = pVertices->New(MaxX, MaxY, 0.0);
00083                 pVertex->SetValue((dMaxValue - dMin) * dTemp);
00084 #ifdef LOG_VERTICES
00085                 ss << MaxX << ',' << MaxY << "; ";
00086 #endif //LOG_VERTICES
00087             }
00088         }
00089     }
00090 
00091     // Logging
00092 #ifdef LOG_VERTICES
00093     ss << "]';";
00094     MDS_LOG_NOTE(ss.str());
00095 #endif //LOG_VERTICES
00096 
00097 /*    vctl::MCVertex *pVertex = pVertices->New(50.0, 50.0, 0.0);
00098     pVertex->SetValue(0.9);
00099  
00100     pVertex = pVertices->New(100.0, 50.0, 0.0);
00101     pVertex->SetValue(0.8);
00102  
00103     pVertex = pVertices->New(75.0, 100.0, 0.0);
00104     pVertex->SetValue(0.7);*/
00105 
00106     // O.K.
00107     return true;
00108 }
00109 

Generated on Thu Mar 11 10:35:45 2010 for MDSTk Extension Libraries by  doxygen 1.4.6-NO