资源简介
边界提取,链码生成,差分链码生成及频率向量生成程序)具有旋转不变性了的链码
代码片段和文件信息
function B=boundaries(BWconndir)
%BOUNDARIES Trace object boundaries.
%B=BOUNDARIES(BW) traces the exterior boundaries of objects in the binary
%image BW.B is a p_by_1 cell arraywhere p is the number of objects in the
%image.Each cell contains a Q_by_2 matrixeach row of which contains the
%row and column coordinates of a boundary pixel.Q is the number of boundary
%pixels for the corresponding object.object boundaries are traced in the
%clockwise direction.
%
%B=BOUNDARIES(BWCONN) specifies the connectivity to use when tracing
%boundaries.CONN may be either 8 or 4.The default value for CONN is 8.
%
%B=BOUNDARIES(BWCONNDIR) specifies the direction used for tracing
%boundaries.DIR should be either ‘cw‘(trace boundaries clockwise) or
%‘ccw‘(trace boundaries counterclockwise).If DIR is omitted BOUNDARIES
%traces in the clockwise direction.
if nargin<3 %nargin定义在用户自定义函数体内,nargin返回
%用来调用函数的变量的个数。
dir=‘cw‘;
end
if nargin<2
conn=8;
end
L=bwlabel(BWconn); %返回值是矩阵L,大小同BW,包含了BW中的连通部分的标记
%The number of objects is the maximum value of L.Initialize the cell
%array(元包数组)B so that each cell initially contains a 0_by_2 matrix.
numobjects=max(L(:));%寻找L中所作标记中的最大值,这个最大值实际上就对应着L中
% 包含的最多的连通部分的数目。
if numobjects>0
B={zeros(02)};%元包数组中仅包含一个元素。
B=repmat(Bnumobjects1);%将B进行numobjects*1个复制构成新的B。
else
B={};
end
%Pad label matrix with zeros.This lets us write the boundary_following loop
%without worrying about going off the edge of the image.
Lp=padarray(L[1 1]0‘both‘);
%Compute the linear indexing offsets to take us from a pixel to its
%neighbors.
M=size(Lp1);%SIZE(X1) returns the number of rows.
if conn==8
%Order is N NE E SE S SW W NW.
offsets=[-1M-1MM+11-M+1-M-M-1];
else
%Order is N E S W.
offsets=[-1M1-M];
end
%next_search_direction_lut is a lookup table.Given the direction from pixel
%k to pixel k+1what is the direction to start with when examining the
%neighborhood of pixel k+1?
if conn==8
next_search_direction_lut=[8 8 2 2 4 4 6 6];
else
next_search_direction_lut=[4 1 2 3];
end
%next_direction_lut is a lookup table.Given that we just looked at neighbor
%in a given directionwhich neighbor do we look at next?
if conn==8
next_direction_lut=[2 3 4 5 6 7 8 1];
else
next_direction_lut=[2 3 4 1];
end
%Values used for marking the starting and boundary pixels.
START=-1;
BOUNDARY=-2;
%Initialize scratch space in which to record the boundary pixels as well as
%follow the boundary.
scratch=zeros(1001);
%Find candidate starting locations for boundaries.
[rrcc]=find((Lp(2:end-1:)>0)&(Lp(1:end-2:)==0));
rr=rr+1;
for k=1:length(rr)
r=rr(k);
c=cc(k);
if (Lp(rc)>0)&(Lp(r-1c)==0)&isempty(B{Lp(rc)})
%We‘ve found the start of the next boundary.Compute its linear
%offsetrecord which boundary it ismark itand initialize the
%counter for the number of boundary p
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2007-05-15 15:29 matlab_lianma\
文件 5689 2007-05-07 16:40 matlab_lianma\boundaries.m
文件 798 2007-05-10 10:12 matlab_lianma\creatcode.m
文件 886 2007-05-10 10:42 matlab_lianma\creatfrequence.m
文件 455 2007-05-10 10:41 matlab_lianma\creatsubcode.m
文件 1724 2007-05-10 16:30 matlab_lianma\main.m
文件 1819 2007-05-10 10:30 matlab_lianma\singleimagecode.m
- 上一篇:车型识别算法-matlab
- 下一篇:MATLAB下扩展卡尔曼滤波的S函数实现
相关资源
- MATLAB下扩展卡尔曼滤波的S函数实现
- 车型识别算法-matlab
- 字符识别matlab程序
- 基于Matlab的GPS卫星仿真器设计
- 三维重建 网格交叉点的提取 MATLAB程序
- JPEG2000代码_matlab
- 任意发送天线,任意接收天线的STBC
- matlab识别英文字母程序 附带图像处理
- 二维码识别 matlab代码 内
- MIMO通信系统matlab实现
- matlab 读取、制作视频操作,入门必备
- 加噪matlab椒盐噪声,高斯噪声
- MATLAB图像分割提取算法源代码车牌识
- 内弹道求解程序
- 自适应滤波器matlab仿真246008
- MATLAB期末论文
- MATLAB-gui各种功能代码
- 数值方法matlab版源代码
- 机械设计计算齿轮强度校核M文件
- matlab优化算法源码大全
- 数字下变频的matlab算法仿真,雷达方
- matlab2010b链接+安装教程链接+crack破解
- MATLAB\\心电滤波效果查看器GUI设计
- 蜂窝网络TDOA定位方法的Fang算法研究及
- 计算李雅普诺夫特性指数的matlab函数
- BP神经网络matlab(简单而经典)
- C4.5算法matlab实现以及西瓜数据集.ra
- MATLAB 代码 基于C-V模型的水平集图像分
- 结构化svm代码-matlab版
- matlab 语音识别系统源代码
评论
共有 条评论