initphi.m
来自「这是一个利用水平集方法进行分割的方法」· M 代码 · 共 33 行
M
33 行
function phi = initphi( imsize, center, radius, isinside )% INITPHI Initialize the phi funcion% INITPHI( center, radius ) initializes the zero level level-set% of the phi function by the circle with the given center (x, y)% and radius. The size of phi is given by 'imsize'.% grab the requested size of phim = imsize( 1 ); n = imsize( 2 );% create a zero matrixphi = zeros( imsize );% go over each pixelfor i = 1 : m; for j = 1 : n; % get the sum of squares distance of the pixel from the center % of the circle distance = sqrt( sum( ( center - [ i, j ] ).^2 ) ); % set phi to be the signed distance from the pixel to the % circle's boundary, where the distance is positive for pixels % outside the boundary and negative for pixels inside the % boundary phi( i, j ) = distance - radius; if( isinside == 0 ) phi( i, j ) = -phi( i, j ); end endend
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?