00001
00029 #ifndef ModifiedDijkstra_h
00030 #define ModifiedDijkstra_h
00031
00032 #include "DistanceTransform.h"
00033 #ifdef WIN32
00034 #pragma warning(disable:4786) //necessary because stl generates longer
00035
00036 #endif
00037 #include <set>
00038
00039 using namespace std;
00040
00042 class ModifiedDijkstra : public DistanceTransform {
00043
00044 public:
00045 ModifiedDijkstra ( const int xSize, const int ySize,
00046 const bool unload=true )
00047 : DistanceTransform(xSize, ySize, unload)
00048 {
00049 }
00050
00055 void doTransform ( const unsigned char* const I ) {
00056 modifiedDijkstra(I);
00057 }
00058
00066 void modifiedDijkstra ( const unsigned char* const I );
00073 void modifiedDijkstra_DeadReckoning ( const unsigned char* const I );
00080 void modifiedDijkstra_ModifiedDeadReckoning ( const unsigned char* const I );
00081
00084 virtual inline bool getP ( const int x, const int y, int& px, int& py ) const {
00085 if (p==NULL) return false;
00086 const int s = sub(x,y);
00087 px = p[s].x;
00088 py = p[s].y;
00089 return true;
00090 }
00091
00092 protected:
00094 P *p;
00095
00096 private:
00102 typedef struct {
00103 double d;
00104 int x;
00105 int y;
00106 } SetElement;
00107
00109 struct ltSetElement {
00112 bool operator() ( const SetElement* s1, const SetElement* s2 ) const {
00113 if (s1->d < s2->d) return true;
00114 if (s1->d > s2->d) return false;
00115
00116 if (s1->x < s2->x) return true;
00117 if (s1->x > s2->x) return false;
00118
00119 if (s1->y < s2->y) return true;
00120 if (s1->y > s2->y) return false;
00121 return false;
00122 }
00123 };
00124
00133 void init ( const unsigned char* const I, double* &d, SetElement* &se,
00134 set< const SetElement *, ltSetElement > &s );
00135
00136 inline void check ( double* d, const int center, const int X,
00137 const int Y, SetElement* se, set< const SetElement*, ltSetElement > &s );
00138 };
00139
00140 #endif
00141
00142