Point Cloud Library (PCL)  1.14.0-dev
intensity_gradient.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #pragma once
42 
43 #include <pcl/features/feature.h>
44 #include <pcl/common/intensity.h>
45 
46 namespace pcl
47 {
48  /** \brief IntensityGradientEstimation estimates the intensity gradient for a point cloud that contains position
49  * and intensity values. The intensity gradient at a given point will be a vector orthogonal to the surface
50  * normal and pointing in the direction of the greatest increase in local intensity; the vector's magnitude
51  * indicates the rate of intensity change.
52  * \author Michael Dixon
53  * \ingroup features
54  */
55  template <typename PointInT, typename PointNT, typename PointOutT, typename IntensitySelectorT = pcl::common::IntensityFieldAccessor<PointInT> >
56  class IntensityGradientEstimation : public FeatureFromNormals<PointInT, PointNT, PointOutT>
57  {
58  public:
59  using Ptr = shared_ptr<IntensityGradientEstimation<PointInT, PointNT, PointOutT, IntensitySelectorT> >;
60  using ConstPtr = shared_ptr<const IntensityGradientEstimation<PointInT, PointNT, PointOutT, IntensitySelectorT> >;
68 
70 
71  /** \brief Empty constructor. */
73  {
74  feature_name_ = "IntensityGradientEstimation";
75  }
76 
77  /** \brief Initialize the scheduler and set the number of threads to use.
78  * \param nr_threads the number of hardware threads to use (0 sets the value back to automatic)
79  */
80  inline void
81  setNumberOfThreads (unsigned int nr_threads = 0) { threads_ = nr_threads; }
82 
83  protected:
84  /** \brief Estimate the intensity gradients for a set of points given in <setInputCloud (), setIndices ()> using
85  * the surface in setSearchSurface () and the spatial locator in setSearchMethod ().
86  * \param output the resultant point cloud that contains the intensity gradient vectors
87  */
88  void
89  computeFeature (PointCloudOut &output) override;
90 
91  /** \brief Estimate the intensity gradient around a given point based on its spatial neighborhood of points
92  * \param cloud a point cloud dataset containing XYZI coordinates (Cartesian coordinates + intensity)
93  * \param indices the indices of the neighboring points in the dataset
94  * \param point the 3D Cartesian coordinates of the point at which to estimate the gradient
95  * \param mean_intensity
96  * \param normal the 3D surface normal of the given point
97  * \param gradient the resultant 3D gradient vector
98  */
99  void
101  const pcl::Indices &indices,
102  const Eigen::Vector3f &point,
103  float mean_intensity,
104  const Eigen::Vector3f &normal,
105  Eigen::Vector3f &gradient);
106 
107  protected:
108  ///intensity field accessor structure
109  IntensitySelectorT intensity_;
110  ///number of threads to be used, default 0 (auto)
111  unsigned int threads_{0};
112  };
113 }
114 
115 #ifdef PCL_NO_PRECOMPILE
116 #include <pcl/features/impl/intensity_gradient.hpp>
117 #endif
Feature represents the base feature class.
Definition: feature.h:107
shared_ptr< Feature< PointInT, PointOutT > > Ptr
Definition: feature.h:114
std::string feature_name_
The feature name.
Definition: feature.h:220
shared_ptr< const Feature< PointInT, PointOutT > > ConstPtr
Definition: feature.h:115
IntensityGradientEstimation estimates the intensity gradient for a point cloud that contains position...
void setNumberOfThreads(unsigned int nr_threads=0)
Initialize the scheduler and set the number of threads to use.
void computePointIntensityGradient(const pcl::PointCloud< PointInT > &cloud, const pcl::Indices &indices, const Eigen::Vector3f &point, float mean_intensity, const Eigen::Vector3f &normal, Eigen::Vector3f &gradient)
Estimate the intensity gradient around a given point based on its spatial neighborhood of points.
IntensitySelectorT intensity_
intensity field accessor structure
void computeFeature(PointCloudOut &output) override
Estimate the intensity gradients for a set of points given in <setInputCloud (), setIndices ()> using...
unsigned int threads_
number of threads to be used, default 0 (auto)
IntensityGradientEstimation()
Empty constructor.
typename Feature< PointInT, PointOutT >::PointCloudOut PointCloudOut
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133