水平集图像分割序列——CV模型

1. 参考文献



2. CV模型代码

2.1 CV 模型代码

%demo_CV.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('CV 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


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部