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