1 % EXAMPLE an example of traditional snake on U-shape image
4 % Chenyang Xu and Jerry Prince 6/17/97
5 % Copyright (c) 1996-97 by Chenyang Xu and Jerry Prince
7 cd ..; s = cd; s = [s, '/snake']; path(s, path); cd examples;
10 % ==== Example 1: U-shape object ====
12 % Read in the 64x64 U-shape image
13 %[I,map] = rawread('../images/cochon64.pgm');
14 I = imread('../images/cochon128.pgm');
15 % Compute its edge map,
16 disp(' Compute edge map ...');
18 f0 = gaussianBlur(f,1);
19 % note: snake potential is the negative of edge map
20 disp(' Comute the traditional external force ...');
21 [px,py] = gradient(f0);
25 subplot(121); imdisp(-f); title('snake potential');
26 subplot(122); quiver(px,py);
27 axis('square', 'equal', 'off', 'ij'); % fix the axis
28 title('traditional force');
32 disp(' Press any key to start the deformation');
34 figure(1); subplot(121); cla;
35 colormap(gray(64)); image(((1-f)+1)*40);
36 axis('square', 'equal', 'off');
38 disp('... Now capture range is small, use closer initialization.')
42 [x,y] = snakeinterp(x,y,2,0.5);
46 disp('... Press <CTRL>-C to stop the program at any time.');
48 [x,y] = snakedeform(x,y,5,0,0.1,5,px,py,5);
49 [x,y] = snakeinterp(x,y,2,0.5);
51 title(['Deformation in progress, iter = ' num2str(i*5)])
56 disp(' Press any key to display the final result');
59 colormap(gray(64)); image(((1-f)+1)*40); axis equal
61 title(['Final result, iter = ' num2str(i*5)]);