canny_tool.h

Go to the documentation of this file.
00001 //
00002 // canny stuff. rewritten, though based on tina
00003 // stumeikle Sat May  4 19:22:36 2002
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     //operator. operates on images
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         // Compute horizontal and vertical gradients.
00071         grad_x( gaussGradientX< float >( input, sigma ) ),
00072         grad_y( gaussGradientY< float >( input, sigma ) ),
00073   // Create grad sq. The following would be very elegant, but more memory
00074         // intensive:
00075   // gradsq = (grad_x*grad_x) + (grad_y*grad_y);
00076   // (... so we wont ...)
00077         gradsq( sumSquares( grad_x, grad_y ) );
00078 
00079   // Do non maxima suppression
00080   // (errr.. shouldnt we look for zero crossings of grad^2 im?)
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   //(5.0) post process the resulting edgels
00089   // what's the best way to do this ? we could create an edge_image function
00090   // but it would be better *not* to have specific edge images. better to have image properties
00091   // than specific image types. anyway image<int> is a perfectly valid edge image too.
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   //done canny ----------------------------------------------------
00098   return edge_strings;
00099     }
00100 };
00101 
00102 };
00103 
00104 #endif

[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:16 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...