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;
113 chk_neighbors =
true;
115 chk_neighbors =
false;
122 if (extract_removed_indices_)
123 (*removed_indices_)[rii++] = index;
128 indices[oii++] = index;
134 for (
const auto& index : (*indices_))
138 int k = searcher_->radiusSearch (index, search_radius_, nn_indices, nn_dists);
142 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
144 if (extract_removed_indices_)
145 (*removed_indices_)[rii++] = index;
150 indices[oii++] = index;
155 indices.resize (oii);
156 removed_indices_->resize (rii);
159 #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 neigbhor search in organized point clouds.
IndicesAllocator<> Indices
Type used for indices in PCL.