contrib/tbl/vipl/vipl_x_gradient.h
Go to the documentation of this file.
00001 #ifndef vipl_x_gradient_h_
00002 #define vipl_x_gradient_h_
00003 //:
00004 // \file
00005 // \brief Convolve image with horizontal [-1 1] filter
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 user has to make sure that the output values fall into
00012 //   the output pixel range, by specifying appropriate scale and shift;
00013 //   wrap-around will occur if it does not.
00014 //
00015 //   Note also the implicit use of DataOut::DataOut(DataIn),
00016 //   which you probably will have to provide when DataIn and DataOut
00017 //   are not the same type.
00018 //
00019 // \author Peter Vanroose, K.U.Leuven (ESAT/PSI)
00020 // \date   1 June 1998.
00021 //
00022 // \verbatim
00023 // Modifications:
00024 //   Peter Vanroose, Aug.2000 - adapted to vxl
00025 // \endverbatim
00026 //
00027 // \example examples/example_x_gradient.cxx
00028 
00029 #include <vipl/filter/vipl_filter_2d.h> // parent class
00030 
00031 //: Convolve image with horizontal [-1 1] filter
00032 template <class ImgIn,class ImgOut,class DataIn,class DataOut, VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) >
00033 class vipl_x_gradient : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>
00034 {
00035   // -+-+- data members: -+-+-
00036   // term to add to the gradient result:
00037  private: DataOut shift_;
00038  public: DataOut shift() const { return shift_; }
00039   // scale factor to multiply the shifted gradient with:
00040  private: double scale_;
00041  public: double scale() const { return scale_; }
00042 
00043   // -+-+- constructors/destructors: -+-+-
00044  public:
00045   inline vipl_x_gradient(double s=1.0, DataOut h=DataOut())
00046            : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(),
00047              shift_(h), scale_(s) {}
00048   inline vipl_x_gradient(vipl_x_gradient const& A)
00049            : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A),
00050              shift_(A.shift()), scale_(A.scale()) {}
00051   inline ~vipl_x_gradient() {}
00052 
00053   // -+-+- required method for filters: -+-+-
00054   bool section_applyop();
00055 };
00056 
00057 #ifdef INSTANTIATE_TEMPLATES
00058 #include "vipl_x_gradient.txx"
00059 #endif
00060 
00061 #endif // vipl_x_gradient_h_