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

📄 adaptivescript.m

📁 这是一个利用水平集方法进行分割的方法
💻 M
字号:
% ADAPTIVESCRIPT Script to open image file, set initial circle, and% run narrow band algorithm on several different sizes of the% image.% constantsclear close allglobal ITERATIONS;ITERATIONS = 25;display_it = 100;movie_it = inf;scales = [ 0.1, 0.25, 0.375, 0.5, 0.75, 1.0 ];iterations = [ 5000, 4000, 3000, 2000, 1000, 500 ];% grab the image filename and path[ filename, pathname ] = uigetfile( '*', 'Select an image to segment' );% if user cancelled dialog box then exitif( filename == 0 )  return;end;% otherwise open the image and display itim = readimage( strcat( pathname, filename ) );im_resized = imresize( im, scales( 6 ) );%im_resized = imresize( im);imshow( uint8( im_resized ) );% and get the user to click on the circle centerdisp( 'Click on circle center' );center = ginput( 1 );% display the center and get the user to click again to define the% radiusdisp( 'Click again to define radius' );hold on;plot( center(1), center(2), 'go-' );hold off;radius = round( sqrt( sum( ( center - ginput( 1 ) ).^2 ) ) )% Get the user to pick whether the circle contains the objectdisp( 'Choose whether or not entire object is inside circle' );disp( '1. Completely Inside' );disp( '2. Not Completely Inside' );inside = 0;while( inside ~= 1 & inside ~= 2 )  inside = input( 'Please pick (1) or (2): ' );end;% determine movie namemoviename = filename( 1 : strfind( filename, '.' ) - 1 );% initialize phi to signed distance functionphi = initphi( size( im_resized ), circshift( center, [ 0, 1 ] ), radius, inside );% and run the level set segmentationfor i = 1 : size( iterations, 2 );%for i = 1 : 2;% setup adaptive parameters  ITERATIONS = iterations( i );  im_resized = imresize( im, scales( i ) );  phi = imresize( phi, size( im_resized ) );  % perform segmentation at i'th level  phi = levelsetbandadaptive( im_resized, display_it, movie_it, moviename, phi );end;im_segmented = createimage( im, phi );% display the segmented image and save it to diskclf; imshow( im_segmented ); drawnow;imwrite( im_segmented, strcat( moviename, '_segmented.png' ) );

⌨️ 快捷键说明

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