demo_cv.m

来自「实现无边界主动轮廓的的很好的算法」· M 代码 · 共 53 行

M
53
字号
%   Matlad code implementing Chan-Vese model in the paper 'Active Contours Without Edges'
%   Author: Chunming Li, all right reserved
%   email: li_chunming@hotmail.com
%   URL:   http://www.engr.uconn.edu/~cmli/research/

clear all;
clc;
Img=imread('house.tif');   
% Img=imread('vessel3.bmp');  
Img=double(Img(:,:,1));

% get the size
[nrow,ncol] =size(Img);

ic=nrow/2;
jc=ncol/2;
r=40;
initialLSF = sdf2circle(nrow,ncol,ic,jc,r);
u=initialLSF;

numIter = 500;
timestep = 0.1;
lambda_1=1;
lambda_2=1;
nu=0;
h = 1;
epsilon=1;
mu =0.00001*255*255;  % tune this parameter for different images

figure;
imagesc(Img,[0 255]);
colormap(gray)
hold on;
contour(u,[0 0],'r');


% % start level set evolution
mov=avifile('example7.avi');
for k=1:numIter
    u=EVOL_CV(Img, u, mu, nu, lambda_1, lambda_2, timestep, epsilon, 1);   % update level set function
    if mod(k,10)==0
        pause(.00005);
        imagesc(Img,[0 255]);colormap(gray)   %每次都读入图像
        hold on;
        contour(u,[0 0],'r');
        hold off;
    end
    F = getframe(gca);
    mov = addframe(mov,F);
end;
hold off
mov = close(mov);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?