- Main Page
- Classes
- Files

- File List
- File Members

# CSED.h

Go to the documentation of this file.

    00001
    00029 #ifndef CSED_h
    00030 #define CSED_h
    00031
    00032 #include "DistanceTransform.h"
    00033 #include <iostream>
    00034 using namespace std;
    00035 //----------------------------------------------------------------------
    00047 class CSED : public DistanceTransform {
    00048
    00049 public:
    00050     CSED ( const int xSize, const int ySize, const bool unload=true )
    00051         : DistanceTransform(xSize, ySize, unload)
    00052     {
    00053     }
    00054
    00055     ~CSED ( ) {
    00056         if (this->v!=NULL) {
    00057             free( this->v );
    00058             this->v = NULL;
    00059         }
    00060     }
    00061
    00062     void doTransform ( const unsigned char* const I );
    00063
    00071     virtual inline bool getP ( const int x, const int y, int& px, int& py )
    00072     const {
    00073         if (v==NULL) {
    00074             px = py = -1;
    00075             return false;
    00076         }
    00077         const int s = sub(x,y);
    00078         px = x - v[s].x;
    00079         py = y - v[s].y;
    00080         return true;
    00081     }
    00082
    00083 protected:
    00084     P*  v;
    00085
    00086 private:
    00087     inline void test ( const int px, const int py, const int ox, const int oy,
    00088                        vector<P*>* list2, const int i );
    00089
    00091     static inline double D ( const int x, const int y ) {
    00092         return sqrt( (double)x * x + y * y );
    00093     }
    00094
    00096     static inline double D ( P& p ) {
    00097         return sqrt( (double)p.x * p.x + p.y * p.y );
    00098     }
    00099
    00101     static inline int sgn ( int i ) {
    00102         if (i<0)    return -1;
    00103         if (i>0)    return  1;
    00104         return 0;
    00105     }
    00106 };
    00107
    00108 #endif
    00109 //----------------------------------------------------------------------