1. 参考文献

2. LBF模型

%demo_LBF.m
%Author: HSW
%Date;2015/4/12
%HARBIN INSTITUTE OF TECHNOLOGY
% Set Matlab
close all;
clear all;
clc;
% demo 编号,需要修改
ii = 1;
% Add path
addpath(genpath('Image\'));
addpath(genpath('LBF solver\'));% save result path
SaveFilePath = 'Results\';% Read Image
c0 = 2;
imgID = 6;Img = imread('Image\vessel2.bmp');
Temp = Img;if ndims(Img) == 3Img = rgb2gray(Img);
end
Img = double(Img);
% Initial phi is the level set function
switch imgIDcase 1phi= ones(size(Img(:,:,1))).*c0;a=43;b=51;c=20;d=28;phi(a:b,c:d) = -c0;figure;imshow(Temp);colormap;hold on;[c,h] = contour(phi, 0, 'r');hold off;case 2[m,n] = size(Img(:,:,1));a=m/2; b=n/2; r=min(m,n)/4;%set the radiusphi= ones(m,n).*c0;phi(a-r:a+r,b-r:b+r) = -c0;imshow(Temp);colormap;hold on;[c,h] = contour(phi, 0, 'r');hold off;case 3figure;imshow(Temp);colormap;text(6,6,'Left click to get points, right click to get end point','FontSize',12,'Color', 'g');BW=roipoly;     %BW is maskphi=c0*2*(0.5-BW);hold on;[c,h] = contour(phi,[0 0],'r');hold off;case 4%figure;imagesc(Img,[0,255]);colormap(gray);hold on; axis off; axis equal;figure;imshow(Temp);colormap;[x,y] = ginput(9);%set nine centre points of nine initial level set function[m,n] = size(Img);r = min(m,n)/6;   %we need to set the radiusphi= ones(m,n).*c0;for iter = 1:length(x)phi(x(iter)-r:x(iter)+r,y(iter)-r:y(iter)+r) = -c0;%initial zero level set is square%  initial zero level set is circle,this method is not recommended%             for i = 1:m%                 for j = 1:n%                     d = (i - x(iter))^2 + (j - y(iter))^2;%                     if d <= r^2%                         phi(i,j) = -c0;%                     end%if%                 end% j%             end% i%       上述注释部分为实现选择的中心点初始化为圆形,不推荐这种方法end% iterhold on;[c,h] = contour(phi,[0 0],'r');hold off;case 5%figure;imagesc(Img,[0,255]);colormap(gray);hold on; axis off; axis equal;figure;imshow(Temp);colormap;rNum = 1;% the cicle number in a rowcNum = 1;% the cicle number in a colcumn[m,n] = size(Img);phi= ones(m,n).*c0;r = min(m/(2*rNum),n/(2*cNum))/2;for i = 1:rNumfor j = 1:cNumpx = (2*i-1)*(m/(2*rNum));py = (2*j-1)*(n/(2*cNum));%(px,py) is the centre of the initial zero level set ciclefor x = 1:mfor y = 1:nd = (x-px)^2 + (y - py)^2;if d < r^2phi(x,y) = -c0;end%ifend%yend%xend%for jend%for ihold on;[c,h] = contour(phi,[0 0],'r');hold off;case 6% 产生随机位置figure;imshow(Temp);colormap;rand('seed',0);boardsize = 20; %距离边界的位置iscircle = 1; % 产生圆形,否则产生矩形r = 10; %产生圆形时为半径,产生矩形时为(1/2)*边长if r > boardsizer = boardsize;endpossiblex = (boardsize + 1): (size(Img,1) - boardsize);possibley = (boardsize + 1): (size(Img,2) - boardsize);labelx = randperm(length(possiblex));labely = randperm(length(possibley));centrex = possiblex(labelx(1));centrey = possibley(labely(1));[m,n] = size(Img);phi= -ones(m,n).*c0;if iscircle == 1% 产生圆形for x = 1:size(Img,1)for y = 1:size(Img,2)d = (x - centrex)^2 + (y - centrey)^2;if d <= r^2phi(x,y) = c0;endendendelse% 产生矩形for x = 1:size(Img,1)for y = 1:size(Img,2)phi(centrex-r:centrex+r,centrey - r:centrey + r) = c0;endendendhold on;[c,h] = contour(phi,[0 0],'r');hold off;case 7% 用鼠标获取中心位置figure;imshow(Temp);colormap;text('Press the Enter Button to end');[centrex,centrey] = ginput; % 按回车键结束if length(centrex) > 1centrex = centrex(1);centrey = centrey(1);endboardsize = 20; %距离边界的位置iscircle = 1; % 产生圆形,否则产生矩形r = 10; %产生圆形时为半径,产生矩形时为(1/2)*边长if r > boardsizer = boardsize;end[m,n] = size(Img);phi= -ones(m,n).*c0;if iscircle == 1% 产生圆形for x = 1:size(Img,1)for y = 1:size(Img,2)d = (x - centrex)^2 + (y - centrey)^2;if d <= r^2phi(x,y) = c0;endendendelse% 产生矩形for x = 1:size(Img,1)for y = 1:size(Img,2)phi(centrex-r:centrex+r,centrey - r:centrey + r) = c0;endendendhold on;[c,h] = contour(phi,[0 0],'r');hold off;
end%switch imgIDiterNum = 500; % the total number of the iteration
lambda1 = 1;   % the weight parameter of the globe term which is inside the level set
lambda2 = 1;   % the weight parameter of the globe term which is ouside the level set
mu = 0.002*255*255; % the weight parameter of the length term
nu = 0; % the weight parameter of the area term
pu = 1.0; %the weight parameter of the penalizing term
timestep = 0.1; % the time step of the level set function evolution
epsilon = 1.0; % the parameter of the Heaviside function and the Dirac delta function%scale parameter in Gaussian kernel
% this part code is for the LBF model and LIGF model
sigmaG = 3.0;
Klbf = fspecial('gaussian',round(2*sigmaG)*2+1,sigmaG); % Gaussian kernel
KIG = conv2(Img,Klbf,'same'); % KIG is the result of Gaussian kernel Klbf convol Img
KONE = conv2(ones(size(Img)),Klbf,'same'); % KONE is the convolution of Gaussian kernel Klbf convol all one matrix
Kligf = Klbf;% all model's initial level set is same
phi_LBF       = phi;
phi_star      = phi;
%
figure;
imshow(Temp); colormap; %start the level set evolution
% LBF MODEL
time = cputime;
for iter = 1:iterNumnumIter=1;%level set evolution.phi_LBF = EVOL_LBF(phi_LBF,Img,Klbf,KIG,KONE,mu,timestep,pu,lambda1,lambda2,epsilon,numIter);if mod(iter,10) == 0contour(phi_LBF,[0,0],'r');end
end %for
totaltime_LBF = cputime - time;% Display Results
figure;
imshow(Temp);
hold on;
contour(phi_star,[0,0],'r','linewidth',1);
title('Initial Level set');figure;
imshow(Temp);
hold on;
contour(phi_LBF,[0,0],'r','linewidth',1);
title('Results of LBF model');% Save Results
LBFFilePath = [SaveFilePath,'LBF\Demo',num2str(ii),'.bmp'];SaveLBF = phi_LBF >= 0;
imwrite(SaveLBF,LBFFilePath,'bmp');

2.2 LBF模型实现

function u = EVOL_LBF(u0,Img,K,KI,KONE,nu,timestep,mu,lambda1,lambda2,epsilon,numIter)
%  u = EVOL_LBF(u0,Img,Ksigma,KI,KONE,nu,timestep,mu,lambda1,lambda2,epsilon,numIter)u=u0;
for k1=1:numIteru=NeumannBoundCond(u);C=curvature_central(u);    % div()  HeavU=Heaviside(u,epsilon);DiracU=Dirac(u,epsilon);[f1,f2]=LBF_LocalBinaryFit(K,Img,KI,KONE,HeavU);    LBF=LBF_dataForce(Img,K,KONE,f1,f2,lambda1,lambda2);areaTerm=-DiracU.*LBF;penalizeTerm=mu*(4*del2(u)-C);lengthTerm=nu.*DiracU.*C;u=u+timestep*(lengthTerm+penalizeTerm+areaTerm);
end% Make a function satisfy Neumann boundary condition
function g = NeumannBoundCond(f)
[nrow,ncol] = size(f);
g = f;
g([1 nrow],[1 ncol]) = g([3 nrow-2],[3 ncol-2]);
g([1 nrow],2:end-1) = g([3 nrow-2],2:end-1);
g(2:end-1,[1 ncol]) = g(2:end-1,[3 ncol-2]);  function k = curvature_central(u)
% compute curvature for u with central difference scheme
[ux,uy] = gradient(u);
normDu = sqrt(ux.^2+uy.^2+1e-10);
Nx = ux./normDu;
Ny = uy./normDu;
[nxx,junk] = gradient(Nx);
[junk,nyy] = gradient(Ny);
k = nxx+nyy;function [f1,f2] = LBF_LocalBinaryFit(K,Img,KI,KONE,H)
I=Img.*H;
c1=conv2(H,K,'same');
c2=conv2(I,K,'same');
f1=c2./(c1);
f2=(KI-c2)./(KONE-c1);function h = Heaviside(x,epsilon)     % function (11)
h=0.5*(1+(2/pi)*atan(x./epsilon));function f = Dirac(x, epsilon)    % function (12)
f=(epsilon/pi)./(epsilon^2.+x.^2);function f=LBF_dataForce(Img,K,KONE,f1,f2,lamda1,lamda2)
s1=lamda1.*f1.^2-lamda2.*f2.^2;
s2=lamda1.*f1-lamda2.*f2;
f=(lamda1-lamda2)*KONE.*Img.*Img+conv2(s1,K,'same')-2.*Img.*conv2(s2,K,'same');

3. 模型效果

水平集图像分割序列——LBF模型相关推荐

  1. 水平集图像分割序列——多尺度LBF模型

    1. 背景 如下图所示,为LBF模型当水平集初始化位置不同时,分割效果不同: 分析其原因是,LBF模型是一个考虑局部区域的模型,当水平集演化到一个比较平坦的位置时,水平集演化速度将会迅速下降:为了克服 ...

  2. 水平集图像分割序列——Order LBF模型

    1. 参考文献 2. 模型实现 2.1 Order-LBF模型Demo %demo_Order_LBF.m %Author: HSW %Date:2015/4/12 %HARBIN INSTITUTE ...

  3. 基于水平集方法和G0模型的SAR图像分割

    基于水平集方法和G0模型的SAR图像分割 Abstract(摘要) 这篇文章提出了一种分割SAR图像的方法,探索利用SAR数据中的统计特性将图像分区域.我们假设为SAR图像分割分配参数,并与水平集模型 ...

  4. 水平集图像分割并行加速算法设计与实现(串行、OpenMP、CUDA)——串行实现篇

    本次水平集图像分割并行加速算法设计与实现包含:原理篇.串行实现篇.OpenMP并行实现篇与CUDA GPU并行实现篇四个部分.具体各篇章链接如下: 水平集图像分割并行加速算法设计与实现--原理篇 水平 ...

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

    1 简介 图像分割是计算机视觉中的关键步骤之一.传统的分割方法由于方法自身的局部性,难以满足复杂分割的要求,基于水平集方法的图像分割研究正是这种需求下出现的.C-V模型对灰度图像的变化处理非常自然,解 ...

  6. 图像分割之水平集(Level Set)分割

    几何活动轮廓模型--水平集分割:Active Contours Without Edges 水平集方法 水平集是跟踪轮廓和表面运动的一种数字化方法,它不直接对轮廓进行操作,而是将轮廓设置成一个高维函数 ...

  7. 基于水平集的图像分割方法

    一.引言 借鉴一些流体中的重要思想, 1988年,Osher和Sethian首次提出了水平集算法[1],这是一种有效解决曲线演化问题的数值方法,并且计算稳定,适宜任意维数空间.随后,Osher等人对水 ...

  8. 基于水平集LBF模型的图像边缘轮廓分割凸优化 - Split Bregman分裂布雷格曼算法的最优解

    目录 1. 凸优化简介 : 2. 次梯度(subgradient): 次梯度概念: 次梯度例子: 次梯度存在性: 3. Bregman距离(布雷格曼距离) : Bregman距离概念 : Bregma ...

  9. 图像分割 - 水平集算法

    水平集介绍 水平集分为三种: 1 . 基于图像边缘灰度梯度信息 ,适用于边缘强的图像分割 2 . 基于区域特征 ,利用区域信息引导曲线慢慢靠近 ,比如分割曲线区域的内外灰度均值,分割曲线内部区域面积( ...

最新文章

  1. verilog中数组的定义_开源仿真工具Icarus Verilog中的verilog parser
  2. QT界面操作1:如何跟踪鼠标位置?
  3. python的GUI之Tkinter的Label组件
  4. 【收藏】Windows编译安装Redis 6.0
  5. boost::incremental_components用法的测试程序
  6. Leetcode 279. Perfect Square
  7. 2017-2018-1 20155339 《信息安全系统设计基础》第三周学习总结
  8. jsp 内置对象 登录 cookie + session
  9. java 弱引用 使用场景_Java 强软弱虚引用介绍及使用场景
  10. vue 针试打印机实现
  11. 手把手教你申请计算机软件著作权(1)——填写软著申请表
  12. Flash实例教程:AS3代码简单表现照片底片效果
  13. 中文乱码——编码问题
  14. 边际效用递减推导需求曲线_软件需求曲线
  15. 灰度变换-位图切割(比特平面分层)
  16. Linux网卡中断使单个CPU过载
  17. Canvas入门篇(一)
  18. 论文阅读:FFA-Net: Feature Fusion Attention Network for Single Image Dehazing
  19. 闲的发慌系列01-家庭版NAS
  20. python卸载不干净_mysql卸载不干净解决方法

热门文章

  1. go 学习笔记之有意思的变量和不安分的常量
  2. Lesson 28 No parking 禁止停车
  3. 《Sequence to Sequence Learning with Neural Networks》阅读笔记
  4. pycharm定义空的二维数组_Excel VAB入门(二)数组和字典
  5. POI + PDFbox将PPT有图表页转换成图片
  6. Linux学习——Linux常用文件和目录管理命令(超详细)
  7. 电脑无XD软件查看XD文件
  8. bzoj 4044: [Cerc2014] Virus synthesis 回文树
  9. SAP-MM STO订单详解 3 (库存转储调拨单的后台配置)
  10. 黑客利用“我是查理”运动传播恶意软件