00001 //-*- c++ -*------------------------------------------------------------------- 00002 #ifndef osl_canny_ox_h 00003 #define osl_canny_ox_h 00004 // 00005 // .NAME osl_canny_ox - The `Sheffield' Canny edge detector 00006 // .INCLUDE osl/osl_canny_ox.h 00007 // .FILE osl_canny_ox.cxx 00008 // 00009 // .SECTION Description 00010 // 00011 // A class for performing the AZ-standard version of Canny's edge detector. 00012 // The basic implementation is similar to that described in Canny's thesis, 00013 // though sub-pixel interpolation of the final edge output has been included, 00014 // and there is patching of single pixel gaps in the edgel chains. 00015 // 00016 // In order not to ignore a border of size width_ (half the kernel size) 00017 // around the image, as is done in class Canny, this implementation 00018 // uses sub_area_OX_ to normalise the (gaussian) smoothed border pixels---see 00019 // the description of Smooth_imageOX(). 00020 // 00021 // .SECTION Author 00022 // Samer Abdallah (samer@robots.ox.ac.uk) - 5/10/95 00023 // Robotics Research Group, University of Oxford 00024 // 00025 // .SECTION Modifications 00026 // The original C implementation of this canny edge detector 00027 // came from AIRUV at Sheffield. It was later modified by 00028 // Charlie Rothwell, Nic Pillow and Sven Utcke. 00029 // 00030 // Samer Abdallah - 18/05/96 - Cleared some compiler warnings 00031 // Samer Abdallah - 24/05/96 - Fixed theta_[x][y] in Non_maximal_supressionOX 00032 // theta_[x][y] now stores the edge normal 00033 // Maarten Vergauwen (ESAT, KULeuven) - 08/10/98 - Added AdjustForMask method 00034 // Peter Vanroose - 30/12/99 - Link_edgelsOX rewritten and documented 00035 // F. Schaffalitzky 2-apr-99 converted from Segmentation to osl 00036 00037 #include <vcl_vector.h> 00038 #include <vil1/vil1_image.h> 00039 #include <osl/osl_canny_base.h> 00040 00041 class osl_canny_ox_params; 00042 00043 struct osl_LINK 00044 { 00045 int to; 00046 osl_LINK *nextl; 00047 }; 00048 00049 00050 class osl_canny_ox : public osl_canny_base 00051 { 00052 public: 00053 osl_canny_ox(osl_canny_ox_params const ¶ms); 00054 void detect_edges(vil1_image const &image, vcl_list<osl_edge*>*); 00055 ~osl_canny_ox(); 00056 00057 protected: 00058 osl_edgel_chain *Get_NMS_edgelsOX(int n_edgels_NMS, int *x_, int *y_); 00059 00060 // Functions used in performing the hysteresis part of canny 00061 int HysteresisOX(osl_edgel_chain *&, int *&); 00062 void Initial_followOX(int,int,osl_edgel_chain *&,osl_LINK *[],int *&,float); 00063 void Add_linkOX(int,int,osl_LINK *[]); 00064 void Link_edgelsOX(vcl_vector<unsigned> const &, vcl_vector<unsigned> const &,osl_LINK *[]); 00065 int Get_n_edgels_hysteresisOX(osl_edgel_chain *&,int *&); 00066 void Get_hysteresis_edgelsOX(osl_edgel_chain *&,int *&, osl_edgel_chain *&, int *x_, int *y_); 00067 void Delete_linksOX(osl_LINK **, int); 00068 osl_edge *NO_FollowerOX(osl_edgel_chain *); 00069 00070 // Functions used in the follow part of canny 00071 void FollowerOX(vcl_list<osl_edge*> *); 00072 void Final_followOX(int,int,vcl_list<int> *,vcl_list<int> *,vcl_list<float> *,int); 00073 int Join_dotsOX(int,int,int,int,int&,int&); 00074 void Scale_imageOX(float **, float); 00075 void Set_image_borderOX(float **, int, float); 00076 00077 // Functions used in locating junctions 00078 void Find_junctionsOX(); 00079 void Find_junction_clustersOX(); 00080 00081 protected: 00082 int max_width_OX_; // The maximum smoothing kernel width 00083 float *sub_area_OX_; // Used in smoothing the image near the borders 00084 00085 int edge_min_OX_; // Minimum edge pixel intensity 00086 00087 int min_length_OX_; // Minimum number of pixels in a curve 00088 int border_size_OX_; // Border size around the image to be set 00089 float border_value_OX_; // to border_value_OX_ (usually 0) to ensure 00090 // follow won't overrun. 00091 float scale_OX_; // Value used in the follow part of canny to 00092 // scale image after the hysteresis part. 00093 int follow_strategy_OX_; // Flag used in the Final_followOX() to determined 00094 // the order of neighboring pixel checking 00095 // (see Final_followOX() function in osl_canny_ox.C 00096 // When equal to 0, only NMS and Hysteresis 00097 // are performed; FollowerOX is not performed. 00098 // Locating Junctions in not performed either. 00099 // See Do_osl_canny_ox(...) 00100 00101 bool join_flag_OX_; // True to enable pixel jumping 00102 int junction_option_OX_; // True if we want to locate junctions 00103 }; 00104 00105 #endif // osl_canny_ox_h