Automated Colony-Forming Unit (CFU) Counting of Bacteria Using Digital Image Analysis Through Computer Vision with Python
DOI:
https://doi.org/10.15649/2346075X.5677Keywords:
CFU counting, Bacteria, automation, image analysis, programmingAbstract
Introduction. Quantitative analysis of bacterial growth is essential in microbiological studies, as it enables the evaluation of microbial survival and proliferation rates, facilitating control and manipulation of microbial communities. However, traditional manual counting of colony-forming units (CFUs) on Petri dishes presents major limitations, including high time and resource consumption, and variability linked to the analyst’s subjectivity. Objectives. This study aimed to develop a Python-based script for efficient and accurate CFU counting using digital images. Materials and Methods. Water samples were collected from supraglacial lakes of the Llaca Glacier (Peru) and inoculated on nutrient agar and R2A media using the spread plate method. Cultures were incubated at 5 °C for 30 days and photographed using a custom-built photographic chamber that standardized image capture. Results. The script, implemented in Google Colaboratory, follows a three-stage process: preprocessing, segmentation, and colony counting. Gaussian adaptive thresholding was selected for segmentation due to its robustness under variable image conditions. The system’s performance was evaluated by comparing automated results with manual counts across 91 images. The method demonstrated high efficiency, achieving an precision of 97% ± 0.12, a recall of 95% ± 1.10, and an F-measure of 96% ± 0.10, with a processing time of only 0.4 seconds per image. Conclusions. These results demonstrate that the system offers a reliable, fast, and low-cost alternative for CFU quantification. Its design is simple and adaptable, making it a replicable tool for microbiological laboratories, especially in resource-limited settings.
References
1. Rodrigues PM, Luís J, Tavaria FK. Image Analysis Semi-Automatic System for Colony-Forming-Unit Counting. Bioengineering [Internet]. 2022;9(7):271. Available from: https://doi.org/10.3390/bioengineering9070271
2. Chiang PJ, Tseng MJ, He ZS, Li CH. Automated counting of bacterial colonies by image analysis. J Microbiol Methods [Internet]. 2015;108:74–82. Available from: https://doi.org/10.1016/j.mimet.2014.11.009
3. Corral-Lugo A, Morales-García YE, Pazos-Rojas LA, Ramírez-Valverde A, Martínez-Contreras RD, Muñoz-Rojas J. Cuantificación de bacterias cultivables mediante el método de “Goteo en Placa por Sellado (o estampado) Masivo.” Rev Colomb Biotecnol [Internet]. 2012;14(2):147–56. Available from: http://www.revistas.unal.edu.co/index.php/biotecnologia/article/view/37416/40417
4. Martinez-Espinosa JC, Cordova-Fraga T, Vargas-Luna M, Ortiz-Alvarado JD, Pablo AIR, Cisneros MT, et al. Nondestructive technique for bacterial count based on image processing. Biol Eng Med [Internet]. 2016;1(1):1–6. Available from: https://doi.org/10.15761/BEM.1000103
5. Uppal NK, Goyal R. Computational approach to count bacterial colonies. Int J Adv Eng Technol [Internet]. 2012;4(2):364–72. Available from: https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=5f04eb14873221475956488c09198360724cbdda
6. Zhang J, Li C, Rahaman MM, Yao Y, Ma P, Zhang J, et al. A comprehensive review of image analysis methods for microorganism counting: from classical image processing to deep learning approaches [Internet]. Vol. 55, Artificial Intelligence Review. 2021. 2875–2944 p. Available from: https://doi.org/10.1007/s10462-021-10082-4
7. Ramírez J, Parra J, Alvarez-Aldana A. Análisis de técnicas de recuento de microorganismos. Mente Joven. 2017;6:10–6. https://doi.org/10.18041/2323-0312/mente_joven.0.2017.3665
8. Brugger SD, Baumberger C, Jost M, Jenni W, Brugger U, Mühlemann K. Automated counting of bacterial colony forming units on agar plates. PLoS One [Internet]. 2012;7(3):1–6. Available from: https://doi.org/10.1371/journal.pone.0033695
9. Choudhry P. High-Throughput method for automated colony and cell counting by digital image analysis based on edge detection. PLoS One [Internet]. 2016;11(2):1–23. Available from: https://doi.org/10.1371/journal.pone.0148469
10. Ateş H, Gerek ÖN. An image-processing based automated bacteria colony counter. 2009 24th Int Symp Comput Inf Sci Isc 2009 [Internet]. 2009;18–23. Available from: https://doi.org/10.1109/ISCIS.2009.5291926
11. Hogekamp L, Hogekamp SH, Stahl MR. Experimental setup and image processing method for automatic enumeration of bacterial colonies on agar plates. PLoS One [Internet]. 2020;15(6):1–17. Available from: http://dx.doi.org/10.1371/journal.pone.0232869
12. Mallard F, Le Bourlot V, Tully T. An Automated Image Analysis System to Measure and Count Organisms in Laboratory Microcosms. PLoS One [Internet]. 2013;8(5):1–10. Available from: https://doi.org/10.1371/journal.pone.0064387
13. Williams REO, Trotman RE. Automation in diagnostic bacteriology. J Clin Pathol [Internet]. 1969;S2-3(1):8–13. Available from: https://doi.org/10.1136/jcp.s2-3.1.8
14. Putman M, Burton R, Nahm MH. Simplified method to automatically count bacterial colony forming unit. J Immunol Methods [Internet]. 2005;302(1–2):99–102. Available from: https://doi.org/10.1016/j.jim.2005.05.003
15. Zhang C, Chen WB, Liu WL, Chen CB. An automated bacterial colony counting system. Proc - IEEE Int Conf Sens Networks, Ubiquitous, Trust Comput [Internet]. 2008;233–40. Available from: https://doi.org/10.1109/SUTC.2008.50
16. Marotz J, Lübbert C, Eisenbeiß W. Effective object recognition for automated counting of colonies in Petri dishes (automated colony counting). Comput Methods Programs Biomed [Internet]. 2001;66(2):183–98. Available from: https://doi.org/10.1016/S0169-2607(00)00128-0
17. Wong CF, Yeo JY, Gan SKE. Republication – APD Colony Counter App: Using Watershed Algorithm for improved colony counting. Sci Phone apps Mob Device [Internet]. 2019;5(5):5–7. Available from: https://doi.org/10.30943/2019/c23122019
18. Khan AUM, Torelli A, Wolf I, Gretz N. AutoCellSeg: Robust automatic colony forming unit (CFU)/cell analysis using adaptive image segmentation and easy-to-use post-editing techniques. Sci Rep. 2018;8(1):1–10. https://doi.org/10.1038/s41598-018-24916-9
19. Geissmann Q. OpenCFU, a New Free and Open-Source Software to Count Cell Colonies and Other Circular Objects. PLoS One [Internet]. 2013;8(2):1–10. Available from: https://doi.org/10.1371/journal.pone.0054072
20. Kumar S, Gupta P. Comparative Analysis of Intersection Algorithms on Queries using Precision , Recall and F-Score. Int J Comput Appl. 130(7):28–36. https://doi.org/10.5120/ijca2015907042
21. Powers D. Evaluation: From Precision, Recall and F-Factor to ROC, Informedness, Markedness & Correlation. Mach Learn Technol. 2007;2:37–63.
22. Hand D, Christen P. A note on using the F-measure for evaluating record linkage algorithms. Stat Comput. 2018;28:539–47. https://doi.org/10.1007/s11222-017-9746-6
23. Pineda, Alvarado D, Canales D. Metodología de la investigación. Manual para el desarrollo de personal de salud. Segunda ed. Organización Panamericana de la Salud; 1994. 81–86 p.
24. Van Rossum G, Drake F. Python 3 Reference Manual. Scotts Val CA Creat [Internet]. 1995;Python ver. Available from: https://www.python.org/
25. Bradski G. The OpenCV Library. Dr Dobb’s J Softw Tools [Internet]. 2000;OpenCV ver. Available from: https://opencv.org/
26. Harris CR, Millman KJ, van der Walt SJ, Gommers R, Virtanen P, Cournapeau D, et al. Array programming with NumPy. Nature [Internet]. 2020;585(7825):357–62. Available from: https://doi.org/10.1038/s41586-020-2649-2
27. Hunter J. Matplotlib: A 2D graphics environment. Comput Sci Eng. 2007;9(3):90–5. https://doi.org/10.1109/MCSE.2007.55
28. Kis B, Unay M, Ekimci GD, Ercan UK, Akan A. Counting bacteria colonies based on image processing methods. TIPTEKNO 2019 - Tip Teknol Kongresi [Internet]. 2019;1–4. Available from: https://doi.org/10.1109/TIPTEKNO.2019.8895213
29. Corkidi G, Diaz-Uribe R, Folch-Mallol JL, Nieto-Sotelo J. COVASIAM: An image analysis method that allows detection of confluent microbial colonies and colonies of various sizes for automated counting. Appl Environ Microbiol [Internet]. 1998;64(4):1400–4. Available from: https://doi.org/10.1128/AEM.64.4.1400-1404.1998
30. Peña C, Peña L, Moreno G. Sistema de visión artificial para el reconocimiento y el conteo de Unidades Formadoras de Colonias (UFC). Rev Colomb Tecnol Av. 2011;1(17):9–15.
31. Naranajo A. Conteo de Colonias de Bacterias en Cápsulas de Petri [Internet]. Universidad de Talca; 2017. Available from: https://dspace.utalca.cl/bitstream/1950/12105/2/naranjo_espinoza.pdf
32. Li Y, Liu T, Koydemir HC, Wang H, Riordan KO, Bai B, et al. Deep Learning-enabled Detection and Classification of Bacterial Colonies using a Thin Film Transistor (TFT ) Image Sensor. ACS Photonics. 2022;9:1–18. https://doi.org/10.1021/acsphotonics.2c00572
33. Cao L, Zeng L, Wang Y, Cao J, Han Z, Chen Y, et al. U2-Net and ResNet50-Based Automatic Pipeline for Bacterial Colony Counting. Microorganisms. 2024;12(1):201. https://doi.org/10.3390/microorganisms12010201
34. Albaradei SA, Napolitano F, Uludag M, Thafar M, Napolitano S, Essack M, et al. Automated counting of colony forming units using deep transfer learning from a model for congested scenes analysis. IEEE Access [Internet]. 2020;8:164340–6. Available from: https://doi.org/10.1109/ACCESS.2020.3021656
Downloads
Published
How to Cite
Downloads
Issue
Section
License
Copyright (c) 2026 Innovaciencia

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
All articles published in this scientific journal are protected by copyright. The authors retain copyright and grant the journal the right of first publication, with the work simultaneously licensed under a Creative Commons Attribution-NonCommercial 4.0 International License (CC BY-NC 4.0), which permits sharing the work with authorship recognition and without commercial purposes.
Readers may copy and distribute the material from this journal issue for non-commercial purposes in any medium, provided the original work is cited and credit is given to the authors and the journal.
Any commercial use of the material from this journal is strictly prohibited without written permission from the copyright holder.
For more information on the copyright of the journal and open access policies, please visit our website.










