Point Cloud Library (PCL)  1.15.1-dev
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  */
23  HSVColorCoherence() : PointCoherence<PointInT>() {}
24 
25  /** \brief set the weight of coherence
26  * \param[in] weight the weight of coherence.
27  */
28  inline void
29  setWeight(double weight)
30  {
31  weight_ = weight;
32  }
33 
34  /** \brief get the weight (w) of coherence */
35  inline double
37  {
38  return weight_;
39  }
40 
41  /** \brief set the hue weight (w_h) of coherence
42  * \param[in] weight the hue weight (w_h) of coherence.
43  */
44  inline void
45  setHWeight(double weight)
46  {
47  h_weight_ = weight;
48  }
49 
50  /** \brief get the hue weight (w_h) of coherence */
51  inline double
53  {
54  return h_weight_;
55  }
56 
57  /** \brief set the saturation weight (w_s) of coherence
58  * \param[in] weight the saturation weight (w_s) of coherence.
59  */
60  inline void
61  setSWeight(double weight)
62  {
63  s_weight_ = weight;
64  }
65 
66  /** \brief get the saturation weight (w_s) of coherence */
67  inline double
69  {
70  return s_weight_;
71  }
72 
73  /** \brief set the value weight (w_v) of coherence
74  * \param[in] weight the value weight (w_v) of coherence.
75  */
76  inline void
77  setVWeight(double weight)
78  {
79  v_weight_ = weight;
80  }
81 
82  /** \brief get the value weight (w_v) of coherence */
83  inline double
85  {
86  return v_weight_;
87  }
88 
89 protected:
90  /** \brief return the color coherence between the two points.
91  * \param[in] source instance of source point.
92  * \param[in] target instance of target point.
93  */
94  double
95  computeCoherence(PointInT& source, PointInT& target) override;
96 
97  /** \brief the weight of coherence (w) */
98  double weight_{1.0};
99 
100  /** \brief the hue weight (w_h) */
101  double h_weight_{1.0};
102 
103  /** \brief the saturation weight (w_s) */
104  double s_weight_{1.0};
105 
106  /** \brief the value weight (w_v) */
107  double v_weight_{0.0};
108 };
109 } // namespace tracking
110 } // namespace pcl
111 
112 #ifdef PCL_NO_PRECOMPILE
113 #include <pcl/tracking/impl/hsv_color_coherence.hpp>
114 #endif
HSVColorCoherence computes coherence between the two points from the color difference between them.
void setWeight(double weight)
set the weight of coherence
HSVColorCoherence()
initialize the weights of the computation.
void setHWeight(double weight)
set the hue weight (w_h) of coherence
void setSWeight(double weight)
set the saturation weight (w_s) of coherence
double getWeight()
get the weight (w) of coherence
double getSWeight()
get the saturation weight (w_s) of coherence
double computeCoherence(PointInT &source, PointInT &target) override
return the color coherence between the two points.
double h_weight_
the hue weight (w_h)
double weight_
the weight of coherence (w)
double s_weight_
the saturation weight (w_s)
double getVWeight()
get the value weight (w_v) of coherence
double v_weight_
the value weight (w_v)
void setVWeight(double weight)
set the value weight (w_v) of coherence
double getHWeight()
get the hue weight (w_h) of coherence
PointCoherence is a base class to compute coherence between the two points.
Definition: coherence.h:15
shared_ptr< const PointCoherence< PointInT > > ConstPtr
Definition: coherence.h:18
shared_ptr< PointCoherence< PointInT > > Ptr
Definition: coherence.h:17