资源简介

实现snake算法的源程序,对源程序的英文注释做了翻译。 程序同时实现了GVFsnake算法,同时加入了气球力对snake算法进行改进。

资源截图

代码片段和文件信息

function J=DrawSegmentedArea2D(PIsize)
% Draw the contour as one closed line in a logical image 
% and make the inside of the contour true with imfill
%
%  J=DrawSegmentedArea2D(PIsize)
%
% inputs
%  P : The list with contour points 2 x N
%  Isize : The size of the output image [x y]
%
% outputs
%  J : The binary image with the contour filled
%
% example:
%   y=[182 233 251 205 169];
%   x=[163 166 207 248 210];
%   P=[x(:) y(:)];
%
%   J=DrawSegmentedArea(P[400 400]);
%   figure imshow(J); 
%   hold on; plot([P(:2);P(12)][P(:1);P(11)]);
%
% Function is written by D.Kroon University of Twente (July 2010)


J=false(Isize+2);
% Loop through all line coordinates
x=round([P(:1);P(11)]); x=min(max(x1)Isize(1));
y=round([P(:2);P(12)]); y=min(max(y1)Isize(2));
for i=1:(length(x)-1)
   % Calculate the pixels needed to construct a line of 1 pixel thickness
   % between two coordinates.
   xp=[x(i) x(i+1)];  yp=[y(i) y(i+1)]; 
   dx=abs(xp(2)-xp(1)); dy=abs(yp(2)-yp(1));
   if(dx==dy)
     if(xp(2)>xp(1)) xline=xp(1):xp(2); else xline=xp(1):-1:xp(2); end
     if(yp(2)>yp(1)) yline=yp(1):yp(2); else yline=yp(1):-1:yp(2); end
   elseif(dx>dy)
     if(xp(2)>xp(1)) xline=xp(1):xp(2); else xline=xp(1):-1:xp(2); end
     yline=linspace(yp(1)yp(2)length(xline));
   else
     if(yp(2)>yp(1)) yline=yp(1):yp(2); else yline=yp(1):-1:yp(2); end
     xline=linspace(xp(1)xp(2)length(yline));   
   end
   % Insert all pixels in the fill image
   J(round(xline+1)+(round(yline+1)-1)*size(J1))=1;
end
J=bwfill(J11); J=~J(2:end-12:end-1);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1895  2011-05-01 19:31  imgaussian.m

     文件        962  2011-05-09 15:50  InterpolateContourPoints2D.m

     文件        486  2011-05-01 17:56  MakeContourClockwise2D.m

     文件       8377  2011-05-04 23:26  SeparateKernel.m

     文件       5099  2011-05-01 17:15  Snake2D.m

     文件        768  2011-05-04 21:29  SnakeInternalForceMatrix2D.m

     文件       1110  2011-05-04 21:39  SnakeMoveIteration2D.m

     文件        649  2011-06-01 22:21  testGVF.m

     文件       2367  2010-07-07 16:27  testimage.png

     文件       1328  2010-07-08 16:46  testimage2.png

     文件       1613  2010-07-12 14:12  DrawSegmentedArea2D.m

     文件        842  2011-05-01 19:07  ExternalForceImage2D.m

     文件        567  2011-05-04 22:03  GetContourNormals2D.m

     文件       1042  2011-05-04 20:52  GVFOptimizeImageForces2D.m

     文件        967  2011-05-01 19:19  ImageDerivatives2D.m

----------- ---------  ---------- -----  ----

                28072                    15


评论

共有 条评论