1 简介

图像分割是计算机视觉中的关键步骤之一。传统的分割方法由于方法自身的局部性,难以满足复杂分割的要求,基于水平集方法的图像分割研究正是这种需求下出现的。C-V模型对灰度图像的变化处理非常自然,解决了M-S模型难以解决的问题,而C-V模型应用于彩色图像极大地推动了彩色图像分割的研究。 本文主要研究了基于水平集方法的彩色图像分割方法。首先介绍本论文的课题背景、目标与意义,基于水平集方法的彩色图像分割方法研究进展以及本论文的主要工作和结构安排。其次介绍了彩色图像分割基础,从彩色空间与纹理特征两个方面分析了常用彩色图像分割方法存在的问题。接着,重点阐述了彩色图像分割的常用方法。然后,讲述了图像分割的偏微分方程PDE( Partial Differential Equation)的解法以及水平集的重要概念。在此基础上,又介绍了C-V模型图像分割的方法,将基于传统C-V方法的RGB颜色模型与HSV颜色模型的图像分割实验进行了比较并通过MATLAB软件对图片进行了分割,实验结果验证了算法的有效性。【图像分割】基于 C-V模型水平集图像分割Matlab代码_彩色图像

2 部分代码

%   Matlad code implementing Chan-Vese model in the paper 'Active Contours Without Edges'

%  

clear all;

close all;

Img=imread('Head.bmp');   

% Img=imread('vessel3.bmp'); % Note: this an example of images with intensity inhomogeneity. 

                             % CV model does not work for this image. 

Img=double(Img(:,:,1));


% get the size

[nrow,ncol] =size(Img);


ic=nrow/2;

jc=ncol/2;

r=10;  %起始园半径

initialLSF = sdf2circle(nrow,ncol,ic,jc,r);

u=initialLSF;



numIter = 200;

timestep = 0.5;

lambda_1=1;

lambda_2=1;

% h = 1;

h = 1;

epsilon=1;

nu = 0.001*255*255;  % tune this parameter for different images


% figure;

% imagesc(Img,[0 255]);colormap(gray)

% hold on;

% contour(u,[0 0],'r');



% start level set evolution

% for k=1:numIter

%     u=EVOL_CV(Img, u, nu, lambda_1, lambda_2, timestep, epsilon, 1);   % update level set function

%     if mod(k,10)==0

%         pause(.1);

%         imagesc(Img,[0 255]);colormap(gray)

%         hold on;

%         contour(u,[0 0],'r');

%         hold off;

%     end    

% end;


% start level set evolution

% figure;

% imagesc(Img, [0, 255]);colormap(gray);hold on;

% contour(u,[0 0],'r');                          

% title('Initial contour');   


for k=1:numIter

    u=EVOL_CV(Img, u, nu, lambda_1, lambda_2, timestep, epsilon, 1);   % update level set function

    if mod(k,10)==0

        pause(.1);

        imagesc(Img,[0 255]);colormap(gray)

         hold on;

        contour(u,[0 0],'r'); 

        iterNum=[num2str(k), ' iterations'];        

        title(['process of evolution,',iterNum]);

        hold off;

    end    

end;


figure;

imagesc(Img, [0, 255]);colormap(gray);hold on;

contour(u,[0 0],'r'); 

totalIterNum=[num2str(k), ' iterations'];  

title(['Final contour, ', totalIterNum]);


​3 仿真结果

【图像分割】基于 C-V模型水平集图像分割Matlab代码_图像分割_02

【图像分割】基于 C-V模型水平集图像分割Matlab代码_图像分割_03

4 参考文献

[1]李永军. 基于C-V模型水平集方法的彩色图像分割研究. Diss. 苏州大学.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

【图像分割】基于 C-V模型水平集图像分割Matlab代码_彩色图像_04