GraphCuts算法解析,Graphcuts算法求最大流,最小割实例

本文涉及的产品
全局流量管理 GTM,标准版 1个月
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
云解析 DNS,旗舰版 1个月
简介:    图割论文大合集下载: http://download.csdn.net/detail/wangyaninglm/8292305   代码: /* graph.h *//* Vladimir Kolmogorov (vnk@cs.

 

 图割论文大合集下载:

http://download.csdn.net/detail/wangyaninglm/8292305

 

代码:

/* graph.h */
/* Vladimir Kolmogorov (vnk@cs.cornell.edu), 2001. */

/*
	This software library is a modification of the maxflow algorithm
	described in

	An Experimental Comparison of Min-Cut/Max-Flow Algorithms
	for Energy Minimization in Computer Vision.
	Yuri Boykov and Vladimir Kolmogorov.
	In Third International Workshop on Energy Minimization
	Methods in Computer Vision and Pattern Recognition, September 2001

	This algorithm was originally developed at Siemens.
	The main modification is that two trees are used for finding
	augmenting paths - one grows from the source and the other
	from the sink. (The original algorithm used only the former one).
	Details will be described in my PhD thesis.

	This implementation uses an adjacency list graph representation.邻接链表
	Memory allocation:
		Nodes: 22 bytes + one field to hold a residual capacity
		       of t-links (by default it is 'short' - 2 bytes)
		Arcs: 12 bytes + one field to hold a residual capacity 剩余容量
		      (by default it is 'short' - 2 bytes)
	(Note that arcs are always added in pairs (弧都是成对的添加)- in forward and reverse directions)

	Example usage (computes a maxflow on the following graph):

		        SOURCE
		       /       \
		     1/         \2
		     /      3    \
		   node0 -----> node1
		     |   <-----   |
		     |      4     |
		     \            /
		     5\          /6
		       \        /
		          SINK

	///////////////////////////////////////////////////

	#include <stdio.h>
	#include "graph.h"

	void test_maxflow()
	{
		Graph::node_id nodes[2];
		Graph *g = new Graph();

		nodes[0] = g -> add_node();
		nodes[1] = g -> add_node();
		g -> set_tweights(nodes[0], 1, 5);
		g -> set_tweights(nodes[1], 2, 6);
		g -> add_edge(nodes[0], nodes[1], 3, 4);

		Graph::flowtype flow = g -> maxflow();

		printf("Flow = %d\n", flow);
		printf("Minimum cut:\n");
		if (g->what_segment(nodes[0]) == Graph::SOURCE)
			printf("node0 is in the SOURCE set\n");
		else
			printf("node0 is in the SINK set\n");
		if (g->what_segment(nodes[1]) == Graph::SOURCE)
			printf("node1 is in the SOURCE set\n");
		else
			printf("node1 is in the SINK set\n");

		delete g;
	}

	///////////////////////////////////////////////////
*/


 

 

void test_maxflow()
{
	Graph::node_id nodes[2];
	Graph *g = new Graph();

	nodes[0] = g -> add_node();
	nodes[1] = g -> add_node();
	g -> set_tweights(nodes[0], 3, 3);
	g -> set_tweights(nodes[1], 3, 1);
	g -> add_edge(nodes[0], nodes[1], 1, 0);

	Graph::flowtype flow = g -> maxflow();

	printf("Flow = %d\n", flow);
	printf("Minimum cut:\n");
	if (g->what_segment(nodes[0]) == Graph::SOURCE)
		printf("node0 is in the SOURCE set\n");
	else
		printf("node0 is in the SINK set\n");
	if (g->what_segment(nodes[1]) == Graph::SOURCE)
		printf("node1 is in the SOURCE set\n");
	else
		printf("node1 is in the SINK set\n");

	delete g;
}


 

 

 

 

这块主要就是要理解,什么是maxflow,以及节点最后分割的类型是SOURCE还是SINK分别意味着什么

 

graphcuts算法时间复杂度与其他最大流算法的比较:

 

 

 

添加几篇文章地址:

 

graphcuts资料博客大合集

http://vision.csd.uwo.ca/code/

 

http://lincccc.blogspot.tw/2011/04/graph-cut-and-its-application-in.html

http://blog.csdn.net/zouxy09/article/details/8532106

http://lincccc.blogspot.tw/2011/03/cuda-cuts-fast-graph-cuts-on-gpu_03.html

http://blog.csdn.net/hebby06/article/details/5341228

相关文章
|
2天前
|
安全 算法 Java
密码学基础知识与加密算法解析
密码学基础知识与加密算法解析
|
2天前
|
机器学习/深度学习 人工智能 算法
计算机算法基础概述与常用算法解析
计算机算法基础概述与常用算法解析
|
5天前
|
存储 算法 安全
深入解析消息认证码(MAC)算法:HmacMD5与HmacSHA1
深入解析消息认证码(MAC)算法:HmacMD5与HmacSHA1
|
5天前
|
存储 算法 安全
深入解析RSA算法原理及其安全性机制
深入解析RSA算法原理及其安全性机制
|
5天前
|
存储 算法 安全
MD5哈希算法:原理、应用与安全性深入解析
MD5哈希算法:原理、应用与安全性深入解析
|
5天前
|
算法 安全 Java
AES加解密算法:原理、应用与安全性解析
AES加解密算法:原理、应用与安全性解析
|
5天前
|
算法 安全 Java
深入解析ECC(椭圆曲线密码学)加解密算法
深入解析ECC(椭圆曲线密码学)加解密算法
深入解析ECC(椭圆曲线密码学)加解密算法
|
1天前
|
算法 索引
基于Prony算法的系统参数辨识matlab仿真
Prony算法在MATLAB2022a中用于信号分析,识别复指数信号成分。核心程序通过模拟信号X1,添加不同SNR的噪声,应用Prony方法处理并计算误差。算法基于离散序列的复指数叠加模型,通过构建矩阵并解线性方程组估计参数,实现LTI系统动态特性的辨识。
|
2天前
|
算法 安全 数据库
基于结点电压法的配电网状态估计算法matlab仿真
**摘要** 该程序实现了基于结点电压法的配电网状态估计算法,旨在提升数据的准确性和可靠性。在MATLAB2022a中运行,显示了状态估计过程中的电压和相位估计值,以及误差随迭代变化的图表。算法通过迭代计算雅可比矩阵,结合基尔霍夫定律解决线性方程组,估算网络节点电压。状态估计过程中应用了高斯-牛顿或莱文贝格-马夸尔特法,处理量测数据并考虑约束条件,以提高估计精度。程序结果以图形形式展示电压幅值和角度估计的比较,以及估计误差的演变,体现了算法在处理配电网状态估计问题的有效性。
|
2天前
|
算法
基于PSO粒子群优化的PID控制器参数整定算法matlab仿真
该文探讨了使用PSO(粒子群优化)算法优化PID控制器参数的方法。通过PSO迭代,不断调整PID控制器的Kp、Ki、Kd增益,以减小控制误差。文中提供了MATLAB2022a版本的核心代码,展示了参数优化过程及结果。系统仿真图像显示了参数随迭代优化的变化。PID控制器结合PSO算法能有效提升控制性能,适用于复杂系统的参数整定,未来研究可关注算法效率提升和应对不确定性。

推荐镜像

更多