contrib/tbl/vipl/vipl_monadic.h
Go to the documentation of this file.
00001 #ifndef vipl_monadic_h_
00002 #define vipl_monadic_h_
00003 //:
00004 // \file
00005 // \brief apply any (fixed) function to all pixels
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 only parameter to be passed to the constructor must be a (monadic)
00012 //   function that takes a pixel value from the input image and produces
00013 //   a pixel value of the output image, i.e., its signature must be
00014 //   DataOut f(DataIn const&).
00015 //   A typical example is, e.g., log(), but any point operator (like e.g.
00016 //   thresholding) could be implemented through this more general monadic IP
00017 //   operator, notably shift or scale of intensity values.
00018 //
00019 //   Note that the input and output images are allowed to be identical.
00020 //
00021 // \author Peter Vanroose, K.U.Leuven (ESAT/PSI)
00022 // \date   15 September 1999.
00023 //
00024 // \verbatim
00025 // Modifications:
00026 //   Peter Vanroose, Aug.2000 - adapted to vxl
00027 // \endverbatim
00028 //
00029 // \example examples/example_std_dev.cxx
00030 
00031 #include <vipl/filter/vipl_filter_2d.h> // parent class
00032 
00033 //: apply any (fixed) function to all pixels
00034 template <class ImgIn,class ImgOut,class DataIn,class DataOut, VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) >
00035 class vipl_monadic : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>
00036 {
00037  public:
00038   typedef DataOut (*MonadicFunction)(DataIn const&);
00039   // -+-+- data members: -+-+-
00040  private: MonadicFunction func_;
00041  public: MonadicFunction func() const { return func_; }
00042 
00043   // -+-+- constructors/destructors: -+-+-
00044  public:
00045   inline vipl_monadic(MonadicFunction f)
00046     : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(), func_(f) {}
00047   inline vipl_monadic(vipl_monadic const& A)
00048     : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A), func_(A.func()) {}
00049   inline ~vipl_monadic() {}
00050 
00051   // -+-+- required method for filters: -+-+-
00052   bool section_applyop();
00053 };
00054 
00055 #ifdef INSTANTIATE_TEMPLATES
00056 #include "vipl_monadic.txx"
00057 #endif
00058 
00059 #endif // vipl_monadic_h_