In medicine, the study of microbes is essential for understanding the spread of infectious diseases, drug development, and advances in the biomedical field. As a basic work in microbial experiments, colony counting is used to evaluate the growth and distribution of microorganisms, so it plays an important role in medical experiments. Traditional colony counting methods usually involve placing Petri dishes on a counting plate and manually counting each colony one by one. Although this method is simple, it is very time-consuming and prone to subjective operator errors. In recent years, rapid advances in computer vision and image processing techniques have provided new opportunities for automated colony counting. OpenCV (Open Source Computer Vision Library) is a widely used open source computer vision library, which provides a series of powerful image processing tools. This paper aims to develop an automatic method for counting the number of colonies in photos of Pseudomonas aeruginosa colonies to improve the accuracy and efficiency of counting, using the OpenCV algorithm.
(1) Colony photos: photos of microbial culture dishes taken with a microscope or high-resolution photography equipment.
(2)Computer: A computer equipped with the OpenCV library for image processing and analysis.
(1)Read image: Load the test image with the colony into the algorithm.
(2)Grayscale processing: the test image is converted to grayscale image to simplify the subsequent processing.
(3)Erosion and dilation operations: The image is processed using erosion and dilation operations to remove noise and highlight colonies in the image. This operation helps to segment the image.
(4)Thresholding: Use the binary method to split the image into black and white parts, where the object part is white and the background is black. This operation helps to segment the image.
(5)Gaussian filter: Gaussian blur is applied to the image to smooth the image and reduce the noise.
(6)Find connected contours: Use the findContours function in the CV library to find the connected contours of an image.
(7)Filter connected components: Calculate the sum of mina of each connected component, and only keep the connected components with an area greater than 10 pixels to remove the noise with small area.
(8)Calculate the number of connected domains: count the number of retained connected domains, which will be used as the final number of colonies.
(9)Delineate connected components: Use the drawContours function from the CV library to delineate the remaining connected components on the image and display them.
(10) Draw numbers: Calculate the barycentric coordinates of each preserved connected domain, and draw the corresponding numbers at this coordinate point to identify each colony.
(11) Display image: Create a window and display the processed image, including the depicted connected components and numbers.
According to the display effect of the depicted connected domain, the threshold size of filtering connected domain was constantly modified for different colony test samples. Finally, the average error rate in 15 tests reaches 1.23%. The specific test table is as follows:
Despite the positive results of this study, some potential challenges and directions for improvement need to be considered:
(1) Image quality: The quality of photos of colonies may affect the performance of the algorithm. Lower resolution or blurred images may lead to counting errors. Therefore, it is necessary to ensure that the photos taken are of sufficiently high quality.
(2) Large-scale application: in real medical experiments, it may be necessary to process a large number of colony photos. Therefore, the scalability and efficiency of the algorithm are crucial for processing large-scale data sets.
(3) Algorithm optimization: Further algorithm optimization and parameter tuning may help to improve the accuracy and stability of the counting.
(4) Practical application: The method of this study needs to be more widely applied and verified in actual medical experiments to ensure its feasibility and reliability in real scenarios.
[1] Bradski, G., & Kaehler, A. (2000). OpenCV. Dr. Dobb’s journal of software tools, 3(2).
[2] Culjak, I., Abram, D., Pribanic, T., Dzapo, H., & Cifrek, M. (2012, May). A brief introduction to OpenCV. In 2012 proceedings of the 35th international convention MIPRO (pp. 1725-1730). IEEE.
[3] Howse, J. (2013). OpenCV computer vision with python (Vol. 27). Birmingham: Packt Publishing.