Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

/home/slang/XVision2/src/Segmentation/XVSegmentation.h

00001 // *** BEGIN_XVISION2_COPYRIGHT_NOTICE ***
00002 // *** END_XVISION2_COPYRIGHT_NOTICE ***
00003 
00004 // 
00005 // XVSegmentation.h
00006 //
00007 // Samuel Lang
00008 // 9.21.00
00009 //
00010 
00011 #ifndef _XVSEGMENTATION_H_
00012 #define _XVSEGMENTATION_H_
00013 
00014 #include <XVImageBase.h>
00015 #include <XVImageScalar.h>
00016 #include <XVBlobs.h>
00017 #include <vector>
00018 #include <math.h>
00019 
00020 #define NULL_VALUE ~0
00021 
00022 #define MAX_REGIONS      2000
00023 #define DEFAULT_PADDING  40
00024 #define M_TO_S_RATIO     1.1
00025 
00026 class XVSegException : public XVException { public:  
00027   XVSegException() : XVException(){}
00028   XVSegException(char * str) : XVException(str) {} }; 
00029 
00036 template <class T, class Y>
00037 class LookupTable{
00038 
00039  protected:
00040 
00041   Y * table;
00042 
00043  public:
00044 
00045   LookupTable() : table(NULL) {}
00046 
00047   virtual ~LookupTable(){ delete [] table; }
00048 
00049   virtual Y computePixelValue(T pixel) = 0;
00050   
00051   virtual void buildTable() = 0;
00052   
00053   virtual Y & operator [] (T) = 0;
00054 };
00055 
00070 template <class T, class Y>
00071 class XVSegmentation{
00072 
00073   typedef T PIXELINTYPE;
00074   typedef Y PIXELOUTTYPE;
00075 
00076  protected:
00077   
00078   int             histSize;
00079   int             histArraySize;
00080   u_int *         histogram;
00081   LookupTable<T,Y> * lookup;
00082   
00083 public:
00084 
00085   bool (*SEGFUNC) (const Y);
00086   
00087   ~XVSegmentation();
00088 
00089   virtual void update(const XVImageBase<T> &) = 0;
00090   
00098   virtual void segment(const XVImageBase<T> &, XVImageBase<Y> &);
00099   virtual void findCentroid(const XVImageScalar<Y> &, XVPosition &, 
00100                    int, bool (*pf) (const Y) = NULL);
00101   virtual XVRectangleBlob & findBoundingBox(const XVImageBase<T> &, 
00102                             XVRectangleBlob &,  
00103                             bool (*pf) (const Y) = NULL);
00104   virtual void regionGrow(const XVImageScalar<Y> &, vector<XVRectangleBlob> &, 
00105                  bool (*pf) (const Y) = NULL, 
00106                  int padding = DEFAULT_PADDING,
00107                  int maxRegions = MAX_REGIONS,
00108                  float ratio    = M_TO_S_RATIO);
00109 
00110   void setCheck(bool (*pf) (const Y)){ this->SEGFUNC = pf; }
00111 
00112   u_int * getHistogram(){ return histogram; }
00113 };
00114 
00115 template <class T, class Y>
00116 class ScalarTable;
00117 
00118 template <class T, class Y>
00119 class RGBTable;
00120 
00121 #include <XVSegmentation.icc>
00122 
00123 #endif

Generated at Thu Mar 29 22:37:28 2001 for XVision by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000