spm_bwlabel.m 1.2 KB

123456789101112131415161718192021222324252627
  1. function [L,num] = spm_bwlabel(BW,n)
  2. % Label connected components in 2D or 3D binary images - a compiled routine
  3. %
  4. % FORMAT [L,num] = spm_bwlabel(BW,n)
  5. % BW - 2D or 3D binary image to perform labelling on.
  6. % n - connectivity criterion: 6 (surface), 18 (edge) or 26 (corner).
  7. % [Default: 18].
  8. % (for a 2D image these correspond to 4, 8 and 8 respectively).
  9. %
  10. % L - connected component image, i.e. image where each non-zero voxel
  11. % in BW will have a value corresponding to its label.
  12. % num - number of connected components in L.
  13. %
  14. %__________________________________________________________________________
  15. %
  16. % The implementation is loosely based on:
  17. % Thurfjell et al. 1992, A new three-dimensional connected components
  18. % labeling algorithm with simultaneous object feature extraction
  19. % capability. CVGIP: Graphical Models and Image Processing 54(4):357-364.
  20. %__________________________________________________________________________
  21. % Copyright (C) 2002-2012 Wellcome Trust Centre for Neuroimaging
  22. % Jesper Andersson
  23. % $Id: spm_bwlabel.m 4929 2012-09-17 14:21:01Z guillaume $
  24. %-This is merely the help file for the compiled routine
  25. error('spm_bwlabel.c not compiled - see Makefile');