extendspeedband.m

来自「这是一个利用水平集方法进行分割的方法」· M 代码 · 共 35 行

M
35
字号
function speed = extendspeedband( speed, front, band )% EXTENDSPEEDBAND Extends speed to non-front points%    EXTENDSPEEDBAND( speed, front ) Extends speed function to%    all pixels in a narrow band around 'front' given by the%    indices in 'band'. For each band 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 and band pointsn_front = size( front, 1 );n_band  = size( band, 1 );% for every pixel in the bandfor ii = 1 : n_band;  % grab the coordinates of the band pixel  i = band( ii, 1 ); j = band( ii, 2 );  % find the front pixel it is closest to  closest_dist = inf;  closest_pt = front( 1, : );  for kk = 1 : n_front;    dist = sum( ( front( kk, : ) - [ i, j ] ).^2 );    if( dist < closest_dist )      closest_dist = dist;      closest_pt = front( kk, : );    end;  end;  % and copy its speed  speed( i, j ) = speed( closest_pt( 1 ), closest_pt( 2 ) );end;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?