contrib/oxl/osl/osl_canny_base.h
Go to the documentation of this file.
00001 //-*- c++ -*-------------------------------------------------------------------
00002 #ifndef osl_canny_base_h_
00003 #define osl_canny_base_h_
00004 //
00005 // .NAME osl_canny_base - a base class for edge detectors
00006 // .LIBRARY osl
00007 // .HEADER vxl package
00008 // .INCLUDE osl/osl_canny_base.h
00009 // .FILE osl_canny_base.cxx
00010 //
00011 // .SECTION Description
00012 //
00013 // Definition of a base class for doing Canny edge detection.
00014 // Note that nothing special has been done around the border of the image;
00015 // we have simply ignored a border of size width_ all the way round. Perhaps
00016 // this should be changed to provide consistency with the rest of TargetJr.
00017 //
00018 // .SECTION Author
00019 //       Samer Abdallah - 5/10/95
00020 //       Robotics Research Group, Oxford University
00021 //         osl_canny_base is built from Canny  which was originally developed by
00022 //         Charlie Rothwell - 25/1/92
00023 //         GE Corporate Research and Development
00024 // .SECTION Modifications
00025 //       Samer Abdallah (samer@robots.ox.ac.uk) - 18/05/96
00026 //        Cleared some compiler warnings
00027 //
00028 //-----------------------------------------------------------------------------
00029 
00030 #include <osl/osl_canny_port.h>
00031 
00032 template <class T>
00033 T     **osl_canny_base_make_raw_image(int, int, T *dummy);
00034 template <class T>
00035 void    osl_canny_base_fill_raw_image(T **, int, int, T value);
00036 template <class T>
00037 void    osl_canny_base_free_raw_image(T **);
00038 template <class S, class T>
00039 void    osl_canny_base_copy_raw_image(S const * const *src, T * const *dst, int, int);
00040 
00041 class osl_canny_base {
00042 public:
00043   osl_canny_base(float sigma, float low, float high, bool verbose = true);
00044   ~osl_canny_base();
00045 
00046 protected:
00047 
00048   static void Initial_follow(float * const *thin, int xsize, int ysize, float low,
00049                              int x,int y,
00050                              vcl_list<int> *xc,vcl_list<int> *yc,
00051                              vcl_list<float> *grad);
00052   void Final_follow(int,int,vcl_list<int>*,vcl_list<int>*,vcl_list<float>*,int);
00053   static void Follow_junctions(int * const *junction, int x, int y, vcl_list<int> *xc, vcl_list<int> *yc);
00054   static void Cluster_centre_of_gravity(int * const *jx, int * const *jy,
00055                                         vcl_list<int> &xc, vcl_list<int> &yc,
00056                                         int &x0,int &y0);
00057   static int Junction_neighbour(int const * const *junction, int x, int y);
00058 
00059 
00060   unsigned int xstart_,ystart_; // The origin of the buffer in the image
00061   unsigned int xsize_,ysize_;   // The width of the image buffer
00062 
00063   float **smooth_;     // Smoothed intensity image
00064   float **dx_;         // Derivatives in x, and sub-pixel x coordinates
00065   float **dy_;         // Derivatives in y, and sub-pixel y coordinates
00066   float **grad_;       // Gradient image
00067 
00068   float **thick_;      // Gradient image after NMS
00069   float **thin_;       // Gradient image after NMS and thinning
00070   float **theta_;      // Orientation image
00071 
00072 
00073   int **junction_;     // Binary image true only at junctions ends, and relevant lists
00074   int **jx_,**jy_;     // Images of (x,y) coordinates of nearest cluster centre
00075   vcl_list<int> *xjunc_;
00076   vcl_list<int> *yjunc_;
00077   vcl_list<osl_Vertex*> *vlist_;   // The junction cluster centres
00078 
00079   float gauss_tail_;  // The value of the kernel at its tail
00080   float sigma_;       // Smoothing sigma
00081   int width_;         // The smoothing kernel width - can change
00082   int w0_;            // Same as above, but does not change
00083   int k_size_;        // The kernel is 2*width_+1s
00084   float *kernel_;     // 1-Dimensional convolution kernel of size k_size
00085   float low_;         // Low threshold for hysteresis
00086   float high_;        // High threshold for hysteresis
00087 
00088   float jval_;        // A dummy junction intensity step value
00089   int chain_no_;      // A dummy variable used in following
00090   bool verbose;
00091 };
00092 
00093 #endif // osl_canny_base_h_