41 #ifndef PCL_FILTERS_IMPL_PYRAMID_HPP
42 #define PCL_FILTERS_IMPL_PYRAMID_HPP
45 #include <pcl/filters/pyramid.h>
46 #include <pcl/console/print.h>
53 template <
typename Po
intT>
bool
54 Pyramid<PointT>::initCompute ()
56 if (!input_->isOrganized ())
58 PCL_ERROR (
"[pcl::filters::%s::initCompute] Number of levels should be at least 2!\n", getClassName ().c_str ());
64 PCL_ERROR (
"[pcl::filters::%s::initCompute] Number of levels should be at least 2!\n", getClassName ().c_str ());
74 PCL_ERROR (
"[pcl::filters::%s::initCompute] Number of levels should not exceed 4!\n", getClassName ().c_str ());
80 Eigen::VectorXf k (5);
81 k << 1.f/16.f, 1.f/4.f, 3.f/8.f, 1.f/4.f, 1.f/16.f;
82 kernel_ = k * k.transpose ();
83 if (threshold_ != std::numeric_limits<float>::infinity ())
84 threshold_ *= 2 * threshold_;
89 Eigen::VectorXf k (3);
90 k << 1.f/4.f, 1.f/2.f, 1.f/4.f;
91 kernel_ = k * k.transpose ();
92 if (threshold_ != std::numeric_limits<float>::infinity ())
93 threshold_ *= threshold_;
99 template <
typename Po
intT>
void
102 std::cout <<
"compute" << std::endl;
105 PCL_ERROR (
"[pcl::%s::compute] initCompute failed!\n", getClassName ().c_str ());
109 int kernel_rows =
static_cast<int> (kernel_.rows ());
110 int kernel_cols =
static_cast<int> (kernel_.cols ());
111 int kernel_center_x = kernel_cols / 2;
112 int kernel_center_y = kernel_rows / 2;
114 output.resize (levels_ + 1);
116 *(output[0]) = *input_;
118 if (input_->is_dense)
120 for (
int l = 1; l <= levels_; ++l)
125 #pragma omp parallel for \
128 num_threads(threads_)
129 for(
int i=0; i < next.
height; ++i)
131 for(
int j=0; j < next.
width; ++j)
133 for(
int m=0; m < kernel_rows; ++m)
135 int mm = kernel_rows - 1 - m;
136 for(
int n=0; n < kernel_cols; ++n)
138 int nn = kernel_cols - 1 - n;
140 int ii = 2*i + (m - kernel_center_y);
141 int jj = 2*j + (n - kernel_center_x);
146 if (jj >= previous.
width) jj = previous.
width - 1;
147 next.
at (j,i) += previous.
at (jj,ii) * kernel_ (mm,nn);
156 for (
int l = 1; l <= levels_; ++l)
161 #pragma omp parallel for \
164 num_threads(threads_)
165 for(
int i=0; i < next.
height; ++i)
167 for(
int j=0; j < next.
width; ++j)
170 for(
int m=0; m < kernel_rows; ++m)
172 int mm = kernel_rows - 1 - m;
173 for(
int n=0; n < kernel_cols; ++n)
175 int nn = kernel_cols - 1 - n;
176 int ii = 2*i + (m - kernel_center_y);
177 int jj = 2*j + (n - kernel_center_x);
181 if (jj >= previous.
width) jj = previous.
width - 1;
186 next.
at (j,i) += previous.
at (jj,ii).x * kernel_ (mm,nn);
187 weight+= kernel_ (mm,nn);
192 nullify (next.
at (j,i));
196 next.
at (j,i)*= weight;
213 p.r = 0; p.g = 0; p.b = 0;
PointCloud represents the base class in PCL for storing collections of 3D points.
const PointT & at(int column, int row) const
Obtain the point given by the (column, row) coordinates.
std::uint32_t width
The point cloud width (if organized as an image-structure).
std::uint32_t height
The point cloud height (if organized as an image-structure).
Pyramid constructs a multi-scale representation of an organised point cloud.
void compute(std::vector< PointCloudPtr > &output)
compute the pyramid levels.
typename PointCloud< PointT >::Ptr PointCloudPtr
Define standard C methods to do distance calculations.
Defines all the PCL implemented PointT point type structures.
float squaredEuclideanDistance(const PointType1 &p1, const PointType2 &p2)
Calculate the squared euclidean distance between the two given points.
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...
A structure representing RGB color information.