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