]> AND Private Git Repository - these_gilles.git/blob - THESE/codes/snake/gvf_dist_v4.2c/snake/snakeinit.m
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
27 aout
[these_gilles.git] / THESE / codes / snake / gvf_dist_v4.2c / snake / snakeinit.m
1 function [x,y] = snakeinit(delta)
2 %SNAKEINIT  Manually initialize a 2-D, closed snake 
3 %   [x,y] = SNAKEINIT(delta)
4 %
5 %   delta: interpolation step
6
7 %   Chenyang Xu and Jerry L. Prince, 4/1/95, 6/17/97
8 %   Copyright (c) 1995-97 by Chenyang Xu and Jerry L. Prince
9 %   Image Analysis and Communications Lab, Johns Hopkins University
10
11 hold on
12
13 x = [];
14 y = [];
15 n =0;
16
17 % Loop, picking up the points
18 disp('Left mouse button picks points.')
19 disp('Right mouse button picks last point.')
20
21 but = 1;
22 while but == 1
23       [s, t, but] = ginput(1);
24       n = n + 1;
25       x(n,1) = s;
26       y(n,1) = t;
27       plot(x, y, 'r-');
28 end   
29
30 plot([x;x(1,1)],[y;y(1,1)],'r-');
31 hold off
32
33 % sampling and record number to N
34 x = [x;x(1,1)];
35 y = [y;y(1,1)];
36 t = 1:n+1;
37 ts = [1:delta:n+1]';
38 xi = interp1(t,x,ts);
39 yi = interp1(t,y,ts);
40 n = length(xi);
41 x = xi(1:n-1);
42 y = yi(1:n-1);
43
44
45
46