资源简介
使用GVF域和VFC域进行图片分割
% Vector field convolution (VFC) external force field example.
%
% See also AMT, EXAMPLE_PIG, AM_VFC, AM_VFK, AC_DISPLAY.
%
% Reference
% [1] Bing Li and Scott T. Acton, "Active contour external force using
% vector field convolution for image segmentation," Image Processing,
% IEEE Trans. on, vol. 16, pp. 2096-2106, 2007.
% [2] Bing Li and Scott T. Acton, "Automatic Active Model
% Initialization via Poisson Inverse Gradient," Image Processing,
% IEEE Trans. on, vol. 17, pp. 1406-1420, 2008.
%
% (c) Copyright Bing Li 2005 - 2009.
clear all
disp('======================================')
disp('Vector field convolution (VFC) example')
%% parameter settings
disp('Initializing parameters ...')
SAVE_AVI = 0; % set it to 1 if you want to save the process as .avi movie
DISPLAY_STREAMLINE = 0; % set it to 1 if you want to plot streamlines, note that it takes a while
mu = .2;
GVF_ITER = 100;
normalize = 1;
alpha = .5;
beta = 0;
tau = .5;
SNAKE_ITER = 5;
SNAKE_ITER1 = 60;
RES = .5;
clr = {'b' 'b' 'r'};
%% Read images
disp('Reading images ...')
U = imread('im_U.bmp');
noisyU=imread('im_Unoisy.bmp');
figure(1)
%% compare 3 different cases
for cs = 1:3,
%% compute external force fields
switch cs,
case 1, % traditional GVF with Gaussian filter
disp('--------------------------------------------------')
disp('Case 1: GVF snake with initial circle close to FOI')
disp('Computing the external force field ...')
h = fspecial('gaussian',[5 5],5);
f = imfilter(double(noisyU),h);
titl = 'GVF';
Fext = AM_GVF(f, mu, GVF_ITER, normalize);
R = 20;
case 2, % traditional GVF with Gaussian filter
disp('--------------------------------------------------')
disp('Case 2: GVF snake with initial circle far away from FOI')
disp('Computing the external force field ...
代码片段和文件信息
function vertex = AC_deform(vertexalphabetatauFextITERtype)
% AC_DEFORM Deform an active contour (AC) also known as snake.
% vertex1 = AC_DEFORM(vertex0alphabetatauFextiter)
% vertex1 = AC_DEFORM(vertex0alphabetatauFextitertype)
%
% Inputs
% vertex0 position of the vertices n-by-2 matrix each row of
% which is [x y]. n is the number of vertices.
% alpha AC elasticity (1st order) parameter ranges from 0 to 1.
% beta AC rigidity (2nd order) parameter ranges from 0 to 1.
% tau time step of each iteration.
% Fext the external force fieldd1-by-d2-by-2 matrix
% the force at (xy) is [Fext(yx1) Fext(yx2)].
% iter number of iterations usually ranges from 1 to 5.
% type ‘close‘ - close contour (default) the last vertex and
% first vertex are connected
% ‘open‘ - open contour the last vertex and first vertex
% are not connected
%
% Outputs
% vertex1 position of the vertices after deformation n-by-2 matrix
%
% Note that if the vertices are outside the valid range i.e. y>d1 ||
% y<1 || x>d2 || x<1 they will be pulled inside the valid range.
%
% Example
% See EXAMPLE_VFC EXAMPLE_PIG.
%
% See also AMT AM_VFC AM_VFK AM_PIG AC_INITIAL AC_REMESH
% AC_DISPLAY AM_GVF EXAMPLE_VFC EXAMPLE_PIG.
%
% Reference
% [1] Bing Li and Scott T. Acton “Active contour external force using
% vector field convolution for image segmentation“ Image Processing
% IEEE Trans. on vol. 16 pp. 2096-2106 2007.
% [2] Bing Li and Scott T. Acton “Automatic Active Model
% Initialization via Poisson Inverse Gradient“ Image Processing
% IEEE Trans. on vol. 17 pp. 1406-1420 2008.
%
% (c) Copyright Bing Li 2005 - 2009.
% Revision Log
% 11-30-2005 original
% 01-30-2006 external force interpolation outside the image
% 02-18-2006 add open contour codes
% 01-30-2009 minor bug fix
%% inputs check
if ~ismember(nargin 6:7) || ndims(Fext) ~= 3 || size(Fext3) ~= 2
error(‘Invalid inputs to AC_DEFORM!‘)
end
if nargin == 6
type = ‘close‘;
end
N = size(vertex1);
if size(vertex2) ~= 2
error(‘Invalid vertex matrix!‘)
end
if N < 3
return
end
%% compute T = (I + tao*A) of equation (9) in reference [1]
Lap = sparse(1:N 1:N -2) + sparse(1:N [N 1:N-1] 1) + sparse(1:N [2:N 1] 1);
if strcmp(type‘open‘) % offset tau for boundary vertices
tau = sparse(1:N 1:N tau);
tau(1) = 0;
tau(end) = 0;
offset = sparse(1:N 1:N 1);
offset(11)=0; offset(NN) = 0;
offset(12)=1; offset(NN-1) = 1;
Lap = offset*Lap;
end
T =sparse(1:N1:N1)+ tau*(beta*Lap*Lap-alpha*Lap);
%% Another way to compute T for close AC
% a
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-06-17 17:31 AMT\
文件 4014 2009-02-01 05:48 AMT\AC_deform.m
文件 2223 2009-01-31 08:05 AMT\AC_display.m
文件 2391 2009-01-31 06:13 AMT\AC_initial.m
文件 3651 2009-01-31 08:09 AMT\AC_isoLine.m
文件 1813 2009-02-01 05:13 AMT\AC_quiver.m
文件 4108 2009-01-31 08:08 AMT\AC_remesh.m
文件 3777 2009-01-31 08:43 AMT\AM_CoD.m
文件 11139 2009-02-01 05:50 AMT\AM_FFS.m
文件 3629 2009-02-03 02:49 AMT\AM_gradient.m
文件 3063 2009-01-31 09:07 AMT\AM_gradient_c.c
文件 3157 2009-02-03 02:49 AMT\AM_GVF.m
文件 11490 2009-01-31 09:07 AMT\AM_GVF_c.c
文件 1979 2009-02-03 02:49 AMT\AM_laplacian.m
文件 7321 2009-01-31 09:07 AMT\AM_laplacian_c.c
文件 5122 2009-02-01 02:22 AMT\AM_PIG.m
文件 4755 2009-02-01 04:42 AMT\AM_VFC.m
文件 3033 2009-02-01 04:34 AMT\AM_VFK.m
文件 2538 2009-02-01 05:28 AMT\Contents.m
文件 5500 2010-02-26 16:34 AMT\example_pig.asv
文件 5488 2009-02-01 05:50 AMT\example_pig.m
文件 4888 2010-02-26 14:39 AMT\example_vfc.asv
文件 4921 2010-07-03 20:19 AMT\example_vfc.m
文件 41554 2010-06-18 12:46 AMT\Fext.mat
文件 78520 2009-01-23 22:03 AMT\im_lung.png
文件 574 2006-01-10 05:52 AMT\im_U.bmp
文件 574 2006-01-10 09:27 AMT\im_Unoisy.bmp
文件 18011 2006-03-08 22:33 AMT\licence.txt
文件 1174 2009-02-01 05:34 AMT\readme.txt
文件 2290146 2008-04-18 21:50 AMT\TIP.07.VFC.pdf
文件 2672665 2010-07-14 18:58 AMT\TIP.08.PIG.pdf
............此处省略0个文件信息
评论
共有 条评论