40 #include <pcl/2d/convolution.h>
44 template <
typename Po
intT>
53 int iw =
static_cast<int>(input_->width), ih =
static_cast<int>(input_->height),
54 kw =
static_cast<int>(kernel_.width), kh =
static_cast<int>(kernel_.height);
55 switch (boundary_options_) {
57 case BOUNDARY_OPTION_CLAMP: {
58 for (
int i = 0; i < ih; i++) {
59 for (
int j = 0; j < iw; j++) {
61 for (
int k = 0; k < kh; k++) {
62 for (
int l = 0; l < kw; l++) {
63 int ikkh = i + k - kh / 2, jlkw = j + l - kw / 2;
79 kernel_(l, k).intensity * (*input_)(input_col, input_row).intensity;
82 output(j, i).intensity = intensity;
88 case BOUNDARY_OPTION_MIRROR: {
89 for (
int i = 0; i < ih; i++) {
90 for (
int j = 0; j < iw; j++) {
92 for (
int k = 0; k < kh; k++) {
93 for (
int l = 0; l < kw; l++) {
94 int ikkh = i + k - kh / 2, jlkw = j + l - kw / 2;
96 input_row = -ikkh - 1;
98 input_row = 2 * ih - 1 - ikkh;
103 input_col = -jlkw - 1;
105 input_col = 2 * iw - 1 - jlkw;
110 kernel_(l, k).intensity * ((*input_)(input_col, input_row).intensity);
113 output(j, i).intensity = intensity;
119 case BOUNDARY_OPTION_ZERO_PADDING: {
120 for (
int i = 0; i < ih; i++) {
121 for (
int j = 0; j < iw; j++) {
123 for (
int k = 0; k < kh; k++) {
124 for (
int l = 0; l < kw; l++) {
125 int ikkh = i + k - kh / 2, jlkw = j + l - kw / 2;
126 if (ikkh < 0 || ikkh >= ih || jlkw < 0 || jlkw >= iw)
128 intensity += kernel_(l, k).intensity * ((*input_)(jlkw, ikkh).intensity);
131 output(j, i).intensity = intensity;
void filter(pcl::PointCloud< PointT > &output)
Performs 2D convolution of the input point cloud with the kernel.
PointCloud represents the base class in PCL for storing collections of 3D points.