A microscopic computer vision algorithm for ...

0 downloads 0 Views 2MB Size Report
Jun 7, 2018 - The size distribution of bubbles in cake batters is often determined from .... could range between 0.5–0.9, as with sponge and angel cakes.
A microscopic computer vision algorithm for autonomous bubble detection in aerated complex liquids N.N. Misra* 1 , Rohit Phalak2 , and Alex Martynenko„ 3 1

Research & Development, General Mills India Pvt Ltd, Mumbai, India 2 Research & Development, General Mills India Pvt Ltd, Mumbai, India 3 Department of Engineering, Faculty of Agriculture, Dalhousie University, Canada June 7, 2018

Abstract The size distribution of bubbles in cake batters is often determined from optical microscopic imaging, considering the lesser availability and non-affordability of sophisticated techniques such as light scattering, and acoustic methods. We present an automated bubble detection and counting method from microscopic images, that is flexible and robust than existing manual approaches. The method is able to successfully resolve connected bubbles and recognise far many bubbles in an image than would be possible by naked eye or hitherto reported methods in chemical and food engineering literature. Furthermore, the size data obtained for the bubbles can easily be used for routine statistical analysis. We demonstrate the application of our method for studying the influence of two different mixer geometries and three different speeds on bubble size.

Keywords: Cake batter; Foam; Aeration; Image Analysis; Log-Normal

Contents 1 Introduction

2

2 Experiments 2.1 Batter preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Image acquisition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4 4 5

* Present

Address: Center for Crops Utilization Research, Iowa State University, Ames, IA 50011 author; E-mail: [email protected]

„ Corresponding

1

3 Image analysis 3.1 Pre-processing . . . . . . 3.2 Image binarization . . . 3.3 Segmentation . . . . . . 3.4 Geometric properties . . 3.5 Bubble size calculations

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

4 Results & discussion 4.1 Choice of thresholding . . . . . . . . 4.2 Bubble detection . . . . . . . . . . . 4.3 Bubble size distributions . . . . . . . 4.4 Effect of mixing speed on distribution

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . . . . . . . . . . . . . . . . . . parameters

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

. . . .

. . . . .

5 5 5 6 6 7

. . . .

8 8 9 11 11

5 Conclusions

12

6 Future Research

13

Nomenclature P¯

Perimeter of the region

b(x, y) Binary image

µ

Mean of the log-normal distribution

db

Mean bubble diameter, µm

µg

Geometric mean of the distribution

Di

σ

Standard deviation of the log-normal distribution

Midpoint of the i-th class in the histogram of bubble sizes

Deq

Equivalent diameter of the region

σg AR

1

Geometric standard deviation of the distribution

f (Di ) Probability density function of Di

Area of the region

Th

R(x, y) Image region Threshold value

Introduction

The bubble size distribution in viscous aerated foods has a large effect on their bulk physical properties (Labbafi et al., 2007). The size distribution of bubbles depends on the process of gas infusion, product viscosity and mixing technology. Mixing and homogenizing of viscous foods, such as cake batters, provides uniform distribution of bubbles over the volume; however this discrete structure is not stable over time. In Angel cakes and similar recipes, the bubbles remain relatively discrete as the high viscosity of the continuous phase retards coalescence (Chesterton et al., 2013). Despite widespread practice of bubble inclusion into foods as unit operation, bubble size distribution has received relatively little research attention. Batters are highly viscous liquids with a dispersion of numerous bubbles of wide ranging sizes and are commonly designated as complex liquids (Misra and Tiwari, 2014; Van der Sman, 2

2012). Consequently, they do not allow sufficient light transmission during imaging microscopy. In addition, if the sample on a glass slide is thicker than the typical diameter of the bubbles, refraction of light and noise from other dissolved substances become challenging. The challenges turn even more prominent when bubbles overlap. To increase the visibility under a light microscope, Sahi and Alava (2003) recommended placing the sample between microscope slides. However, this approach affects intact food structure and considerably increases the probability of bubble coalescence due to compression and formation of liquid bridges because of capillary forces. Thus, direct observation of undisturbed batter samples, placed on microscopic slides is preferable. Traditionally, bubble size quantification in cake batters has been performed by manual detection and counting of bubbles available from light microscopy images. A summary of the experimental studies in literature employing microscopic image analysis of batters is provided in Table 1. Massey et al. (2001) employed a horizontal pressure whisk aerator at 102 rpm and 300 rpm, whereas Chesterton et al. (2013) employed a vertical wire whisk planetary aerator at 61, 125, and 259 rpm. The traditionally employed microscopic methods are time consuming and subject to both human error and experimenter bias. Automation of the measurement process has the potential to improve the accuracy of the measurements, considerably reduce the time required for analysis, and promote reporting of size distribution data by food researchers. Moreover, an increasing number of research topics and applications in chemical, food and pharmaceuticals demand a precise measurement of the bubble and particle size distribution in liquids through reliable and automated image analysis (Arnaout et al., 2016). Table 1: Bubble sizes reported from analysis of optical microscopy images of batters. (Emul.: Whether emulsifier added; db = Mean bubble diameter) Batter type Sponge cake Sponge cake Sponge cake High ratio High ratio

Emul. Yes No Yes No Yes

Size db = db = db = db = db =

(µm) 70-110 35-50 20-50 25-45 7-29

Mixing/Time (rpm/min) Whisk (102, 300/2-30) Whisk (102, 300/2-30) Rotor-stator (300/n.a.) Whisk (61, 125, 259/0-10) Whisk (61, 125, 259/0-10)

Source Massey et al. (2001) Massey et al. (2001) Sahi and Alava (2003) Chesterton et al. (2013) Chesterton et al. (2013)

In this work, an automated approach to obtain bubble size distribution from microscopic images that overcomes many of the limitations of existing methods is presented. The method enables to detect bubbles in noisy images obtained from direct microscopic imaging of translucent batters, whereas earlier methods required batter handling for long durations (Sahi and Alava, 2003). Our approach is robust, flexible and has the ability to detect maximum number of bubbles, without the requirement of any human intervention to trace the bubble boundaries (Massey et al., 2001; Jakubczyk and Niranjan, 2006). The method is free from any approximation with regards to the minimum or maximum bubble size, as with Hough transformation (HT) based methods. In addition, it allows to eliminate the need for expensive computer hardware, enabling the method to be used more routinely and effectively in food research laboratories. To demonstrate the real-world applicability of the method, the effects of mixer geometry and the mixing speed on the bubble size distribution in a non-ideal cake batter system is quantified. 3

2 2.1

Experiments Batter preparation

The composition (%w/w) of the non-ideal, model batter prepared for all studies described in this work is as follows: flour (28%), sugar (31.5%), egg white powder (6%), ammonium bicarbonate (0.5%), and water (34%). The batter was prepared by mixing the ingredients in a Hobart bench-top mixer at low speed (60 rpm) for 1 minute, followed by 5 minutes of mixing at slow (60 rpm) or intermediate (125 rpm) or high speed (250 rpm), depending on the experiment. The specific gravity of the model batters prepared for this work ranged between 0.9–1.08 (in the order of chocolate and other “rich” cakes), depending on the mixing process. However, for other commercial batter formulations, under similar aeration conditions, the specific gravity could range between 0.5–0.9, as with sponge and angel cakes. Experiments were carried out using two different mixing elements, viz. a wire whip, and a flat beater to compare the resulting effects (see Figure 1). For each experiment a 1 kg batch of the batter sample was freshly prepared. Details of the experimental conditions are provided in Table 2.

Figure 1: The wire whip (left), and the flat beater (right) mixer geometries.

Table 2: Details of samples prepared and experimental conditions. Sample Code RPM60 W RPM125 W RPM250 W RPM60 P RPM125 P RPM250 P

Mixer geometry Wire Whip Wire Whip Wire Whip Flat Beater Flat Beater Flat Beater

4

Speed (rpm) 60 125 250 60 125 250

2.2

Image acquisition

The batters to be analysed were prepared for microscopy immediately after mixing. Two microscopic slides were prepared for each sample and four images from different non-overlapping spatial locations were acquired per slide. For sample preparation for microscopy, a drop of the batter was placed on a glass slide and allowed to spread by holding the slide in a slanted position. The sample was not covered by a cover glass to prevent the bubbles from flattening and thereby increasing the chances of coalescence. Slides were observed under an optical microscope (Olympus CX41, USA) with a 10× magnification objective lens. A digital camera (QImaging Micropublisher 3.3 RTV, BC, Canada) was mounted on the microscope, and in turn connected to a personal computer. Images were acquired at 925×694 pixels and stored using QCapture Pro 7 software (QImaging, BC, Canada). For calibration, a transparent micrometer scale was employed to determine the number of pixels per measured physical length. The process of sample preparation and image acquisition altogether required less than 3-4 minutes. When thin films of batter are left open to ambient conditions for more than 7-8 minutes, drying effects become pronounced. It should be noted that such a loss of moisture may affect the matrix properties and thus, the bubble dynamics (e.g., disproportionation rate).

3

Image analysis

An algorithm for the automated detection and morphological measurement of the bubbles in the image was developed. A Computer code for the image analysis algorithm was scripted in MATLABTM (The Mathworks Inc, MA). The algorithm for bubble detection in the images involved the following steps: preprocessing, thresholding, distance transformation, watershed segmentation, feature screening to detect the bubbles, and analysis of the features detected. Detailed accounts of the algorithm are provided in the following subsections.

3.1

Pre-processing

The image pre-processing step involved conversion of the red, green and blue (RGB) channel images into HSV (hue, saturation and value), followed by extraction of the value matrix (Vchannel) for all further processing. Each pixel of the V-channel image was squared to emphasize the darker objects, followed by median filtering to remove the “salt and pepper” noise (also known as speckle noise). The speckle noise primarily arises from malfunctioning pixels in camera sensors, faulty memory location in hardware or error in data transmission (Vasicek and Sekanina, 2008). It should be noted that the median filter, though computationally slightly expensive, does not create new unrealistic values near the edges and preserves sharp edges Ruparelia (2012). These pre-processing steps aided in preventing over-segmentation when applying watershed algorithm (described later).

3.2

Image binarization

The output of a thresholding operation is a binary image whose one state will indicate the bubbles, while the complementary state will correspond to the background. The thresholding 5

procedure essentially transforms a gray scale image (in which any pixel assumes values ranging from 0 to 1) into a binary one, suitable for object identification. Mathematically, this is described by the following expression, relating the pixel luminance l(x, y) of the original image to the pixel luminance of the binary image b(x, y): ( 1 if l(x, y) ≥ T h b(x, y) = (1) 0 if l(x, y) < T h where, T h is the threshold. Now, the crucial step is to choose a proper thresholding value. The methods available for image binarization can be conveniently classified into global, local and adaptive. After initial screening, we evaluated the performance of two different thresholding methods for binarization in our work, viz. Otsu’s method (global) and Bradley’s method (adaptive). The algorithm for Otsu thresholding performs cluster analysis to find the optimal threshold value by minimizing the weighted sum of the variance of the pixel values within the foreground and background clusters (Otsu, 1979). The Bradley’s method relies on a adaptive thresholding algorithm wherein the pixel is set to black (0) if its brightness is a certain percent lower than the average brightness of the surrounding pixels in a specified window, otherwise it is set to white (1). This is sometimes also referred to as dynamic thresholding. Details regarding Bradley’s adaptive thresholding method can be found in Bradley and Roth (2007).

3.3

Segmentation

To improve the accuracy of object boundary detection, the binary images were used as active contours for Chan-Vese active contour (AC) partitioning (Chan and Vese, 2001) using the builtin algorithm in Matlab. The AC method was applied to the original images after conversion to grayscale. As expected, the bubbles have a morphology different from that of particles, in that there exist holes in the binarized images. Therefore, a hole-filling step was necessary prior to the watershed segmentation and determination of region properties. Once the binary image were visually ascertained to be of high accuracy, the bubble containing regions were to be separated for computing various characteristics that could be used for bubble localization. This process of segregating the image into multiple homogeneous segments such that pixels within the same region are similar in nature is called segmentation. We employed an efficient watershed image segmentation algorithm on the Eucledian distance transformed images, considering the low computational complexity and wide recognition for optimal segmentation results (Vincent and Soille, 1991; Tarabalka et al., 2010). The distance transform of a binary image is the distance from every pixel to the nearest nonzero-valued pixel.

3.4

Geometric properties

Suppose, we denote the set of pixels in each segmented region by R. The area of a region (AR ) is then calculated as the number of pixels that form the object (mathematically equivalent to the zeroth moment of the region): ZZ X AR = R(x, y) dx dy = R(xj , yj ) (2) 6

where, R represents the region of the binary image. The co-ordinates of the region centroids (xc , yc ) ∈ R was computed as the first moment using the following relations1 X xj ∈ R(xj , yj ) AR 1 X = yj ∈ R(xj , yj ) AR

xc =

RR

xR(x, y)dxdy/As =

(3)

yc =

RR

yR(x, y)dxdy/As

(4)

where, the integrals are over the area occupied by the regions obtained from segmentation. The equivalent diameter of the regions was calculated using the relationp Deq = 4AR /π (5) In order to ensure that the regions obtained from the segmentation actually correspond to signals from air bubbles, the following criteria was imposed to be satisfied (P¯ − πDeq )/Deq < 1 2

(6)

where, Deq is the equivalent diameter, and P¯ is the perimeter of the region calculated as the sum of all distances measured from edge pixels. The value of 0.5 was chosen based on screening of many bubble versus noise regions and the results were found to be optimal. Note that one could in practice, employ any of the several other relations for circularity, depending on the problem in hand. The equivalent diameter of each region was multiplied by the calibration factor to obtain the value in physical units. For completeness and reproducibility, a pseudo-code is provided in algorithm 1.

3.5

Bubble size calculations

Bubble size distributions resulting from mixing processes are known to be asymmetrical and skewed to the left, suggesting that the distribution is log-normal (Limpert et al., 2001; Bellido et al., 2006). To determine the parameters of bubble size distribution, we fitted the diameter data to log-normal distribution. A logarithmic normal distribution is a continuous distribution of a random variable whose logarithm is normally distributed. Log normality has been qualitatively defined by Kolmogoroff (1941) as ‘the asymptotic result of an iterative process of successive breakage of a particle into two randomly sized particles’. The positive random variable bubble diameter Di > 0 of the batter was statistically described by two parameters, the mean µ, and the variance σ 2 . This characterization assumes that the random variable, ln Di is normally distributed, and the probability density function of Di is given by (Crow and Shimizu, 1988)  (ln Di − µ)2 1 √ exp − ; Di > 0 (7) f (Di |µ, σ) = 2σ 2 Di σ 2π where, f (Di ) is the probability density function of Di , µ is the mean of the log-normal distribution, σ is the standard deviation of the log-normal distribution. We wish to point that the interpretation of data in the log scale is often not very intuitive and therefore, the statistical 7

parameters (µ, σ) are often transformed back into their original scale for reporting purposes, as followsµg = exp(µ) σg = exp(σ)

(8) (9)

where, µg and σg represent the geometric mean and the geometric standard deviation, respectively, of f (Di ). Next, the χ2 -test reveals whether the sample distributions actually follow the theoretic distribution, within a specified confidence interval. Therefore, we evaluated the χ2 statistics to assess whether each experimental bubble size distribution is consistent with the theoretic distribution. In all the cases, we found the hypothesis to be valid at 95% level of confidence.

4 4.1

Results & discussion Choice of thresholding

An example of the microscopic image of batter is presented in figure 2 (left), wherein bubbles appear as two-dimensional bright circles with a dark boundary. This boundary is due to the refraction of light at the interface of the bubble towards the center which depends on the differences in the refractive indices of the two phases (air/liquid) (Pateras et al., 1994). The bubbles are almost perfectly spherical bodies due to the Laplace pressure. Original

Otsu

Adaptive

Figure 2: An exemplary microscopic RGB image of the batter (left); the binary image obtained via Otsu thresholding (middle), and adaptive thresholding (right). (Colour online) The raw images reveal two types of noise overlaid over the signal- (1) noise from spatial depths, due to the direct imaging of a thick layer and the high spatial bubble density (“outof-focus” noise), and (2) background noise from the presence of several dispersed particles, primarily wheat flour and proteins. The second type of noise could easily be eliminated through median filtering (or a combination of suitable filters) as the dissolved substances cause nonuniform brightness, and contrast over the spatial regions. The first type of noise, i.e. “outof-focus” noise requires the careful selection of a suitable thresholding method. The results from the two different threholding methods that we explored are provided in figure 2. It can 8

be observed that the adaptive thresholding (Bradley’s method) resulted in considerably better binarization. The underlying assumption of Otsu’s method is that the histogram of the image follows a bi-modal distribution. However, the images seldom follow a clear bimodal distribution, owing to the non-uniform light transmission and a differential thickness across the field of view. Thus, the adaptive thresholding also overcomes the issue of non-uniform lighting. Number of Pixels

Red Green Blue

0.2

0.4

0.6

0.8

1.0

0.2

0.4

0.6

0.8

1.0

Number of Pixels

0.0

0.0

Intensity

Figure 3: Histogram of the red, green, and blue channels of the image in figure 2 (top), and the corresponding grayscale image (bottom). The histograms are approximately bimodal. (Colour online) The Eucledian distance transformation allowed to distinguish the overlapping and touching bubbles during segmentation (see figure 4). The segmentation process yielded numerous disjoint regions as can be observed in the image on the right in figure 4.

4.2

Bubble detection

Our computer program successfully identified a population of over 100 to 350 bubbles in each image and more than 1800 bubbles for each sample of the batter analysed through 5 to 8 images (see figure 5). Obviously, this would be a tiresome exercise if carried out manually. The adaptive thresholding algorithm was chosen as the method of choice for all further analysis, as it successfully tackled the issues with non-uniform brightness, contrast, and noise. At first sight, it may be argued that edge-detection methods could be suitable for the bubble detection challenge. However, it should be noted that edge-finding algorithms operate by detecting sudden changes in grey-scale values, making them susceptible to miscounting overlapping bubbles in the images for batter. Similarly, it may also be argued that circular Hough transformation method (HTM) can be employed for the task of bubble detection (Barber et al., 2001; Ballard, 1981). We found HTM to be little useful for bubble counting in microscopic images considering several false detections and/or low detection rates. In addition, HTM requires a prior knowledge of the size range of bubbles to be detected in pixel units and is computationally very expensive (Yuen et al., 1990). This could limit the size range of bubbles to be identified, 9

Eucledian distance transform

Segmented image 100 200 300 400 500 600

100

200

300

400

500

600

700

800

900

Figure 4: The Eucledian distance transformed image showing the centres of the bubble regions (left), and the pseudo-coloured segmented image from watershed algorithm showing the disjoint regions (right). (Colour online)

Bradley Method

Otsu Method

Figure 5: Example of the bubbles identified by the algorithm following Otsu thresholding (left), and Bradley’s adaptive thresholding method (right). Batter was obtained by mixing at 60 rpm for 5 minute using the flat beater mixer element. (Colour online)

10

as was reported in an earlier work (Gordiychuk et al., 2016). On contrary, our algorithm does not require any prior input with respect to the size range of the bubbles.

4.3

Bubble size distributions

The log-normal probability density of the bubble diameters for different experimental conditions are plotted in figure 6. The distributions when investigated on log-scale were confirmed to be unimodal and positively skewed (mean > median). The air-bubble size distribution tends to become narrower at higher mixing speeds. A narrow size distribution of the bubbles is known to minimize diffusion-controlled bubble coalescence, and improve the texture and mouth feel of the resulting cakes (Pateras et al., 1994). Thus, mixing at the maximum speed using the flat beater should be the method of choice for the batter composition chosen in this study. 0.02

0.015 0.15

Relative Frequency

Probability Density

250 rpm/whisk 250 rpm/beater

125 rpm/whisk 125 rpm/beater

60 rpm/whisk 60 rpm/beater

0.01

0.005

0

60 rpm/whisk 60 rpm/beater

0.1

0.05

0

0

100

2

2.5

200

3

3.5

4

4.5

log(bubble diamter)

300

Diameter (µm)

5

400

5.5

6

500

Figure 6: The log-normal probability density function, f (Di ) fitted to the bubble diameter dataset. Inset shows an example of a normalized histogram for logarithm of bubble diamaters at 60 rpm mixing speed for the two mixer types. (Colour online)

4.4

Effect of mixing speed on distribution parameters

As aeration progresses, the turbulence induced by the rotating mixing elements initiates breakup of bubbles. As a consequence, increasing number of small bubbles are formed with time. This implies that whisk speed determines the rate of aeration. The effect of mixing rotational speed on the mean bubble size for the two different mixing elements can be seen in figure 7. The mean bubble size is found to decrease with increase in the mixing speed. This result is follows 11

the trends reported in previous studies for food batters, wherein a linear decrease in bubble size with increasing speed are reported (c.f. Mezdour et al. (2008)). 54 Wire Whisk Flat Beater

52

Diameter (μm)

50 48 46 44 42 40 38 50

100

150

200

Mixer Speed (rpm)

250

Figure 7: The mean bubble diameter (µ) as a function of the mixing speed using the wire whisk and flat beater mixer elements. Error bars represent standard deviation of the size distributions (σ). (Colour online) In the present experimental situation, the results from image analysis lead us to the conclusion that a flat beater outperforms the wire whisk geometry. Note that a lower mean bubble size indicates higher population of smaller bubbles, whilst a greater mean bubble size corresponds to a higher population of larger bubbles. It may be noted that the geometric means in our experiments are notably larger than those reported in earlier studies (Chesterton et al., 2013; Massey et al., 2001; Sahi and Alava, 2003). This is because all the previous works employed emulsifiers in their formulation and/or the mixing speeds were much higher.

5

Conclusions

Recent progress in image recognition, processing and analysis boosted the development of particle size analyzers, sorters and classifiers for automated inspection of food product quality (Mittal, 1996). The present research demonstrated significant potential of image analysis for automated recognition of bubble size distribution in highly viscous transparent and semi-transparent liquids. An algorithm was developed for discrete measurements and analysis of information contained in individual images. The applicability of the algorithm was demonstrated for the study of the influence of mixer speed on bubble size distribution in cake batters. In its present state the method has the known limitation of being able to resolve bubbles of a minimum size of 6 µm diameter at 10× resolution and therefore, fails to detect some bubbles (see figure 8). When the 12

bubble size are expected to be smaller than this limit, a higher optical resolution for microscopy (> 10×) and a high resolution camera are recommended for image acquisition. This will lead to a trade-off between the number of samples to be prepared versus detecting the smallest possible bubble. Further, when offline analysis is intended, the ‘.tif’ (or any uncompressed) file format be used. When bubbles from several images are analysed, the accuracy in predicting the bubble size distribution increases. We recommend that at least 2000 bubbles be detected before embarking on the size statistics calculation step.

Figure 8: The arrows point at some undetected bubbles in a zoomed-in microscopic image. (Colour online)

6

Future Research

The algorithm developed in this work, though applied to independent images, is equally applicable to real-time or continuous measurements (using time-series analysis of image sequences). Our next step is the validation of the developed methodology for real-time, autonomous measurement of bubble size evolution in continuous flows, by continuously recirculating samples through a microfluidic stage with imaging capabilities. It is expected that the algorithm is particularly suitable for in-line analysis of viscous multi-phase flows, containing not only air bubbles, but also air voids or solid particles. It can be also applied for in-situ particle size analysis of undisturbed laminar flow of semi-transparent viscous foods, which is not possible to achieve with traditional light scattering based particle size analyzers. The range of applications

13

could be extended from evaluation of particle size distribution to characterization of the degree of homogeneity in multi-phase (gas-liquid-solid) food systems. Real-time image acquisition, processing and analysis could be implemented, using LabVIEW platform with embedded MATLAB scripts (Martynenko, 2017). In this case, real-time image analysis is beneficial for (i) precise estimation of bubble size distribution, and (ii) process monitoring and control, within the framework of the emerging process analytical technologies (PAT). The present work will open new opportunities for further development of intelligent control strategies in food and bio-processing of complex liquids, based on real-time estimation of product quality attributes, machine learning (for example, Bayes optimal classifier or neuro-fuzzy algorithms) and control actions. We expect that integration of computer vision and machine learning with decision-making framework will significantly improve mixing performance, energy efficiency, and product quality in chemical, food and pharmaceutical processing.

Acknowledgements NN acknowledges helpful discussions with Dr Kiran Desai, General Mills. Authors acknowledge the three anonymous reviewers for their valuable comments, which helped to improve the manuscript.

14

Algorithm 1 Bubble detection and counting Require: directory containing microscopic images of the sample Ensure: Im is RGB or grayscale 1: for Im in the directory do 2: if Im is RGB then 3: convert to HSV 4: vIm ← V-channel matrix 5: gsIm ← RGB to grayscale of Im 6: else if Im is grayscale then 7: vIm ← Im 8: gsIm ← Im 9: end if 10: vIm ← vIm(x, y)2 11: medFiltIm ← median filter of vIm 12: calculate local thresholds (Th) using Bradley’s adaptive method 13: bin1Im ← Binarize the image using the threshold calculated 14: bin2Im ← With binIm as active contour do Chan-Vese segmentation of gsIm 15: complement bin2Im 16: contour closing 17: hole filling 18: distance transformation 19: watershed segmentation 20: clear border objects 21: for all (xj ,yj ) pixels in disjoint regions R do 22: propsIm ← area, perimeter, and equivalent diameter of R 23: end for 24: if abs((perimeter - π×equivalent diameter)/equivalent diameter) < 0.5 then 25: declare as a bubble return bubble centroids (xc , yc ), diameter (Di ), and 26: geomteric properties of the bubble 27: else 28: discard the region 29: end if 30: end for 31: convert propsIm to physical units from calibration data 32: fit log-normal distribution to diameters (Di ) return µg , σg

15

References Arnaout, T. E., Cullen, P., and Sullivan, C. (2016). A novel backlight fiber optical probe and image algorithms for real time size-shape analysis during crystallization. Chemical Engineering Science, 149:42 – 50. Ballard, D. (1981). Generalizing the hough transform to detect arbitrary shapes. Pattern Recognition, 13(2):111 – 122. Barber, P. R., Vojnovic, B., Kelly, J., Mayes, C. R., Boulton, P., Woodcock, M., and Joiner, M. C. (2001). Automated counting of mammalian cell colonies. Physics in Medicine & Biology, 46(1):63. Bellido, G. G., Scanlon, M. G., Page, J. H., and Hallgrimsson, B. (2006). The bubble size distribution in wheat flour dough. Food Research International, 39:1058–1066. Bradley, D. and Roth, G. (2007). Adaptive thresholding using the integral image. Journal of graphics tools, 12:13–21. Chan, T. F. and Vese, L. A. (2001). Active contours without edges. IEEE Transactions on image processing, 10:266–277. Chesterton, A., de Abreu, D. P., Moggridge, G., Sadd, P., and Wilson, D. (2013). Evolution of cake batter bubble structure and rheology during planetary mixing. Food and bioproducts processing, 91:192–206. Crow, E. L. and Shimizu, K., editors (1988). Lognormal distributions: theory and applications. Marcel Dekker, Inc. Gordiychuk, A., Svanera, M., Benini, S., and Poesio, P. (2016). Size distribution and sauter mean diameter of micro bubbles for a venturi type bubble generator. Experimental Thermal and Fluid Science, 70:51 – 60. Jakubczyk, E. and Niranjan, K. (2006). Transient development of whipped cream properties. Journal of Food Engineering, 77:79 – 83. ¨ Kolmogoroff, A. (1941). Uber das logarithmisch normale verteilungsgesetz der dimensionen der teilchen bei zerst¨ uckelung. In CR (Doklady) Acad. Sci. URSS (NS), volume 31, pages 99–101. Labbafi, M., Thakur, R. K., Vial, C., and Djelveh, G. (2007). Development of an on-line optical method for assessment of the bubble size and morphology in aerated food products. Food Chemistry, 102:454 – 465. Limpert, E., Stahel, W. A., and Abbt, M. (2001). Log-normal distributions across the sciences: Keys and clues. AIBS Bulletin, 51:341–352. Martynenko, A. (2017). Computer vision for real-time control in drying. Food Engineering Reviews, 9(2):91–111. 16

Massey, A., Khare, A., and Niranjan, K. (2001). Air inclusion into a model cake batter using a pressure whisk: Development of gas hold-up and bubble size distribution. Journal of Food Science, 66(8):1152–1157. Mezdour, S., Balerin, C., Aymard, P., Cuvelier, G., and Ducept, F. (2008). Effect of the rheology of the continuous phase on foaming processes: Viscosity-temperature impact. In Campbell, G. M., Scanlon, M. G., and Pyle, D. L., editors, Bubbles in Food 2, chapter 18, pages 175 – 183. AACC International Press. Misra, N. and Tiwari, B. (2014). Biscuits. Bakery Products Science and Technology, Second Edition, pages 585–601. Mittal, G. S. (1996). Computerized control systems in the food industry. Marcel Dekker, Inc. Otsu, N. (1979). A threshold selection method from gray-level histograms. IEEE transactions on systems, man, and cybernetics, 9:62–66. Pateras, I., Howells, K., and Rosenthal, A. (1994). Hot-stage microscopy of cake batter bubbles during simulated baking: Sucrose replacement by polydextrose. Journal of food science, 59:168–170. Ruparelia, S. (2012). Implementation of watershed based image segmentation algorithm in fpga, university of stuttgart, germany. Master’s thesis. Sahi, S. S. and Alava, J. M. (2003). Functionality of emulsifiers in sponge cake production. Journal of the Science of Food and Agriculture, 83(14):1419–1429. Tarabalka, Y., Chanussot, J., and Benediktsson, J. (2010). Segmentation and classification of hyperspectral images using watershed transformation. Pattern Recognition, 43:2367 – 2379. Van der Sman, R. (2012). Soft matter approaches to food structuring. Advances in colloid and interface science, 176:18–30. Vasicek, Z. and Sekanina, L. (2008). Novel hardware implementation of adaptive median filters. In Design and Diagnostics of Electronic Circuits and Systems, 11th IEEE Workshop on DDECS 2008, pages 1–6. IEEE. Vincent, L. and Soille, P. (1991). Watersheds in digital spaces: an efficient algorithm based on immersion simulations. IEEE Transactions on Pattern Analysis and Machine Intelligence, 13:583–598. Yuen, H., Princen, J., Illingworth, J., and Kittler, J. (1990). Comparative study of hough transform methods for circle finding. Image and vision computing, 8:71–77.

17