contrib/tbl/vipl/vipl_moment.h
Go to the documentation of this file.
00001 #ifndef vipl_moment_h_
00002 #define vipl_moment_h_
00003 //:
00004 // \file
00005 // \brief computation of n-th order moment
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 //   The n-th order moment operation replaces a pixel with the expected value
00012 //   of x^n of its surrounding pixels, in a certain neighbourhood. Here the
00013 //   neighbourhood is an arbitrary rectangular mask, the height and width of which
00014 //   are passed to the constructor.
00015 //
00016 //   A fast computation method is used which needs only seven + or - operations per
00017 //   pixel (except for initialization of first row and column) because it uses
00018 //   computed values of previous pixels
00019 //
00020 // \author Maarten Vergauwen, K.U.Leuven (ESAT/PSI)
00021 // \date   21 September 1999.
00022 //
00023 // \verbatim
00024 // Modifications:
00025 //   Peter Vanroose, Aug.2000 - adapted to vxl
00026 // \endverbatim
00027 //
00028 // \example examples/example_std_dev.cxx
00029 
00030 #include <vipl/filter/vipl_filter_2d.h> // parent class
00031 
00032 //: computation of n-th order moment
00033 template <class ImgIn,class ImgOut,class DataIn,class DataOut,VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) >
00034 class vipl_moment : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>
00035 {
00036   // -+-+- data members: -+-+-
00037  private:
00038   int order_;
00039   int width_;
00040   int height_;
00041   int& ref_order(){return order_;}
00042   int& ref_width(){return width_;}
00043   int& ref_height(){return height_;}
00044   void put_order(int v){order_=v;}
00045   void put_width(int v){width_=v;}
00046   void put_height(int v){height_=v;}
00047  public:
00048   int order() const {return order_;}
00049   int width() const {return width_;}
00050   int height() const {return height_;}
00051 
00052   // -+-+- constructors/destructors: -+-+-
00053  public:
00054   inline vipl_moment(int n,int w=3,int h=3)
00055     : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(), order_(n), width_(w), height_(h) {}
00056   inline vipl_moment(vipl_moment const& A)
00057     : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A), order_(A.order()), width_(A.width()), height_(A.height()) {}
00058   inline ~vipl_moment() {}
00059 
00060   // -+-+- required method for filters: -+-+-
00061   bool section_applyop();
00062 };
00063 
00064 #ifdef INSTANTIATE_TEMPLATES
00065 #include "vipl_moment.txx"
00066 #endif
00067 
00068 #endif // vipl_moment_h_