40 #include <pcl/2d/kernel.h>
44 template <
typename Po
intT>
48 switch (kernel_type_) {
70 case DERIVATIVE_CENTRAL_X:
71 derivativeXCentralKernel(
kernel);
73 case DERIVATIVE_FORWARD_X:
74 derivativeXForwardKernel(
kernel);
76 case DERIVATIVE_BACKWARD_X:
77 derivativeXBackwardKernel(
kernel);
79 case DERIVATIVE_CENTRAL_Y:
80 derivativeYCentralKernel(
kernel);
82 case DERIVATIVE_FORWARD_Y:
83 derivativeYForwardKernel(
kernel);
85 case DERIVATIVE_BACKWARD_Y:
86 derivativeYBackwardKernel(
kernel);
94 template <
typename Po
intT>
99 kernel.resize(kernel_size_ * kernel_size_);
100 kernel.height = kernel_size_;
101 kernel.width = kernel_size_;
103 double sigma_sqr = 2 * sigma_ * sigma_;
105 for (
int i = 0; i < kernel_size_; i++) {
106 for (
int j = 0; j < kernel_size_; j++) {
107 int iks = (i - kernel_size_ / 2);
108 int jks = (j - kernel_size_ / 2);
109 kernel(j, i).intensity = std::exp(
110 static_cast<float>(-
static_cast<double>(iks * iks + jks * jks) / sigma_sqr));
111 sum += (
kernel(j, i).intensity);
116 for (std::size_t i = 0; i <
kernel.size(); ++i)
117 kernel[i].intensity /= sum;
120 template <
typename Po
intT>
125 kernel.resize(kernel_size_ * kernel_size_);
126 kernel.height = kernel_size_;
127 kernel.width = kernel_size_;
129 double sigma_sqr = 2 * sigma_ * sigma_;
131 for (
int i = 0; i < kernel_size_; i++) {
132 for (
int j = 0; j < kernel_size_; j++) {
133 int iks = (i - kernel_size_ / 2);
134 int jks = (j - kernel_size_ / 2);
136 static_cast<float>(
static_cast<double>(iks * iks + jks * jks) / sigma_sqr);
137 kernel(j, i).intensity = (1.0f - temp) * std::exp(-temp);
138 sum +=
kernel(j, i).intensity;
143 for (std::size_t i = 0; i <
kernel.size(); ++i)
144 kernel[i].intensity /= sum;
147 template <
typename Po
intT>
154 kernel(0, 0).intensity = -1;
155 kernel(1, 0).intensity = 0;
156 kernel(2, 0).intensity = 1;
157 kernel(0, 1).intensity = -2;
158 kernel(1, 1).intensity = 0;
159 kernel(2, 1).intensity = 2;
160 kernel(0, 2).intensity = -1;
162 kernel(2, 2).intensity = 1;
165 template <
typename Po
intT>
172 kernel(0, 0).intensity = -1;
173 kernel(1, 0).intensity = 0;
174 kernel(2, 0).intensity = 1;
175 kernel(0, 1).intensity = -1;
176 kernel(1, 1).intensity = 0;
177 kernel(2, 1).intensity = 1;
178 kernel(0, 2).intensity = -1;
180 kernel(2, 2).intensity = 1;
183 template <
typename Po
intT>
190 kernel(0, 0).intensity = 1;
191 kernel(1, 0).intensity = 0;
192 kernel(0, 1).intensity = 0;
193 kernel(1, 1).intensity = -1;
196 template <
typename Po
intT>
203 kernel(0, 0).intensity = -1;
204 kernel(1, 0).intensity = -2;
205 kernel(2, 0).intensity = -1;
207 kernel(1, 1).intensity = 0;
208 kernel(2, 1).intensity = 0;
209 kernel(0, 2).intensity = 1;
210 kernel(1, 2).intensity = 2;
211 kernel(2, 2).intensity = 1;
214 template <
typename Po
intT>
221 kernel(0, 0).intensity = 1;
222 kernel(1, 0).intensity = 1;
223 kernel(2, 0).intensity = 1;
224 kernel(0, 1).intensity = 0;
226 kernel(2, 1).intensity = 0;
227 kernel(0, 2).intensity = -1;
228 kernel(1, 2).intensity = -1;
229 kernel(2, 2).intensity = -1;
232 template <
typename Po
intT>
239 kernel(0, 0).intensity = 0;
240 kernel(1, 0).intensity = 1;
241 kernel(0, 1).intensity = -1;
242 kernel(1, 1).intensity = 0;
245 template <
typename Po
intT>
252 kernel(0, 0).intensity = -1;
253 kernel(1, 0).intensity = 0;
254 kernel(2, 0).intensity = 1;
257 template <
typename Po
intT>
264 kernel(0, 0).intensity = 0;
265 kernel(1, 0).intensity = -1;
266 kernel(2, 0).intensity = 1;
269 template <
typename Po
intT>
276 kernel(0, 0).intensity = -1;
277 kernel(1, 0).intensity = 1;
278 kernel(2, 0).intensity = 0;
281 template <
typename Po
intT>
288 kernel(0, 0).intensity = -1;
289 kernel(0, 1).intensity = 0;
290 kernel(0, 2).intensity = 1;
293 template <
typename Po
intT>
300 kernel(0, 0).intensity = 0;
301 kernel(0, 1).intensity = -1;
302 kernel(0, 2).intensity = 1;
305 template <
typename Po
intT>
312 kernel(0, 0).intensity = -1;
313 kernel(0, 1).intensity = 1;
314 kernel(0, 2).intensity = 0;
317 template <
typename Po
intT>
321 kernel_type_ = kernel_type;
324 template <
typename Po
intT>
328 kernel_size_ = kernel_size;
331 template <
typename Po
intT>
335 sigma_ = kernel_sigma;
PointCloud represents the base class in PCL for storing collections of 3D points.
void prewittKernelY(pcl::PointCloud< PointT > &kernel)
void derivativeXBackwardKernel(pcl::PointCloud< PointT > &kernel)
void derivativeYBackwardKernel(PointCloud< PointT > &kernel)
void prewittKernelX(pcl::PointCloud< PointT > &kernel)
void loGKernel(pcl::PointCloud< PointT > &kernel)
void setKernelSize(int kernel_size)
void sobelKernelX(pcl::PointCloud< PointT > &kernel)
void setKernelSigma(float kernel_sigma)
void derivativeXCentralKernel(pcl::PointCloud< PointT > &kernel)
void robertsKernelY(pcl::PointCloud< PointT > &kernel)
KERNEL_ENUM
Different types of kernels available.
void setKernelType(KERNEL_ENUM kernel_type)
void gaussianKernel(pcl::PointCloud< PointT > &kernel)
void sobelKernelY(pcl::PointCloud< PointT > &kernel)
void fetchKernel(pcl::PointCloud< PointT > &kernel)
void derivativeXForwardKernel(pcl::PointCloud< PointT > &kernel)
void derivativeYForwardKernel(pcl::PointCloud< PointT > &kernel)
void robertsKernelX(pcl::PointCloud< PointT > &kernel)
void derivativeYCentralKernel(pcl::PointCloud< PointT > &kernel)