**1. Introduction**

Eggs are one of the best sources of nutrition for human beings and are known as the best protein food. To ensure the quality of eggs, cracked eggs produced in packaging, processing, transportation, and other links should be eliminated. Cracks in eggs will not only lead to a reduction of freshness but also breed bacteria and do harm to health [1,2]. The quality and safety of eggs is a matter of concern to the public, so the detection of egg cracks is a necessary operation before the eggs enter the market for consumption. Manual detection is high-cost, low-efficiency, and depends on detection experience. After a long

**Citation:** Shi, C.; Cheng, Y.; Zhang, C.; Yuan, J.; Wang, Y.; Jiang, X.; Zhu, C. Wavelet Scattering Convolution Network-Based Detection Algorithm on Nondestructive Microcrack Electrical Signals of Eggs. *Agriculture* **2023**, *13*, 730. https://doi.org/ 10.3390/agriculture13030730

Academic Editor: Quan-Sheng Chen

Received: 28 February 2023 Revised: 13 March 2023 Accepted: 20 March 2023 Published: 22 March 2023

period of operation, the probability of missing cracks and false detection increases due to visual fatigue. This can also cause some damage to the operators' vision [3]. With the continuous development of industrialization and informatization, people are trying to find an automatic detection method to reduce the labor intensity of this task while simultaneously improving efficiency and accuracy.

Numerous techniques for egg crack detection have been put forth by researchers and academics, of which acoustic [4–7] and visual [8–11] methods are the most well-known and established. Crack detection based on acoustic characteristics is realized by collecting knock response signals with sound sensors after mechanical excitation on several parts of the egg surface, analyzing and processing the signal differences between the intact area and the cracked area of the egg surface, and finally extracting characteristic parameters. However, its accuracy easily suffers from interference by eggshell thickness, external noise, and the knock location. The detection of cracks in poultry eggs based on visual characteristics involves taking pictures of the surface of poultry eggs with an industrial camera and transmitting the images to supporting software. By analyzing the images, the software can identify the characteristics of cracked and intact eggs and then construct a model for discrimination. Nevertheless, many simple factors must be considered in practice, such as the camera's resolution, the recognition algorithm, and the shape of the egg crack. Additionally, the online detection speed and accuracy for microcracks cannot meet today's requirements. Hence, significant limitations remain on industrial sites.

The detection method based on high-voltage discharge has a good ability to detect leakage. Hu [12] proposed a "conductivity method" for ampoule bottle detection, applying a 3000 V∼5000 V direct current(DC) on the tested drug bottle and judging the leakage of the test sample by setting the threshold value of the measured current. Yan et al. [13] used 20 kHz of high voltage to carry out their experiment and finally verified the feasibility of high-voltage discharge for the detection of small leaks of large infusion plastic bottles. The micro-current high-voltage discharge method is similar to the traditional high-voltage discharge method. It requires that the package itself is not conductive and the contents are conductive, creating a difference between the electrical parameters of a defect-free package and a defective package. The micro-current high-voltage discharge method can also be used to detect tiny cracks or damages to sealed packaging in the food industry. With the further deepening of the basic theoretical research on the dielectric properties of eggs, egg crack detection based on electrical properties will become our research direction.

Recent research shows that detecting cracked eggs using the response model of egg electrical characteristics can effectively compensate for the shortcomings of the above methods [14]. Figure 1 illustrates how the electrical characteristic model can be used to detect egg cracks. The capacitors include the two electrodes and the egg in the center, and the eggshell is the insulator. Due to its low resistance value, the egg liquid is approximately the conductor. The current value detected is either a capacitance jump, a breakdown, or a combination of both. When the egg is intact, the whole system is in equilibrium, and the current value will remain stable . When the egg has a crack, the electrical characteristic model will change when the electrode passes through the crack, resulting in a transient current. Therefore, if the voltage of the two electrodes is kept constant and only the breakdown of the air medium is allowed, it is possible to identify cracked eggs based on the change in the current signal. Traditional machine learning methods have been used to classify the current signals, and the accuracy of detecting eggs with microcracks less than 3 μm compared to intact eggs was found to be 99%. Relevant experiments also prove that the proposed method has a certain universality and versatility. However, it has three shortcomings. In terms of the experimental device, the electrode position is fixed, which can easily cause the egg size to not fit with the upper electrode, thus causing errors in detection. In signal analysis, the extracted features are inadequate to allow capturing the details and changes of cracked eggs in the current signal, so further study of the feature extraction method of the current signal is necessary. A further area of research is how to reduce the 1500 V voltage used in the experiments because it is too high and might harm the unhatched eggs.

Therefore, this research aimed to propose an accurate and effective nondestructive method based on the electrical characteristics of eggs to detect cracks in poultry eggs in the industrial field on the basis of existing experiments [14]. The main objectives of the study are as follows:


**Figure 1.** Schematic diagram of capacitor system composed of electrode and egg body in poultry egg crack detection method based on egg electrical characteristic model [14]. *d*<sup>1</sup> and *d*<sup>2</sup> represent the thickness of the upper and lower layers of the eggshell; *ε<sup>l</sup>* represents the dielectric constant of egg liquid; and *εr* represents the relative dielectric constant, which represents the dielectric or polarization physical parameter of the dielectric material.

Employing wavelet scattering transform, Jinghui Li et al. [15] stratified and dispersed the information of a heart sound signal to each layer so that the information would not be lost and maintained the stability of signal features, which effectively expressed the corresponding characteristic information of the signal. Then they obtained the characteristic matrix of the signal , which was input into a double support-vector machine for classification, yielding excellent results. Ahmad A. Al-Taee et al. [16] used deep wavelet scattering transform as a feature extraction method for electromyographic signals and compared it with other wavelet methods, significantly improving the performance of electromyographic pattern recognition. Liu Hui et al. [17] adopted a wavelet scattering network to extract the features of the fault zero sequence current signal. Academics have found that wavelet scattering transform can extract both simple and complex characteristics from low-frequency and high-frequency signals, respectively, and thus can reduce intra-class differences to the greatest extent while preserving inter-class differentiation. The fault feature vector is input into bi-directional LSTM, which has the advantages of high identification accuracy and short training time compared with the fault identification methods in other literature. In addition, wavelet scattering convolutional neural networks have been widely used in sound, image , and time series fields due to their superior performance and perfect mathematical properties, and some achievements have been made [18–21]. To our

knowledge, no researchers have applied appropriate research methods and ideas to detect microcurrent signals in eggs.

In recent years, deep learning has been rapidly developed. Because of its advantages of automatic feature extraction, ability to process unstructured data, and high accuracy, it has been widely used and studied in industrial defect detection. Yu et al. [22] combined convolutional neural networks(CNN), migration learning, and decision-level images to propose a vision-based automatic recognition method for the identification of the surface condition of concrete structures and designed an improved Dempster–Shafer (D-S) algorithm, which greatly improved the recognition accuracy of concrete structures. Yu et al. [23] used the improved bird swarm algorithm to optimize a 2DCNN, which performed better than other machine learning models in the evaluation of the torsional capacity of reinforced concrete (RC) beams. Deep learning has also shown strong performance in the processing of one-dimensional(1D) data. Hu et al. [24] designed a fault diagnosis method based on a one-dimensional convolutional neural network (1DCNN) and L2-support-vector machine(L2-SVM) for unbalanced data, which, compared with other intelligent methods, significantly improved the recognition accuracy and diagnostic performance of the model compared with other intelligent methods in processing unbalanced data. Le et al. [25] developed a 1DCNN for automated fault diagnosis, which can autonomously learn damagesensitive features without pre-processing and can accurately diagnose potential faults that damage the smart chain. Relevant research [26–28] also shows that deep learning exhibits good performance in processing time series classifications.

Therefore, this study focuses on applying wavelet scattering on poultry eggs based on real-time electrical characteristics. The main innovations and contributions of this research can be summarized as follows:


The remaining chapters are organized as follows. Section 2 introduces the deployment of experimental equipment and the method of microcurrent signal analysis. In Section 3, we compare and analyze the experimental results to verify the effectiveness of the proposed method. Finally, the whole paper is summarized and the future research on egg crack detection is prospected in Section 4.

#### **2. Materials and Methods**

#### *2.1. Egg Electrical Characteristic Crack Detection System*

In this study, a crack detection system for poultry eggs based on real-time electrical characteristics was developed. As shown in Figure 2a, the system is mainly composed of four parts: a data acquisition platform, a high-voltage power supply, a controller, and a computer processing system. The data acquisition platform includes a visual detection part and a discharge detection part. The visual detection part is used to detect the size of eggs and control the automatic electrode adjustment mechanism. The discharge detection part comprises a rotating mechanism, a discharge electrode, an automatic electrode regulating mechanism, etc. The rotating mechanism ensures that eggs of different sizes can rotate flexibly and uniformly. The automatic electrode regulating mechanism adjusts up and down according to the data from the visual detection part to provide stable and reliable surface contact, as shown in Figure 2b. Through preliminary experiments and debugging, conductive silica gel was used as the electrode material for crack detection under a voltage of 1000 V, average humidity of 40% , and an average temperature of 18.5 °C. In this experiment, the current value is strictly controlled, and the automatic protection mechanism is triggered when the current exceeds 1 mA so that no damage will be caused to the eggs. In this study, the microcurrent signal obtained from an egg under the electrical characteristic crack detection system was used to evaluate and detect egg cracks. The detection and collection frequency of the detection system was set at 100 Hz, the collection time was 4.5 s, and the data length was 450 points. The data of egg rotation were collected 2.5 times in a single time, and one datum was collected for each egg.

**Figure 2.** Discharge principle and experimental setup. (**a**) Schematic diagram of poultry egg crack detection system based on real-time electrical characteristics. (**b**) The nondestructive detecting device based on electrical characteristics of eggs used in this paper.

After the eggs are subjected to the application of a DC voltage, the data acquisition card acquires the micro-current signal from 450 sample points on the eggs. Three representative egg samples are selected for analysis, as shown in Figure 3a–c, which are examples of cracked egg samples, minimally cracked egg samples, and intact egg samples, respectively. Figure 3d shows a micro-current detection signal of the cracked egg sample in Figure 3a. When the electrode is swept to the crack location, a strong current response is generated, and the sample shows a sudden rise in a steady microcurrent signal. Figure 3f shows the microcurrent detection signal of the intact egg sample, which does not produce a strong current reaction under DC voltage. There is no special change in the whole rotation process, and the sample is very stable. The existing classification algorithm based on the electrical characteristic signals of eggs can have a good classification effect on the above samples. However, for some extremely tiny cracks, such as thsoe in Figure 3c, a microcurrent signal is used, as shown in Figure 3e. The strong current response is small, and the performance is similar to that of intact egg samples. Currently, the existing classification algorithms based on the electrical signal characteristics of eggs struggle to distinguish those extremely small cracks.

**Figure 3.** Comparison of current signal changes between cracked and intact eggs, where the abscissa is the sampling point, and the ordinate is the microcurrent. (**a**) A cracked egg sample. (**b**) An indistinguishable cracked egg sample. (**c**) An intact egg sample. (**d**) Micro-current signal of sample (**a**). (**e**) Micro-current signal of sample (**b**). (**f**) Micro-current signal of sample (**c**).

In order to verify the accuracy of the results, each experiment was executed multiple times. In each experiment, the training set and test set used by different methods remained the same. We randomly selected 70% of the sample data as the training set and the remaining 30% as the testing set for scattering feature extraction and then input these data to the deep learning network for classification for different experiments.

#### *2.2. Detection Framework*

The framework of the current crack detection algorithm based on the egg electrical characteristics model is shown in part A of Figure 4. The time, frequency , and wavelet domain features were manually extracted, and the traditional machine learning algorithm was used for classification [14]. The features extracted by such methods are fixed, making it challenging to capture multi-scale features and, therefore, easy to overlook feature variations in detail. At the same time, traditional machine learning algorithms have low compatibility with feature dimensions and high dependence on features, leading to limitations in classification. Considering this situation, this paper investigates the feature extraction and classification of current signals separately, using wavelet scattering transform in conjunction with deep learning methods for experiments.Part Proposed of Figure 4 illustrates the algorithm framework based on the wavelet scattering convolution network used in this paper. In the feature extraction part, we used the wavelet scattering transform to extract the features of the current signal, which has the properties and advantages of translation invariance and local deformation stability and does not require a manual design to extract features from the signal. It is immune to translational and slight deformation information and discards the parts of the signal sensitive to translation and deformation while obtaining high-frequency information. The classification part was analyzed using deep learning methods, which have the advantages of high learning ability, portability, and compatibility with feature dimensions compared to traditional methods. In this paper, we tried different deep-learning methods to study the algorithms that can be used for the classification of microcurrent signals.

**Figure 4.** Research ideas for a non-destructive detection algorithm based on electrical characteristics of microcracks.

#### 2.2.1. Wavelet Scattering Transform-Based Feature Extraction

Wavelet scattering transform (WST) [29–31] is an improved time-frequency analysis method based on wavelet transform, which solves the shortcomings of wavelet transform changing with time and has the advantages of translation invariance and local deformation stability of signal analysis and feature extraction. The wavelet scattering network is a framework for automatically extracting input signal features, requiring convolutional, nonlinear, and average cascade operations. After constructing the wavelet scattering network, the scattering coefficient matrix of training data can be obtained. The framework is shown in Figure 5a. In the wavelet scattering transform network, the convolution task is performed by the wavelet, the modular operator is used for nonlinearization, and the filtering function of the wavelet low-pass filter completes the pooling task.

**Figure 5.** Principle of wavelet scattering transform. (**a**) Framework of wavelet scattering network. (**b**) Structure of wavelet scattering transform.

Wavelet scattering takes the modulus of the wavelet transform, mainly because the mean value of the wavelet coefficient is 0. In contrast, the mean value of linear transformation will not change, so the non-0 wavelet coefficient can be obtained through nonlinear transformation to carry specific information. After removing the complex phase of all wavelet scattering coefficients, operator |*W*| can be obtained. By convolving with input signal *X*, the operator of the wavelet modulus transformation can be obtained:

$$|W|X = \{S(X), \mathcal{U}(X)\}\tag{1}$$

$$S(X) = X \times \phi\_I \tag{2}$$

$$\mathcal{U}I(X) = |X \times \psi\_{\lambda}|\tag{3}$$

Equation (1) contains two parts: *S*(*X*) (see Equation (2), where *φ<sup>J</sup>* is the low-pass filter) is the invariant part, namely the scattering coefficient, which is the low-pass filtering and averaging of the input signal. It represents the translation invariance of the wavelet scattering transform, with the purpose of extracting the low-frequency information of the input signal and removing the high-frequency information. *U*(*X*) (see Equation (3), where *ψλ* is high frequency wavelet) is the covariant part, representing the high frequency information on scale *λ* and acting as the exchange modulus of the nonlinear wavelet change. It is also the input to the next transformation and represents the stability of the operator, with the purpose of recovering the high-frequency information lost by the operation of the invariant part.

Therefore, the 0th-order wavelet scattering transform information is:

$$|\mathcal{W}\_0|X = \{S\_0(X), \mathcal{U}\_0(X)\}\tag{4}$$

$$S\_0(X) = X \times \Phi\_{\parallel} \tag{5}$$

$$\mathcal{U}l\_0(X) = |X \times \psi\_{\lambda 0}|\tag{6}$$

By taking the 0th-order high-frequency *U*0(*X*) as the input *X*<sup>1</sup> of the first-order scattering transform and calculating with the new wavelet modulus operator, the information of the 1st-order wavelet scattering transform is obtained.

$$\left| \left| \mathcal{W}\_1 \right| X\_1 = \left\{ S\_1(X\_1), \mathcal{U}\_1(X\_1) \right\} \right. \tag{7}$$

$$S\_1(X\_1) = X\_1 \times \phi\_I = |X \times \psi\_{\lambda 0}| \ast \phi\_I \tag{8}$$

$$\mathcal{U}I\_1(X\_1) = |X\_1 \times \psi\_{\lambda 1}| = ||X \times \psi\_{\lambda 0}| \times \psi\_{\lambda 1}|\tag{9}$$

Similarly, by iterating the above process, the *g* − 1-order high-frequency *Ug*−<sup>1</sup> *Xg*−<sup>1</sup> can be used as the input *Xg* of the first-order scattering transform to operate with the new wavelet modulus operator for the higher *g*-order scattering transform:

$$\lfloor \mathcal{W}\_{\mathcal{S}} \rfloor X\_{\mathcal{S}} = \{ S\_{\mathcal{S}}(X\_{\mathcal{S}}), \mathcal{U}\_{\mathcal{S}}(X\_{\mathcal{S}}) \} \tag{10}$$

The structure of the scattering transformation is shown in Figure 5b. Input current signals are iterated successively in layers, forming a series of scattering coefficients from order 0 to order *g*:

$$S\_G(X) = \left\{ S\_0(X), S\_1(X\_1), \dots, S\_{\mathcal{S}}(X\_{\mathcal{S}}) \right\} \tag{11}$$

The scattering coefficient is the extracted micro-current wavelet scattering feature. After collecting the microcurrent signal of the egg, the wavelet scattering network is constructed to extract the wavelet scattering characteristics of the microcurrent signal, and a wavelet time scattering network with two cascaded filter banks is constructed. The first filter bank has eight wavelets per octave, the second filter bank has one wavelet per octave, the wavelet filter in the two filter banks is shown in Figure 6a,b, and the Littlewood–Paley sums of the filter banks are shown in Figure 6c. Figure 6d shows the Gabor small wave used for its low-pass filter to prove the invariance scale, obtain the inverse Fourier transform of the scale function, and center it in 0 s.

**Figure 6.** The principle of wavelet scattering characteristic parameters used in this paper. (**a**) The first filter bank with 8 wavelets per octave. (**b**) The second filter bank with 1 wavelet per octave. (**c**) The Littlewood −Paley sums of the filter banks. (**d**) The real and imaginary parts of the coarsest-scale wavelet from the first filter bank.

#### 2.2.2. Classification Modeling Methods

Compared with traditional machine learning methods, deeper networks can accommodate richer semantic information and are more effective in processing temporal order, feature dimensionality, and scale. LSTM can effectively capture the association between long sequences, which is very effective in processing temporal information and can also alleviate the phenomena of gradient disappearance or explosion . Bi-LSTM is a combination of forward LSTM and backward LSTM, which can effectively use the input forward and backward feature information. GRU can effectively capture the association of long sequences, and the number of parameters used is small, which can also reduce the risk of overfitting. 1DCNN features scale shifts and invariance, region awareness, comprehensive feature learning, and fault tolerance, which can compensate for the shortcomings of other shallow classification algorithms with inadequate feature learning and poor generalization ability.

The data used in this paper are characterized by disorder, mutation, nonlinearity, and time discontinuity. Therefore, in this study, LSTM, Bi-LSTM, GRU, and 1DCNN were used to classify the features extracted from wavelet scattering. The details of these methods are as follows.

Long short-term memory (LSTM) [32] is a particular recurrent neural network (RNN), which is an improved neural network used to solve the problems of gradient disappearance and gradient explosion inherent to traditional RNNs in long sequence samples. The neural unit of LSTM contains three different gate structures: forgetting gates, input gates, and output gates to control information. Its appearance successfully solves the problem that the original RNN cannot store information for a long time and can effectively reduce the feature input dimension of the signal and enhance the temporal modeling capability.

Bi-directional long short-term memory (Bi-LSTM) [33] is a variant of LSTM, which refers to the combination of forward LSTM and reverse LSTM. The forward and reverse layers are simultaneously connected to the input and output layers through different weights. There is input each time, while the hidden layer has two node vectors, which can be transmitted from forward to backward or backward to forward. The state transmission is bidirectional. It can learn not only the rule of forward data but also the rule of backward data. Applying LSTM twice can improve the long-term dependence on learning and thus improve the model's accuracy.

A gated recurrent unit (GRU) [34] is a simple variant of LSTM, and its working principle is similar to LSTM. It has two gates: update doors and reset doors. GRU aims to reduce parameters to optimize the cell structure and improve operational efficiency, making converging during training more manageable. Its flexible and straightforward structure guarantees accuracy while significantly reducing the time required for classification.

A convolutional neural network (CNN) [35] is a typical representative of deep learning, consisting of an input layer, convolutional layer, pooling layer, fully connected layer, and output layer. Similar in structure to CNN, a one-dimensional convolutional neural network (1DCNN) [36] refers to a CNN whose input is a one-dimensional vector; similarly, its convolution kernel is one-dimensional, and it carries out a one-dimensional convolution operation. It is a deep learning algorithm suitable for processing one-dimensional data. Compared with 2DCNN, the convolution kernel of 1DCNN only needs to be scanned in one direction. The convolutional layer performs convolution operations on the one-dimensional input signal and the one-dimensional convolution kernel and then extracts the features through the activation function. The pooling layer scales and maps the input data through the pooling kernel and extracts features while reducing the dimension of the data. This paper uses max pooling, which selects the maximum value of each small region as the output. Pooling operations can reduce the size of spatial information, improve operational efficiency, and reduce the risk of overfitting.

As we all know, the selection of hyperparameters affects the performance of deep learning to a large extent. The improper setting of hyperparameters may lead to underfitting and over-fitting of the network model during training, so that the samples outside the training samples cannot be accurately classified. In this paper, the method of grid search [37] is used for hyperparameter selection first, and the optimal hyperparameter method is determined by traversing the given parameter combination to determine the optimal value performance. Finally, we used the methods of LSTM, Bi-LSTM, GRU, and 1DCNN to classify the extracted feature data. The maximum number of rounds of training was 150. The Adam optimizer was applied. The learning rate was 0.01. The learning rate decline factor was set to 0.2. The number of iterations when the learning rate decreases was 5. The fully connected layer had two layers, and the number of corresponding classifications in the second layer was finally classified using the probability of the Softmax layer. The prediction label of the test sample was the output.
