How do I find and how do I change the starting point of the active contour?
3 次查看(过去 30 天)
显示 更早的评论
Hi
I use the below code for automated segmentation. It is granted, that every time the circular active snake contour will start at the lower left corner of the image and keep evolving.
How can I change the starting point of the contour? Where is this located in the code below?
Thank you
clc;clear all;close all;
Img=imread('A6_(14.9N).bmp');
Img = double(Img(:,:,1));
Img = imcrop(Img,[253.875 161.625 447 177]);
imadjust(Img);
imsharpen(Img);
histeq(Img);
adapthisteq(Img);
NumIter = 4000; %iterations
timestep=0.1; %time step
mu=0.1/timestep;% level set regularization term, please refer to "Chunming Li and et al. Level Set Evolution Without Re-initialization: A New Variational Formulation, CVPR 2005"
sigma = 5;%size of kernel
epsilon = 1;
c0 = 2; % the constant value
lambda1=1.05;%outer weight, please refer to "Chunming Li and et al, Minimization of Region-Scalable Fitting Energy for Image Segmentation, IEEE Trans. Image Processing, vol. 17 (10), pp. 1940-1949, 2008"
lambda2=1.0;%inner weight
%if lambda1>lambda2; tend to inflate
%if lambda1<lambda2; tend to deflate
nu = 0.001*255*255;%length term
alf = 20;%data term weight
figure,imagesc(uint8(Img),[0 255]),colormap(gray),axis off;axis equal
[Height Wide] = size(Img);
[xx yy] = meshgrid(1:Wide,1:Height);
phi = (sqrt(((xx - 64).^2 + (yy - 65).^2 )) - 17);
phi = sign(phi).*c0;
Ksigma=fspecial('gaussian',round(2*sigma)*2 + 1,sigma); % kernel
ONE=ones(size(Img));
KONE = imfilter(ONE,Ksigma,'replicate');
KI = imfilter(Img,Ksigma,'replicate');
KI2 = imfilter(Img.^2,Ksigma,'replicate');
figure,imagesc(uint8(Img),[0 255]),colormap(gray),axis off;axis equal,
hold on,[c,h] = contour(phi,[0 0],'r','linewidth',1); hold off
pause(0.5)
tic
for iter = 1:NumIter
phi =evolution_LGD(Img,phi,epsilon,Ksigma,KONE,KI,KI2,mu,nu,lambda1,lambda2,timestep,alf);
if(mod(iter,100) == 0)
figure(2),
imagesc(uint8(Img),[0 255]),colormap(gray),axis off;axis equal,title(num2str(iter))
hold on,[c,h] = contour(phi,[0 0],'r','linewidth',1); hold off
pause(0.02);
end
end
toc
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!