Point Cloud Library (PCL)  1.14.0-dev
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 #pragma once
39 
40 #include <pcl/pcl_base.h>
41 #include <pcl/point_types.h>
42 
43 namespace pcl {
44 
45 template <typename PointT>
46 class kernel {
47 public:
48  /// Different types of kernels available.
49  enum KERNEL_ENUM {
50  SOBEL_X, //!< SOBEL_X
51  SOBEL_Y, //!< SOBEL_Y
52  PREWITT_X, //!< PREWITT_X
53  PREWITT_Y, //!< PREWITT_Y
54  ROBERTS_X, //!< ROBERTS_X
55  ROBERTS_Y, //!< ROBERTS_Y
56  LOG, //!< LOG
57  DERIVATIVE_CENTRAL_X, //!< DERIVATIVE_CENTRAL_X
58  DERIVATIVE_FORWARD_X, //!< DERIVATIVE_FORWARD_X
59  DERIVATIVE_BACKWARD_X, //!< DERIVATIVE_BACKWARD_X
60  DERIVATIVE_CENTRAL_Y, //!< DERIVATIVE_CENTRAL_Y
61  DERIVATIVE_FORWARD_Y, //!< DERIVATIVE_FORWARD_Y
62  DERIVATIVE_BACKWARD_Y, //!< DERIVATIVE_BACKWARD_Y
63  GAUSSIAN //!< GAUSSIAN
64  };
65 
66  int kernel_size_{3};
67  float sigma_{1.0};
69 
71 
72  /**
73  *
74  * @param kernel Kernel point cloud passed by reference
75  *
76  * Helper function which returns the kernel selected by the kernel_type_ enum
77  */
78  void
80 
81  /**
82  *
83  * @param kernel Kernel point cloud passed by reference
84  *
85  * Gaussian kernel with size (kernel_size_ x kernel_size_) and variance sigma_
86  */
87  void
89 
90  /**
91  *
92  * @param kernel Kernel point cloud passed by reference
93  *
94  * Laplacian of Gaussian kernel with size (kernel_size_ x kernel_size_) and variance
95  * sigma_
96  */
97  void
99 
100  /**
101  *
102  * @param kernel Kernel point cloud passed by reference
103  *
104  * 3x3 Sobel kernel in the X direction
105  */
106  void
108 
109  /**
110  *
111  * @param kernel Kernel point cloud passed by reference
112  *
113  * 3x3 Prewitt kernel in the X direction
114  */
115  void
117 
118  /**
119  *
120  * @param kernel Kernel point cloud passed by reference
121  *
122  * 2x2 Roberts kernel in the X direction
123  */
124  void
126 
127  /**
128  *
129  * @param kernel Kernel point cloud passed by reference
130  *
131  * 3x3 Sobel kernel in the Y direction
132  */
133  void
135 
136  /**
137  *
138  * @param kernel Kernel point cloud passed by reference
139  *
140  * 3x3 Prewitt kernel in the Y direction
141  */
142  void
144 
145  /**
146  *
147  * @param kernel Kernel point cloud passed by reference
148  *
149  * 2x2 Roberts kernel in the Y direction
150  */
151  void
153 
154  /**
155  *
156  * @param kernel Kernel point cloud passed by reference
157  *
158  * kernel [-1 0 1]
159  */
160  void
162 
163  /**
164  *
165  * @param kernel Kernel point cloud passed by reference
166  *
167  * kernel [-1 0 1]'
168  */
169  void
171 
172  /**
173  *
174  * @param kernel Kernel point cloud passed by reference
175  *
176  * kernel [0 -1 1]
177  */
178  void
180 
181  /**
182  *
183  * @param kernel Kernel point cloud passed by reference
184  *
185  * kernel [0 -1 1]'
186  */
187  void
189 
190  /**
191  *
192  * @param kernel Kernel point cloud passed by reference
193  *
194  * kernel [-1 1 0]
195  */
196  void
198 
199  /**
200  *
201  * @param kernel Kernel point cloud passed by reference
202  *
203  * kernel [-1 1 0]'
204  */
205  void
207 
208  /**
209  *
210  * @param kernel_type enum indicating the kernel type wanted
211  *
212  * select the kernel type.
213  */
214  void
215  setKernelType(KERNEL_ENUM kernel_type);
216 
217  /**
218  *
219  * @param kernel_size kernel of size kernel_size x kernel_size is created(LoG and
220  * Gaussian only)
221  *
222  * Setter function for kernel_size_
223  */
224  void
225  setKernelSize(int kernel_size);
226 
227  /**
228  *
229  * @param kernel_sigma variance of the Gaussian or LoG kernels.
230  *
231  * Setter function for kernel_sigma_
232  */
233  void
234  setKernelSigma(float kernel_sigma);
235 };
236 
237 } // namespace pcl
238 
239 #include <pcl/2d/impl/kernel.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
void prewittKernelY(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:216
void derivativeXBackwardKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:271
void derivativeYBackwardKernel(PointCloud< PointT > &kernel)
Definition: kernel.hpp:307
void prewittKernelX(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:167
void loGKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:122
void setKernelSize(int kernel_size)
Definition: kernel.hpp:326
void sobelKernelX(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:149
void setKernelSigma(float kernel_sigma)
Definition: kernel.hpp:333
void derivativeXCentralKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:247
void robertsKernelY(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:234
KERNEL_ENUM
Different types of kernels available.
Definition: kernel.h:49
@ ROBERTS_Y
ROBERTS_Y.
Definition: kernel.h:55
@ DERIVATIVE_BACKWARD_Y
DERIVATIVE_BACKWARD_Y.
Definition: kernel.h:62
@ SOBEL_X
SOBEL_X.
Definition: kernel.h:50
@ SOBEL_Y
SOBEL_Y.
Definition: kernel.h:51
@ ROBERTS_X
ROBERTS_X.
Definition: kernel.h:54
@ GAUSSIAN
GAUSSIAN.
Definition: kernel.h:63
@ DERIVATIVE_FORWARD_X
DERIVATIVE_FORWARD_X.
Definition: kernel.h:58
@ DERIVATIVE_BACKWARD_X
DERIVATIVE_BACKWARD_X.
Definition: kernel.h:59
@ PREWITT_Y
PREWITT_Y.
Definition: kernel.h:53
@ DERIVATIVE_FORWARD_Y
DERIVATIVE_FORWARD_Y.
Definition: kernel.h:61
@ LOG
LOG.
Definition: kernel.h:56
@ DERIVATIVE_CENTRAL_Y
DERIVATIVE_CENTRAL_Y.
Definition: kernel.h:60
@ DERIVATIVE_CENTRAL_X
DERIVATIVE_CENTRAL_X.
Definition: kernel.h:57
@ PREWITT_X
PREWITT_X.
Definition: kernel.h:52
void setKernelType(KERNEL_ENUM kernel_type)
Definition: kernel.hpp:319
KERNEL_ENUM kernel_type_
Definition: kernel.h:68
float sigma_
Definition: kernel.h:67
int kernel_size_
Definition: kernel.h:66
void gaussianKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:96
void sobelKernelY(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:198
void fetchKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:46
kernel()
Definition: kernel.h:70
void derivativeXForwardKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:259
void derivativeYForwardKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:295
void robertsKernelX(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:185
void derivativeYCentralKernel(pcl::PointCloud< PointT > &kernel)
Definition: kernel.hpp:283
Defines all the PCL implemented PointT point type structures.