Skip to main content
Log in

Optimizing two-pass connected-component labeling algorithms

  • Theoretical Advances
  • Published:
Pattern Analysis and Applications Aims and scope Submit manuscript

Abstract

We present two optimization strategies to improve connected-component labeling algorithms. Taking together, they form an efficient two-pass labeling algorithm that is fast and theoretically optimal. The first optimization strategy reduces the number of neighboring pixels accessed through the use of a decision tree, and the second one streamlines the union-find algorithms used to track equivalent labels. We show that the first strategy reduces the average number of neighbors accessed by a factor of about 2. We prove our streamlined union-find algorithms have the same theoretical optimality as the more sophisticated ones in literature. This result generalizes an earlier one on using union-find in labeling algorithms by Fiorio and Gustedt (Theor Comput Sci 154(2):165–181, 1996). In tests, the new union-find algorithms improve a labeling algorithm by a factor of 4 or more. Through analyses and experiments, we demonstrate that our new two-pass labeling algorithm scales linearly with the number of pixels in the image, which is optimal in computational complexity theory. Furthermore, the new labeling algorithm outperforms the published labeling algorithms irrespective of test platforms. In comparing with the fastest known labeling algorithm for two-dimensional (2D) binary images called contour tracing algorithm, our new labeling algorithm is up to ten times faster than the contour tracing program distributed by the original authors.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8

Similar content being viewed by others

Notes

  1. An implementation of the Contour Tracing algorithm distributed by the original authors of the algorithm is available from http://www.iis.sinica.edu.tw/∼fchang/03src.html.

  2. Note that we have made an arbitrary choice of denoting a background pixel by 0 and an object pixel by 1; however, there are other equally valid choices [38]. It is also possible to use other types of labels than the integers used in this paper.

  3. In C++ convention, all indices to arrays start from 0. The word array or vector in all pseudo-code segments is a short-hand of C++ STL type std::vector<unsigned> .

  4. The computation uses the function lsqlin from the optimization toolbox of MATLAB.

References

  1. Agarwal PK, Arge L, Ke Yi (2006) I/O-efficient batched union-find and its applications to terrain analysis. In: SCG ’06: Proceedings of the 22nd annual symposium on computational geometry. ACM Press, New York, pp 167–176

  2. Aho AV, Hopcroft JE, Ullman JD (1974) The design and analysis of computer algorithms. Addison–Wesley, Reading

    MATH  Google Scholar 

  3. Aho AV, Ullman JD, Hopcroft JE (1983) Data structures and algorithms. Addison–Wesley, Reading

    MATH  Google Scholar 

  4. Alnuweiri HM, Prasanna VK (1992) Parallel architectures and algorithms for image component labeling. IEEE Trans Pattern Anal Mach Intell 14(10):1014–1034

    Article  Google Scholar 

  5. Alstrup S, Ben-Amram AM, Rauhe T (1999) Worst-case and amortised optimality in union-find. In: Proceedings of 31th Annual ACM symposium on theory of computing (STOC’99). ACM Press, New York, pp 499–506

  6. Amin A, Fisher S (2000) A document skew detection method using the Hough transform. Pattern Anal Appl 3(3):243–253

    Article  MATH  Google Scholar 

  7. Ballard DH (1982) Computer vision. Prentice-Hall, Englewood

    Google Scholar 

  8. Bollobás B, Simon I (1985) On the expected behavior of disjoint set union algorithms. In: STOC ’85: Proceedings of the 17th annual ACM symposium on theory of computing. ACM Press, New York, pp 224–231

  9. Chang F, Chen C-J, Lu C-J (2004) A linear-time component-labeling algorithm using contour tracing technique. Comput Vis Image Underst 93(2):206–220

    Article  Google Scholar 

  10. Dillencourt MB, Samet H, Tamminen M (1992) A general approach to connected-component labeling for arbitrary image representations. J ACM 39(2):253–280

    Article  MATH  MathSciNet  Google Scholar 

  11. Doyle J, Rivest RL (1976) Linear expected time of a simple union-find algorithm. Inf Process Lett 5(5):146–148

    Article  MATH  MathSciNet  Google Scholar 

  12. Fiorio C, Gustedt J (1996) Two linear time union-find strategies for image processing. Theor Comput Sci 154(2):165–181

    Article  MATH  MathSciNet  Google Scholar 

  13. Fiorio C, Gustedt J (1997) Memory management for union-find algorithms. In: Proceedings of 14th symposium on theoretical aspects of computer Science. Springer, New York, pp 67–79

  14. Gabow HN, Tarjan RE (1983) A linear-time algorithm for a special case of disjoint set union. In: STOC ’83: Proceedings of the 15th annual ACM symposium on theory of computing. ACM Press, New York, pp 246–251

  15. Galil Z, Italiano GF (1991) Data structures and algorithms for disjoint set union problems. ACM Comput Surv 23(3):319–344

    Article  Google Scholar 

  16. Galler BA, Fisher MJ (1964) An improved equivalence algorithm. Commun ACM 7(5):301–303

    Article  MATH  Google Scholar 

  17. Gonzalez RC, Woods RE (2002) Digital Image Processing, 2nd edn. Prentice-Hall, New Jersy

    Google Scholar 

  18. Gotoh T, Ohta Y, Yoshida M, Shirai Y (1987) Component labeling algorithm for video rate processing. In: Proceedings of SPIE 1987. Advances in image processing, vol 804, pp 217–224

  19. Haralick RM (1981) Some neighborhood operations. Plenum Press, New York, pp 11–35

    Google Scholar 

  20. Haralick RM, Shapiro LG (1985) Image segmentation techniques. Comput Vis Graph Image Process 29(1):100–132

    Article  Google Scholar 

  21. Hayashi H, Kudo M, Toyama J, Shimbo M (2001) Fast labelling of natural scenes using enhanced knowledge. Pattern Anal Appl 4(1):20–27

    Article  MATH  MathSciNet  Google Scholar 

  22. Qingmao H, Guoyu Q, Nowinski WL (2005) Fast connected-component labelling in three-dimensional binary images based on iterative recursion. Comput Vis Image Underst 99:414–434

    Article  Google Scholar 

  23. Kim J-H, Kim KK, Suen CY (2000) An HMM-MLP hybrid model for cursive script recognition. Pattern Anal Appl 3(4):314–324

    Article  MathSciNet  Google Scholar 

  24. Knop F, Rego V (1998) Parallel labeling of three-dimensional clusters on networks of workstations. J Parallel Distrib Comput 49(2):182–203

    Article  MATH  Google Scholar 

  25. Knuth DE, Schönhage A (1978) The expected linearity of a simple equivalence algorithm. Theor Comput Sci 6:281–315

    Article  MATH  Google Scholar 

  26. Lucas JM (1990) Postorder disjoint set union is linear. SIAM J Comput 19(5):868–882

    Article  MATH  MathSciNet  Google Scholar 

  27. Lumia R (1983) A new three-dimensional connected components algorithm. Comput Vis Graph Image Process 23(2):207–217

    Article  Google Scholar 

  28. Lumia R, Shapiro L, Zungia O (1983) A new connected components algorithm for virtual memory computers. Comput Vis Graph Image Process 22(2):287–300

    Article  Google Scholar 

  29. Moga AN, Gabbouj M (1997) Parallel image component labeling with watershed transformations. IEEE Trans Pattern Anal Mach Intell 19(5):441–450

    Article  Google Scholar 

  30. Naoi S (1995) High-speed labeling method using adaptive variable window size for character shape feature. In: IEEE Asian Conference on computer vision, vol 1, pp 408–411

  31. Otsu N (1979) A threshold selection method from gray level histograms. IEEE Trans Syst Man Cybern 9:62–66

    Article  Google Scholar 

  32. Regentova E, Latifi S, Deng S, Yao D (2002) An algorithm with reduced operations for connected components detection in itu-t group 3/4 coded images. IEEE Trans Pattern Anal Mach Intell 24(8):1039–1047

    Article  Google Scholar 

  33. Rosenfeld A (1970) Connectivity in digital pictures. J ACM 17(1):146–160

    Article  MATH  MathSciNet  Google Scholar 

  34. Rosenfeld A, Kak AC (1982) Digital picture processing, 2nd edn. Academic Press, San Diego

    Google Scholar 

  35. Shi J, Malik J (2000) Normalized cuts and image segmentation. IEEE Trans Pattern Anal Mach Intell 22(8):888–905

    Article  Google Scholar 

  36. Stockman GC, Shapiro LG (2001) Computer Vision. Prentice-Hall, Englewood

    Google Scholar 

  37. Suri JS, Singh B, Reden L (2002) Computer vision and pattern recognition techniques for 2-d and 3-d MR cerebral cortical segmentation: a state-of-the-art review. Pattern Analy Appl 5(1):46–76

    Article  MathSciNet  Google Scholar 

  38. Suzuki K, Horiba I, Sugie N (2003) Linear-time connected-component labeling based on sequential local operations. Comput Vis Image Underst 89(1):1–23

    Article  MATH  Google Scholar 

  39. Tarjan RE, van Leeuwen J (1984) Worst-case analysis of set union algorithms. J ACM 31(2):245–281

    Article  MATH  Google Scholar 

  40. Tarjan RE (1975) Efficiency of a good but not linear set union algorithm. J ACM 22(2):215–225

    Article  MATH  MathSciNet  Google Scholar 

  41. Tarjan RE (1977) Reference machines require non-linear time to maintain disjoint sets. In: STOC ’77: Proceedings of the 9th annual ACM symposium on theory of computing. ACM Press, pp 18–29

  42. Udupa JK, Ajjanagadde VG (1990) Boundary and object labelling in three-dimensional images. Comput Vis Graph Image Process 51(3):355–369

    Article  Google Scholar 

  43. Wang K-B, Chia T-L, Chen Z, Lou D-C (2003) Parallel execution of a connected component labeling operation on a linear array architecture. J Inf Sci Eng 19:353–370

    Google Scholar 

  44. Wang Y, Bhattacharya P (2003) Using connected components to guide image understanding and segmentation. Mach Graph Vis 12(2):163–186

    Google Scholar 

  45. Wu K, Otoo E, Shoshani A (2005) Optimizing connected component labeling algorithms. In: Proceedings of SPIE medical imaging conference 2005, San Diego, CA, 2005. LBNL report LBNL-56864

  46. Yao AC (1985) On the expected performance of path compression algorithms. SIAM J Comput 14(1):129–133

    Article  MATH  MathSciNet  Google Scholar 

  47. Yapa RD, Koichi H (2007) A connected component labeling algorithm for grayscale images and application of the algorithm on mammograms. In: SAC’07: Proceedings of the 2007 ACM symposium on applied computing. ACM Press, New York, pp 146–152

Download references

Acknowledgment

This work was supported in part by the Office of Science of the U.S. Department of Energy under Contract No. DE-AC03-76SF00098.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Kesheng Wu.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Wu, K., Otoo, E. & Suzuki, K. Optimizing two-pass connected-component labeling algorithms. Pattern Anal Applic 12, 117–135 (2009). https://doi.org/10.1007/s10044-008-0109-y

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10044-008-0109-y

Keywords

Navigation