contrib/tbl/vipl/vipl_y_gradient.h
Go to the documentation of this file.
00001 #ifndef vipl_y_gradient_h_
00002 #define vipl_y_gradient_h_
00003 //:
00004 // \file
00005 // \brief Convolve image with vertical [-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 
00028 #include <vipl/filter/vipl_filter_2d.h> // parent class
00029 
00030 //: Convolve image with vertical [-1 1] filter
00031 template <class ImgIn,class ImgOut,class DataIn,class DataOut, VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) >
00032 class vipl_y_gradient : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>
00033 {
00034   // -+-+- data members: -+-+-
00035   // term to add to the gradient result:
00036  private: DataOut shift_;
00037  public: DataOut shift() const { return shift_; }
00038   // scale factor to multiply the shifted gradient with:
00039  private: double scale_;
00040  public: double scale() const { return scale_; }
00041 
00042   // -+-+- constructors/destructors: -+-+-
00043  public:
00044   inline vipl_y_gradient(double s=1.0, DataOut h=DataOut())
00045            : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(),
00046              shift_(h), scale_(s) {}
00047   inline vipl_y_gradient(vipl_y_gradient const& A)
00048            : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A),
00049              shift_(A.shift()), scale_(A.scale()) {}
00050   inline ~vipl_y_gradient() {}
00051 
00052   // -+-+- required method for filters: -+-+-
00053   bool section_applyop();
00054 };
00055 
00056 #ifdef INSTANTIATE_TEMPLATES
00057 #include "vipl_y_gradient.txx"
00058 #endif
00059 
00060 #endif // vipl_y_gradient_h_