问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

求图割算法 graph cut 的matlab代码

发布网友 发布时间:2022-05-03 10:03

我来回答

2个回答

热心网友 时间:2023-11-11 13:15

function [Ncut] = graphcuts(I,pad,MAXVAL)
% function [Ncut] = graphcuts(I)
% Input: I image
% pad: spatial connectivity; eg. 3
% MAXVAL: maximum image value
% Output: Ncut: Binary map 0 or 1 corresponding to image segmentation
I = double(I); [H,W] = size(I);
% Find weights between nodes I1 and I2, w = exp(a*abs(I1-I2));
% Set a to have a weight of 0.01 for diff = MAXVAL
a = log(0.01)/MAXVAL; x = [0:MAXVAL/100:MAXVAL]'; y = exp(a*x);
figure;plot(x,y);xlabel('intensity diff');ylabel('weights'); title('weights')
ws = 2*pad + 1;
if(ws <= 3)
ws = 3;
end
%Build the weight matrix
disp('Building Weight Matrix'); close all; tic
WM = zeros(H*W,H*W); countWM = 0;
for kk = 1:W
for jj = 1:H
mask = logical(zeros(H,W));
cs = kk-pad; ce = kk+pad; rs = jj-pad; re = jj+pad;
if(cs<1)
cs = 1;
end;
if(ce>W)
ce = W;
end;
if(rs<1)
rs = 1;
end;
if(re>H)
re = H;
end;
mask(rs:re,cs:ce) = 1;
idx = find(mask==1);
p = abs(I(idx) - I(jj,kk)); p = exp(a*p);
countWM = countWM + 1; WM(countWM,idx) = p(:)';
end
end
ttime = toc; disp(sprintf('Time for generating weight matrix = %f',ttime)); clear countWM
% Weight between a node and iteself is 0
for jj = 1:H*W
WM(jj,jj) = 0;
end;
WM = sparse(WM);
% Shi and Malik Algorithm: second smallest eigen vector
disp('Finding Eigen Vector');
d = sum(WM,2); D = diag(d); tic
B = (D-WM); B = (B+B')/2; OPTS.disp = 0;
[v,d,flag] = eigs(B,D,2,'SA',OPTS); ttime = toc;
disp(sprintf('Time for finding eigen vector = %f',ttime)); clear OPTS
y = v(:,2);
Ncut = reshape(y,H,W);
Ncut = Ncut > 0;

热心网友 时间:2023-11-11 13:15

解决方案1:
直接用缉鼎光刮叱钙癸水含惊ifft();例如信号x
y=fft(x);%对信号傅里叶变换到频域
z=ifft(y);%对信号y傅里叶反变换到时域,

解决方案2:
工具箱啊。IFFT()函数

热心网友 时间:2023-10-20 12:17

function [Ncut] = graphcuts(I,pad,MAXVAL)
% function [Ncut] = graphcuts(I)
% Input: I image
% pad: spatial connectivity; eg. 3
% MAXVAL: maximum image value
% Output: Ncut: Binary map 0 or 1 corresponding to image segmentation
I = double(I); [H,W] = size(I);
% Find weights between nodes I1 and I2, w = exp(a*abs(I1-I2));
% Set a to have a weight of 0.01 for diff = MAXVAL
a = log(0.01)/MAXVAL; x = [0:MAXVAL/100:MAXVAL]'; y = exp(a*x);
figure;plot(x,y);xlabel('intensity diff');ylabel('weights'); title('weights')
ws = 2*pad + 1;
if(ws <= 3)
ws = 3;
end
%Build the weight matrix
disp('Building Weight Matrix'); close all; tic
WM = zeros(H*W,H*W); countWM = 0;
for kk = 1:W
for jj = 1:H
mask = logical(zeros(H,W));
cs = kk-pad; ce = kk+pad; rs = jj-pad; re = jj+pad;
if(cs<1)
cs = 1;
end;
if(ce>W)
ce = W;
end;
if(rs<1)
rs = 1;
end;
if(re>H)
re = H;
end;
mask(rs:re,cs:ce) = 1;
idx = find(mask==1);
p = abs(I(idx) - I(jj,kk)); p = exp(a*p);
countWM = countWM + 1; WM(countWM,idx) = p(:)';
end
end
ttime = toc; disp(sprintf('Time for generating weight matrix = %f',ttime)); clear countWM
% Weight between a node and iteself is 0
for jj = 1:H*W
WM(jj,jj) = 0;
end;
WM = sparse(WM);
% Shi and Malik Algorithm: second smallest eigen vector
disp('Finding Eigen Vector');
d = sum(WM,2); D = diag(d); tic
B = (D-WM); B = (B+B')/2; OPTS.disp = 0;
[v,d,flag] = eigs(B,D,2,'SA',OPTS); ttime = toc;
disp(sprintf('Time for finding eigen vector = %f',ttime)); clear OPTS
y = v(:,2);
Ncut = reshape(y,H,W);
Ncut = Ncut > 0;

热心网友 时间:2023-10-20 12:18

解决方案1:
直接用缉鼎光刮叱钙癸水含惊ifft();例如信号x
y=fft(x);%对信号傅里叶变换到频域
z=ifft(y);%对信号y傅里叶反变换到时域,

解决方案2:
工具箱啊。IFFT()函数

热心网友 时间:2023-10-20 12:17

function [Ncut] = graphcuts(I,pad,MAXVAL)
% function [Ncut] = graphcuts(I)
% Input: I image
% pad: spatial connectivity; eg. 3
% MAXVAL: maximum image value
% Output: Ncut: Binary map 0 or 1 corresponding to image segmentation
I = double(I); [H,W] = size(I);
% Find weights between nodes I1 and I2, w = exp(a*abs(I1-I2));
% Set a to have a weight of 0.01 for diff = MAXVAL
a = log(0.01)/MAXVAL; x = [0:MAXVAL/100:MAXVAL]'; y = exp(a*x);
figure;plot(x,y);xlabel('intensity diff');ylabel('weights'); title('weights')
ws = 2*pad + 1;
if(ws <= 3)
ws = 3;
end
%Build the weight matrix
disp('Building Weight Matrix'); close all; tic
WM = zeros(H*W,H*W); countWM = 0;
for kk = 1:W
for jj = 1:H
mask = logical(zeros(H,W));
cs = kk-pad; ce = kk+pad; rs = jj-pad; re = jj+pad;
if(cs<1)
cs = 1;
end;
if(ce>W)
ce = W;
end;
if(rs<1)
rs = 1;
end;
if(re>H)
re = H;
end;
mask(rs:re,cs:ce) = 1;
idx = find(mask==1);
p = abs(I(idx) - I(jj,kk)); p = exp(a*p);
countWM = countWM + 1; WM(countWM,idx) = p(:)';
end
end
ttime = toc; disp(sprintf('Time for generating weight matrix = %f',ttime)); clear countWM
% Weight between a node and iteself is 0
for jj = 1:H*W
WM(jj,jj) = 0;
end;
WM = sparse(WM);
% Shi and Malik Algorithm: second smallest eigen vector
disp('Finding Eigen Vector');
d = sum(WM,2); D = diag(d); tic
B = (D-WM); B = (B+B')/2; OPTS.disp = 0;
[v,d,flag] = eigs(B,D,2,'SA',OPTS); ttime = toc;
disp(sprintf('Time for finding eigen vector = %f',ttime)); clear OPTS
y = v(:,2);
Ncut = reshape(y,H,W);
Ncut = Ncut > 0;

热心网友 时间:2023-10-20 12:18

解决方案1:
直接用缉鼎光刮叱钙癸水含惊ifft();例如信号x
y=fft(x);%对信号傅里叶变换到频域
z=ifft(y);%对信号y傅里叶反变换到时域,

解决方案2:
工具箱啊。IFFT()函数
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
被培训机构骗了,他们耍无赖不退钱,如果我把他公司砸到他们骗走我的钱... 木地板的类型以及可以使用的拖把 冯小刚脸有红斑!可以去东北步行街特产店买百草之王人参!吃段时间就好... Empires &amp; Allies – 社交网络 UID 是什么?我如何找到它? Empires &amp; Allies – Regarder pour gagner (RG) – FAQ Empires &amp; Allies – 如何建造并升级基地营地? 男领导是喜欢这个女人吗? 地雷战纪念馆的主要展览 我想问一下打火机爆炸能伤人吗 万能焊条可以用打火机烧吗? 液晶材料的液晶材料国内行业现状 LCD拼接屏企业该如何找到自己的生存点呢? k-means和gmm在求解聚类问题中的异同 谱聚类算法的划分准则 谱聚类算法的算法的新进展 谱聚类算法的典型的算法 ncuts 意思 佳能r6拍完一张全黑照片后四周隐隐约约有小红点,正常吗? 将象和牌砭石艾灸罐的作用 佳能R6拍的图片用什么软件可以直接看图片 佳能r6拍出冷色系的照片 iqoo手机怎么自检电池 给老师写一封信作文的开头!!! 作文(给老师的一封信)开头怎么写 作文《写给老师的一封信》 开头怎么写 iphone6s手机生产日期怎么查询 如何查询iphone6s的生产日期 iphone 6s是怎么看生产日期 怎样查看iphone 6s出厂日期? 如何查询iphone6s手机的生产日期 TFT-LCD行业还能有多久的前景? C语言填幻方(不要穷举,要详细讲解) 贝叶斯mcmc的matlab程序怎么写 电子级磷酸市场调研报告40 线性分类器MATLAB程序 北方工业大学计算机专业好吗? LCD拼接屏主要跑哪些客户?客户一般会问到哪些问题? mcmc在r程序中用哪个软件包 TFT-LCD行业未来的发展前景有多大? 北方工业大学信息安全专业怎么样? LCD技术员的年终总结报告怎么写 北方工业大学的信息与计算科学是什么专业? 寻找一个用JAVA 写的计算器程序,要简洁的,可以发地址 北方工业大学 理学院 信息与计算科学 kmeans||最先在哪篇论文中出现 怎么在window7中打开shell并创建一个软连接 Linux系统对从Windows*享过来的文件,不支持创建软连接的解决办法。 Unix里的软连接和硬链接有什么区别?UNIX的常用命令有哪些? 小度在家1C4G版如果我的WIFI和4G流量同时打开,会使用哪个? 小度WiFi能接收WiFi热点吗