91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-26
  • 語言: Matlab
  • 標(biāo)簽: graphcut??

資源簡介

graphcut用于圖像分割的matlab代碼

資源截圖

代碼片段和文件信息

function?[Ncut]?=?graphcuts(IpadMAXVAL)
%?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);?[HW]?=?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(xy);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*WH*W);?countWM?=?0;
for?kk?=?1:W
for?jj?=?1:H
mask?=?logical(zeros(HW));
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:recs:ce)?=?1;
idx?=?find(mask==1);
p?=?abs(I(idx)?-?I(jjkk));?p?=?exp(a*p);
countWM?=?countWM?+?1;?WM(countWMidx)?=?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(jjjj)?=?0;?
end;?
WM?=?sparse(WM);
%?Shi?and?Malik?Algorithm:?second?smallest?eigen?vector
disp(‘Finding?Eigen?Vector‘);
d?=?sum(WM2);?D?=?diag(d);?tic
B?=?(D-WM);?B?=?(B+B‘)/2;?OPTS.disp?=?0;
[vdflag]?=?eigs(BD2‘SA‘OPTS);?ttime?=?toc;
disp(sprintf(‘Time?for?finding?eigen?vector?=?%f‘ttime));?clear?OPTS
y?=?v(:2);
Ncut?=?reshape(yHW);
Ncut?=?Ncut?>?0;

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????1596??2013-03-07?12:18??graphcuts.m
?????文件????????1307??2014-02-12?14:19??license.txt

評(píng)論

共有 條評(píng)論