00001 // This is brl/bseg/sdet/sdet_denoise_mrf_bp.h 00002 #ifndef sdet_denoise_mrf_bp_h_ 00003 #define sdet_denoise_mrf_bp_h_ 00004 //--------------------------------------------------------------------- 00005 //: 00006 // \file 00007 // \brief a processor applying a mrf denoise algorithm 00008 // 00009 // \author 00010 // J.L. Mundy - March 30, 2011 00011 // 00012 // This algorithm selectively smooths the image based on 00013 // a variance value at each pixel. The smoothing is carried out 00014 // by a MRF with binary cliques all of equal weight (kappa_) 00015 // The data cost is related to the variance by 00016 // 00017 // D(fp) = lambda_*(fp-x)^2 00018 // ------- 00019 // var 00020 // The clique cost is V(fp, fq) = kappa_(fp-fq)^2 00021 // 00022 // The algorithm uses belief propagation based on the paper by 00023 // 00024 // Pedro F. Felzenszwalb, Daniel P. Huttenlocher, 00025 // Efficient Belief Propagation for Early Vision 00026 // International Journal of Computer Vision 70(1): 41-54 (2006) 00027 // 00028 // The MRF message storage could be reduced by 1/2 00029 // if a checkerboard update scheme is used, but it was decided to 00030 // update all sites on each iteration. 00031 // 00032 // If a variance image is not set, then the data cost is 00033 // 00034 // D(fp) = lambda_*(fp-x)^2 00035 // 00036 // \verbatim 00037 // Modifications 00038 // <none yet> 00039 // \endverbatim 00040 // 00041 //------------------------------------------------------------------------- 00042 00043 #include <vcl_vector.h> 00044 #include <sdet/sdet_denoise_mrf_bp_params.h> 00045 #include <sdet/sdet_mrf_bp.h> 00046 #include <vil/vil_image_resource.h> 00047 #include <vil/vil_pyramid_image_view.h> 00048 00049 class sdet_denoise_mrf_bp : public sdet_denoise_mrf_bp_params 00050 { 00051 public: 00052 //:Constructors/destructor 00053 sdet_denoise_mrf_bp(sdet_denoise_mrf_bp_params& imp); 00054 ~sdet_denoise_mrf_bp(); 00055 //: Process methods 00056 00057 void set_image(vil_image_resource_sptr const& resource); 00058 void set_variance(vil_image_resource_sptr const& var_resc); 00059 00060 //: the full denoising process 00061 bool denoise(); 00062 00063 //: Accessors 00064 vil_image_resource_sptr output() { return out_resc_; } 00065 bool output_valid() const { return output_valid_; } 00066 00067 //: Internals (for debug purposes) 00068 sdet_mrf_bp_sptr mrf() { return mrf_; } 00069 00070 protected: 00071 // === protected methods === 00072 00073 //: upsample the messages from a mrf by a factor of two. 00074 // \p level is the pyramid level of the input mrf. 00075 // the returned mrf is at the next higher resolution level of the pyramid. 00076 // the prior messages of the returned mrf are initialized be the message 00077 // values of in_mrf. 00078 sdet_mrf_bp_sptr pyramid_upsample(sdet_mrf_bp_sptr const& in_mrf, 00079 unsigned level); 00080 00081 // === members === 00082 00083 bool output_valid_; //!< process state flag 00084 bool use_var_; 00085 vil_pyramid_image_view<float> pyr_in_; 00086 vil_pyramid_image_view<float> pyr_var_; 00087 vil_image_resource_sptr out_resc_; 00088 sdet_mrf_bp_sptr mrf_; 00089 }; 00090 00091 #endif // sdet_denoise_mrf_bp_h_