网站安装百度商桥,wordpress 微信打赏,南京网站建设王道下拉??,网络工程师前景如何1、算法原理 统计滤波算法是一种利用统计学原理对点云数据进行处理的方法。它主要通过计算点云中每个点的统计特性#xff0c;如均值、方差等#xff0c;来决定是否保留该点。算法首先会设定一个统计阈值#xff0c;然后对点云中的每个点进行分析。如果一个点的统计特性与周…1、算法原理 统计滤波算法是一种利用统计学原理对点云数据进行处理的方法。它主要通过计算点云中每个点的统计特性如均值、方差等来决定是否保留该点。算法首先会设定一个统计阈值然后对点云中的每个点进行分析。如果一个点的统计特性与周围点的统计特性相差不大即认为该点是可靠的并将其保留反之如果一个点的统计特性与周围点相比差异较大那么这个点可能是一个异常点或噪声点算法会将其移除。通过这种方式统计滤波算法能够有效地减少数据中的噪声和异常值提高点云数据的质量。这种算法特别适用于需要对数据进行精细处理的场合例如在高精度建模和测量中。由于其能够提供较为精确的数据处理结果统计滤波算法在点云数据处理领域中也占有一席之地。算法的实现步骤如下 第1步创建点云数据的拓扑结构如KDtree或Octree。 第2步计算每一个点的K邻域集合。 第3步计算每个点与其K邻域的距离dij的均值,其中i[1,....,m] 表示点云数目j[1,....,k] 点的K邻域点。 第4步计算点云数据高斯分布模型参数d~Nu,α距离的均值u距离的标准差α具体公式内容如下 第5步计算统计滤波的阈值。 dt u S*α ; 第6步遍历所有点如果其距离的均值大于指定置阈值则为外点将会被移除。
2、主要成员函数和变量 1.主要的成员变量 1、 构建点云空间拓扑的方法如KDtree和Octree SearcherPtr searcher_;2、搜索点K邻域的个数用于计算点的平均距离信息 int mean_k_; 3、标准差修正因子 double std_mul_; 2.主要的成员函数 1、设置搜索点K邻域的个数用于计算点的平均距离可以根据直接点云数据分布情况设置一般值15、30、50等。 inline void setMeanK (int nr_k) 2、标准差修正因子 如0.1、0.3和0.5等。 inline void setStddevMulThresh (double stddev_mult)
3、主要实现代码注解
template typename PointT void
pcl::StatisticalOutlierRemovalPointT::applyFilterIndices (std::vectorint indices)
{// 初始化构建点云拓扑关系方法if (!searcher_){if (input_-isOrganized ())//有序点云searcher_.reset (new pcl::search::OrganizedNeighborPointT ());else //无序点云数据用KD树方法searcher_.reset (new pcl::search::KdTreePointT (false));}searcher_-setInputCloud (input_);// 初始化需要的参数K个邻域的索引集、距离集所有点云数据的距离集std::vectorint nn_indices (mean_k_);std::vectorfloat nn_dists (mean_k_);std::vectorfloat distances (indices_-size ());//内点、外点索引集初始化indices.resize (indices_-size ());removed_indices_-resize (indices_-size ());int oii 0, rii 0; // oii output indices iterator, rii removed indices iterator//第一步计算所有点相对于k个最近邻域点的平均距离int valid_distances 0;for (int iii 0; iii static_castint (indices_-size ()); iii) // iii input indices iterator{//无效点判断if (!std::isfinite (input_-points[(*indices_)[iii]].x) ||!std::isfinite (input_-points[(*indices_)[iii]].y) ||!std::isfinite (input_-points[(*indices_)[iii]].z)){//无序点的距离为0distances[iii] 0.0;continue;}// P执行K个邻域点搜索if (searcher_-nearestKSearch ((*indices_)[iii], mean_k_ 1, nn_indices, nn_dists) 0){distances[iii] 0.0;PCL_WARN ([pcl::%s::applyFilter] Searching for the closest %d neighbors failed.\n, getClassName ().c_str (), mean_k_);continue;}// 计算点与K个邻域点之间距离的平均值double dist_sum 0.0;for (int k 1; k mean_k_ 1; k) // k 0 is the query pointdist_sum sqrt (nn_dists[k]);//将距离均值信息保存到对应索引值中 distances[iii] static_castfloat (dist_sum / mean_k_);valid_distances;}// 估计距离的均值和标准差u,adouble sum 0, sq_sum 0;for (const float distance : distances){sum distance;sq_sum distance * distance;}//均值double mean sum / static_castdouble(valid_distances);//方差---》前半部分为母体方差double variance (sq_sum - sum * sum / static_castdouble(valid_distances)) / (static_castdouble(valid_distances) - 1);//标准差double stddev sqrt (variance);//getMeanStd (distances, mean, stddev);// 计算外点阈值 等于均值标准差的修正系数double distance_threshold mean std_mul_ * stddev;// 第二步根据计算的距离阈值和每个点的距离值分辨率对点进行分类内点和外点for (int iii 0; iii static_castint (indices_-size ()); iii) // iii input indices iterator{//平均距离太高的点是离群值传递给移除的索引if ((!negative_ distances[iii] distance_threshold) || (negative_ distances[iii] distance_threshold)){if (extract_removed_indices_)(*removed_indices_)[rii] (*indices_)[iii];continue;}// Otherwise it was a normal point for output (inlier)indices[oii] (*indices_)[iii];}// Resize the output arraysindices.resize (oii);removed_indices_-resize (rii);
}
4、代码示例
/*****************************************************************//**
* \file PCLPCLRadiusOutliermain.cpp
* \brief
*
* \author YZS
* \date January 2025
*********************************************************************/
#includeiostream
#include vector
#include ctime
#include pcl/point_types.h
#include pcl/point_cloud.h
#include pcl/io/auto_io.h
#include pcl/visualization/pcl_visualizer.h
#include pcl/filters/statistical_outlier_removal.h
using namespace std;void PCLStatisticalOutlier()
{pcl::PointCloudpcl::PointXYZ::Ptr cloud(new pcl::PointCloudpcl::PointXYZ());std::string fileName E:/PCLlearnData/11/table.pcd;pcl::io::load(fileName, *cloud);std::cout Cloud Size: cloud-points.size() std::endl;//保存滤波后的结果点云pcl::PointCloudpcl::PointXYZ::Ptr cloudFilter(new pcl::PointCloudpcl::PointXYZ());//统计滤波算法pcl::StatisticalOutlierRemovalpcl::PointXYZ sorFilter;// 统计滤波器对象sorFilter.setInputCloud(cloud);sorFilter.setMeanK(30);//设置搜索点K邻域的个数sorFilter.setStddevMulThresh(0.3);//设置标准差修正因子 如0.1、0.3和0.5等sorFilter.filter(*cloudFilter); // 执行滤波并且保存结果到cloudFilter中std::cout filter Cloud Size: cloudFilter-points.size() std::endl;//结果可视化
// PCLVisualizer对象pcl::visualization::PCLVisualizer viewer(FilterVIS);//创建左右窗口的ID v1和v2int v1(0);int v2(1);//设置V1窗口尺寸和背景颜色viewer.createViewPort(0.0, 0.0, 0.5, 1, v1);viewer.setBackgroundColor(0, 0, 0, v1);//设置V2窗口尺寸和背景颜色viewer.createViewPort(0.5, 0.0, 1, 1, v2);viewer.setBackgroundColor(0.1, 0.1, 0.1, v2);// 添加2d文字标签viewer.addText(v1, 10, 10, 20, 1, 0, 0, Txtv1, v1);viewer.addText(v2, 10, 10, 20, 0, 1, 0, Txtv2, v2);//设置cloud1的渲染属性点云的ID和指定可视化窗口v1viewer.addPointCloud(cloud, cloud1, v1);viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, cloud1);//设置cloud2的渲染属性点云的ID和指定可视化窗口v2viewer.addPointCloud(cloudFilter, cloud2, v2);viewer.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, cloud2);// 可视化循环主体while (!viewer.wasStopped()){viewer.spinOnce();}
}
int main(int argc, char* argv[])
{PCLStatisticalOutlier();std::cout Hello World! std::endl;std::system(pause);return 0;
}
结果 5、统计滤波算法缺点 1、计算每一个点的邻域集合时可能会因为数据集的复杂性导致邻域集合的计算不准确从而影响后续的距离计算和滤波效果。 2、在计算每个点与其邻域的距离dij时如果点云数据中存在噪声或异常值这些异常值可能会扭曲距离的计算导致滤波结果不理想。 3、高斯分布模型参数的计算依赖于距离的均值u和标准差α如果数据集中的离群值较多可能会使得均值和标准差的估计不准确进而影响到离群值的识别和删除。 4、遍历所有点并移除外点的过程中如果设定的置信度阈值过高或过低可能会导致过多的正常点被错误地识别为离群点而被移除或者真正的离群点没有被有效识别从而影响数据集的质量。 至此完成第十二节PCL库点云滤波算法之统计滤波StatisticalOutlierRemoval学习下一节我们将进入《PCL库中点云特征》的学习。 文章转载自: http://www.morning.stxg.cn.gov.cn.stxg.cn http://www.morning.grtwn.cn.gov.cn.grtwn.cn http://www.morning.sftrt.cn.gov.cn.sftrt.cn http://www.morning.hqgkx.cn.gov.cn.hqgkx.cn http://www.morning.brlgf.cn.gov.cn.brlgf.cn http://www.morning.gsjw.cn.gov.cn.gsjw.cn http://www.morning.qnlbb.cn.gov.cn.qnlbb.cn http://www.morning.zfhwm.cn.gov.cn.zfhwm.cn http://www.morning.qprtm.cn.gov.cn.qprtm.cn http://www.morning.rxhn.cn.gov.cn.rxhn.cn http://www.morning.mtyhk.cn.gov.cn.mtyhk.cn http://www.morning.dnqpq.cn.gov.cn.dnqpq.cn http://www.morning.fpczq.cn.gov.cn.fpczq.cn http://www.morning.gnzsd.cn.gov.cn.gnzsd.cn http://www.morning.rwls.cn.gov.cn.rwls.cn http://www.morning.bqqzg.cn.gov.cn.bqqzg.cn http://www.morning.mfcbk.cn.gov.cn.mfcbk.cn http://www.morning.yrrnx.cn.gov.cn.yrrnx.cn http://www.morning.zhghd.cn.gov.cn.zhghd.cn http://www.morning.tzzxs.cn.gov.cn.tzzxs.cn http://www.morning.qfnrx.cn.gov.cn.qfnrx.cn http://www.morning.mqfkd.cn.gov.cn.mqfkd.cn http://www.morning.bdwqy.cn.gov.cn.bdwqy.cn http://www.morning.mkydt.cn.gov.cn.mkydt.cn http://www.morning.gnwse.com.gov.cn.gnwse.com http://www.morning.gtbjf.cn.gov.cn.gtbjf.cn http://www.morning.bflwj.cn.gov.cn.bflwj.cn http://www.morning.ymyhg.cn.gov.cn.ymyhg.cn http://www.morning.xcxj.cn.gov.cn.xcxj.cn http://www.morning.cwrnr.cn.gov.cn.cwrnr.cn http://www.morning.qqtzn.cn.gov.cn.qqtzn.cn http://www.morning.rmtmk.cn.gov.cn.rmtmk.cn http://www.morning.lrnfn.cn.gov.cn.lrnfn.cn http://www.morning.nknt.cn.gov.cn.nknt.cn http://www.morning.thrtt.cn.gov.cn.thrtt.cn http://www.morning.lxhrq.cn.gov.cn.lxhrq.cn http://www.morning.bfrff.cn.gov.cn.bfrff.cn http://www.morning.nyqzz.cn.gov.cn.nyqzz.cn http://www.morning.pkwwq.cn.gov.cn.pkwwq.cn http://www.morning.jhrtq.cn.gov.cn.jhrtq.cn http://www.morning.wqgr.cn.gov.cn.wqgr.cn http://www.morning.mcndn.cn.gov.cn.mcndn.cn http://www.morning.litao7.cn.gov.cn.litao7.cn http://www.morning.btqqh.cn.gov.cn.btqqh.cn http://www.morning.tpssx.cn.gov.cn.tpssx.cn http://www.morning.llcgz.cn.gov.cn.llcgz.cn http://www.morning.jkpnm.cn.gov.cn.jkpnm.cn http://www.morning.cwjxg.cn.gov.cn.cwjxg.cn http://www.morning.pjfmq.cn.gov.cn.pjfmq.cn http://www.morning.lxjxl.cn.gov.cn.lxjxl.cn http://www.morning.gccdr.cn.gov.cn.gccdr.cn http://www.morning.rhkmn.cn.gov.cn.rhkmn.cn http://www.morning.rlwcs.cn.gov.cn.rlwcs.cn http://www.morning.pzdxg.cn.gov.cn.pzdxg.cn http://www.morning.sjzsjsm.com.gov.cn.sjzsjsm.com http://www.morning.wpjst.cn.gov.cn.wpjst.cn http://www.morning.syqtt.cn.gov.cn.syqtt.cn http://www.morning.gctgc.cn.gov.cn.gctgc.cn http://www.morning.tldhq.cn.gov.cn.tldhq.cn http://www.morning.byjwl.cn.gov.cn.byjwl.cn http://www.morning.kxymr.cn.gov.cn.kxymr.cn http://www.morning.kszkm.cn.gov.cn.kszkm.cn http://www.morning.spghj.cn.gov.cn.spghj.cn http://www.morning.zqsnj.cn.gov.cn.zqsnj.cn http://www.morning.qzglh.cn.gov.cn.qzglh.cn http://www.morning.crxdn.cn.gov.cn.crxdn.cn http://www.morning.dmzzt.cn.gov.cn.dmzzt.cn http://www.morning.bhxzx.cn.gov.cn.bhxzx.cn http://www.morning.hkng.cn.gov.cn.hkng.cn http://www.morning.tpyrn.cn.gov.cn.tpyrn.cn http://www.morning.kaoshou.net.gov.cn.kaoshou.net http://www.morning.wnxqf.cn.gov.cn.wnxqf.cn http://www.morning.skrxp.cn.gov.cn.skrxp.cn http://www.morning.rjznm.cn.gov.cn.rjznm.cn http://www.morning.zwzwn.cn.gov.cn.zwzwn.cn http://www.morning.xhkgl.cn.gov.cn.xhkgl.cn http://www.morning.wscfl.cn.gov.cn.wscfl.cn http://www.morning.jtszm.cn.gov.cn.jtszm.cn http://www.morning.tzzfy.cn.gov.cn.tzzfy.cn http://www.morning.lhyhx.cn.gov.cn.lhyhx.cn