denoiseCommand.cpp
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 
00039 
00040 #include <pcl/PointIndices.h>
00041 #include <pcl/point_types.h>
00042 #include <pcl/filters/statistical_outlier_removal.h>
00043 #include <pcl/apps/point_cloud_editor/denoiseCommand.h>
00044 #include <pcl/apps/point_cloud_editor/selection.h>
00045 #include <pcl/apps/point_cloud_editor/cloud.h>
00046 
00047 void
00048 DenoiseCommand::execute ()
00049 {
00050   Cloud3D temp_cloud;
00051   // denoise
00052   // uses point neighborhood statistics to filter outlier data.
00053   // For a more detailed explanation, see PCL's tutorial on denoising:
00054   // http://pointclouds.org/documentation/tutorials/statistical_outlier.php
00055   pcl::StatisticalOutlierRemoval<Point3D> filter(true);
00056   filter.setInputCloud(cloud_ptr_->getInternalCloud().makeShared());
00057   filter.setMeanK(mean_);
00058   filter.setStddevMulThresh (threshold_);
00059   // filtering and back up
00060   filter.setNegative(false);
00061   filter.filter(temp_cloud);
00062   // back up the removed indices.
00063   pcl::IndicesConstPtr indices_ptr = filter.getRemovedIndices();
00064   std::vector<int>::const_iterator it;
00065   for(it = indices_ptr->begin(); it != indices_ptr->end(); ++it)
00066     removed_indices_.addIndex(static_cast<unsigned int>(*it));
00067   // back up the removed points.
00068   removed_points_.set(cloud_ptr_, removed_indices_);
00069   // remove the noisy points.
00070   cloud_ptr_->remove(removed_indices_);
00071   selection_ptr_->clear();
00072 }
00073 
00074 void
00075 DenoiseCommand::undo ()
00076 {
00077   cloud_ptr_->restore(removed_points_, removed_indices_);
00078 }


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:23:21