Point Cloud Library (PCL)  1.11.1
hsv_color_coherence.h
1 #pragma once
2 
3 #include <pcl/tracking/coherence.h>
4 
5 namespace pcl {
6 namespace tracking {
7 /** \brief @b HSVColorCoherence computes coherence between the two points from the color
8  * difference between them. the color difference is calculated in HSV color space. the
9  * coherence is calculated by 1 / ( 1 + w * (w_h^2 * h_diff^2 + w_s^2 * s_diff^2 + w_v^2
10  * * v_diff^2))
11  * \author Ryohei Ueda
12  * \ingroup tracking
13  */
14 template <typename PointInT>
15 class HSVColorCoherence : public PointCoherence<PointInT> {
16 public:
17  using Ptr = shared_ptr<HSVColorCoherence<PointInT>>;
18  using ConstPtr = shared_ptr<const HSVColorCoherence<PointInT>>;
19 
20  /** \brief initialize the weights of the computation. weight_, h_weight_, s_weight_
21  * default to 1.0 and v_weight_ defaults to 0.0.
22  */
24  : PointCoherence<PointInT>()
25  , weight_(1.0)
26  , h_weight_(1.0)
27  , s_weight_(1.0)
28  , v_weight_(0.0)
29  {}
30 
31  /** \brief set the weight of coherence
32  * \param[in] weight the weight of coherence.
33  */
34  inline void
35  setWeight(double weight)
36  {
37  weight_ = weight;
38  }
39 
40  /** \brief get the weight (w) of coherence */
41  inline double
43  {
44  return weight_;
45  }
46 
47  /** \brief set the hue weight (w_h) of coherence
48  * \param[in] weight the hue weight (w_h) of coherence.
49  */
50  inline void
51  setHWeight(double weight)
52  {
53  h_weight_ = weight;
54  }
55 
56  /** \brief get the hue weight (w_h) of coherence */
57  inline double
59  {
60  return h_weight_;
61  }
62 
63  /** \brief set the saturation weight (w_s) of coherence
64  * \param[in] weight the saturation weight (w_s) of coherence.
65  */
66  inline void
67  setSWeight(double weight)
68  {
69  s_weight_ = weight;
70  }
71 
72  /** \brief get the saturation weight (w_s) of coherence */
73  inline double
75  {
76  return s_weight_;
77  }
78 
79  /** \brief set the value weight (w_v) of coherence
80  * \param[in] weight the value weight (w_v) of coherence.
81  */
82  inline void
83  setVWeight(double weight)
84  {
85  v_weight_ = weight;
86  }
87 
88  /** \brief get the value weight (w_v) of coherence */
89  inline double
91  {
92  return v_weight_;
93  }
94 
95 protected:
96  /** \brief return the color coherence between the two points.
97  * \param[in] source instance of source point.
98  * \param[in] target instance of target point.
99  */
100  double
101  computeCoherence(PointInT& source, PointInT& target) override;
102 
103  /** \brief the weight of coherence (w) */
104  double weight_;
105 
106  /** \brief the hue weight (w_h) */
107  double h_weight_;
108 
109  /** \brief the saturation weight (w_s) */
110  double s_weight_;
111 
112  /** \brief the value weight (w_v) */
113  double v_weight_;
114 };
115 } // namespace tracking
116 } // namespace pcl
117 
118 #ifdef PCL_NO_PRECOMPILE
119 #include <pcl/tracking/impl/hsv_color_coherence.hpp>
120 #endif
double computeCoherence(PointInT &source, PointInT &target) override
return the color coherence between the two points.
HSVColorCoherence computes coherence between the two points from the color difference between them...
double s_weight_
the saturation weight (w_s)
double v_weight_
the value weight (w_v)
shared_ptr< PointCoherence< PointInT > > Ptr
Definition: coherence.h:17
shared_ptr< const PointCoherence< PointInT > > ConstPtr
Definition: coherence.h:18
double weight_
the weight of coherence (w)
double getVWeight()
get the value weight (w_v) of coherence
PointCoherence is a base class to compute coherence between the two points.
Definition: coherence.h:15
void setVWeight(double weight)
set the value weight (w_v) of coherence
HSVColorCoherence()
initialize the weights of the computation.
void setWeight(double weight)
set the weight of coherence
double getHWeight()
get the hue weight (w_h) of coherence
double getWeight()
get the weight (w) of coherence
void setSWeight(double weight)
set the saturation weight (w_s) of coherence
double getSWeight()
get the saturation weight (w_s) of coherence
double h_weight_
the hue weight (w_h)
void setHWeight(double weight)
set the hue weight (w_h) of coherence