基于GVF和VFC的主动轮廓模型在图像分割中的应用

使用GVF域和VFC域进行图片分割。代码如下:

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' '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 ...')
h = fspecial('gaussian',[5 5],5);
f = imfilter(double(noisyU),h);
titl = 'GVF';
Fext = AM_GVF(f, mu, GVF_ITER, normalize);
R = 28;
        case 3,
            % VFC
disp('-----')
disp('Case 3: VFC snake with initial circle far away from FOI')
disp('Computing the external force field ...')
f = noisyU;
K = AM_VFK(2, 32, 'power',1.8);
Fext = AM_VFC(f, K, 1);
R = 28;
titl = 'VFC';
    end
    %% display
    I = (1-noisyU)*.3+.7; % for display
    subplot(2,3,cs)
    disp('Displaying the external force field ...')
    if DISPLAY_STREAMLINE,
        cla
        [x y] = meshgrid(.5:64,.5:64);
        vt = [x(:) y(:)]; % seeds
        VT = zeros([size(vt) 40]);
        VT(:,:,1) = vt;
        for i = 1:39,
            % moving these seeds
            vt = AC_deform(vt,0,0,tau,Fext,1);
            VT(:,:,i+1) = vt;
        end
        [Ty Tx] = find(~U); % ground truth
        hold on
        for i = 1:size(vt,1),
            if min(abs(VT(i,1,end)-Tx)+abs(VT(i,2,end)-Ty))

参考文献:

  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.
zip 文件大小:4.58MB