Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

StructuringElement.h

00001 // StructuringElement.h: interface for the CStructuringElement class.
00002 //
00004 
00005 #if !defined(AFX_STRUCTURINGELEMENT_H__CAC256CA_3E2A_4A38_8F2C_B9A69732BC00__INCLUDED_)
00006 #define AFX_STRUCTURINGELEMENT_H__CAC256CA_3E2A_4A38_8F2C_B9A69732BC00__INCLUDED_
00007 
00008 #include "Error.h"
00009 #include "PixelTypes.h"
00010 #include "ImageGrey.h"
00011 
00012 #ifndef SWIG
00013 
00014 #if _MSC_VER > 1000
00015 #pragma once
00016 #endif // _MSC_VER > 1000
00017 
00018 class CPixel {
00019         public:
00020                 int x,y;
00021                 int offset;
00022 };
00023 
00028 typedef list<CPixel> ListPixelT;
00029 #endif //SWIG
00030 enum EltStructT {
00031         EltGeneric = 0,
00032         EltConvex,
00033         EltLinear
00034 };
00035 
00054 class CStructuringElement : public CError
00055 {
00056 protected:
00057         PIXEL histo[512];
00058         PIXEL maximum, minimum;
00059         int LineLength;
00060         int centerx, centery;
00061         int Width, Height;
00062         int top, left, bottom, right;
00063         int baricenterx, baricentery;
00064 
00066         inline void updateMax(ListPixelT *remove, ListPixelT *add, LPPIXEL start);
00068         inline void updateMin(ListPixelT *remove, ListPixelT *add, LPPIXEL start);
00070         void init(CImageGrey *image);
00071 
00073         inline int offset(CPixel pix) {
00074                 return pix.offset;
00075         };
00076 
00078         double alpha;
00079 
00081         ListPixelT allpixels;
00083         ListPixelT removeBottom, removeLeft, removeRight;
00084         ListPixelT addBottom, addLeft, addRight;
00086         ListPixelT extremSet;
00087 
00089         EltStructT type;
00090 
00091 
00092 public:
00093 #ifndef SWIG
00094         CStructuringElement() {};
00096         CStructuringElement(int *pix, int nb, int *extrem, int nbe);
00097 #endif
00098 #ifdef SWIG
00099         %name(createLine)
00100 #endif
00101 
00102         CStructuringElement(double alpha);
00104         CStructuringElement(CImageGrey *img);
00106         virtual ~CStructuringElement();
00107 
00108 
00110         inline EltStructT TypeGet() const { return type;}
00112         inline int WidthGet() const { return Width;};
00114         inline int HeightGet() const { return Height;};
00115 
00117         inline int BaricenterXGet() const {return baricenterx;};
00119         inline int BaricenterYGet() const {return baricentery;};
00120 
00122         void Translate(int x, int y);
00123 
00125         CImageGrey *createImage(PIXEL color=1);
00126 
00128         CImageGrey *dilate(CImageGrey *img, int size);
00130         CImageGrey *erode(CImageGrey *img, int size);
00131 
00133         CImageGrey *test(int x1, int y1, int x2, int y2);
00134 
00135 protected:
00137         CImageGrey *dilate1Gen(CImageGrey *img);
00139         CImageGrey *erode1Gen(CImageGrey *img);
00141         CImageGrey * dilateGen(CImageGrey* img, int size);
00143         CImageGrey * erodeGen(CImageGrey* img, int size);
00144 
00146         CImageGrey * dilate1Conv(CImageGrey* img, CImageGrey* imgOut, ListPixelT *lpix, int size);
00148         CImageGrey * erode1Conv(CImageGrey* img, CImageGrey* imgOut, ListPixelT *lpix, int size);
00150         CImageGrey * dilateConv(CImageGrey* img, int size);
00152         CImageGrey * erodeConv(CImageGrey* img, int size);
00153 
00155         CImageGrey * dilateLinear(CImageGrey *img, int size);
00157         CImageGrey * erodeLinear(CImageGrey *img, int size);
00158 
00160         void BresenhamOffset(int x1, int y1, int x2, int y2, int *pb, int *rlc, int nx);
00161 
00162 private:
00163         inline void computeMaxG(LPPIXEL f, int *p, PIXEL *g, int k, int nx);
00164         inline void computeMaxH(LPPIXEL f, int *p, PIXEL *h, int k, int nx);
00165         inline void computeMaxGH(PIXEL *gh, PIXEL *g,PIXEL *h,int k,int nx);
00166         inline void computeMaxH2(LPPIXEL f, int *p, PIXEL *h2, int k, int nx);
00167         inline void computeMaxR(LPPIXEL f, int *p, PIXEL *g, PIXEL *h, PIXEL *gh, PIXEL *h2, int k, int nx);
00168 
00169         inline void computeMinG(LPPIXEL f, int *p, PIXEL *g, int k, int nx);
00170         inline void computeMinH(LPPIXEL f, int *p, PIXEL *h, int k, int nx);
00171         inline void computeMinGH(PIXEL *gh, PIXEL *g,PIXEL *h,int k,int nx);
00172         inline void computeMinH2(LPPIXEL f, int *p, PIXEL *h2, int k, int nx);
00173         inline void computeMinR(LPPIXEL f, int *p, PIXEL *g, PIXEL *h, PIXEL *gh, PIXEL *h2, int k, int nx);
00174 };
00175 
00181 class Xelt 
00182 {
00183 public:
00184         Xelt() {};
00185         ~Xelt() {};
00186         CStructuringElement *makeCross() {
00187                 extern CStructuringElement cross;
00188                 return &cross;
00189         };
00190         
00191         CStructuringElement *makeSquare() {
00192                 extern CStructuringElement square;
00193                 return &square;
00194         };
00195         CStructuringElement *makeLineH() {
00196                 extern CStructuringElement lineH;
00197                 return &lineH;
00198         };
00199         CStructuringElement *makeLineV() {
00200                 extern CStructuringElement lineV;
00201                 return &lineV;
00202         };
00203         CStructuringElement *makeLine(double alpha) {
00204                 CStructuringElement *l;
00205                 l = new CStructuringElement(alpha);
00206                 return l;
00207         };
00208 };
00209 
00210 #endif // !defined(AFX_STRUCTURINGELEMENT_H__CAC256CA_3E2A_4A38_8F2C_B9A69732BC00__INCLUDED_)

Generated at Sun May 12 19:04:22 2002 for OpenMorpho by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000