资源简介
简单,明确,适合初学者,代码可以直接运行,自带图片
代码片段和文件信息
% Region based Active Contour Segmentation
%
% seg = region_seg(Iinit_maskmax_itsalphadisplay)
%
% Inputs: I 2D image
% init_mask Initialization (1 = foreground 0 = bg)
% max_its Number of iterations to run segmentation for
% alpha (optional) Weight of smoothing term
% higer = smoother. default = 0.2
% display (optional) displays intermediate outputs
% default = true
%
% Outputs: seg Final segmentation mask (1=fg 0=bg)
%
% Description: This code implements the paper: “Active Contours Without
% Edges“ By Chan Vese. This is a nice way to segment images whose
% foregrounds and backgrounds are statistically different and homogeneous.
%
% Example:
% img = imread(‘tire.tif‘);
% m = zeros(size(img));
% m(33:33+11744:44+128) = 1;
% seg = region_seg(imgm500);
%
% Coded by: Shawn Lankton (www.shawnlankton.com)
%------------------------------------------------------------------------
function seg = region_seg(Iinit_maskmax_itsalphadisplay)
%-- default value for parameter alpha is .1
if(~exist(‘alpha‘‘var‘))
alpha = .2;
end
%-- default behavior is to display intermediate outputs
if(~exist(‘display‘‘var‘))
display = true;
end
%-- ensures image is 2D double matrix
I = im2graydouble(I);
%-- Create a signed distance map (SDF) from mask
phi = mask2phi(init_mask);
%--main loop
for its = 1:max_its % Note: no automatic convergence test
idx = find(phi <= 1.2 & phi >= -1.2); %get the curve‘s narrow band
%-- find interior and exterior mean
upts = find(phi<=0); % interior points
vpts = find(phi>0); % exterior points
u = sum(I(upts))/(length(upts)+eps); % interior mean
v = sum(I(vpts))/(length(vpts)+eps); % exterior mean
F = (I(idx)-u).^2-(I(idx)-v).^2; % force from image information
curvature = get_curvature(phiidx); % force from curvature penalty
dphidt = F./max(abs(F)) + alpha*curvature; % gradient descent to minimize energy
%-- maintain the CFL condition
dt = .45/(max(dphidt)+eps);
%-- evolve the curve
phi(idx) = phi(idx) + dt.*dphidt;
%-- Keep SDF smooth
phi = sussman(phi .5);
%-- intermediate output
if((display>0)&&(mod(its20) == 0))
showCurveAndPhi(Iphiits);
end
end
%-- final output
if(display)
showCurveAndPhi(Iphiits);
end
%-- make mask from SDF
seg = phi<=0; %-- Get mask from levelset
%---------------------------------------------------------------------
%---------------------------------------------------------------------
%-- AUXILIARY FUNCTIONS ----------------------------------------------
%---------------------------------------------------------------------
%---------------------------------------------------------------------
%-- Displays the image with curve superimposed
function showCurveAn
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7871 2008-09-04 10:43 主动轮廓模型分割程序\airplane.jpg
文件 6207 2008-09-04 10:43 主动轮廓模型分割程序\region_seg.m
文件 618 2008-09-04 10:45 主动轮廓模型分割程序\region_seg_demo.m
目录 0 2012-11-09 10:35 主动轮廓模型分割程序
----------- --------- ---------- ----- ----
14696 4
- 上一篇:PL_Simuli
nk.slx - 下一篇:Matlab三次样条插值函数
相关资源
- 基于lab空间的图像分割
- MATLAB大脑腔体图像分割
- LAB空间分别提取红色、绿色、紫色、
- 图像分割matlab
- 模糊聚类图像分割FCM/FLICM等
- ASM二维图像分割MATLAB代码
- matlab 静态图像分割
- 基于信息熵方法的多阈值图像分割算
- KFCM与FCM进行脑电图分割
- 纹理图像分割Matlab源代码 PDF PPT
- 基于变分水平集的图像分割
- MATLAB简介+图像轮廓线提取+图像分割技
- 遗传算法图像分割matlab+源代码
- 用matlab写的图像分割的代码
- MRI图像分割
- 基于颜色的图像分割算法MATLAB代码
- 一种效果极好的交互式图像分割算法
- GVFSnake(matlab)边缘检测和图像分割
- LBF和LDF模型的matlab程序,用于图像分
- 图像分割分形算法
- 基于形态学的图像分割算法研究
- 基于Matlab实现的图像分割的常用算法
- 图像分割源代码(Matlab)
- 基于FCN的侧扫声呐图像分割matlab代码
- MATLAB 彩色图像分割
- 图像分割程序matlab版
- Chan-Vese算法的MATLAB代码
- 细胞图像分割与计数
- 基于图像轮廓的图像分割程序 matlab
- 使用FCM进行图像分割
评论
共有 条评论