levelsetorig.m

来自「这是一个利用水平集方法进行分割的方法」· M 代码 · 共 55 行

M
55
字号
function phi = levelsetorig( im, center, radius, isinside, d_it, m_it, m_name )% LEVELSETORIG Segment the image%    LEVELSETORIG( im, center, radius, isinside, d_it, m_it, m_name )%    Segment the image im using level sets, given that the%    zero-level, level-set is a circle with the argument center and%    radius. The current segmented image is displayed every d_it%    iterations and written to disk every m_iterations with name%    m_name*.png.% constantsITERATIONS = 1000;delta_t  = 0.0005;% initialize the phi functionphi = initphi( size( im ), center, radius, isinside );% calculate the stopping functionim = double(im);K_I = edgestop( im, 5, 3.25 );for ii = 1 : ITERATIONS;  % display current iteration  fprintf( 1, '%d\n', ii );  % display the segmented image every 'd_it' iterations  if( mod( ii - 1, d_it ) == 0 )    disp( 'Displaying Segmented Image' );    segim = createimage( im, phi );    clf; imshow( segim );    drawnow;  end;  % write current segmented image to file every 'm_it'  % iterations  if( mod( ii - 1, m_it ) == 0 )    segim = createimage( im, phi );    filename = strcat( m_name, sprintf( '%06d', ( ( ii - 1 )/ m_it ) + 1 ), '.png' );    imwrite( segim, filename );  end;  % determine the indices of the front points  [ x, y ] = find( isfront( phi ) );  front = [ x, y ];  % calculate the speed at those points and then globally extend  % the speed to all the other points  speed = calcspeed( phi, K_I, front );  speed = extendspeed( speed, front );  % update phi  phi = phi - delta_t * speed;end

⌨️ 快捷键说明

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