Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
00041 #define PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
00042
00043 #include <pcl/filters/radius_outlier_removal.h>
00044 #include <pcl/common/io.h>
00045
00047 template <typename PointT> void
00048 pcl::RadiusOutlierRemoval<PointT>::applyFilter (PointCloud &output)
00049 {
00050 std::vector<int> indices;
00051 if (keep_organized_)
00052 {
00053 bool temp = extract_removed_indices_;
00054 extract_removed_indices_ = true;
00055 applyFilterIndices (indices);
00056 extract_removed_indices_ = temp;
00057
00058 output = *input_;
00059 for (int rii = 0; rii < static_cast<int> (removed_indices_->size ()); ++rii)
00060 output.points[(*removed_indices_)[rii]].x = output.points[(*removed_indices_)[rii]].y = output.points[(*removed_indices_)[rii]].z = user_filter_value_;
00061 if (!pcl_isfinite (user_filter_value_))
00062 output.is_dense = false;
00063 }
00064 else
00065 {
00066 applyFilterIndices (indices);
00067 copyPointCloud (*input_, indices, output);
00068 }
00069 }
00070
00072 template <typename PointT> void
00073 pcl::RadiusOutlierRemoval<PointT>::applyFilterIndices (std::vector<int> &indices)
00074 {
00075 if (search_radius_ == 0.0)
00076 {
00077 PCL_ERROR ("[pcl::%s::applyFilter] No radius defined!\n", getClassName ().c_str ());
00078 indices.clear ();
00079 removed_indices_->clear ();
00080 return;
00081 }
00082
00083
00084 if (!searcher_)
00085 {
00086 if (input_->isOrganized ())
00087 searcher_.reset (new pcl::search::OrganizedNeighbor<PointT> ());
00088 else
00089 searcher_.reset (new pcl::search::KdTree<PointT> (false));
00090 }
00091 searcher_->setInputCloud (input_);
00092
00093
00094 std::vector<int> nn_indices (indices_->size ());
00095 std::vector<float> nn_dists (indices_->size ());
00096 indices.resize (indices_->size ());
00097 removed_indices_->resize (indices_->size ());
00098 int oii = 0, rii = 0;
00099
00100 for (int iii = 0; iii < static_cast<int> (indices_->size ()); ++iii)
00101 {
00102
00103
00104 int k = searcher_->radiusSearch ((*indices_)[iii], search_radius_, nn_indices, nn_dists);
00105
00106
00107
00108 if ((!negative_ && k <= min_pts_radius_) || (negative_ && k > min_pts_radius_))
00109 {
00110 if (extract_removed_indices_)
00111 (*removed_indices_)[rii++] = (*indices_)[iii];
00112 continue;
00113 }
00114
00115
00116 indices[oii++] = (*indices_)[iii];
00117 }
00118
00119
00120 indices.resize (oii);
00121 removed_indices_->resize (rii);
00122 }
00123
00124 #define PCL_INSTANTIATE_RadiusOutlierRemoval(T) template class PCL_EXPORTS pcl::RadiusOutlierRemoval<T>;
00125
00126 #endif // PCL_FILTERS_IMPL_RADIUS_OUTLIER_REMOVAL_H_
00127