📄 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -