40#ifndef PCL_FILTERS_CONVOLUTION_3D_IMPL_HPP
41#define PCL_FILTERS_CONVOLUTION_3D_IMPL_HPP
43#include <pcl/pcl_config.h>
56 template <
typename Po
intT>
62 n.normal_x = n.normal_y = n.normal_z = std::numeric_limits<float>::quiet_NaN ();
66 template <
typename Po
intT>
class
72 p.
x = p.
y = std::numeric_limits<float>::quiet_NaN ();
79template<
typename Po
intInT,
typename Po
intOutT>
bool
84 PCL_ERROR (
"Sigma is not set or equal to 0!\n", sigma_);
87 sigma_sqr_ = sigma_ * sigma_;
89 if (sigma_coefficient_)
91 if ((*sigma_coefficient_) > 6 || (*sigma_coefficient_) < 3)
93 PCL_ERROR (
"Sigma coefficient (%f) out of [3..6]!\n", (*sigma_coefficient_));
97 threshold_ = (*sigma_coefficient_) * (*sigma_coefficient_) * sigma_sqr_;
104template<
typename Po
intInT,
typename Po
intOutT>
PointOutT
106 const std::vector<float>& distances)
111 std::vector<float>::const_iterator
dist_it = distances.begin ();
113 for (Indices::const_iterator
idx_it = indices.begin ();
119 float weight = std::exp (-0.5f * (*
dist_it) / sigma_sqr_);
133template<
typename Po
intInT,
typename Po
intOutT>
PointOutT
139 float r = 0, g = 0, b = 0;
140 std::vector<float>::const_iterator
dist_it = distances.begin ();
142 for (Indices::const_iterator
idx_it = indices.begin ();
148 float weight = std::exp (-0.5f * (*
dist_it) / sigma_sqr_);
152 r += weight *
static_cast<float> ((*input_) [*
idx_it].r);
153 g += weight *
static_cast<float> ((*input_) [*
idx_it].g);
154 b += weight *
static_cast<float> ((*input_) [*
idx_it].b);
163 result.r =
static_cast<std::uint8_t
> (r);
164 result.g =
static_cast<std::uint8_t
> (g);
165 result.b =
static_cast<std::uint8_t
> (b);
174template <
typename Po
intInT,
typename Po
intOutT,
typename KernelT>
183template <
typename Po
intInT,
typename Po
intOutT,
typename KernelT>
bool
188 PCL_ERROR (
"[pcl::filters::Convlution3D::initCompute] init failed!\n");
194 if (input_->isOrganized ())
203 tree_->setInputCloud (surface_);
205 if (search_radius_ <= 0.0)
207 PCL_ERROR (
"[pcl::filters::Convlution3D::initCompute] search radius (%f) must be > 0\n",
214 PCL_ERROR (
"[pcl::filters::Convlution3D::initCompute] init failed : ");
215 PCL_ERROR (
"kernel_ must implement ConvolvingKernel interface\n!");
218 kernel_.setInputCloud (surface_);
220 if (!kernel_.initCompute ())
222 PCL_ERROR (
"[pcl::filters::Convlution3D::initCompute] kernel initialization failed!\n");
229template <
typename Po
intInT,
typename Po
intOutT,
typename KernelT>
void
234 PCL_ERROR (
"[pcl::filters::Convlution3D::convolve] init failed!\n");
237 output.resize (surface_->size ());
238 output.width = surface_->width;
239 output.height = surface_->height;
240 output.is_dense = surface_->is_dense;
244#pragma omp parallel for \
247 firstprivate(nn_indices, nn_distances) \
248 num_threads(threads_)
Iterator class for point clouds with or without given indices.
PointCloud represents the base class in PCL for storing collections of 3D points.
bool initCompute()
initialize computation
void convolve(PointCloudOut &output)
Convolve point cloud.
Convolution3D()
Constructor.
Class ConvolvingKernel base class for all convolving kernels.
static void makeInfinite(PointOutT &p)
Utility function that annihilates a point making it fail the pcl::isFinite test.
virtual PointOutT operator()(const Indices &indices, const std::vector< float > &distances)
Convolve point at the center of this local information.
bool initCompute()
Must call this method before doing any computation.
PointOutT operator()(const Indices &indices, const std::vector< float > &distances)
Convolve point at the center of this local information.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
OrganizedNeighbor is a class for optimized nearest neigbhor search in organized point clouds.
Defines all the PCL implemented PointT point type structures.
bool isFinite(const PointT &pt)
Tests if the 3D components of a point are all finite param[in] pt point to be tested return true if f...
IndicesAllocator<> Indices
Type used for indices in PCL.
A point structure representing normal coordinates and the surface curvature estimate.
A 2D point structure representing Euclidean xy coordinates.
A point structure representing Euclidean xyz coordinates, and the RGB color.