• 大小: 8KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-13
  • 语言: Matlab
  • 标签:

资源简介

用matlab实现了水平集的方法,文件夹解压后加入图片即可运行

资源截图

代码片段和文件信息

%%计算符号函数
function tag=Create_Tag(curve)%%curve=1代表边界线
[mn]=size(curve);

%%%状态标记Accepted:0Fararway:1存储在tag中
tag=zeros(mn);
T=zeros(mn);
for i=1:m
   for j=1:n
       if(curve(ij)==1)
           tag(ij)=0;
       else
           tag(ij)=1;
       end
   end
end


%%开辟两个数组用来存储压栈时的坐标值
%%设置种子点坐标为kt

%%找种子点
seedi=zeros(1m);
seedj=zeros(1n);
stacki=0;
stackj=0;
sizei=size(stacki2);
% sizej=size(stackj2);
for i=1:m
    count=0;
    for j=1:n
        if(curve(ij)==1)
            count=count+1;
            seedi(count)=i;
            seedj(count)=j;
        end
    end
    if(count>1 && mod(count2)==0)
        for t1=1:2:count
            if(seedj(t1+1)-seedj(t1)==1)
%                 tempseedi=floor((seedi(t1)+seedi(t1+1))/2);
                break;
            else
                tempseedj=floor((seedj(t1)+seedj(t1+1))/2);
                if(sizei==1)
                    stacki=i;
                    stackj=tempseedj;
                    sizei=sizei+1;
                else
                    if(tag(itempseedj)~=0)
                        stacki=[stacki i];
                        stackj=[stackj tempseedj];
                        sizei=sizei+1;
                    end
                end
            end
        end
    end
end

%将曲线内部填充为0
sizei=size(stacki2);
sizej=size(stackj2);
while(sizei~=0)
    tempi=stacki(sizei);%%存储当前处理点的坐标值
    tempj=stackj(sizej);
    stacki=stacki(1:(sizei-1));%%出栈
    sizei=sizei-1;
    stackj=stackj(1:(sizej-1));
    sizej=sizej-1;
    tag(tempitempj)=0;
    for t1=-1:2:1
        if(tempi+t1>0 && tempi+t10 && tempj+t1            if(tag(tempi+t1tempj)==1)
                stacki=[stackitempi+t1];%%压栈
                sizei=sizei+1;
                stackj=[stackjtempj];
                sizej=sizej+1;
            end
            if(tag(tempitempj+t1)==1)
                stacki=[stackitempi];
                sizei=sizei+1;
                stackj=[stackjtempj+t1];
                sizej=sizej+1;
            end
        end
    end
end
%%换算得到符号函数
tag=tag*2-1;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2221  2012-12-13 20:33  Create_Tag.m
     文件        1202  2012-12-13 20:33  Curvature.m
     文件         372  2012-12-13 20:33  Extend_gradient.m
     文件         471  2012-12-13 20:33  Gradient.m
     文件         840  2012-12-13 20:33  Image_gradient.m
     文件         978  2012-12-13 20:33  LevelSet_New.m
     文件        5312  2012-12-13 20:33  SDF_create.m
     文件        4009  2012-12-13 20:33  SDF_create2.m
     文件        2510  2012-12-13 20:33  Search_Curve.m
     文件        1729  2012-12-13 20:33  Search_Curve2.m
     文件       11910  2012-12-13 20:33  Search_Curve3.m
     文件         131  2012-12-13 20:33  Speed.m
     文件         332  2012-12-13 20:33  Speed2.m
     文件         702  2012-12-18 00:46  test.m

评论

共有 条评论