00001 #ifndef __DistanceFMM_O2__ 00002 #define __DistanceFMM_O2__ 00003 00004 00005 00035 #include "AnImage.hpp" 00036 #include "RImage.hpp" 00037 00038 #include "AnImageOp.hpp" 00039 00040 #include "Psi2DValue.hpp" 00041 #include "DomainOfAction.hpp" 00042 #include "CandidateHeapList.hpp" 00043 #include "NeigbourSet.hpp" 00044 00045 00046 class DistanceFMM_O2 : public AnImageOp 00047 { 00048 protected: 00049 00050 int maskFlag; // 1= mask area, -1 not mask, 0 = both 00051 00052 int iteration; 00053 00054 double selectedDistance; 00055 00056 double root2; 00057 00058 double slowness; 00059 NeigbourSet* neigbourSet; 00060 00061 CandidateHeapList* candidateList; 00062 00063 protected: 00064 00065 int iterMax; 00066 int width; 00067 int height; 00068 00070 DomainOfAction* dmap; 00071 00073 int xSelected, ySelected; 00074 00075 protected: 00076 00078 00087 virtual double getPotential(int i, int j) 00088 {return (dmap->getLabel(i,j) != Unknown ? (slowness) : 1e12); } 00089 00090 // selection 00091 virtual Psi2DValue* select(); 00092 virtual void getSelectionNeighbour(int x, int y); 00093 00094 00095 00096 // resolving the quadratic system (See Sethian & Kimmel) 00097 virtual void resolve(int x, int y); 00098 00099 public: 00100 00101 DistanceFMM_O2(int amaskFlag=1); 00102 virtual ~DistanceFMM_O2(){ delete dmap; delete candidateList; delete neigbourSet; } 00103 00104 virtual void setMaskActivity(int amaskFlag){ maskFlag= amaskFlag; } 00105 00106 virtual double getDistance(int x, int y){return dmap->getValue(x, y);} 00107 virtual StatePsi getLabel(int x, int y){return dmap->getLabel(x, y);} 00108 00110 virtual void setData(int w, int h, int x0, int y0); 00111 virtual void setData(int w, int h, int n, int* xMask, int* yMask); 00112 virtual void setData(AnImage* im); 00113 00114 00115 virtual int getMaxIterations(){ return iterMax; } 00116 virtual int numberOfIteration(){ return iteration; } 00117 virtual void setIteration(int i){ iteration=i; } 00118 00120 virtual bool iterate(); 00121 00123 00132 virtual bool iterate(int* x, int* y) 00133 { 00134 bool rc= iterate(); 00135 00136 *x= xSelected; 00137 *y= ySelected; 00138 00139 return rc; 00140 } 00141 00143 00153 virtual bool iterate(int* x, int* y, double* rate) 00154 { 00155 bool rc= iterate(x,y); 00156 00157 *rate= dmap->getValue(xSelected,ySelected); 00158 00159 return rc; 00160 } 00161 00163 virtual RImage* compute(RImage* dest=0); 00164 00166 virtual void sortedArea(AnImage* mask, 00167 int* npoints, int** xposition, int** yposition, bool inside=true); 00169 virtual void sortedArea(AnImage* mask, int* npoints, 00170 int** xposition, int** yposition, double** rating, bool inside=true); 00171 00173 virtual AnImage* filter(AnImage* mask, AnImage* dest=0); 00174 virtual AnImage* selectedFilter(AnImage* mask, AnImage* src, AnImage* dest=0); 00175 00177 virtual RImage* rfilter(AnImage* mask, RImage* dest=0); 00178 00180 virtual AnImage* singlePath(AnImage* src, int x0, int y0, int x1, int y1, AnImage* dest=0); 00181 00182 virtual void report(){} 00183 }; 00184 00185 #endif