【圖像分割】基于水平集圖像分割LGIF模型實(shí)現(xiàn)醫(yī)學(xué)圖像分割附matlab代碼
1 簡(jiǎn)介
基于全局和局部圖像信息的水平集模型(LGIF模型),其基本思想是:在演化過(guò)程中,既利用圖像的全局信息,也利用圖像的局部信息來(lái)驅(qū)動(dòng)曲線的演化,LGIF模型其實(shí)就是將LIF模型和GIF模型(ACM with Global Image Fitting?model)兩者的優(yōu)點(diǎn)結(jié)合而形成的新模型,其中LIF模型表示圖像的局部信息項(xiàng),GIF模型表示圖像的全局信息項(xiàng)。因而,LGIF模型既具有LIF模型的優(yōu)點(diǎn),利用圖像的局部領(lǐng)域信息,可以在一定程度上處理灰度不均勻的圖像;也具有GIF模型的優(yōu)點(diǎn),運(yùn)用圖像的全局信息,使得LGIF模型對(duì)初始輪廓的位置不敏感。其中,LIF模型的能量泛函定義如下:





2 部分代碼
% ? Matlab code implementing Chan-Vese model in the paper 'Active Contours Without Edges'
% ? This method works well for bimodal images, for example the image 'three.bmp'
clc
clear all
close all
c0 =2;
imgID=2;
Img=imread('cq391.jpg'); ? ?
U=Img(:,:,1);
% the initial level set
switch imgID
? ? case 1
? ? ? phi= ones(size(Img(:,:,1))).*c0;
? ? ? a=43;b=51;c=20;d=28;
? ? ? phi(a:b,c:d) = -c0;
? ? ? figure;
? ? ? imshow(Img);colormap;
? ? ? hold on;
? ? ? plotLevelSet(phi, 0, 'g');
? ? ? hold off;
? ?case 2
? ? ? [m,n]=size(Img(:,:,1));
? ? ? a=m/2; b=n/2;r=5;
? ? ? phi= ones(m,n).*c0;
? ? ? phi(a-r:a+r,b-r:b+r) = -c0;
? ? ? imshow(Img);colormap;
? ? ? hold on;
? ? ? plotLevelSet(phi, 0, 'r');
? ? ? hold off;
? ?case 3
? ? ? figure;imagesc(Img, [0, 255]);colormap(gray);hold on; axis off;axis equal;
? ? ? text(6,6,'Left click to get points, right click to get end point','FontSize',[12],'Color', 'g');
? ? ? BW=roipoly;
? ? ? phi=c0*2*(0.5-BW);
? ? ? hold on;
? ? ? [c,h] = contour(phi,[0 0],'r');
? ? ? hold off;
end
pause(1);
%參數(shù)選擇
pause(0.1);
lambda=0.001*255*255;
lambda1=1.0;
lambda2=1.0;
delta_t =0.1;
epsilon=1;
mu =1;
numIter = 1;
% CV和LBF的權(quán)重
Img=double(U);
M=0.05;
% scale parameter in Gaussian kernel
sigma=3.0; ?
K=fspecial('gaussian',round(2*sigma)*2+1,sigma); % Gaussian kernel
KI=conv2(Img,K,'same'); ?
KONE=conv2(ones(size(Img)),K,'same');
% start level set evolution
time = cputime;
for k=1:1000
? phi = evolution_LGIF(Img,K,KI,KONE,phi,M,lambda1,lambda2,mu,lambda,delta_t,epsilon,numIter); ?% update level set function
? ?if mod(k,5)==0
? ? ? ?pause(0.01);
? ? ? ?imagesc(Img, [0, 255]);colormap(gray);hold on; axis off;
? ? ? ?contour(phi,[0 0],'r');
? ? ? ?iterNum=[num2str(k), ' iterations'];
? ? ? ?title(iterNum);
? ? ? ?hold off;
? ?end ? ?
end
totaltime = cputime - time;
imagesc(Img, [0, 255]);colormap(gray);hold on; axis off;
contour(phi,[0 0],'r');
iterNum=[num2str(k), ' iterations'];
title(iterNum);
3 仿真結(jié)果

4 參考文獻(xiàn)
[1]管觀華. 基于水平集方法的胰腺圖像分割研究.?
博主簡(jiǎn)介:擅長(zhǎng)智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)、信號(hào)處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無(wú)人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問(wèn)題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。
