/usr/include/pcl-1.7/pcl/common/gaussian.h is in libpcl-dev 1.7.2-14build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | /*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2011, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
*/
#ifndef PCL_GAUSSIAN_KERNEL
#define PCL_GAUSSIAN_KERNEL
#include <sstream>
#include <pcl/common/eigen.h>
#include <pcl/point_cloud.h>
#include <boost/function.hpp>
namespace pcl
{
/** Class GaussianKernel assembles all the method for computing,
* convolving, smoothing, gradients computing an image using
* a gaussian kernel. The image is stored in point cloud elements
* intensity member or rgb or...
* \author Nizar Sallem
* \ingroup common
*/
class PCL_EXPORTS GaussianKernel
{
public:
GaussianKernel () {}
static const unsigned MAX_KERNEL_WIDTH = 71;
/** Computes the gaussian kernel and dervative assiociated to sigma.
* The kernel and derivative width are adjusted according.
* \param[in] sigma
* \param[out] kernel the computed gaussian kernel
* \param[in] kernel_width the desired kernel width upper bond
* \throws pcl::KernelWidthTooSmallException
*/
void
compute (float sigma,
Eigen::VectorXf &kernel,
unsigned kernel_width = MAX_KERNEL_WIDTH) const;
/** Computes the gaussian kernel and dervative assiociated to sigma.
* The kernel and derivative width are adjusted according.
* \param[in] sigma
* \param[out] kernel the computed gaussian kernel
* \param[out] derivative the computed kernel derivative
* \param[in] kernel_width the desired kernel width upper bond
* \throws pcl::KernelWidthTooSmallException
*/
void
compute (float sigma,
Eigen::VectorXf &kernel,
Eigen::VectorXf &derivative,
unsigned kernel_width = MAX_KERNEL_WIDTH) const;
/** Convolve a float image rows by a given kernel.
* \param[in] kernel convolution kernel
* \param[in] input the image to convolve
* \param[out] output the convolved image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
void
convolveRows (const pcl::PointCloud<float> &input,
const Eigen::VectorXf &kernel,
pcl::PointCloud<float> &output) const;
/** Convolve a float image rows by a given kernel.
* \param[in] input the image to convolve
* \param[in] field_accessor a field accessor
* \param[in] kernel convolution kernel
* \param[out] output the convolved image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
template <typename PointT> void
convolveRows (const pcl::PointCloud<PointT> &input,
boost::function <float (const PointT& p)> field_accessor,
const Eigen::VectorXf &kernel,
pcl::PointCloud<float> &output) const;
/** Convolve a float image columns by a given kernel.
* \param[in] input the image to convolve
* \param[in] kernel convolution kernel
* \param[out] output the convolved image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
void
convolveCols (const pcl::PointCloud<float> &input,
const Eigen::VectorXf &kernel,
pcl::PointCloud<float> &output) const;
/** Convolve a float image columns by a given kernel.
* \param[in] input the image to convolve
* \param[in] field_accessor a field accessor
* \param[in] kernel convolution kernel
* \param[out] output the convolved image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
template <typename PointT> void
convolveCols (const pcl::PointCloud<PointT> &input,
boost::function <float (const PointT& p)> field_accessor,
const Eigen::VectorXf &kernel,
pcl::PointCloud<float> &output) const;
/** Convolve a float image in the 2 directions
* \param[in] horiz_kernel kernel for convolving rows
* \param[in] vert_kernel kernel for convolving columns
* \param[in] input image to convolve
* \param[out] output the convolved image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
inline void
convolve (const pcl::PointCloud<float> &input,
const Eigen::VectorXf &horiz_kernel,
const Eigen::VectorXf &vert_kernel,
pcl::PointCloud<float> &output) const
{
std::cout << ">>> convolve cpp" << std::endl;
pcl::PointCloud<float> tmp (input.width, input.height) ;
convolveRows (input, horiz_kernel, tmp);
convolveCols (tmp, vert_kernel, output);
std::cout << "<<< convolve cpp" << std::endl;
}
/** Convolve a float image in the 2 directions
* \param[in] input image to convolve
* \param[in] field_accessor a field accessor
* \param[in] horiz_kernel kernel for convolving rows
* \param[in] vert_kernel kernel for convolving columns
* \param[out] output the convolved image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
template <typename PointT> inline void
convolve (const pcl::PointCloud<PointT> &input,
boost::function <float (const PointT& p)> field_accessor,
const Eigen::VectorXf &horiz_kernel,
const Eigen::VectorXf &vert_kernel,
pcl::PointCloud<float> &output) const
{
std::cout << ">>> convolve hpp" << std::endl;
pcl::PointCloud<float> tmp (input.width, input.height);
convolveRows<PointT>(input, field_accessor, horiz_kernel, tmp);
convolveCols(tmp, vert_kernel, output);
std::cout << "<<< convolve hpp" << std::endl;
}
/** Computes float image gradients using a gaussian kernel and gaussian kernel
* derivative.
* \param[in] input image to compute gardients for
* \param[in] gaussian_kernel the gaussian kernel to be used
* \param[in] gaussian_kernel_derivative the associated derivative
* \param[out] grad_x gradient along X direction
* \param[out] grad_y gradient along Y direction
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
inline void
computeGradients (const pcl::PointCloud<float> &input,
const Eigen::VectorXf &gaussian_kernel,
const Eigen::VectorXf &gaussian_kernel_derivative,
pcl::PointCloud<float> &grad_x,
pcl::PointCloud<float> &grad_y) const
{
convolve (input, gaussian_kernel_derivative, gaussian_kernel, grad_x);
convolve (input, gaussian_kernel, gaussian_kernel_derivative, grad_y);
}
/** Computes float image gradients using a gaussian kernel and gaussian kernel
* derivative.
* \param[in] input image to compute gardients for
* \param[in] field_accessor a field accessor
* \param[in] gaussian_kernel the gaussian kernel to be used
* \param[in] gaussian_kernel_derivative the associated derivative
* \param[out] grad_x gradient along X direction
* \param[out] grad_y gradient along Y direction
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
template <typename PointT> inline void
computeGradients (const pcl::PointCloud<PointT> &input,
boost::function <float (const PointT& p)> field_accessor,
const Eigen::VectorXf &gaussian_kernel,
const Eigen::VectorXf &gaussian_kernel_derivative,
pcl::PointCloud<float> &grad_x,
pcl::PointCloud<float> &grad_y) const
{
convolve<PointT> (input, field_accessor, gaussian_kernel_derivative, gaussian_kernel, grad_x);
convolve<PointT> (input, field_accessor, gaussian_kernel, gaussian_kernel_derivative, grad_y);
}
/** Smooth image using a gaussian kernel.
* \param[in] input image
* \param[in] gaussian_kernel the gaussian kernel to be used
* \param[out] output the smoothed image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
inline void
smooth (const pcl::PointCloud<float> &input,
const Eigen::VectorXf &gaussian_kernel,
pcl::PointCloud<float> &output) const
{
convolve (input, gaussian_kernel, gaussian_kernel, output);
}
/** Smooth image using a gaussian kernel.
* \param[in] input image
* \param[in] field_accessor a field accessor
* \param[in] gaussian_kernel the gaussian kernel to be used
* \param[out] output the smoothed image
* \note if output doesn't fit in input i.e. output.rows () < input.rows () or
* output.cols () < input.cols () then output is resized to input sizes.
*/
template <typename PointT> inline void
smooth (const pcl::PointCloud<PointT> &input,
boost::function <float (const PointT& p)> field_accessor,
const Eigen::VectorXf &gaussian_kernel,
pcl::PointCloud<float> &output) const
{
convolve<PointT> (input, field_accessor, gaussian_kernel, gaussian_kernel, output);
}
};
}
#include <pcl/common/impl/gaussian.hpp>
#endif // PCL_GAUSSIAN_KERNEL
|