⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 levelsetband.m

📁 这是一个利用水平集方法进行分割的方法
💻 M
字号:
function phi = levelsetband( im, center, radius, isinside, d_it, m_it, m_name )% LEVELSETBAND Segment the image using narrow band algorithm%    LEVELSETBAND( 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.% constantsdelta_t  = 0.001;ITERATIONS = 250;BAND_ITERATIONS = 100;BAND_WIDTH = 2;% initialize the phi functionphi = initphi( size( im ), center, radius, isinside );% calculate the stopping functionK_I = edgestop( im, 5, 2 );% keep track of iterationsiterations = 0;while( iterations < ITERATIONS )  % determine the front and narrow band points  [ x, y ] = find( isfront( phi ) );  front = [ x, y ];  [ x, y ] = find( isband( phi, front, BAND_WIDTH ) );  band = [ x, y ];  % update the narrow band for BAND_ITERATIONS  for kk = 1 : BAND_ITERATIONS;    % display current iteration    fprintf( 1, '%d\n', iterations );    % display the segmented image every 'd_it' iterations    if( mod( iterations, d_it ) == 0 )      disp( 'Displaying segmented image' );      segim = createimage( im, phi );      imshow( segim ); drawnow;    end;    % write current segmented image to file every 'm_it'    % iterations    if( mod( iterations, m_it ) == 0 )      disp( 'Saving movie frame to file' );      segim = createimage( im, phi );      filename = strcat( m_name, sprintf( '%06d', ( iterations / m_it ) + 1 ), '.png' );      imwrite( segim, filename );    end;    % calculate the speed, extend it, and update phi    speed = calcspeed( phi, K_I, front );    speed = extendspeedband( speed, front, band );    phi = phi - delta_t .* speed;    % increment number of iterations    iterations = iterations + 1;  end;end

⌨️ 快捷键说明

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