MTF
RSCV.h
1 #ifndef MTF_RSCV_H
2 #define MTF_RSCV_H
3 
4 #include "SSDBase.h"
5 
6 _MTF_BEGIN_NAMESPACE
7 
9  // use BSpline function of order 3 rather than the Dirac Delta function
11  bool use_bspl;
17  int n_bins;
23  double pre_seed;
24  // enable this to map each intensity to the weighted average of the two entries of the intensity map corresponding
25  // to the floor and ceil of that intensity; if disabled it will be mapped to the entry corresponding to its floor
26  // leading to some information loss due to the fractional part that was discarded
27  bool weighted_mapping;
28  // enable this to use intensity mapping while numerically computing the image gradient (using finite difference);
29  // if disabled, the original intensities will be used instead;
30  bool mapped_gradient;
31  // decides if true RSCV will be computed between the distance features or
32  // an approximate one based on mapping the distance feature itself with
33  // the original template; if it is turned off then the joint distribution will be
34  // computed from the two arguments to the distance functor itself after which the
35  // second argument will be mapped according to the expectation formula; note that
36  // using a KD tree index with this turned off will not produce the desired results because
37  // in that case this AM is no longer KD Tree compatible
38  bool approx_dist_feat;
41  bool debug_mode;
42 
44  RSCVParams(const AMParams *am_params,
45  bool _use_bspl, int _n_bins, double _pre_seed,
46  bool _partition_of_unity, bool _weighted_mapping,
47  bool _mapped_gradient, bool _approx_dist_feat,
48  bool _debug_mode);
50  RSCVParams(const RSCVParams *params = nullptr);
51 };
52 
54  typedef double ElementType;
55  typedef double ResultType;
56  RSCVDist(const string &_name, const unsigned int _patch_size,
57  const int _n_bins, const bool _approx_dist_feat);
58  double operator()(const double* a, const double* b,
59  size_t size, double worst_dist = -1) const override;
60 private:
61  const unsigned int patch_size;
62  const int n_bins;
63  const bool approx_dist_feat;
64 };
65 
67 class RSCV : public SSDBase{
68 public:
69 
70  typedef RSCVParams ParamType;
71  typedef RSCVDist DistType;
72 
73  RSCV(const ParamType *rscv_params = nullptr, const int _n_channels = 1);
74 
75  void initializePixVals(const Matrix2Xd& init_pts) override;
76  void updatePixVals(const Matrix2Xd& curr_pts) override;
77 
78  void updatePixGrad(const Matrix2Xd &curr_pts) override;
79  void updatePixHess(const Matrix2Xd &curr_pts) override;
80 
81  void updatePixGrad(const Matrix8Xd &warped_offset_pts) override;
82  void updatePixHess(const Matrix2Xd& curr_pts,
83  const Matrix16Xd &warped_offset_pts) override;
84 
85  const DistType* getDistFunc() override{
86  return new DistType(name, patch_size, params.n_bins, params.approx_dist_feat);
87  }
88  void updateDistFeat(double* feat_addr) override;
89  void updateDistFeat() override{}
90  const double* getDistFeat() override{
91  return params.approx_dist_feat ? It.data() : It_orig.data();
92  }
93 
94 protected:
95 
96  ParamType params;
97 
98  double hist_pre_seed;
99  VectorXd intensity_map;
100  // let A = n_bins*n_bins and N = n_pix = no. of pixels
101  PixValT It_orig;
103  MatrixXd curr_joint_hist;
104  VectorXd init_hist, curr_hist;
105  MatrixXd init_hist_mat, curr_hist_mat;
106 
107 private:
108 
110  MatrixX2i _std_bspl_ids, _init_bspl_ids, _curr_bspl_ids;
111 };
112 
113 _MTF_END_NAMESPACE
114 
115 #endif
Reversed Sum of Conditional Variance.
Definition: RSCV.h:67
double pre_seed
initial value with which each bin of the joint histogram is pre-seeded to avoid numerical instabiliti...
Definition: RSCV.h:23
Definition: SSDBase.h:45
MatrixXd curr_joint_hist
n_bins x n_bins joint histograms;
Definition: RSCV.h:103
Definition: AMParams.h:12
base class for appearance models that use the negative sum of squared differences ("SSD") or L2 norm ...
Definition: SSDBase.h:16
bool partition_of_unity
decides whether the partition of unity constraint has to be strictly observed for border bins; if ena...
Definition: RSCV.h:20
void updateDistFeat() override
computes a "distance" vector using the current image patch such that, when the distance vectors corre...
Definition: RSCV.h:89
RSCVParams(const AMParams *am_params, bool _use_bspl, int _n_bins, double _pre_seed, bool _partition_of_unity, bool _weighted_mapping, bool _mapped_gradient, bool _approx_dist_feat, bool _debug_mode)
value constructor
bool debug_mode
decides whether logging data will be printed for debugging purposes; only matters if logging option i...
Definition: RSCV.h:41
bool use_bspl
as the kernel function for Parzen density estimation
Definition: RSCV.h:11
Definition: RSCV.h:53
int n_bins
no.
Definition: RSCV.h:17
Definition: RSCV.h:8