isfront.m

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

M
25
字号
function front = isfront( phi )% ISFRONT Determine whether a pixel is a front point%    ISFRONT( phi ) return binary matrix whose value at each pixel%    represents whether the corresponding pixel in phi is a front%    point or not.% grab the size of phi[ n, m ] = size( phi );% create an boolean matrix whose value at each pixel is 0 or 1% depending on whether that pixel is a front point or notfront = zeros( size( phi ) );% A piecewise linear approximation to the front is contructed by% checking each pixels neighbour. Do not check pixels on border.for i = 2 : n - 1;  for j = 2 : m - 1;    % if there is a sign change then we have a front point    maxVal = max( max( phi( i:i+1, j:j+1 ) ) );    minVal = min( min( phi( i:i+1, j:j+1 ) ) );    front( i, j ) = ( ( maxVal > 0 ) & ( minVal < 0 ) ) | phi( i, j ) == 0;  endend

⌨️ 快捷键说明

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