00001 #ifndef __MDistanceFMM__ 00002 #define __MDistanceFMM__ 00003 00004 00005 00035 #include "AnImage.hpp" 00036 #include "RImage.hpp" 00037 00038 #include "AnImageOp.hpp" 00039 00040 #include "MPsi2DValue.hpp" 00041 #include "MDomainOfAction.hpp" 00042 #include "MCandidateHeapList.hpp" 00043 #include "MNeigbourSet.hpp" 00044 00045 00046 class MDistanceFMM : public AnImageOp 00047 { 00048 public: 00049 00050 const static int lookupTable[256][3]; 00051 00052 protected: 00053 00054 int frontMax; 00055 double* speedFactor; 00056 00057 int maskFlag; // 1= mask area, -1 not mask, 0 = both 00058 00059 int iteration; 00060 00061 double selectedDistance; 00062 00063 double root2; 00064 00065 double slowness; 00066 MNeigbourSet* neigbourSet; 00067 00068 MCandidateHeapList* candidateList; 00069 00070 protected: 00071 00072 int iterMax; 00073 int width; 00074 int height; 00075 00077 MDomainOfAction* dmap; 00078 00080 int xSelected, ySelected, currentFront; 00081 00082 protected: 00083 00085 00094 virtual double getPotential(int i, int j) 00095 {return (dmap->getLabel(i,j) != Unknown ? (slowness ) : 1e12); } 00096 00097 // selection 00098 virtual MPsi2DValue* select(){ return candidateList->getTop(); } 00099 virtual void getSelectionNeighbour(int x, int y); 00100 00101 00102 00103 // resolving the quadratic system (See Sethian & Kimmel) 00104 virtual void resolve(int x, int y); 00105 00106 public: 00107 00108 MDistanceFMM(int amaskFlag=1); 00109 virtual ~MDistanceFMM(){ delete dmap; delete candidateList; delete neigbourSet; delete speedFactor; } 00110 00111 virtual void setMaskActivity(int amaskFlag){ maskFlag= amaskFlag; } 00112 00113 virtual double getDistance(int x, int y){return dmap->getValue(x, y);} 00114 virtual int getFront(int x, int y){return dmap->getFront(x, y);} 00115 virtual StatePsi getLabel(int x, int y){return dmap->getLabel(x, y);} 00116 virtual double getSpeedCoeff(int fronNumber){return speedFactor[fronNumber];} 00117 00118 00120 virtual void setData(int w, int h, double v0, int x0, int y0, double v1, int x1, int y1); 00121 virtual void setData(int w, int h, int n, int* frontNum, double* v, int* xMask, int* yMask); 00122 virtual void setData(int w, int h, int n0, double v0, int* xMask0, int* yMask0, 00123 int n1, double v1, int* xMask1, int* yMask1); 00124 virtual void setData(AnImage* im); 00125 00126 00127 virtual int getMaxIterations(){ return iterMax; } 00128 virtual int numberOfIteration(){ return iteration; } 00129 virtual void setIteration(int i){ iteration=i; } 00130 00132 virtual bool iterate(); 00133 00135 00144 virtual bool iterate(int* x, int* y) 00145 { 00146 bool rc= iterate(); 00147 00148 *x= xSelected; 00149 *y= ySelected; 00150 00151 return rc; 00152 } 00153 00155 00165 virtual bool iterate(int* x, int* y, double* rate) 00166 { 00167 bool rc= iterate(x,y); 00168 00169 *rate= dmap->getValue(xSelected,ySelected); 00170 00171 return rc; 00172 } 00173 00175 virtual RImage* compute(RImage* dest=0); 00176 00178 virtual void sortedArea(AnImage* mask, 00179 int* npoints, int** xposition, int** yposition, bool inside=true); 00181 virtual void sortedArea(AnImage* mask, int* npoints, 00182 int** xposition, int** yposition, double** rating, bool inside=true); 00183 00185 virtual AnImage* filter(AnImage* mask, AnImage* dest=0); 00186 virtual AnImage* selectedFilter(AnImage* mask, AnImage* src, AnImage* dest=0); 00187 00189 virtual RImage* rfilter(AnImage* mask, RImage* dest=0); 00190 00192 virtual AnImage* greyLabelFilter(AnImage* src, AnImage* dest=0); 00193 virtual AnImage* colorLabelFilter(AnImage* src, AnImage* dest=0); 00194 00195 // euclidian Paths 00196 virtual AnImage* bidirPath(AnImage* src, double v0, int x0, int y0, double v1, int x1, int y1, AnImage* dest=0); 00197 00198 virtual void report(){} 00199 }; 00200 00201 #endif