00001 #ifndef vipl_median_h_ 00002 #define vipl_median_h_ 00003 //: 00004 // \file 00005 // \brief median filter with circular element 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 // vipl_median filtering is an operation that replaces a pixel with the 00012 // median value of its surrounding pixels, in a certain neighbourhood. 00013 // Here, the neighbourhood is circular, with an arbitrary (float) radius, 00014 // which is to be passed to the constructor. 00015 // 00016 // Note that the function operator>(DataIn,DataIn) is being used; for 00017 // non-scalar data types (like colour pixels) an appropriate ">" function 00018 // must thus be supplied. 00019 // 00020 // Note also the implicit use of DataOut::DataOut(DataIn), 00021 // which you probably will have to provide when DataIn and DataOut 00022 // are not the same type. It could even be argued that these types should 00023 // always be the same! 00024 // 00025 // \author Peter Vanroose, K.U.Leuven (ESAT/PSI) 00026 // \date 18 December 1998. 00027 // 00028 // \verbatim 00029 // Modifications: 00030 // Peter Vanroose, Aug.2000 - adapted to vxl 00031 // \endverbatim 00032 // 00033 // \example examples/example_median.cxx 00034 00035 #include <vipl/filter/vipl_filter_2d.h> // parent class 00036 00037 //: median filter with circular element 00038 template <class ImgIn,class ImgOut,class DataIn,class DataOut, VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) > 00039 class vipl_median : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr> 00040 { 00041 // -+-+- data members: -+-+- 00042 private: 00043 float radius_; 00044 float& ref_radius() { return radius_; } 00045 void put_radius(float v) { radius_=v; } 00046 public: 00047 float radius() const { return radius_; } 00048 00049 private: 00050 // attribute to store the "temporary mask" 00051 bool** mask_; 00052 bool**& ref_mask() { return mask_; } 00053 void put_mask(bool** v) { mask_=v; } 00054 bool** mask() const { return mask_; } 00055 00056 // -+-+- constructors/destructors: -+-+- 00057 public: 00058 inline vipl_median(float r=1) 00059 : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(), radius_(r), mask_(0){} 00060 inline vipl_median(vipl_median const& A) 00061 : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A), radius_(A.radius()), mask_(0) {} 00062 inline ~vipl_median() {} 00063 00064 // -+-+- required method for filters: -+-+- 00065 bool section_applyop(); 00066 // -+-+- optional method for filters, compute mask only once in preop, free in postop: -+-+- 00067 bool preop(); 00068 bool postop(); 00069 }; 00070 00071 #ifdef INSTANTIATE_TEMPLATES 00072 #include "vipl_median.txx" 00073 #endif 00074 00075 #endif // vipl_median_h_
1.5.1