//************************************************************************** #ifndef REGION_H #define REGION_H //************************************************************************** #include "list.h" #include "pixel.h" //************************************************************************** class Region { private: List<Pixel> L; Pixel phead; Pixel ptail; int length; int closed; public: Region() { length = 0; closed = 0;} // Constructor ~Region() { } // Destructor void reInitialize() { length = 0; closed = 0; L.reInitialize(); } inline void Insert(int x, int y, double strength) { Pixel P(x,y,strength); Insert(P);} inline void Insert(Pixel p) { if (length == 0) phead = p; L.Insert(p); ++length; ptail = p;} inline Pixel &begin() { L.First(); return L();} inline Pixel &head() { return phead;} inline Pixel &tail() { return ptail;} inline Pixel &operator() ( ) { return L();} inline void get(int *x, int *y, double *strength) { L().get(x, y, strength); } inline void operator++ ( ) {++L;} inline int operator! ( ) { return !L; } inline int x() { return L().x; } inline int y() { return L().y; } inline double strength() { return L().strength; } inline int size() {return length;} inline void close() {closed = 1;} inline void open() {closed = 0;} inline int isOpen() { return (closed == 0); } inline int isClosed() { return (closed == 1); } Region &operator= (Region &Reg); }; //************************************************************************** void makeRegions(Matrix &Im, int thresholdsize); void followAndfillRegion(Region *R, Matrix *img); void makeRegions(GrayImage &Im, int thresholdsize); void writeAllRegions(GrayImage *img); void joinRegions(Region &r1, Region &r2, Region *final, int r_num); void insertLine(Region *r, Pixel &p0, Pixel &p1, int value); void joinRegions(void); int FindNearestRegion(Region &r, int regnum); int dist(Region &r1, Region &r2); void printRegionLengths(void); void compactRegions(void); int numNonzeroRegions(void); void refineRegions(int reg_size, int n); //************************************************************************** #endif // REGION_H //**************************************************************************