资源简介
标记连通成分,得到连通成分的区域个数,大小
代码片段和文件信息
function [Lnumsz] = label(In)
% Check input arguments
error(nargchk(12nargin));
if nargin==1 n=8; end
assert(ndims(I)==2‘The input I must be a 2-D array‘)
% -----
sizI = size(I);
id = reshape(1:prod(sizI)sizI);
sz = ones(sizI);
% Indexes of the adjacent pixels
vec = @(x) x(:);
if n==4 % 4-connected neighborhood
idx1 = [vec(id(:1:end-1)); vec(id(1:end-1:))];
idx2 = [vec(id(:2:end)); vec(id(2:end:))];
elseif n==8 % 8-connected neighborhood
idx1 = [vec(id(:1:end-1)); vec(id(1:end-1:))];
idx2 = [vec(id(:2:end)); vec(id(2:end:))];
idx1 = [idx1; vec(id(1:end-11:end-1)); vec(id(2:end1:end-1))];
idx2 = [idx2; vec(id(2:end2:end)); vec(id(1:end-12:end))];
else
error(‘The second input argument must be either 4 or 8.‘)
end
% Create the groups and merge them (Union/Find Algorithm)
for k = 1:length(idx1)
root1 = idx1(k);
root2 = idx2(k);
whil
相关资源
- matlab开发-FlockingAlgorithm
- 烟花算法 (Fireworks Algorithm),缩写为
- 微机保护算法仿真.zip
- ISARImagingWithMATLABAlgorithms.rar
- ISAR Imaging With MATLAB Algorithms
- 遗传算法(Genetic Algorithm)MATLAB案例详
- Fusiello极线校正_A compact algorithm for r
- machine trading: deploying computer algorithms
- X S Yang firefly algorithm萤火虫所有算法文
- CURE algorithm
- NETLAB algorithms for pattern recognition
- Synthetic Aperture Radar Signal Processing wit
- synthetic aperture radar signal processing wit
- Inverse Synthetic Aperture Radar Imaging with
- Synthetic Aperture Radar Signal Processing wit
- Robotics Vision and Control (Fundamental Alg
- matlab开发-Edmondsalgorithm
- KLT Algorithm人脸追踪
- easi algorithm for blind source separation
- 神经网络中hopfield算法的Matlab的实现
- 极化目标分解中的四分量FOURCOMPONENT分
- LMS和RLS算法
- grid_connected_doubleloop.mdl 光伏并网双闭
- lm算法的matlab实现
- Chicken Swarm Optimization鸡群优化算法和
- 2014年最新提出的仿生群智能优化算法
-
matlab开发-mssamultiob
jectivesalpswarmalg - The MATLAB Genetic Algorithm Toolbox
- SIMPLE算法Matlab代码
- MAP algorithm Matlab
评论
共有 条评论