matlab中边界跟踪法,急!边界跟踪算法 matlab

function [output]=C_point(image,S,E)

% This function is used to get two basis points between fingers

% 采用轮廓跟踪法,得到两条曲线的坐标集,再通过求质心确定两个基准点

%

% Input Parameters:

%

%          image         --- 输入的图像

%          S,E          --- 起始点和终点的纵坐标

%

% Output Parameters:

%

%     output        --- 提取弧线所有点的重心坐标

%

function [output]=C_point(image,S,E)

n=0; % the number of points on the first curve

B_point=[];% the matrix which contain the coordination of the boundary

D_cw=[-1 1;0 1; 1 1; 1 0; 1 -1;   0 -1; -1 -1;-1 0;

-1 1;0 1; 1 1; 1 0; 1 -1;   0 -1; -1 -1;-1 0; ];

Temp=[S 2];% the begining point

temp=[];

for i=1:5

temp=Temp+D_cw(i,:);              % 探寻起始点的八邻域邻点

if (image(temp(1),temp(2))==1)    % 判断是否为边界点

Temp=temp;

break;                        % 找到第一个边界点,中止循环

end

B_point=[B_point;Temp];           % 将找到的点放到边界矩阵中

n=n+1;                            % 计数

end

begin=1;

while(~((Temp(1)==E)&&(Temp(2)==2)))      % 若是结束点,则中止

for i=0:4

temp=Temp+D_cw(begin+i,:);        % 探寻其八邻域内的点

if (n>3)

if (temp==B_point(n-1,:))     % 若找到下一点与前一点相同,则旋转180度

begin=4;

end

end

if (image(temp(1),temp(2))==1)    % 如果为边界点,则把下一点作为当前点

Temp=temp;

break;

end

B_point=[B_point;Temp];           % 把找到的点放到边界矩阵中

n=n+1;

end

end

X_point=sum(B_point(:,1))/size(B_point,1);% 确定曲线点集的中心

Y_point=sum(B_point(:,2))/size(B_point,1);

output=[X_point Y_point];

小弟对matlab语言不熟,还请哪位大虾帮忙指点一下,万分感谢

我们马上要交作业了!!

[本帖最后由 edifiers2008 于 2008-12-2 16:53 编辑]

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值