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/common/io.h>
47 template <
typename Po
intT>
void
50 if (search_radius_ == 0.0)
52 PCL_ERROR (
"[pcl::%s::applyFilter] No radius defined!\n", getClassName ().c_str ());
54 removed_indices_->clear ();
61 if (input_->isOrganized ())
66 searcher_->setInputCloud (input_);
69 std::vector<int> nn_indices (indices_->size ());
70 std::vector<float> nn_dists (indices_->size ());
71 indices.resize (indices_->size ());
72 removed_indices_->resize (indices_->size ());
79 int mean_k = min_pts_radius_ + 1;
80 double nn_dists_max = search_radius_ * search_radius_;
82 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
85 int k = searcher_->nearestKSearch (*it, mean_k, nn_indices, nn_dists);
89 bool chk_neighbors =
true;
94 chk_neighbors =
false;
95 if (nn_dists_max < nn_dists[k-1])
102 chk_neighbors =
true;
103 if (nn_dists_max < nn_dists[k-1])
105 chk_neighbors =
false;
112 chk_neighbors =
true;
114 chk_neighbors =
false;
121 if (extract_removed_indices_)
122 (*removed_indices_)[rii++] = *it;
127 indices[oii++] = *it;
133 for (std::vector<int>::const_iterator it = indices_->begin (); it != indices_->end (); ++it)
137 int k = searcher_->radiusSearch (*it, search_radius_, nn_indices, nn_dists);
141 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
143 if (extract_removed_indices_)
144 (*removed_indices_)[rii++] = *it;
149 indices[oii++] = *it;
154 indices.resize (oii);
155 removed_indices_->resize (rii);
158 #define PCL_INSTANTIATE_RadiusOutlierRemoval(T) template class PCL_EXPORTS pcl::RadiusOutlierRemoval<T>;
void applyFilterIndices(std::vector< int > &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.