*5.1. Deep-Learning Crystal Extraction*

The experimental case on the crystallization process of β-form LGA was carried out. Compared with traditional methods [8,10,11,33,34], the method of deep-learning crystal extraction did not require too many tedious procedures (e.g., image preprocessing steps or clear crystal identification, etc.). A typically captured image is demonstrated in Figure 6a. Figure 6b displays the result of image preprocessing. In Figure 6c, the crystals are extracted with the deep leaning-based image processing method applied to the image of Figure 6b. It is seen that the minimum enclosing rectangles of the crystals are obtained in Figure 6d. The 2D sizes were obtained from the fitting rectangles. In the experiment, 40 real-time LGA images were employed as the original training set, which uses image augmentation. Flips, translation and rotation were used for variety, and the brightness and contrast were adjusted to reduce the influence of uneven lighting. Finally, noise interference was added to the training set to further improve the generalization ability of the model.

**Figure 6.** Segmentation and measurement results of the LGA image: (**a**) captured image; (**b**) image preprocessing; (**c**) segmented image with an improved U-net; (**d**) rectangle fitting.

In addition, to represent the superiority of the proposed image processing method, the Ostu segmentation method and the Canny method, which are always used in the image processing of crystals [8,10,11,33,34], were performed for the two crystal images in Figure 7a. Figure 7b demonstrates the results with an improved U-net. Figure 7b,c show the results of image preprocessing using the Ostu and Canny segmentation methods, respectively. It can be seen that clear crystals are detected with an improved U-net, whereas the fuzzy crystals may affect the size measurement. Figure 7 shows that the clear crystals are effectively segmented with the proposed online analysis method, while the other two methods make several segmentation mistakes (e.g., overlapping, fuzziness, etc.). Figure 7e shows that the results of the original U-net model are less accurate than the improved one.

**Figure 7.** Segmentation comparison results of two LGA images: (**a**) captured images; (**b**) improved segmentation results; (**c**) threshold segmentation results; (**d**) edge detection results; (**e**) original U-net results.

#### *5.2. Crystal Size Measurement*

CSD information is important for production. For crystallization quality control, it is necessary that the information feedback of crystal sizes is provided timely and effectively. In the experiment, an offline measurement method using an electric microscope was utilized to verify the accuracy of the CSD measurement with the proposed method. For the same batch of crystals, the comparison study was made between the proposed online method and the offline method by measuring 2D sizes (i.e., length and width), as shown in Figure 8. It is presented that the measured results between the two methods are very similar. It is

noted the online images should be captured immediately after the crystals are added into the reactor to avoid the changes of crystal sizes and shapes.

**Figure 8.** Comparisons between online and offline results of LGA crystal products: (**a**) histogram with the online measurement for LGA length; (**b**) histogram with the offline measurement for LGA length; (**c**) histogram with the online measurement for LGA width; (**d**) histogram with offline measurement for LGA width.

In this experiment, the measured CSDs were fitted by the probability density estimation with the lognormal distribution function. In Figure 9, the CSDs are computed with about 200 crystals collected at time points of 0 min, 20 min, 40 min, and 60 min. The predefined time window was set as 30 s. Figure 9 shows that the crystal population size increases with time, but the range of the crystal size distribution becomes much wider. The needle-like crystals may be easier to be broken by the stirring agitator, resulting in small sizes, whereas the LGA crystals are likely to agglomerate, leading to large sizes. Therefore, the size distribution can become wider at the end of LGA crystallization.

**Figure 9.** Evolution of β-form LGA crystal size distribution at four time points with a log-normal distributed model: (**a**) probability density of crystal length sizes; (**b**) probability density of crystal width sizes.

Traditionally, the measurement of growth rate has been used with mean crystal size. However, the growth rate with mean size may not denote the size distribution evolution well, due to the noise of size extremes. It is significant for characterizing the growth rate of crystal size distribution to crystallization control. The evolution of the β-form LGA crystal population size distribution is exemplified in Table 1. At the three intervals of sample times (i.e., 0, 20, 40, and 60 min), the growth rates *Rl* and *Rw* were computed by Equation (11) for crystal size distribution. It is observed that the growth rate gradually increases over time, because solution supersaturation is a main driving force for crystal growth in the cooling crystallization. It is also manifested that the growth rates of β-form LGA population length were much larger than those of β-form LGA population width in Table 1. The growth in length is involved in the growth face (101), and the width is related to the faces (010) and (021) [35]. The behavior of length and width growth rates may be in relation to supersaturation, temperature, etc. It is noted that the growth data for length and width are identified more accurately by increasing the number of sampling time points.


**Table 1.** Measured growth rates for 2D crystal population sizes.

#### **6. Conclusions**

In this work, an imaging measurement method based on a U-net network was developed to estimate crystal size evolution for β-form LGA using an online non-invasive imaging system. To improve image quality, guided filtering was used for removing the image noise. The deep-learning model with an improved U-net was effectively improved to segment the crystals from the online images. The 2D crystal sizes were measured by using the probability density function. Experimental results showed that the proposed method based on deep learning was effective in obtaining the growth rate of crystal population sizes. The agglomeration condition led to the wrong determination of the crystal sizes. Hence, future work will involve the measurement of crystal agglomeration.

**Author Contributions:** Conceptualization, Y.H.; methodology, B.T.; writing—original draft preparation, Y.H.; writing—review and editing, X.L.; project administration, Y.H. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the China Postdoctoral Science Foundation, grant number 2020M680979, and the Doctoral Start-up Foundation of Liaoning Province of China, grant numbers 2021-BS-281 and 2020-BS-263.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** Not applicable.

**Conflicts of Interest:** The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.
