⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initphi.m

📁 matlab 代码为图像的分割
💻 M
字号:
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 phi
m = imsize( 1 ); n = imsize( 2 );

% create a zero matrix
phi = zeros( imsize );

% go over each pixel
for 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

  end
end

⌨️ 快捷键说明

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