参考:

https://www.cnblogs.com/ironstark/p/5008258.html

https://github.com/Ewenwan/MVision/blob/master/PCL_APP/4_%E7%82%B9%E4%BA%91%E5%88%86%E5%89%B2%E4%B8%8E%E5%88%86%E7%B1%BB%20Segmentation.md

最小割分割算法

算法对输入的点云进行二值分割,即分为两组:前景点和背景点(属于对象的点和不属于对象的点)

最小割(min-cut)并不是一个什么很新鲜的东西。它早就用在网络规划,求解桥问题,图像分割等领域,被移植到点云分割上也不足为奇。最小割算法是图论中的一个概念,其作用是以某种方式,将两个点分开,当然这两个点中间可能是通过无数的点再相连的。如图所示。

  如果要分开最左边的点和最右边的点,红绿两种割法都是可行的,但是红线跨过了三条线,绿线只跨过了两条。单从跨线数量上来论可以得出绿线这种切割方法更优的结论。但假设线上有不同的权值,那么最优切割则和权值有关了。它到底是怎么找到那条绿线的暂且不论。总而言之,就是有那么一个算法,当你给出了点之间的 “图” (广义的),以及连线的权值时,最小割算法就能按照你的要求把图分开。

点云 “图”

  显而易见,切割有两个非常重要的因素,第一个是获得点与点之间的拓扑关系,也就是生成一张“图”。第二个是给图中的连线赋予合适的权值。只要这两个要素合适,最小割算法就会办好剩下的事情。点云是一种非常适合分割的对象(我第三次强调这个事情了),点云有天然分开的点。有了点之后,只要把点云中所有的点连起来就可以了。连接算法如下:

  1. 找到每个点最近的n个点
  2. 将这n个点和父点连接
  3. 找到距离最小的两个块(A块中某点与B块中某点距离最小),并连接
  4. 重复3,直至只剩一个块

  现在已经有了“图”,只要给图附上合适的权值,就完成了所有任务。物体分割给人一个直观印象就是属于该物体的点,应该相互之间不会太远。也就是说,可以用点与点之间的欧式距离来构造权值。所有线的权值可映射为线长的函数。

  貌似我们现在已经搞定一切了,其实不然。分割总是有一个目标的,而这种精准打击的算法,显然你要告诉我打击对象是谁,打击范围多大——目标需要人为指定(center),尺寸需要提前给出(radius)。

  OK,我们现在有了打击对象了(指定了目标物体上的一个点),接下来要做的,就是让除此对象之外的物体被保护起来,不受到打击。保护的方法就是认为加重目标范围之外的权值(罚函数)

     上述过程其实看起来还不够智能,如果有办法让我只需要点一下鼠标,选中要分割的物体,接下来电脑替我操心其他事情,那就太好了。这其实是可以实现的,称为AutoMatic Regime.但PCL并没有封装这个算法,忽略不表。

算法思想

The idea of this algorithm is as follows:

  1. For the given point cloud algorithm constructs the graph that contains every single point of the cloud as a set of vertices and two more vertices called source and sink. Every vertex of the graph that corresponds to the point is connected with source and sink with the edges. In addition to these, every vertex (except source and sink) has edges that connect the corresponding point with its nearest neighbours.

  2. Algorithm assigns weights for every edge. There are three different types of weight. Let’s examine them:

    • First of all it assigns weight to the edges between clouds points. This weight is called smooth cost and is calculated by the formula:

      Here  is the distance between points. The farther away the points are, the more is probability that the edge will be cut.

    • Next step the algorithm sets data cost. It consists of foreground and background penalties. The first one is the weight for those edges that connect clouds points with the source vertex and has the constant user-defined value. The second one is assigned to the edges that connect points with the sink vertex and is calculated by the formula:

      Here  is the distance to the expected center of the object in the horizontal plane:

      Radius that occurs in the formula is the input parameter for this algorithm and can be roughly considered as the range from objects center outside of which there are no points that belong to foreground (objects horizontal radius).

PCL编程实现

http://pointclouds.org/documentation/tutorials/min_cut_segmentation.php#min-cut-segmentation

#include <iostream>
#include <vector>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/filters/passthrough.h>
#include <pcl/segmentation/min_cut_segmentation.h>int main (int argc, char** argv)
{pcl::PointCloud <pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud <pcl::PointXYZ>);if ( pcl::io::loadPCDFile <pcl::PointXYZ> ("min_cut_segmentation_tutorial.pcd", *cloud) == -1 ){std::cout << "Cloud reading failed." << std::endl;return (-1);}pcl::IndicesPtr indices (new std::vector <int>);pcl::PassThrough<pcl::PointXYZ> pass;pass.setInputCloud (cloud);pass.setFilterFieldName ("z");pass.setFilterLimits (0.0, 1.0);pass.filter (*indices);pcl::MinCutSegmentation<pcl::PointXYZ> seg;seg.setInputCloud (cloud);seg.setIndices (indices);pcl::PointCloud<pcl::PointXYZ>::Ptr foreground_points(new pcl::PointCloud<pcl::PointXYZ> ());pcl::PointXYZ point;point.x = 68.97;point.y = -18.55;point.z = 0.57;foreground_points->points.push_back(point);seg.setForegroundPoints (foreground_points);seg.setSigma (0.25);seg.setRadius (3.0433856);seg.setNumberOfNeighbours (14);seg.setSourceWeight (0.8);std::vector <pcl::PointIndices> clusters;seg.extract (clusters);std::cout << "Maximum flow is " << seg.getMaxFlow () << std::endl;pcl::PointCloud <pcl::PointXYZRGB>::Ptr colored_cloud = seg.getColoredCloud ();pcl::visualization::CloudViewer viewer ("Cluster viewer");viewer.showCloud(colored_cloud);while (!viewer.wasStopped ()){}return (0);
}

分割效果

基于最小割的分割算法(Min-Cut Based Segmentation)相关推荐

  1. 最小割(Stoer-Wagner算法)

    Stoer-Wagner算法 简介: 割:在一个图G(V,E)中V是点集,E是边集.在E中去掉一个边集C使得G(V,E-C)不连通,C就是图G(V,E)的一个割: 最小割:在G(V,E)的所有割中,边 ...

  2. VIPS:基于视觉的页面分割算法[微软下一代搜索引擎核心分页算法]

    VIPS:基于视觉的页面分割算法[微软下一代搜索引擎核心分页算法] VIPS:基于视觉的页面分割算法[微软下一代搜索引擎核心分页算法] - tingya的专栏 - 博客频道 - CSDN.NET VI ...

  3. 最大流最小割经典例题_最大流, 最小割问题及算法实现

    本博客采用创作共用版权协议, 要求署名.非商业用途和保持一致. 转载本博客文章必须也遵循署名-非商业用途-保持一致的创作共用协议. 由于博文中包含一些LaTex格式数学公式, 在简书中显示不好, 所以 ...

  4. 【HDU - 3002】King of Destruction(无向图全局最小割,SW算法,模板题)

    题干: Zhou xingxing is the successor of one style of kung fu called "Karate Kid".he is falli ...

  5. 基于标记的分水岭分割算法

    分水岭技术是一种众所周知的分割算法,特别适用于提取图片中的相邻或重叠对象.使用分水岭方法时,我们必须从用户定义的标记开始.这些标记可以使用点击手动定义,也可以使用阈值或形态学处理方法定义. 分水岭技术 ...

  6. 一种无监督语义分割算法:Unsupervised Semantic Segmentation using Invariance and Equivariance in Clustering

    论文题目:PiCIE: Unsupervised Semantic Segmentation using Invariance and Equivariance in Clustering 1 摘要 ...

  7. 图像分割经典算法--《最小割最大流》(Minimum Cut——Max Flow)

    1.算法介绍 最小割算法(Minimum Cut)是图像分割的经典算法之一,同时也在"Graph Cut"."Grab Cut"等算法中都有被使用过.最小割最大 ...

  8. 基于FCN,U-Net的深度学习医学影像分割算法(细胞分割算法)以及传统算法分析

    本博文主要分析了基于传统计算机视觉的细胞分割算法和基于深度学习的细胞分割算法.主要针对医学影像分割算法.包括了FCN全卷积网络的细胞分割效果,U-Net细胞分割效果.查阅了采用深度学习分割医学影像的几 ...

  9. 实战|基于图割算法的木材表面缺陷图像分析

    点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 本文转自|新机器视觉 鉴于图割方法的明显优势,白雪冰及其团队采用G ...

最新文章

  1. 创建function实现hive表结果导出到mysql
  2. mof提权原理及其过程
  3. spyder 断点调试python代码
  4. world scientific is the journal to follow
  5. 对pca降维后的手写体数字图片数据分类_python机器学习API介绍13: 数据降维及主成分分析...
  6. python刘卫国实验题_MATLAB 程序设计与应用(刘卫国版)习题答案3-4
  7. 0到1:闲鱼高复杂度高性能社区圈子开发实录
  8. 台式计算机技术参数响应表,联想台式电脑配置推荐及参数详情【图文】
  9. python enumerate的详解
  10. RSA攻击手法及相应例题解析
  11. python爬虫——当当网商品比价爬虫
  12. 一篇文章了解数据库系统
  13. 在 Cocos Creator 中使用缓动系统(cc.tween)
  14. 北上资金 python_股票数据抓取——北上基金持股数据(selenium抓取数据),爬取,之,北向,资金,通过...
  15. icafe 同步到主干
  16. 灵遁者油画作品《认真——沉默》
  17. plt.imshow()无法显示两站图片?
  18. 有梦想,就去追,不犹豫,不后悔
  19. scanner——04scaner进阶
  20. python os.path.exists 已存在_详解python os.path.exists判断文件或文件夹是否存在

热门文章

  1. 阿里云服务器购买指南(适合新手小白的图文指导教程)
  2. 蓝牙耳机+大鼠标垫+笔记本电脑支架
  3. 51单片机c语言led灯闪烁实验报告,实验一LED灯闪烁.doc
  4. 了解一下ES module 和 Commonjs
  5. STM32常用协议之串口通信详解
  6. 显著图(Saliency map)
  7. Intel SGX开发者参考书(四)—— Enclave开发基础(三)
  8. JavaScript在数组尾部添加元素
  9. 使用Keras进行深度学习:(六)LSTM和双向LSTM讲解及实践
  10. Unity-Tilemap 瓦片地图