contrib/tbl/vipl/vipl_gradient_mag.h
Go to the documentation of this file.
00001 #ifndef vipl_gradient_mag_h_
00002 #define vipl_gradient_mag_h_
00003 //:
00004 // \file
00005 // \brief sqrt of vipl_x_gradient square plus vipl_y_gradient square
00006 //
00007 //   This image processing class is implemented using the vipl filters,
00008 //   which means that it can be used with any image class (IUE or not,
00009 //   TargetJr or not, vil or vil1 or not) of any pixel data type.
00010 //
00011 //   Note that the pixel types must support conversion from/to double
00012 //   where the sqrt computation takes place.
00013 //
00014 // \author Peter Vanroose, K.U.Leuven (ESAT/PSI)
00015 // \date   1 June 1998.
00016 //
00017 // \verbatim
00018 // Modifications:
00019 //   Peter Vanroose, Aug.2000 - adapted to vxl
00020 // \endverbatim
00021 //
00022 // \example examples/example_gradient_mag.cxx
00023 
00024 #include <vipl/filter/vipl_filter_2d.h> // parent class
00025 
00026 //: sqrt of vipl_x_gradient square plus vipl_y_gradient square
00027 template <class ImgIn,class ImgOut,class DataIn,class DataOut, VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) >
00028 class vipl_gradient_mag : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>
00029 {
00030   // -+-+- data members: -+-+-
00031   // term to add to the sqrt gradient result:
00032  private: double shift_;
00033  public: double shift() const { return shift_; }
00034   // scale factor to multiply the shifted sqrt with:
00035  private: double scale_;
00036  public: double scale() const { return scale_; }
00037 
00038   // -+-+- constructors/destructors: -+-+-
00039  public:
00040   inline vipl_gradient_mag(double s=1, double h=0)
00041            : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(),
00042              shift_(h), scale_(s) {}
00043   inline vipl_gradient_mag(vipl_gradient_mag const& A)
00044            : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A),
00045              shift_(A.shift()), scale_(A.scale()) {}
00046   inline ~vipl_gradient_mag() {}
00047 
00048   // -+-+- required method for filters: -+-+-
00049   bool section_applyop();
00050 };
00051 
00052 #ifdef INSTANTIATE_TEMPLATES
00053 #include "vipl_gradient_mag.txx"
00054 #endif
00055 
00056 #endif // vipl_gradient_mag_h_