contrib/tbl/vipl/vipl_dyadic.h
Go to the documentation of this file.
00001 #ifndef vipl_dyadic_h_
00002 #define vipl_dyadic_h_
00003 //:
00004 // \file
00005 // \brief apply any (fixed) function to all (out,in) pixel pairs
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 (dyadic)
00012 //   function that takes two pixel values, one from the output image and
00013 //   one from the input image, and changes its first argument is some way.
00014 //   The function should not return a value, i.e., its signature must be
00015 //   void f(DataOut&, DataIn const&).
00016 //   Typical examples are adding or subtracting images pixel-wise.
00017 //
00018 //   Note that the output image has to be initialized in advance, as its
00019 //   pixel values are actually both read and written.
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 (out,in) pixel pairs
00034 template <class ImgIn,class ImgOut,class DataIn,class DataOut, VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) >
00035 class vipl_dyadic : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>
00036 {
00037  public:
00038   typedef void (*DyadicFunction)(DataOut&, DataIn const&);
00039   // -+-+- data members: -+-+-
00040  private: DyadicFunction func_;
00041  public: DyadicFunction func() const { return func_; }
00042 
00043   // -+-+- constructors/destructors: -+-+-
00044  public:
00045   inline vipl_dyadic(DyadicFunction f)
00046     : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(), func_(f) {}
00047   inline vipl_dyadic(vipl_dyadic const& A)
00048     : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A), func_(A.func()) {}
00049   inline ~vipl_dyadic() {}
00050 
00051   // -+-+- required method for filters: -+-+-
00052   bool section_applyop();
00053 };
00054 
00055 #ifdef INSTANTIATE_TEMPLATES
00056 #include "vipl_dyadic.txx"
00057 #endif
00058 
00059 #endif // vipl_dyadic_h_