00001 #ifndef __DistanceFMM1__ 00002 #define __DistanceFMM1__ 00003 00004 00005 00038 #include "AnImage.hpp" 00039 #include "RImage.hpp" 00040 00041 #include "AnImageOp.hpp" 00042 00043 #include "Psi2DValue.hpp" 00044 #include "DomainOfAction.hpp" 00045 #include "CandidateHeapList.hpp" 00046 #include "NeigbourSet.hpp" 00047 00048 00049 class DistanceFMM1 : public AnImageOp 00050 { 00051 protected: 00052 00053 int iteration; 00054 00055 double selectedDistance; 00056 00057 double slowness; 00058 NeigbourSet* neigbourSet; 00059 00060 CandidateHeapList* candidateList; 00061 00062 protected: 00063 00064 int iterMax; 00065 int width; 00066 int height; 00067 00069 DomainOfAction* dmap; 00070 00072 int xSelected, ySelected; 00073 00074 protected: 00075 00077 int getOrder(int x, int y, int dimension, int back_forward); 00078 00080 00089 virtual double getPotential(int i, int j) 00090 {return (dmap->getLabel(i,j) != Unknown ? (slowness) : 1e12); } 00091 00092 // selection 00093 virtual Psi2DValue* select(){ return candidateList->getTop(); } 00094 virtual void getSelectionNeighbour(int x, int y); 00095 00096 // resolving the quadratic system (See Sethian & Kimmel) 00097 virtual void resolve(int x, int y); 00098 00099 public: 00100 00101 DistanceFMM1(); 00102 virtual ~DistanceFMM1(){ delete dmap; delete candidateList; delete neigbourSet; } 00103 00104 virtual double getDistance(int x, int y){return dmap->getValue(x, y);} 00105 virtual StatePsi getLabel(int x, int y){return dmap->getLabel(x, y);} 00106 00108 virtual void setData(int w, int h, int x0, int y0); 00109 virtual void setData(int w, int h, int n, int* xMask, int* yMask); 00110 virtual void setData(AnImage* im); 00111 00112 00113 virtual int getMaxIterations(){ return iterMax; } 00114 virtual int numberOfIteration(){ return iteration; } 00115 virtual void setIteration(int i){ iteration=i; } 00116 00118 virtual bool iterate(); 00119 00121 00130 virtual bool iterate(int* x, int* y) 00131 { 00132 bool rc= iterate(); 00133 00134 *x= xSelected; 00135 *y= ySelected; 00136 00137 return rc; 00138 } 00139 00141 00151 virtual bool iterate(int* x, int* y, double* rate) 00152 { 00153 bool rc= iterate(x,y); 00154 00155 *rate= dmap->getValue(xSelected,ySelected); 00156 00157 return rc; 00158 } 00159 00161 virtual RImage* compute(RImage* dest=0); 00162 00164 virtual void sortedArea(AnImage* mask, 00165 int* npoints, int** xposition, int** yposition, bool inside=true); 00167 virtual void sortedArea(AnImage* mask, int* npoints, 00168 int** xposition, int** yposition, double** rating, bool inside=true); 00169 00171 virtual AnImage* filter(AnImage* mask, AnImage* dest=0); 00172 virtual AnImage* selectedFilter(AnImage* mask, AnImage* src, AnImage* dest=0); 00173 00175 virtual AnImage* singlePath(AnImage* src, int x0, int y0, int x1, int y1, AnImage* dest=0); 00176 00177 virtual void report(){} 00178 }; 00179 00180 #endif