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 const int mean_k = min_pts_radius_ + 1;
77 const double nn_dists_max = search_radius_ * search_radius_;
81 std::vector<float> nn_dists(mean_k);
85 std::vector<std::uint8_t> to_keep(indices_->size(), 1);
86 indices.resize (indices_->size ());
87 removed_indices_->resize (indices_->size ());
93 #pragma omp parallel for \
94 schedule(dynamic,64) \
95 firstprivate(nn_indices, nn_dists) \
97 num_threads(num_threads_)
98 for (ptrdiff_t i = 0; i < static_cast<ptrdiff_t>(indices_->size()); i++)
100 const auto& index = (*indices_)[i];
102 const int k = searcher_->nearestKSearch (index, mean_k, nn_indices, nn_dists);
111 if ((!negative_ && nn_dists_max < nn_dists[k-1]) || (negative_ && nn_dists_max >= nn_dists[k - 1]))
131 #pragma omp parallel for \
132 schedule(dynamic, 64) \
133 firstprivate(nn_indices, nn_dists) \
135 num_threads(num_threads_)
136 for (ptrdiff_t i = 0; i < static_cast<ptrdiff_t>(indices_->size()); i++)
138 const auto& index = (*indices_)[i];
148 const int k = searcher_->radiusSearch (index, search_radius_, nn_indices, nn_dists, min_pts_radius_ + 1);
152 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
160 for (
index_t i=0; i < static_cast<index_t>(to_keep.size()); i++)
164 if (extract_removed_indices_)
165 (*removed_indices_)[rii++] = (*indices_)[i];
170 indices[oii++] = (*indices_)[i];
174 indices.resize (oii);
175 removed_indices_->resize (rii);
178 #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...
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
IndicesAllocator<> Indices
Type used for indices in PCL.
constexpr bool isXYZFinite(const PointT &) noexcept