|
Point Cloud Library (PCL)
1.4.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2010-2011, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id: gaussian.h 3535 2011-12-14 22:21:39Z rusu $ 00037 * 00038 */ 00039 00040 #ifndef PCL_GAUSSIAN_KERNEL 00041 #define PCL_GAUSSIAN_KERNEL 00042 00043 #include <sstream> 00044 #include <Eigen/Core> 00045 00046 #include <pcl/point_cloud.h> 00047 #include <boost/function.hpp> 00048 00049 namespace pcl 00050 { 00058 class PCL_EXPORTS GaussianKernel 00059 { 00060 public: 00061 00062 GaussianKernel () {} 00063 00064 static const unsigned MAX_KERNEL_WIDTH = 71; 00072 void 00073 compute (float sigma, 00074 Eigen::VectorXf &kernel, 00075 unsigned kernel_width = MAX_KERNEL_WIDTH) const; 00076 00085 void 00086 compute (float sigma, 00087 Eigen::VectorXf &kernel, 00088 Eigen::VectorXf &derivative, 00089 unsigned kernel_width = MAX_KERNEL_WIDTH) const; 00090 00098 void 00099 convolveRows (const pcl::PointCloud<float> &input, 00100 const Eigen::VectorXf &kernel, 00101 pcl::PointCloud<float> &output) const; 00102 00111 template <typename PointT> void 00112 convolveRows (const pcl::PointCloud<PointT> &input, 00113 boost::function <float (const PointT& p)> field_accessor, 00114 const Eigen::VectorXf &kernel, 00115 pcl::PointCloud<float> &output) const; 00116 00124 void 00125 convolveCols (const pcl::PointCloud<float> &input, 00126 const Eigen::VectorXf &kernel, 00127 pcl::PointCloud<float> &output) const; 00128 00137 template <typename PointT> void 00138 convolveCols (const pcl::PointCloud<PointT> &input, 00139 boost::function <float (const PointT& p)> field_accessor, 00140 const Eigen::VectorXf &kernel, 00141 pcl::PointCloud<float> &output) const; 00142 00151 inline void 00152 convolve (const pcl::PointCloud<float> &input, 00153 const Eigen::VectorXf &horiz_kernel, 00154 const Eigen::VectorXf &vert_kernel, 00155 pcl::PointCloud<float> &output) const 00156 { 00157 std::cout << ">>> convolve cpp" << std::endl; 00158 pcl::PointCloud<float> tmp (input.width, input.height) ; 00159 convolveRows (input, horiz_kernel, tmp); 00160 convolveCols (tmp, vert_kernel, output); 00161 std::cout << "<<< convolve cpp" << std::endl; 00162 } 00163 00173 template <typename PointT> inline void 00174 convolve (const pcl::PointCloud<PointT> &input, 00175 boost::function <float (const PointT& p)> field_accessor, 00176 const Eigen::VectorXf &horiz_kernel, 00177 const Eigen::VectorXf &vert_kernel, 00178 pcl::PointCloud<float> &output) const 00179 { 00180 std::cout << ">>> convolve hpp" << std::endl; 00181 pcl::PointCloud<float> tmp (input.width, input.height); 00182 convolveRows<PointT>(input, field_accessor, horiz_kernel, tmp); 00183 convolveCols(tmp, vert_kernel, output); 00184 std::cout << "<<< convolve hpp" << std::endl; 00185 } 00186 00197 inline void 00198 computeGradients (const pcl::PointCloud<float> &input, 00199 const Eigen::VectorXf &gaussian_kernel, 00200 const Eigen::VectorXf &gaussian_kernel_derivative, 00201 pcl::PointCloud<float> &grad_x, 00202 pcl::PointCloud<float> &grad_y) const 00203 { 00204 convolve (input, gaussian_kernel_derivative, gaussian_kernel, grad_x); 00205 convolve (input, gaussian_kernel, gaussian_kernel_derivative, grad_y); 00206 } 00207 00219 template <typename PointT> inline void 00220 computeGradients (const pcl::PointCloud<PointT> &input, 00221 boost::function <float (const PointT& p)> field_accessor, 00222 const Eigen::VectorXf &gaussian_kernel, 00223 const Eigen::VectorXf &gaussian_kernel_derivative, 00224 pcl::PointCloud<float> &grad_x, 00225 pcl::PointCloud<float> &grad_y) const 00226 { 00227 convolve<PointT> (input, field_accessor, gaussian_kernel_derivative, gaussian_kernel, grad_x); 00228 convolve<PointT> (input, field_accessor, gaussian_kernel, gaussian_kernel_derivative, grad_y); 00229 } 00230 00238 inline void 00239 smooth (const pcl::PointCloud<float> &input, 00240 const Eigen::VectorXf &gaussian_kernel, 00241 pcl::PointCloud<float> &output) const 00242 { 00243 convolve (input, gaussian_kernel, gaussian_kernel, output); 00244 } 00245 00254 template <typename PointT> inline void 00255 smooth (const pcl::PointCloud<PointT> &input, 00256 boost::function <float (const PointT& p)> field_accessor, 00257 const Eigen::VectorXf &gaussian_kernel, 00258 pcl::PointCloud<float> &output) const 00259 { 00260 convolve<PointT> (input, field_accessor, gaussian_kernel, gaussian_kernel, output); 00261 } 00262 }; 00263 } 00264 00265 #include "pcl/common/impl/gaussian.hpp" 00266 00267 #endif // PCL_GAUSSIAN_KERNEL
1.7.6.1