Go to the documentation of this file.00001 #ifndef vipl_add_random_noise_h_
00002 #define vipl_add_random_noise_h_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <vipl/filter/vipl_filter_2d.h>
00035 #include <vnl/vnl_sample.h>
00036
00037 enum vipl_random_noise_type { UNIFORM_NOISE, GAUSSIAN_NOISE, EXPONENTIAL_NOISE };
00038
00039
00040 template <class ImgIn,class ImgOut,class DataIn,class DataOut, VCL_DFL_TYPE_PARAM_STLDECL(PixelItr, vipl_trivial_pixeliter) >
00041 class vipl_add_random_noise : public vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>
00042 {
00043
00044 private: vipl_random_noise_type type_;
00045 public: vipl_random_noise_type type() const { return type_; }
00046 private: double maxdev_;
00047 public: double maxdev() const { return maxdev_; }
00048 private: bool clipping_;
00049 public: bool clipping() const { return clipping_; }
00050
00051
00052 public:
00053 inline vipl_add_random_noise(vipl_random_noise_type t = GAUSSIAN_NOISE, double m=5, int s=12345, bool clip=false)
00054 : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(), type_(t), maxdev_(m), clipping_(clip)
00055 { if (s==12345) vnl_sample_reseed(); else vnl_sample_reseed(s); }
00056
00057 inline vipl_add_random_noise(vipl_add_random_noise const& A)
00058 : vipl_filter_2d<ImgIn,ImgOut,DataIn,DataOut,PixelItr>(A), type_(A.type()), maxdev_(A.maxdev()), clipping_(A.clipping()) {}
00059
00060
00061 bool section_applyop();
00062 };
00063
00064 #ifdef INSTANTIATE_TEMPLATES
00065 #include "vipl_add_random_noise.txx"
00066 #endif
00067
00068 #endif // vipl_add_random_noise_h_