Design and Implementation of an Automated Colony Counter Using Artificial Vision

An automatic module for counting colony forming units (CFU) present in raw milk, and its analysed by an artificial vision algorithm was designed and implemented as the focus of this work. The purpose of the algorithm was to identify the total number of colonies present and its respective area, after a sample was plated in a selected agar media. The growth and evolution of the colonies with respect to time and a selected temperature could be studied. The results are shown by using a user interface. The designed device can be used not only for counting colonies, but also to obtain specific data when doing research in the area of food safety, among other areas of interest.


INTRODUCTION
Our country suffers from a continuous problem regarding the hygienic quality of milk, since some producers do not carry out proper hygiene practices both during milking and during storage and distribution of it, which may lead to health issues upon human consumption. Studies aiming to inspect or examine foods pay special attention to determine how many living or viable bacteria are present in them, to achieve this goal, the number of them that are capable of forming colonies in a specific solid medium is determined [1]. The procedure of verifying viable bacteria is called the viable number, however for practical reasons this number is known as Colony Forming Units (CFU) [1]. The common practice to diagnose if a product is suitable or not for consumption is based on the determination of its hygienic quality through the use of different laboratory tests and routinely tests, this is referred to as the determination of CFU. CFU is a broadly used technique in different fields and have been used for example to determine the number of bacteria to be inoculated in silage inoculation experiments [2], to test for fungal contamination in fruit salads [3], to help to identify the organisms causing high total bacterial count in bulk tank milk while used in conjunction with other techniques, [4] and to check the contamination of human milk in neonatal care units [5], among others.
In recent years, technologies based on digital image processing have had good results in countless applications, as well as in areas of research such as medical and food biology. These areas have benefited from applications used in diagnostic processes, as well as in the detection of diseases and in the area of quality control [6].
In the area of microbiology, the CFU determination technique is constantly used to detect the behaviour of certain microorganisms present in samples of interest (milk, food, water, urine, etc.). In most cases, the counting is performed manually by a person skilled in the art, however, when the analysis of a large number of samples is required, despite the operatorꞌs skill, there is a high predisposition to make mistakes [7].
Within the microbial analysis process, there is no automated module on the market that allows the CFU growth present in raw milk to be analysed in detail and a real-time analysis using artificial vision techniques. This work carried out the first stage of an investigation to develop an automated system for counting the CFU and its evolution. Raw milk was used as raw material, in order to achieve the identification and quantification of CFU with a competitive and viable technology to the environment through digital image processing processes.
Image analysis is a process that allows the identification and understanding of different types of patterns, so it has a large number of applications. One of the main goals of computer image analysis is to equip a machine with the ability to perceive and analyse a specific environment, something that human beings can normally do [8].

METHODOLOGY 2.1 Design and Construction of the CFU Module
The construction of the module was made intending to integrate the traditional method usually used for this type of work; the design sought the saving of time and greater efficiency in the product's treatment. A CAD model was generated during the project (Fig. 1), seeking to facilitate the prototypeꞌs perception and make it more functional.  When designing the prototype, the operator's comfort was sought, in such a way that it optimized the operator's performance when starting the process. For this, a compartment with two entrances was strategically located in the frontal side of the module in order to facilitate the entry of samples to be studied. The interior was divided into two fundamental sections to have greater organization and control of the prototype. In the upper part, the electronic and electrical components were located (arduino mega 2560 card, circuits, source, buttons, LCD). In the lower section a camera was placed, which made the capture of images, followed by a sensor and the tray levels where the sample was housed in its respective Petri dish (necessary to carry out the analysis) and if possible analyse the sample and arrive at a clear and effective result; finally, a thermal resistance was fixed together with the lamp. The base material of the module was wood (MDF). The final thermal system was constituted by a heat sink of 750 W mounted on a platform with thermal insulation.
The power stage was constituted by a current source having as a power element a TRIAC BT138, mounted on a control circuit. The temperature sensor (LM35) was separated from the heating resistance in order to measure the quantity to be controlled, so that the desired temperature is achieved.
For the acquisition of sensor temperature control data, the Arduino Mega2560 card was implemented, being a good option that allowed relatively easy programming, saving time in the prototype's development.
For image capture the Microsoft LifeCam Cinema HD 720 high resolution camera was used, solving the problem of image capture of the colony forming units.
Keeping the design details for the prototype, data visualization was developed through a LCD feedback, controlled by a pic16f877a microcontroller, whose function was to show the temperature changes given in the sensor.
For the aforementioned components, the respective printed circuit board was elaborated, as shown below (

Temperature Control
The module was designed to maintain a constant temperature of 37 °C, which is the optimum temperature of incubation and evolution of most microorganisms that represent a risk to human health.
In this project, the PID controller [9] was implemented, so that the temperature sensor data was the first to be obtained in order to gain data for later analysis. The stepꞌs input was configured, in our case it was a voltage input headed to the input of the pulse width modulator (PWM), a gain was assigned so that 1 volt could be generated at the output acquisition cardꞌs pin 9. This acquisition was modelled in the Simulink program (Fig. 3)   The response of the plant was then observed (Fig. 6). The Ziegler-Nichols PID regulator tuning method allows defining the proportional (K p ), integral (K i ) and derivative (K d ) gains from the response of the open-loop system [10]. Fig. 6 shows a typical graph of the test, which is also known as the process reaction curve; the "S" shaped response is characteristic of second or higher order processes, with or without dead time. The next step is to match the process reaction curve with the model of a simple process in order to determine the model parameters. The model to be used is defined, where three parameters are characterized: the gain K, the dead time t 0 and the time constant .
First the gain is obtained knowing the desired value as a reference ΔC s as shown in Fig. 6, then times are calculated t 1 , y, t 2 , knowing the 28,3% y 63,2% the value of Then the parameters K c , T i and T d were calculated, based on the response to the step according to the parameters in Tab. 1 [10].
Replacing the values of K c , T i and T d in the Eqs. (4), (5) and (6), the parameters of the PID closed loop controller are obtained, as shown in Fig. 7.
Once this data was obtained, the parameters of the PID controller were entered in the block diagram (Fig. 7) in a closed loop.
Regarding the behaviour of the plant (Fig. 8) the PID controller, in the real test with a working time of 24 hours, where it was observed that after 300 seconds there was an over-impulse below 45 °C, this value is within the controllerꞌs acceptance range, the signal tended to stabilize at 600 seconds where the controller's performance was evidenced, being located at the desired temperature of 37 °C, the oscillations were due to the thermal inertia produced inside of the plant.

Evolution of the Colony Forming Units Through Artificial Vision
Below is the automated system for the recognition and counting of colony forming units (CFU), designed for the purpose of analysing the quality of raw milk (viable bacteria) by means of an artificial vision algorithm, based on the evolution that It is presented in the petri dish.
The initial step in the digital image processing process was to visualize and capture the last image of the process (Fig. 9).

Figure 9 Original image
After that, the process was steered towards the elimination of parts that are not of interest these were cut out to later modify the image starting from the colour components (RGB), see Fig. 10. The next step consisted in the execution of a morphological opening operation, which consists of eroding an image and then dilating it. In the erosion a structuring element (in this case a circle) is passed through the image and the central value is replaced by the minimum value found in its vicinity. This causes regions with high values to shrink in size. By making the disk take a significant size (e.g., 100 pixels), these regions will disappear completely. After the erosion, the dilation is applied so that the region to be analysed regains its original size (now with low values), as can be seen in Fig. 11. Basically, with this procedure the Petri dishꞌs background value is being obtained despite the changes of lighting present in the image. Having the segment of the image to be analysed and its background, we proceeded to subtract the two images obtaining the pixels of interest (corresponding to the colonies), as can be seen in Fig. 12. Subsequently a binarization of the image is performed by means of a pre-established threshold, the smaller regions (corresponding to the noise) are eliminated and the rest are characterized. The characteristics correspond to the size and location of its centroid. Finally, a count of the CFU is made, as can be seen in Fig. 13.

User Interface
The user interface (Fig. 14) created, has two main panels, one for controlling the device and the other for the digital treatment of images. For the case of this device, there were two buttons that allowed executing the block diagram of the controller program and finally analyzing the graphics of the closed loop control system.
For the digital image treatment panel there were also two buttons, one for the capture and recording of images for every determined time and another for the treatment of digital images algorithm's execution, with the purpose of analyzing the behavior and evolution of CFU.

TESTS AND RESULTS
An experimental test was conducted for the food industry in which the behavior and evolution of CFUs present in raw milk was studied in order to diagnose the quality and if this was suitable for human consumption, obtaining a prototype in model real. In Fig. 15 you can see its external appearance (A) and its components on the inside (B). In the analysis process, it was determined that it was of vital importance that the controller was in optimal operation, for this, it was recommended to preheat the module for a period of 10 minutes to achieve the stabilization of the same at the desired incubation temperature, for the current case of 37 °C; Then, the sample was placed in the module, where the artificial vision process began, to then start the program under the parameters already entered by the user. Afterwards, an image capture was made every so often, covering the whole process that lasted 24 hours, and a record was kept in images.
For the analysis of the behavior of the evolution of CFUs present in raw milk, the treatment of images previously described to each of the images had to be done, in order to observe the evolution and formation of said CFU, in addition to this data such as number of colonies, formation time, among others was acquired.
For the final count of the CFUs, the last image was analyzed (see Fig. 16), and thus a report which served as the basis to decide whether the sample complied or not was generated with the UFC standards for human consumption, based in the existing regulations and in technical concepts of the operator. Then it was preceded to perform the following calculation: Where: N -colony forming units per millilitre sample / CFU/ml C -total number of colonies on the plate (6) D -factor or inverse of the dilution (10 4 ) 6 10000 60000 CFU/ml N    According to the final test result, in order to determine the hygienic quality of the sample of raw milk, it was determined that the product was fit for consumer consumption. The foregoing was based on what is stated in the Colombian regulations under Decree 2838 of 2006, which regulates the microbial study for the food industry [11].
With the final treatment of the images, the data from the CFU areas were analysed in the final count, condensed in Tab. 2.  As can be seen, the time in which each of the colony forming units evolve (Fig. 17) was analysed. In the test carried out in the CFU present in the sample of raw milk, with a duration of 24 hours (we highlight the time), it can be noted that the behaviour of the samples [1][2][3][4]6] was not very relevant in its evolution, noting that sample 5 (Fig. 18) obtained a great evolution until the end of the process.
We observe its evolution and the change in size respecting the time and the area to study, where it is shown that from the beginning to the 480th minute there was no evolution, from that moment on, its evolution was increasing significant until the end of the process.

CONCLUSIONS
This prototype contributes to the technical and scientific development for the research areas in the food industry, given the importance of the determination of CFU as the aerobic mesophilic bacteria count, the most indicated test to determine the hygienic quality of the milk.
This prototype, in addition to automatically counting the CFU, allows us to monitor the growth of itself, without altering the temperature conditions, which opens the door to future investigations where premises can be taken in a much shorter analysis time. On the other hand, this prototype allows UFP to be counted in less than a second, which could be used to analyse experiments with a smaller number of dilutions and draw conclusions more quickly, considering them as future work.
Additionally, this prototype can calculate each of the areas of the CFU with which very accurate data for future research can obtained.