MTF
SSD.h
1 #ifndef MTF_SSD_H
2 #define MTF_SSD_H
3 
4 #include "SSDBase.h"
5 
6 _MTF_BEGIN_NAMESPACE
7 
8 struct SSDParams : AMParams{
9  bool show_template;
11  SSDParams(const AMParams *am_params,
12  bool _show_template);
14  SSDParams(const SSDParams *params = nullptr);
15 };
16 
18  typedef double ElementType;
19  typedef double ResultType;
20  SSDDist(const string &_name, const bool _dist_from_likelihood,
21  const double _likelihood_alpha, const unsigned int _patch_size);
22  double operator()(const double* a, const double* b,
23  size_t size, double worst_dist = -1) const override{
24  double dist = SSDBaseDist::operator()(a, b, size, worst_dist);
25  return dist_from_likelihood ?
26  -exp(-likelihood_alpha * sqrt(dist / (static_cast<double>(patch_size)))) : dist;
27  }
28 private:
29  const bool dist_from_likelihood;
30  const double likelihood_alpha;
31  const unsigned int patch_size;
32 };
33 
34 class SSD : public SSDBase{
35 public:
36 
37  typedef SSDParams ParamType;
38  typedef SSDDist DistType;
39 
40  SSD(const ParamType *ssd_params = nullptr, const int _n_channels = 1);
41  double getLikelihood() const override{
42  return exp(-params.likelihood_alpha * sqrt(-f / (static_cast<double>(patch_size))));
43  }
44  void updateModel(const Matrix2Xd& curr_pts) override;
45 
46  /*Support for FLANN library*/
47  const DistType* getDistFunc() override{
48  return new DistType(name, params.dist_from_likelihood,
49  params.likelihood_alpha, patch_size);
50  }
51 
52 protected:
53  ParamType params;
54 
55  bool use_running_avg;
56  double old_pix_wt;
57 
58 };
59 
60 _MTF_END_NAMESPACE
61 
62 #endif
double operator()(const double *a, const double *b, size_t size, double worst_dist=-1) const override
Squared Euclidean distance functor, optimized version.
bool dist_from_likelihood
use negative of likelihood as the distance measure
Definition: AMParams.h:17
Definition: SSDBase.h:45
double likelihood_alpha
multiplicative and additive factors for the exponent in the likelihood
Definition: AMParams.h:15
SSDParams(const AMParams *am_params, bool _show_template)
value constructor
double getLikelihood() const override
returns a normalized version of the similarity that lies between 0 and 1 and can be interpreted as th...
Definition: SSD.h:41
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
Definition: SSD.h:8
Definition: SSD.h:17
Definition: SSD.h:34
double operator()(const double *a, const double *b, size_t size, double worst_dist=-1) const override
computes the distance / dissimilarity between two patches where each is codified or represented by a ...
Definition: SSD.h:22