contrib/mul/msm/msm_shape_perturber.h
Go to the documentation of this file.
00001 #ifndef msm_shape_perturber_h__
00002 #define msm_shape_perturber_h__
00003 //:
00004 // \file
00005 // \brief Class for perturbing shapes from ground truth
00006 // \author Patrick Sauer
00007 
00008 #include <vnl/vnl_random.h>
00009 #include <vnl/vnl_vector.h>
00010 
00011 #include <msm/msm_shape_model.h>
00012 #include <msm/msm_shape_instance.h>
00013 #include <msm/msm_aligner.h>
00014 
00015 #include <vcl_cstddef.h> // for std::size_t
00016 
00017 class msm_shape_perturber
00018 {
00019   private:
00020 
00021     double rel_gauss_;
00022 
00023     msm_shape_model    sm_;
00024     msm_shape_instance sm_inst_;
00025 
00026     msm_shape_instance gt_inst_;
00027 
00028     vnl_random rand_;
00029 
00030     vnl_vector<double> max_dpose_;
00031     vnl_vector<double> max_dparams_;
00032 
00033     vnl_vector<double> dpose_,    inv_dpose_;
00034     vnl_vector<double> dparams_,  inv_dparams_;
00035     vnl_vector<double> all_, dall_, inv_dall_;
00036 
00037     vcl_size_t n_pose_;
00038     vcl_size_t n_params_;
00039 
00040     double trunc_normal_sample( vnl_random& rand1, double sd, double max_d );
00041     double random_value( vnl_random& rand, double max_v, double rel_gauss_sd );
00042 
00043   public:
00044 
00045     msm_shape_perturber();
00046 
00047     void perturb( const msm_points& );
00048 
00049     void set_model( const msm_shape_model& );
00050     void set_max_dp( const vnl_vector<double>&, const vnl_vector<double>& = vnl_vector<double>() );
00051     void set_rel_gauss( double );
00052     void set_seed( vcl_size_t );
00053 
00054     vcl_size_t seed() const;
00055     double rel_gauss() const;
00056 
00057     const vnl_vector<double>& max_d_pose() const;
00058     const vnl_vector<double>& max_d_params() const;
00059 
00060     const vnl_vector<double>& gt_params() const;
00061     const vnl_vector<double>& gt_pose() const;
00062 
00063     //: return model parameters of perturbed points
00064     const vnl_vector<double>& params() const;
00065 
00066     //: return pose of perturbed points
00067     const vnl_vector<double>& pose() const;
00068 
00069     //: return concatenated [pose params] vector of perturbed points
00070     const vnl_vector<double>& all() const;
00071 
00072     //: return params displacement needed to go from perturbed points back to ground truth
00073     const vnl_vector<double>& inv_d_params() const;
00074 
00075     //: return pose displacement needed to go grom perturbed points back to ground truth
00076     const vnl_vector<double>& inv_d_pose() const;
00077 
00078     //: return pose+params displacement needed to go grom perturbed points back to ground truth
00079     const vnl_vector<double>& inv_d_all() const;
00080 
00081     //: return perturbed points
00082     const msm_points& points() const;
00083 };
00084 
00085 #endif // msm_shape_perturber_h__