Point Cloud Library (PCL)  1.9.1
kernel.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, 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 the copyright holder(s) 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  */
37 
38 #ifndef PCL_2D_KERNEL_H_
39 #define PCL_2D_KERNEL_H_
40 #include <pcl/pcl_base.h>
41 #include <pcl/point_types.h>
42 namespace pcl
43 {
44  template<typename PointT>
45  class kernel
46  {
47  public:
48 
49  /**
50  * enumerates the different types of kernels available.
51  */
53  {
54  SOBEL_X, //!< SOBEL_X
55  SOBEL_Y, //!< SOBEL_Y
56  PREWITT_X, //!< PREWITT_X
57  PREWITT_Y, //!< PREWITT_Y
58  ROBERTS_X, //!< ROBERTS_X
59  ROBERTS_Y, //!< ROBERTS_Y
60  LOG, //!< LOG
61  DERIVATIVE_CENTRAL_X, //!< DERIVATIVE_CENTRAL_X
62  DERIVATIVE_FORWARD_X, //!< DERIVATIVE_FORWARD_X
63  DERIVATIVE_BACKWARD_X,//!< DERIVATIVE_BACKWARD_X
64  DERIVATIVE_CENTRAL_Y, //!< DERIVATIVE_CENTRAL_Y
65  DERIVATIVE_FORWARD_Y, //!< DERIVATIVE_FORWARD_Y
66  DERIVATIVE_BACKWARD_Y,//!< DERIVATIVE_BACKWARD_Y
67  GAUSSIAN //!< GAUSSIAN
68  };
69 
71  float sigma_;
73 
74  kernel () :
75  kernel_size_ (3),
76  sigma_ (1.0),
77  kernel_type_ (GAUSSIAN)
78  {
79 
80  }
81 
82  /**
83  *
84  * @param kernel Kernel point cloud passed by reference
85  *
86  * Helper function which returns the kernel selected by the kernel_type_ enum
87  */
89 
90  /**
91  *
92  * @param kernel Kernel point cloud passed by reference
93  *
94  * Gaussian kernel with size (kernel_size_ x kernel_size_) and variance sigma_
95  */
96 
98 
99  /**
100  *
101  * @param kernel Kernel point cloud passed by reference
102  *
103  * Laplacian of Gaussian kernel with size (kernel_size_ x kernel_size_) and variance sigma_
104  */
105 
106  void loGKernel (pcl::PointCloud<PointT> &kernel);
107 
108  /**
109  *
110  * @param kernel Kernel point cloud passed by reference
111  *
112  * 3x3 Sobel kernel in the X direction
113  */
114 
115  void sobelKernelX (pcl::PointCloud<PointT> &kernel);
116 
117  /**
118  *
119  * @param kernel Kernel point cloud passed by reference
120  *
121  * 3x3 Prewitt kernel in the X direction
122  */
123 
125 
126  /**
127  *
128  * @param kernel Kernel point cloud passed by reference
129  *
130  * 2x2 Roberts kernel in the X direction
131  */
132 
134 
135  /**
136  *
137  * @param kernel Kernel point cloud passed by reference
138  *
139  * 3x3 Sobel kernel in the Y direction
140  */
141 
142  void sobelKernelY (pcl::PointCloud<PointT> &kernel);
143 
144  /**
145  *
146  * @param kernel Kernel point cloud passed by reference
147  *
148  * 3x3 Prewitt kernel in the Y direction
149  */
150 
152 
153  /**
154  *
155  * @param kernel Kernel point cloud passed by reference
156  *
157  * 2x2 Roberts kernel in the Y direction
158  */
159 
161 
162  /**
163  *
164  * @param kernel Kernel point cloud passed by reference
165  *
166  * kernel [-1 0 1]
167  */
168 
170 
171  /**
172  *
173  * @param kernel Kernel point cloud passed by reference
174  *
175  * kernel [-1 0 1]'
176  */
177 
179 
180  /**
181  *
182  * @param kernel Kernel point cloud passed by reference
183  *
184  * kernel [0 -1 1]
185  */
186 
188 
189  /**
190  *
191  * @param kernel Kernel point cloud passed by reference
192  *
193  * kernel [0 -1 1]'
194  */
195 
197 
198  /**
199  *
200  * @param kernel Kernel point cloud passed by reference
201  *
202  * kernel [-1 1 0]
203  */
204 
206 
207  /**
208  *
209  * @param kernel Kernel point cloud passed by reference
210  *
211  * kernel [-1 1 0]'
212  */
213 
215 
216  /**
217  *
218  * @param kernel_type enum indicating the kernel type wanted
219  *
220  * select the kernel type.
221  */
222  void setKernelType (KERNEL_ENUM kernel_type);
223 
224  /**
225  *
226  * @param kernel_size kernel of size kernel_size x kernel_size is created(LoG and Gaussian only)
227  *
228  * Setter function for kernel_size_
229  */
230  void setKernelSize (int kernel_size);
231 
232  /**
233  *
234  * @param kernel_sigma variance of the Gaussian or LoG kernels.
235  *
236  * Setter function for kernel_sigma_
237  */
238  void setKernelSigma (float kernel_sigma);
239  };
240 }
241 
242 #include <pcl/2d/impl/kernel.hpp>
243 
244 #endif // PCL_2D_KERNEL_H_
void setKernelType(KERNEL_ENUM kernel_type)
Definition: kernel.hpp:308
void prewittKernelY(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:225
KERNEL_ENUM kernel_type_
Definition: kernel.h:72
DERIVATIVE_CENTRAL_X.
Definition: kernel.h:61
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
PREWITT_X.
Definition: kernel.h:56
float sigma_
Definition: kernel.h:71
DERIVATIVE_FORWARD_Y.
Definition: kernel.h:65
void prewittKernelX(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:190
void robertsKernelX(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:202
void derivativeYForwardKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:287
void sobelKernelX(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:178
void derivativeYBackwardKernel(PointCloud< PointT > &kernel)
Definition: kernel.hpp:297
SOBEL_Y.
Definition: kernel.h:55
DERIVATIVE_CENTRAL_Y.
Definition: kernel.h:64
DERIVATIVE_BACKWARD_Y.
Definition: kernel.h:66
void sobelKernelY(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:213
Defines all the PCL implemented PointT point type structures.
int kernel_size_
Definition: kernel.h:70
void loGKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:149
DERIVATIVE_BACKWARD_X.
Definition: kernel.h:63
void setKernelSigma(float kernel_sigma)
Definition: kernel.hpp:322
KERNEL_ENUM
enumerates the different types of kernels available.
Definition: kernel.h:52
PointCloud represents the base class in PCL for storing collections of 3D points. ...
ROBERTS_X.
Definition: kernel.h:58
kernel()
Definition: kernel.h:74
ROBERTS_Y.
Definition: kernel.h:59
void fetchKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:43
void gaussianKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:122
void derivativeXForwardKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:257
void derivativeYCentralKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:277
DERIVATIVE_FORWARD_X.
Definition: kernel.h:62
void derivativeXCentralKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:247
SOBEL_X.
Definition: kernel.h:54
void derivativeXBackwardKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:267
void robertsKernelY(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:236
PREWITT_Y.
Definition: kernel.h:57
void setKernelSize(int kernel_size)
Definition: kernel.hpp:315
GAUSSIAN.
Definition: kernel.h:67