資源簡介
水平集圖像分割的Matlab程序代碼,搞圖像的人必不可少的利器啊
經(jīng)典的算法

代碼片段和文件信息
%?This?Matlab?program?demomstrates?the?level?set?algorithm?in?paper:
%????“Active?contours?with?selective?local?or?global?segmentation:?a?new?variational?approach?and?level?set?method“?
%????to?appear?in?Image?and?Vision?Computing?2010.?
%?Authors:?Kaihua?Zhang?Lei?Zhang?Huihui?Song?and?Wengang?Zhou
%?E-mail:?zhkhua@mail.ustc.edu.cn?cslzhang@comp.polyu.edu.hk?
%?URL:?http://www4.comp.polyu.edu.hk/~cslzhang/
%?Notes:Some?parameters?may?need?to?be?modified?for?different?types?of?images.?
%?Please?contact?the?authors?if?any?problem?regarding?the?choice?of?parameters.
%?Date:?5/11/2009
clc;clear?all;close?all;
Img?=?imread(‘twocells.bmp‘);
Img?=?Img(::1);
Img?=?double(Img);
%?Img?=?200*ones(100);
%?Img(20:8010:30)=?140;
%?Img(20:8040:70)=?180;
%?Img(20:8080:90)=50;
[rowcol]?=?size(Img);
phi?=?ones(rowcol);
phi(10:row-1010:col-10)?=?-1;
u?=?-?phi;
[c?h]?=?contour(u?[0?0]?‘r‘);
title(‘Initial?contour‘);
%?hold?off;
sigma?=?1;
G?=?fspecial(‘gaussian‘?5?sigma);
delt?=?1;
Iter?=?80;
mu?=?25;%this?parameter?needs?to?be?tuned?according?to?the?images
for?n?=?1:Iter
????[ux?uy]?=?gradient(u);
???
????c1?=?sum(sum(Img.*(u<0)))/(sum(sum(u<0)));%?we?use?the?standard?Heaviside?function?which?yields?similar?results?to?regularized?one.
????c2?=?sum(sum(Img.*(u>=0)))/(sum(sum(u>=0)));
????
????spf?=?Img?-?(c1?+?c2)/2;
????spf?=?spf/(max(abs(spf(:))));
????
????u?=?u?+?delt*(mu*spf.*sqrt(ux.^2?+?uy.^2));
????
????if?mod(n10)==0
????imagesc(Img[0?255]);?colormap(gray);hold?on;
????[c?h]?=?contour(u?[0?0]?‘r‘);
????iterNum?=?[num2str(n)?‘iterations‘];
????title(iterNum);
????pause(0.02);
????end
????u?=?(u?>=?0)?-?(?u0);%?the?selective?step.
????u?=?conv2(u?G?‘same‘);
end
imagesc(Img[0?255]);colormap(gray);hold?on;
[c?h]?=?contour(u?[0?0]?‘b‘);
????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????27512??2009-09-07?17:15??brain1.bmp
?????文件???????53910??2008-03-07?16:42??d.bmp
?????文件????????1862??2009-11-05?13:59??Demo.m
?????文件???????59014??2008-03-07?16:44??e.bmp
?????文件???????15120??2008-06-21?16:16??fin1.bmp
?????文件???????49186??2009-08-06?21:44??galaxy.jpg
?????文件???????26840??2008-03-26?18:54??h.bmp
?????文件???????47001??2009-08-06?20:23??lv1.JPG
?????文件???????68166??2009-08-06?21:17??lvmr1.bmp
?????文件???????34798??2009-08-06?19:11??narrow.bmp
?????文件???????34798??2009-08-09?10:12??nn.bmp
?????文件??????121976??2009-08-08?10:43??plane2.bmp
?????文件???????28173??2007-10-31?15:54??plane4.jpg
?????文件???????16434??2004-07-23?19:36??twocells.bmp
- 上一篇:STOI 短時客觀可懂度MATLAB代碼
- 下一篇:FFT的圖像配準
評論
共有 條評論