You are on page 1of 1

[m,n] = size(f); fmin = min(f(:)); fmax = max(f(:)); f = (f-fmin)/(fmax-fmin); % Normalize f to the range [0,1] f = BoundMirrorExpand(f); [fx,fy] = gradient(f); u = fx;

v = fy; SqrMagf = fx.*fx + fy.*fy; % % % % Take care of boundary condition Calculate the gradient of the edge map Initialize GVF to the gradient Squared magnitude of the gradient field

% Iteratively solve for the GVF u,v for i=1:ITER, u = BoundMirrorEnsure(u); v = BoundMirrorEnsure(v); u = u + mu*4*del2(u) - SqrMagf.*(u-fx); v = v + mu*4*del2(v) - SqrMagf.*(v-fy); fprintf(1, '%3d', i); if (rem(i,20) == 0) fprintf(1, '\n'); end end fprintf(1, '\n'); u = BoundMirrorShrink(u); v = BoundMirrorShrink(v);

You might also like