www.pudn.com > levelsetImage.rar > extendspeed.m
function speed = extendspeed( speed, front )
% EXTENDSPEED Extends speed to non-front points
% EXTENDSPEED( speed, front ) Extends speed function to
% all pixels in 'speed'. For each non-front pixel, its speed is
% the same as the speed of the closest front pixel.
% grab the size of the speed matrix
[ m, n ] = size( speed );
% grab the total number of front points
n_front = size( front, 1 );
% for every pixel
for i = 1 : m;
for j = 1 : n;
% find the front pixel it is closest to
closest_dist = inf;
closest_pt = front( 1, : );
for k = 1 : n_front;
dist = sum( ( front( k, : ) - [ i, j ] ).^2 );
if( dist < closest_dist )
closest_dist = dist;
closest_pt = front( k, : );
end;
end;
% and copy its speed
speed( i, j ) = speed( closest_pt( 1 ), closest_pt( 2 ) );
end;
end;