00001
00015 #define LOG_VERTICES
00016
00017
00018
00019
00020
00021
00022
00023
00024 bool CTriVertexDetector<CELL_MAX>::operator()(const mds::img::CDImage *pImage,
00025 vctl::MCVerticeS *pVertices
00026 )
00027 {
00028 MDS_ASSERT(pImage && pVertices);
00029
00030
00031 mds::tSize XSize = pImage->getXSize();
00032 mds::tSize YSize = pImage->getYSize();
00033
00034
00035 double dThreshold = mds::img::getMean<double>(*pImage) + m_dThreshold * sqrt(mds::img::getVariance<double>(*pImage));
00036
00037
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
00043 mds::tSize FullSize = m_CellSize + 2 * m_CellMargin;
00044 mds::tSize TempSize = m_CellSize + m_CellMargin;
00045
00046
00047 #ifdef LOG_VERTICES
00048 std::stringstream ss;
00049 ss << "points = [";
00050 #endif //LOG_VERTICES
00051
00052
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
00092 #ifdef LOG_VERTICES
00093 ss << "]';";
00094 MDS_LOG_NOTE(ss.str());
00095 #endif //LOG_VERTICES
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 return true;
00108 }
00109