Connected component labelling in 2D or 3D. FORMAT: [L,NUM] = spm_bwlabel(bw,conn) The calling interface has been modelled on the image processing toolbox routine bwlabel. See the help for that routine for further information. Input: bw: : (Binary) image to perform labelling on. Can be 2 or 3D. conn : Connectivity criterion. Could be 6(surface) 18(edge) or 26(corner). For a 2D bw these correspond to 4, 8 and 8 respectively. Output: L : Connected component image, i.e. image where each non-zero voxel in bw will have a value corresponding to its label. NUM : Number of connected components in L. The implementation is not recursive (i.e. will no crash for large connected components) and is losely based on Thurfjell et al. 1992, A new three-dimensional connected components labeling algorithm with simultaneous object feature extraction capability. CVGIP: Graphical Models and Image Processing 54(4):357-364. _______________________________________________________________________ Copyright (C) 2005 Wellcome Department of Imaging Neuroscience

0001 function varargout = nic_spm_bwlabel(varargin) 0002 % Connected component labelling in 2D or 3D. 0003 % 0004 % FORMAT: [L,NUM] = spm_bwlabel(bw,conn) 0005 % 0006 % The calling interface has been modelled on the 0007 % image processing toolbox routine bwlabel. See 0008 % the help for that routine for further information. 0009 % 0010 % Input: 0011 % bw: : (Binary) image to perform labelling on. Can 0012 % be 2 or 3D. 0013 % conn : Connectivity criterion. Could be 6(surface) 0014 % 18(edge) or 26(corner). For a 2D bw these 0015 % correspond to 4, 8 and 8 respectively. 0016 % 0017 % Output: 0018 % L : Connected component image, i.e. image where 0019 % each non-zero voxel in bw will have a value 0020 % corresponding to its label. 0021 % NUM : Number of connected components in L. 0022 % 0023 % 0024 % The implementation is not recursive (i.e. will no crash for 0025 % large connected components) and is losely based on 0026 % Thurfjell et al. 1992, A new three-dimensional connected 0027 % components labeling algorithm with simultaneous object 0028 % feature extraction capability. CVGIP: Graphical Models 0029 % and Image Processing 54(4):357-364. 0030 %_______________________________________________________________________ 0031 % Copyright (C) 2005 Wellcome Department of Imaging Neuroscience 0032 0033 % Jesper Andersson 0034 % $Id: spm_bwlabel.m 159 2005-05-16 14:00:56Z guillaume $ 0035 0036 0037 error('spm_bwlabel.c not compiled - see Makefile'); 0038 0039 0040 0041

Generated on Wed 29-Apr-2009 01:06:38 by