Point Cloud Library (PCL)  1.6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gaussian.h
Go to the documentation of this file.
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  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id: gaussian.h 5294 2012-03-25 18:10:50Z rusu $
37  *
38  */
39 
40 #ifndef PCL_GAUSSIAN_KERNEL
41 #define PCL_GAUSSIAN_KERNEL
42 
43 #include <sstream>
44 #include <pcl/common/eigen.h>
45 #include <pcl/point_cloud.h>
46 #include <boost/function.hpp>
47 
48 namespace pcl
49 {
58  {
59  public:
60 
62 
63  static const unsigned MAX_KERNEL_WIDTH = 71;
71  void
72  compute (float sigma,
73  Eigen::VectorXf &kernel,
74  unsigned kernel_width = MAX_KERNEL_WIDTH) const;
75 
84  void
85  compute (float sigma,
86  Eigen::VectorXf &kernel,
87  Eigen::VectorXf &derivative,
88  unsigned kernel_width = MAX_KERNEL_WIDTH) const;
89 
97  void
98  convolveRows (const pcl::PointCloud<float> &input,
99  const Eigen::VectorXf &kernel,
100  pcl::PointCloud<float> &output) const;
101 
110  template <typename PointT> void
111  convolveRows (const pcl::PointCloud<PointT> &input,
112  boost::function <float (const PointT& p)> field_accessor,
113  const Eigen::VectorXf &kernel,
114  pcl::PointCloud<float> &output) const;
115 
123  void
124  convolveCols (const pcl::PointCloud<float> &input,
125  const Eigen::VectorXf &kernel,
126  pcl::PointCloud<float> &output) const;
127 
136  template <typename PointT> void
137  convolveCols (const pcl::PointCloud<PointT> &input,
138  boost::function <float (const PointT& p)> field_accessor,
139  const Eigen::VectorXf &kernel,
140  pcl::PointCloud<float> &output) const;
141 
150  inline void
152  const Eigen::VectorXf &horiz_kernel,
153  const Eigen::VectorXf &vert_kernel,
154  pcl::PointCloud<float> &output) const
155  {
156  std::cout << ">>> convolve cpp" << std::endl;
157  pcl::PointCloud<float> tmp (input.width, input.height) ;
158  convolveRows (input, horiz_kernel, tmp);
159  convolveCols (tmp, vert_kernel, output);
160  std::cout << "<<< convolve cpp" << std::endl;
161  }
162 
172  template <typename PointT> inline void
174  boost::function <float (const PointT& p)> field_accessor,
175  const Eigen::VectorXf &horiz_kernel,
176  const Eigen::VectorXf &vert_kernel,
177  pcl::PointCloud<float> &output) const
178  {
179  std::cout << ">>> convolve hpp" << std::endl;
180  pcl::PointCloud<float> tmp (input.width, input.height);
181  convolveRows<PointT>(input, field_accessor, horiz_kernel, tmp);
182  convolveCols(tmp, vert_kernel, output);
183  std::cout << "<<< convolve hpp" << std::endl;
184  }
185 
196  inline void
198  const Eigen::VectorXf &gaussian_kernel,
199  const Eigen::VectorXf &gaussian_kernel_derivative,
200  pcl::PointCloud<float> &grad_x,
201  pcl::PointCloud<float> &grad_y) const
202  {
203  convolve (input, gaussian_kernel_derivative, gaussian_kernel, grad_x);
204  convolve (input, gaussian_kernel, gaussian_kernel_derivative, grad_y);
205  }
206 
218  template <typename PointT> inline void
220  boost::function <float (const PointT& p)> field_accessor,
221  const Eigen::VectorXf &gaussian_kernel,
222  const Eigen::VectorXf &gaussian_kernel_derivative,
223  pcl::PointCloud<float> &grad_x,
224  pcl::PointCloud<float> &grad_y) const
225  {
226  convolve<PointT> (input, field_accessor, gaussian_kernel_derivative, gaussian_kernel, grad_x);
227  convolve<PointT> (input, field_accessor, gaussian_kernel, gaussian_kernel_derivative, grad_y);
228  }
229 
237  inline void
239  const Eigen::VectorXf &gaussian_kernel,
240  pcl::PointCloud<float> &output) const
241  {
242  convolve (input, gaussian_kernel, gaussian_kernel, output);
243  }
244 
253  template <typename PointT> inline void
255  boost::function <float (const PointT& p)> field_accessor,
256  const Eigen::VectorXf &gaussian_kernel,
257  pcl::PointCloud<float> &output) const
258  {
259  convolve<PointT> (input, field_accessor, gaussian_kernel, gaussian_kernel, output);
260  }
261  };
262 }
263 
265 
266 #endif // PCL_GAUSSIAN_KERNEL