📄 initdist.m
字号:
function newphi = initdist( phi, front )
% INITDIST Reinitialize to signed distance function
% INITDIST( phi, front ) Reinitializes all points in phi to the
% signed distance of the point to the front.
% grab the size of phi
[ m, n ] = size( phi );
% grab the total number of front points
n_front = size( front, 1 );
% fill the new phi function with zeros to start
newphi = zeros( size( phi ) );
% if there are no front points then return
if( n_front == 0 )
return;
end
% for every pixel
for i = 2 : m - 1;
for j = 2 : n - 1;
% find the front pixel it is closest to
closest_dist = inf;
for k = 1 : n_front;
dist = sum( ( front( k, : ) - [ i, j ] ).^2 );
if( dist < closest_dist )
closest_dist = dist;
end;
end;
% and reinitialize the distance
newphi( i, j ) = sign( phi( i, j ) ) * ceil( sqrt( closest_dist ) );
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -