00001 #ifndef __StructuredElement__ 00002 #define __StructuredElement__ 00003 00004 00005 00006 00024 #include "AnImage.hpp" 00025 00026 00027 class StructuredElement 00028 { 00029 protected: 00030 00031 int xc, yc; 00032 00033 int width, height; 00034 00035 bool largeElement; 00036 00037 int kernelSize; // in number of valid pixels 00038 int* xk; // position in kernel 00039 int* yk; 00040 00041 // delta pixel to remove at next sweep 00042 int nRemove[4]; 00043 int* xr[4]; 00044 int* yr[4]; 00045 00046 // delta pixel to add at next sweep 00047 int nAdd[4]; 00048 int* xa[4]; 00049 int* ya[4]; 00050 00051 AnImage* data; 00052 00053 protected: 00054 00055 void init(); 00056 00057 public: 00058 StructuredElement(); 00059 StructuredElement(int x0, int y0, int w, int h); 00060 StructuredElement(int x0, int y0, AnImage* im); 00061 virtual ~StructuredElement(){delete data;} 00062 00063 StructuredElement* copy(); 00064 00065 void setData(int x0, int y0, AnImage* im); 00066 00067 bool isLarge(){ return largeElement; } 00068 00069 int getWidth(){return width;} 00070 int getHeight(){return height;} 00071 00072 int getKernelSize(){return kernelSize;} 00073 void getKernel(int index, int *x, int *y) 00074 {*x= xk[index]; *y= yk[index]; } 00075 00076 int getRemoveSize(int idir){return nRemove[idir];} 00077 void getRemoveKernel(int idir, int index, int *x, int *y) 00078 {*x= xr[idir][index]; *y= yr[idir][index]; } 00079 00080 int getAddSize(int idir){return nAdd[idir];} 00081 void getAddKernel(int idir, int index, int *x, int *y) 00082 {*x= xa[idir][index]; *y= ya[idir][index]; } 00083 00084 int getX0(){return xc;} 00085 int getY0(){return yc;} 00086 00087 int get(int x, int y){return data->get(x,y);} 00088 void set(int x, int y, int value){data->set(x,y,value);} 00089 00090 void set(int value){data->setValues(value);} 00091 00092 virtual void report(FILE* file){} 00093 00094 }; 00095 00096 #endif