00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef FILTER_CANNY_H
00012 #define FILTER_CANNY_H
00013
00014 #include <cmath>
00015 #include "filter.h"
00016 #include "gauss.h"
00017 #include "image.h"
00018 #include "image_op.h"
00019 #include "property_image.h"
00020 #include "edge_string.h"
00021 #include "edge_string_op.h"
00022
00023 namespace mimas {
00024
00042 template<typename T>
00043 class canny_tool
00044 {
00045 private:
00046 double sigma;
00047 double precision;
00048 double low_edge_thres;
00049 double up_edge_thres;
00050 int len_thres;
00051
00052
00053 public:
00054
00055 canny_tool(void)
00056 {
00057 sigma = 1.0;
00058 precision = 0.01;
00059 low_edge_thres = 3.0;
00060 up_edge_thres = 5.0;
00061 len_thres = 5;
00062 }
00067 edge_string_ptr_list findEdgeStrings( const image<T> &input )
00068 {
00069 image<int>
00070
00071 grad_x( gaussGradientX< float >( input, sigma ) ),
00072 grad_y( gaussGradientY< float >( input, sigma ) ),
00073
00074
00075
00076
00077 gradsq( sumSquares( grad_x, grad_y ) );
00078
00079
00080
00081 edge_image edge_im;
00082 filter<int>::nonMaximaSuppression( grad_x, grad_y, gradsq,
00083 40.0, edge_im );
00084 grad_x.clear();
00085 grad_y.clear();
00086 gradsq.clear();
00087
00088
00089
00090
00091
00092 edge_string_ptr_list edge_strings;
00093 edge_string_op eop;
00094
00095 edge_strings = eop.extractFromImage( edge_im, 5, 5.0 );
00096
00097
00098 return edge_strings;
00099 }
00100 };
00101
00102 };
00103
00104 #endif