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 if (!searcher_->setInputCloud (input_))
69 PCL_ERROR (
"[pcl::%s::applyFilter] Error when initializing search method!\n", getClassName ().c_str ());
71 removed_indices_->clear ();
76 Indices nn_indices (indices_->size ());
77 std::vector<float> nn_dists (indices_->size ());
78 indices.resize (indices_->size ());
79 removed_indices_->resize (indices_->size ());
86 int mean_k = min_pts_radius_ + 1;
87 double nn_dists_max = search_radius_ * search_radius_;
89 for (
const auto& index : (*indices_))
92 int k = searcher_->nearestKSearch (index, mean_k, nn_indices, nn_dists);
96 bool chk_neighbors =
true;
101 chk_neighbors =
false;
102 if (nn_dists_max < nn_dists[k-1])
104 chk_neighbors =
true;
109 chk_neighbors =
true;
110 if (nn_dists_max < nn_dists[k-1])
112 chk_neighbors =
false;
118 chk_neighbors = negative_;
125 if (extract_removed_indices_)
126 (*removed_indices_)[rii++] = index;
131 indices[oii++] = index;
137 for (
const auto& index : (*indices_))
142 int k = searcher_->radiusSearch (index, search_radius_, nn_indices, nn_dists, min_pts_radius_ + 1);
146 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
148 if (extract_removed_indices_)
149 (*removed_indices_)[rii++] = index;
154 indices[oii++] = index;
159 indices.resize (oii);
160 removed_indices_->resize (rii);
163 #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 projectable point clo...
IndicesAllocator<> Indices
Type used for indices in PCL.