40 #ifndef PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
41 #define PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
43 #include <pcl/filters/radius_outlier_removal.h>
44 #include <pcl/search/organized.h>
45 #include <pcl/search/kdtree.h>
48 template <
typename Po
intT>
void
51 if (search_radius_ == 0.0)
53 PCL_ERROR (
"[pcl::%s::applyFilter] No radius defined!\n", getClassName ().c_str ());
55 removed_indices_->clear ();
62 if (input_->isOrganized ())
67 searcher_->setInputCloud (input_);
70 Indices nn_indices (indices_->size ());
71 std::vector<float> nn_dists (indices_->size ());
72 indices.resize (indices_->size ());
73 removed_indices_->resize (indices_->size ());
80 int mean_k = min_pts_radius_ + 1;
81 double nn_dists_max = search_radius_ * search_radius_;
83 for (
const auto& index : (*indices_))
86 int k = searcher_->nearestKSearch (index, mean_k, nn_indices, nn_dists);
90 bool chk_neighbors =
true;
95 chk_neighbors =
false;
96 if (nn_dists_max < nn_dists[k-1])
103 chk_neighbors =
true;
104 if (nn_dists_max < nn_dists[k-1])
106 chk_neighbors =
false;
112 chk_neighbors = negative_;
119 if (extract_removed_indices_)
120 (*removed_indices_)[rii++] = index;
125 indices[oii++] = index;
131 for (
const auto& index : (*indices_))
135 int k = searcher_->radiusSearch (index, search_radius_, nn_indices, nn_dists);
139 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
141 if (extract_removed_indices_)
142 (*removed_indices_)[rii++] = index;
147 indices[oii++] = index;
152 indices.resize (oii);
153 removed_indices_->resize (rii);
156 #define PCL_INSTANTIATE_RadiusOutlierRemoval(T) template class PCL_EXPORTS pcl::RadiusOutlierRemoval<T>;
void applyFilterIndices(Indices &indices)
Filtered results are indexed by an indices array.
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
OrganizedNeighbor is a class for optimized nearest neighbor search in organized point clouds.
IndicesAllocator<> Indices
Type used for indices in PCL.