Application of image processing using NI LabVIEW for mold distribution analysis in blue cheese

The NI LabVIEW is a software for real-time data processing and it is widely used for process control in industry. It has a lot of additional libraries and modules which extend its functions and support its applications in many different areas. Vision Builder and Vision Assistant are modules in NI LabVIEW which support image acquisition and processing. These modules are used for the purpose of the current research in order develop an algorithm to analyze mold distribution in blue cheese. Eight trademarks of blue cheese are used for comparative analysis of mold distribution. Every sample is cut with special cheese slicer in order to evaluate its mold distribution. The samples are captured with digital camera and images are processed in NI LabVIEW environment. Coefficient of mold (ratio of pixels with mold to all pixels in cut surface of cheese) is calculated for nine regions of interest on every picture. This coefficient is used for statistical analysis of mold distribution. It is observed that cheese which have low quantity of mold are presented with non-even mold distribution and cheese which have high quantity of mold are presented with almost even mold distribution. The results show that the upgraded experimental setting could be successfully applied for mold distribution analysis of blue cheese and the LabVIEW environment and its software modules Vision Builder and Vision Assistant could be effectively applied for fast and accurate evaluation of mold quantity and distribution in blue cheese.


Introduction
The visual characteristics of food have high value for human because the human receives the biggest portion of information about environment through his vision (Hutchings 1977;Brunso et al. 2002;Spence et al. 2016;Milanova et al. 2012). Because of this a lot of researches are made in order to improve parameters of visual quality of food: -the quality of fresh-cut fruit and vegetables depends on temperature, atmosphere, relative humidity, and sanitation during processing operations (Barrett et al. 2010). It is observed that physical cutting and processing plant tissues increase the effect of stress which influence on visual quality of fruits and vegetables; -the quality of veal meat during the storage process depends on the preservative effects. A research over preservative effects of a sodium caseinate (SC) coating enriched with Zataria multiflora Boiss. essential oil (ZMEO) proves that this coating prolongs shelf life of meat without undesirable effects on sensory quality (Lashkari et al. 2020).
-the healthy additives are popular in bread production especially to enhance nutritional characteristics, and at the same time retaining the quality and competitiveness of the product. The researchers report that the sensory quality of bread with wheat flour replaced with corn (20%) or green banana (10%) flour is acceptable for consumers (Alcantara et al. 2020). Thanks to the progress of computer techniques a lot of parameters of visual quality of food are measured through computer vision systems. NI LabVIEW is one of the most popular software products with abilities for application of computer vision in varieties of industries. LabVIEW and IMAQ are used for developing of system for fast and accurate quality control in lighting industry (Ng et al. 2011). Six weeks after the start of exploitation of this system, it is observed a significant reduce of the scrap. External defects of batteries are automatically recognized through image processing in LabVIEW using NI vision assistant (Shuprajhaa et al. 2016). A surface defects on oranges are detected by images processing with LabVIEW and Vison Builder (Reparis et al. 2005). Last years some parameters of quality and functional characteristics of variety of cheese types are analyzed through images processing with NI LabVIEW and its modules. It is presented an application of NI LabView and IMAQ for mold detection on yellow cheese (Dobrev 2019). Images analysis with LabVIEW is used for measurement of melting property of Cheddar cheese (Chevanan and Muthukumarappan 2007). The software LabVIEW and Vision Builder are used for quality analysis of Bulgarian white brined cheese (Ganchovska et al. 2012). An image processing algorithm for evaluation of distribution of blue mold on cut surface of the cheese is developed and it is tested with five types (different trademarks) of blue cheese (Ganchovska et al. 2019). Quantity and distribution of mold influence on the sensory parameters for blue cheese quality. The aim of this study is to present a modification of algorithm for evaluation the distribution of blue mold on cut surface of the cheese. The modified algorithm is implemented using NI Vision Builder and NI Visual Assistant. The need of this modification appears after an upgrade of experimental setting in the laboratory for computer vision in Department of Computer Systems and Technologies at the University of Food Technologies, Plovdiv.

Materials and Methods
Experimental setting. The system for images acquisition is developed in Department of Computer Systems and Technologies at the University of Food Technologies. It consists of camera for images capturing, lighting module (ring, 500 lux), tripod and digital camera. The camera for images capturing is a cube with sizes 600 mm and it is covered with dark enclosure white-colored inside. The lighting module is positioned in the center of the upper side of camera and the distance between lighting ring and the base of the camera is 400 mm. The position and shape of lighting module reduce shadows in cavities of cheese samples in comparison with other position and shapes of lighting modules (positions in edges of the capturing camera). This system is upgraded with modern digital camera Canon EOS 2000D with 24.1 Mpx resolution and CMOS sensor. The base of the camera for images capturing is also upgraded with black pad for background homogenization. The cheese samples have light color (excluding mold color) and thus the contrast between pad and sample is good.
Samples of blue cheese. Eight trademarks are chosen for experiments (Bergader, DorBlue, DorBlue 50% fat, DorBlue 55% fat, Emborg Urenholt, Ramberter, Steffel Granbavareze). Two pieces of every trademark are purchased from marketplace. All pieces of blue cheese have parallelepiped form with height about 250 mm. Every block of cheese is cut with special slicer and cut surfaces are captured with digital camera. The distance between the cheese sample (cut surface) and digital camera is 260 mm. The pictures are stored in BMP format.
Algorithm for images processing. It is used an image processing algorithm for evaluation the distribution of blue mold on cut surface of the cheese which is presented on the International conference CompSysTech in 2019 (Ganchovska et al. 2019). This algorithm is modified in order to work properly with images acquired through upgraded experimental setting. Figure 1 presents the modified algorithm.
The blocks with red color are implemented in NI Vision Builder and blue-colored blocks are implemented in NI Vision Assistant (they are subroutines). The first step is to be chosen a directory with images ("Load image"). The next step is "Spatial calibration" in order to measure objects in real measurement units (mm). The color checker card (especially its linear component) is captured and applied for calibration and the result is 10 mm=121 pixels. After that it is performed the brightness and contrast adjustment. These enhancements influence on the mold outline which leads to effective mold extraction in next steps of processing. The next step (step four) is object extraction. On this step some modifications are done in comparison with algorithm developed for non-upgraded experimental setting. Figure 2 presents an original image -(a), Saturation plane of the same image (in HSL color system) -(b) and Red plane of the image (in RGB color system) -(c). It is observed that a shine is not emphasized on Red plane, thus this plane is chosen for further analysis. The shine is a reflection of light from lighting source (ring module).
Other modification of the algorithm is choosing a different thresholding value in comparison with the base algorithm. Figure 3 presents processed image after thresholding with selected value of base algorithm -(a) and processed image after thresholding with corrected threshold value -(b). Тhe histogram of images is bimodal and the corrected threshold value is closer to peak of histogram which presents dark pad color. It is observed that image on Figure 3(b) does not contain spots outside the object (the cut surface of the cheese) and because of this the corrected threshold is chosen.  The operation "Remove small objects" is used because it clears detected objects in border areas of the image. It could be seen a shoulder of tripod on figure 3 which will be removed by this operation. The base algorithm uses this operation with 14 iterations but modified algorithm uses 29 iterations for "Remove small objects" operation. Figure 4 presents original image and fragment of this image processed with 14 iterations (the middle part of figure), and with 29 iterations (right side of figure). It is observed that the number of iterations influence on removing of small spots near to cheese sample. Because of this the high number of iterations is preferred. The next operations are morphological and they are: dilation, erosion and filling holes. These operations are new in the modified algorithm. The main reason for addition of morphological operations is the presence of samples with growing mold on borders of piece of cheese. The reason for mold growing near to cheese border is the usage of piercing as a part of technological process. This manipulation is often preferred in order to introduce more air into cheese matter which improve conditions for mold growth. After cheese piercing, cavities are formed in cheese matter and these cavities are areas which provide good conditions for mold growth. The processing of images of such samples (with mold growing on borders of the cheese) without additional morphological operations destroys the contour of the sample (Fig.  5a). By this way big area with mold will be excluded and area of sample (cut surface) will be incorrectly calculated. Figure 5 presents an image before and after application of morphological operations. After dilation the contour of sample is restored but area of sample significantly increases. On the next step erosion is performed and it decreases the area (Fig. 5c). The last morphological operation removes the black spot inside object (Fig.  5d).  Operations erosion and dilation use a structuring element which is a square with size 3 (Fig. 6). The operation dilation is performed with 8 iterations. The operation erosion is performed with 11 iterations. The last morphological operation (Filling holes) removes black spot inside the object. Then the image is inverted and the result is stored (BufferObject) in order to be used as a pattern for other calculations.

Figure 6. Structuring element for morphological operations
After object extraction, the next step is counting the number of pixels of object. The sixth step of algorithm presented on Figure 1 is a sub-routine implemented in NI Vision Assistant. On this step the modifications are two. First modification is a correction of threshold value in order to extract the mold and second modification is an usage of addition between BufferObject and BufferMold in order to extract only pixels of mold. Figure 7 presents mold extraction.
The seventh step of images processing algorithm is "Detecting areas with mold in five ranges". The ranges are defined as follows: -Range 1: very small areas with mold (size < 1 mm 2 ); -Range 2: small areas with mold (size between 1 mm 2 and 9 mm 2 ); -Range 3: visible areas with mold (size between 9 mm 2 and 36 mm 2 ); -Range 4: big areas with mold (size between 36 mm 2 and 100 mm 2 ); -Range 5: very big areas with mold (size > 100 mm 2 ). On the next step of image processing algorithm, the coefficient of mold for whole cut surface is calculated by next formula: Where: Ao is the number of pixels of the whole cut surface; Am is the number of pixels in all areas with mold.

b) Dilate objects d) Fill holes c) Erode objects a) Before morphological operations
The next step is "Define 9 ROIs for object". First of all, the rectangular ROI (Region of Interest) is defined as an outside border of cheese sample. This ROI is divided into 9 equal by sizes regions. The central ROI contains only pixels of cut surface but other eight ROIs contain pixels of object and pixels of background. Because of this on the next step of images processing algorithm ("Calculation the coefficient of mold for ROIs") calculation of Cm is specific for eight border ROIs. The value of Ao is smaller than product of width and height of the ROI because its value is equal to number of pixels in the part of object which are situated in this ROI. The last step of images processing algorithm is "Save Data". On this step all calculated coefficients and areas with mold by ranges are stored in csv file.

Statistical analysis.
The data for coefficient of mold (Cm) for ROIs of every trademark are used for analysis of mold distribution. Mathematical expectation of Cm is defined as average for all samples of examined trademark: The value of N is between 36 and 72 because the number of cut surfaces for every cheese is different. Some trademarks have soft consistency and because of this the thickness of slices is bigger than the thickness of slices of the samples with a hard consistency. The dispersion and the standard deviation σ are determined by formula 3. (3) For each trademark of blue cheese, the upper LMAX and the lower LMIN limits of Cm are calculated by formulae (4).
where t is Student's t-distribution, φlikelihood, αlevel of confidence. The probability is chosen to be ≥ 95% (α ≤ 0.05) according to the results of previous researches (Ganchovska et al. 2019). Formulae 2, 3 and 4 are based on known statistical functions (Ramachandran and Tsokos 2015).
It is calculated a factor of mold even distribution (fe) as a ratio of Cm values which fall in confidence interval (between LMIN and LMAX) to the number of all Cm values for every trademark. = . 100 In formula 5 with nCi is noted number of Cm values which are between limits LMIN and LMAX and with N it is noted number of Cm values.

Results and Discussion
The images of examined cheese samples are processed with a modified algorithm and the average values for coefficient of mold are summarized by trademarks and presented on figure  8. It is observed that cheese "Emborg Urenholt" has the biggest value for coefficient of mold and cheese "Paladin Blue" has the smallest value for coefficient of mold. The Figure 9 presents the values of fe for all samples summarized by trademarks.
It is observed that the cheese which has high Cm (above 10%) also has almost even mold distribution (fe ≥ 0.5). Only the samples of trademark "Ramberter" have average Cm = 7.84 but the mold is distributed evenly (fe = 0.6). The next two figures present images with nine ROIs and graphics with Cm values for samples with small quantity of mold and samples with higher quantity of mold. Table 1 presents statistical data for examined cheese samples summarized by trademarks. The analysys is performed for α≤0.05. It is observed that the bigest standard deviation for Cm values is calculated for samples of EmborgUrenholt.
The main reason is presence of many areas occupied by mold and small number of areas (near to border of the cheese sample) with small growth of mold (Fig. 13).   The cheese sample of "Paladin Blue" (Fig. 10) has small quantity of mold (Cm = 4.12) and unevenly distributed mold (fe = 0.22). It could be seen that values of Cm for only two ROIs are between the calculated limits. The cheese sample of "Ramberter" (Fig. 11) also has small quantity of mold (9.37) but mold distribution is almost even (fe = 0.78).
The cheese sample of "Dor Blue (50% fat)" (Fig.  12) has big quantity of mold (Cm = 12.9) and even mold distribution (fe = 0.56). For this sample four Cm values are outside the limits. The cheese sample of "Emborg Urenholt" (Fig. 13) has very big quantity of mold (Cm = 33.98) and unevenly distributed mold (fe = 0.33). It could be seen that values of Cm for only three ROIs are between calculated limits.

Conclusions
It is developed an application using NI Vision Builder and NI Vision Assistant which implements a modified algorithm for images analysis of cut surface of blue cheese. This application is used for mold distribution analysis of samples of eight trademarks blue cheese. The results could be summarized as follow: -the upgraded experimental setting could be successfully applied for mold distribution analysis of blue cheese; -the LabVIEW environment and its software modules Vision Builder and Vision Assistant could be effectively applied for fast and accurate evaluation of mold quantity and distribution in blue cheese; -the cheese which have low quantity of mold often are presented with non-even mold distribution, and the cheese which have high quantity of mold in most cases are presented with almost even mold distribution.
The algorithm for images processing could be improved with implementation of options for setting the number of ROIs by user. This improvement will allow more precise analysis of mold distribution in blue cheese. Other improvement could be an implementation of analysis of level of mold growth which could be done by analysis of color intensity for detected pixels with mold. The future work will continue with embedding the images processing algorithm and the statistical analysis in a single LabVIEW application. This application could be tested to work real-time in order to support quality control in process of blue cheese production.