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>
46 template <
typename Po
intT>
void
49 if (search_radius_ == 0.0)
51 PCL_ERROR (
"[pcl::%s::applyFilter] No radius defined!\n", getClassName ().c_str ());
53 removed_indices_->clear ();
60 if (input_->isOrganized ())
65 searcher_->setInputCloud (input_);
68 std::vector<int> nn_indices (indices_->size ());
69 std::vector<float> nn_dists (indices_->size ());
70 indices.resize (indices_->size ());
71 removed_indices_->resize (indices_->size ());
78 int mean_k = min_pts_radius_ + 1;
79 double nn_dists_max = search_radius_ * search_radius_;
81 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
84 int k = searcher_->nearestKSearch (*it, mean_k, nn_indices, nn_dists);
88 bool chk_neighbors =
true;
93 chk_neighbors =
false;
94 if (nn_dists_max < nn_dists[k-1])
101 chk_neighbors =
true;
102 if (nn_dists_max < nn_dists[k-1])
104 chk_neighbors =
false;
111 chk_neighbors =
true;
113 chk_neighbors =
false;
120 if (extract_removed_indices_)
121 (*removed_indices_)[rii++] = *it;
126 indices[oii++] = *it;
132 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
136 int k = searcher_->radiusSearch (*it, search_radius_, nn_indices, nn_dists);
140 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
142 if (extract_removed_indices_)
143 (*removed_indices_)[rii++] = *it;
148 indices[oii++] = *it;
153 indices.resize (oii);
154 removed_indices_->resize (rii);
157 #define PCL_INSTANTIATE_RadiusOutlierRemoval(T) template class PCL_EXPORTS pcl::RadiusOutlierRemoval<T>;
159 #endif // PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_