Moisture content monitoring of cigar leaves during drying based on a Convolutional Neural Network **

. The moisture content of cigar leaves during drying is an important indicator for controlling the management of drying rooms. At present, the determination of cigar leaf moisture content is mainly dependent on traditional destructive detection meth-ods, which are inefficient and damaging to plants. In this study, a Convolution Neural Network method consisting of digital images for monitoring the moisture content of cigar leaves during the drying process was proposed. In this study, the Convolution Neural Network model was trained to learn the relationship between the images and the corresponding moisture content using the extracted colour, shape, and texture features as input factors. In order to compare the Convolution Neural Network estimation results, a widely used traditional machine learning algorithm was applied. The results demonstrated that the estimated value of Convolution Neural Network agreed with the predicted value; the R 2 was 0.9044, and the average accuracy was 87.34%. These results were better than those produced by traditional machine learning methods. The generalization test of the proposed method was conducted using varieties of cigar leaves in other drying rooms. The results showed that Convolution Neural Network is a viable method for an accurate estimation of the moisture content, the R 2 was 0.8673 and the average accuracy was 86.81%. The Convolution Neural Network established by the features extracted from digital images could accurately estimate the moisture content of cigar leaves during drying and was therefore shown to be an effective monitoring tool.


INTRODUCTION
Cigar leaves, which belong to the tobacco genus of Solanaceae, are commonly processed by drying them in a specialized drying room (Ye et al., 2022). The moisture content is an indicator used to characterize the water content of cigar leaves and the desired levels of temperature and humidity in the drying process are set according to their moisture content. In fact, the occurrence of mildew and partially green cigar leaves in the drying process are caused by the incorrect monitoring of the moisture content of cigar leaves, which results in an unfavourable drying environment (Fan et al., 2020) due to factors such as high temperature and humidity. Therefore, it is important to accurately obtain the moisture content and to monitor the processes of water loss and yellowing in cigar leaves during drying. In response to these data, the temperature, humidity, and other management measures in the drying room may be controlled in such a way as to improve the quality of the cigar leaves after drying.
Traditional methods for determining the moisture content include the Karl Fischer (ISO 6488:2021) and oven (ISO 2881(ISO :1992 methods. These methods are applied in the laboratory in order to obtain relatively accurate results, however, they often require destructive sampling, which is time-consuming and also labour-intensive. Research results have determined that the use of non-invasive sensors can accurately detect the moisture content of plant materials, this includes the use of near infrared spectroscopy (NIR) technology for real-time non-contact analysis in the tobacco industry Wei et al., 2022). These instruments are considered to be very accurate and useful in the field of quality control.
However, ongoing scientific research has developed other solutions, such as non-destructive testing based on image processing (Azman and Ismail, 2017;Herzig et al., 2021;Zang et al., 2021). The non-destructive testing method using images aims to obtain features, which include shape, colour, and texture features, from digital plant images. The relationship between these features and the relevant manually measured physical indicators, such as moisture content, tension, and the level of mildew growth, may be established in order to achieve non-destructive monitoring (Mochizuki and Ito, 1995). For example, Wang et al. (2020) proposed a method for estimating the moisture content of sugarcane in multispectral images. Liang et al. (2018) extracted the colour and texture features of black tea in order to predict its moisture content and reported that the correlation coefficient of the support vector machine (SVM) reached 0.9314.
The Convolutional Neural Network (CNN) is a type of deep learning model capable of learning complex features from data by constructing multiple convolution layers and activation layers. Compared with traditional machine learning algorithms, CNN aims to obtain higher-level features, with improved detection accuracy and generalization abilities. It is a new method that has been widely used in the field of plant detection. Xu et al. (2023), for example, established a CNN method to detect the moisture content of seabuckthorn with an accuracy of 98.69%. In addition, the CNN method has also been used to rapidly and non-destructively predict the moisture content of withered red tea leaves (Ting et al., 2020). Other authors have also proposed the nondestructive detection of the water and nitrogen content in Masson pine seedling leaves using near-infrared spectroscopy based on MS-SC-CNN (Huang et al., 2021).
Moreover, machine learning has recently been applied to monitor the moisture content of flue-cured tobacco (Duan et al., 2012;Du et al., 2022), however, the modulation methods of cigar leaves and flue-cured tobacco vary greatly. Flue-cured tobacco is baked in a curing room whereas cigar leaves are dried in a drying room . Additionally, the existing methods are difficult to apply to cigar leaves and the process of image feature extraction can easily be affected by image noise because the image acquisition environment contains a substantial amount of redundant background information and uneven external light, thereby reducing recognition accuracy. Therefore, it is necessary to explore a robust and feasible method for the prediction of the moisture content of cigar leaves during the drying period, this may be used to provide a basis for the adjustment of temperature, humidity, drying density, etc. during the drying period, whilst also providing new directions for research concerning intelligent drying rooms. Accordingly, the present study proposes a CNN method consisting of digital images used to monitor the moisture content of cigar leaves during the drying process.

MATERIALS AND METHODS
This experiment was carried out in 2022 at a cigar planting area in Fengcheng Town, Dazhou City, Sichuan Province, China. The experimental and generalized test varieties were Chuanxue 1 and Chuanxue 2 respectively, with a field plant spacing of 0.4 m, a row spacing of 1.1 m, a nitrogen application rate of 202.5 kg hm -2 , and a plant nutrient ratio of N: P 2 O 5 : K 2 O of 1:1.1:2. The number of test tobacco plants used was 485, whilst the cigar leaf harvesting time was 88 d after transplanting occurred. After harvesting, the cigar leaves were hung in a drying room, with approximately 50 tobacco leaves per rod. The particular drying room used is a new type of intensive air curing room, with specifications for length, width, and height of 15, 6, and 8 m, respectively, and a total of two layers and two routes. The drying method utilizes a five-stage modulation technology; the temperature and humidity at each stage and the moisture content of the cigar leaves are shown in Table 1.
The moisture content of the cigar leaves was measured using an electric blast drying oven (mode 101-3A; Beijing Zhongxing Weiye Instrument Co., Ltd) (ISO 2881(ISO :1992. Measurements were taken on July 25 and 28; August 1, 7, and 14, 2022. Ten pieces of cigar leaves were randomly selected in order to measure their moisture content. The   specific operation consisted of weighing cigar leaves that had not been dried (FW), drying them at 105°C for 15 min, and then at 65°C to achieve a constant weight. The weight was recorded again after drying (DW) and the moisture content (Mc) was subsequently obtained using Eq. (1). The Mc of each drying stage is shown in Table 1: (1) The device used for test image acquisition was a low-cost industrial camera sensor, the particular model used being MVL-MF0828M-8MP. In order to minimize the impact of external wind, light, human movement, and other factors on the image, the shooting environment was a manually built dark box. The length, width, and height of this were 1.2, 0.9, and 0.6 m, respectively. The top, left, and right sides of this dark box were equipped with fill lights, which consisted of natural light with uniform lighting. The sensor was located centrally at the top of the dark box, with the vertical distance from the lens to the bottom plate being 0.8 m. The original image resolution was 4 800 × 2 400, with a bit depth of 24 bits, and a JPG storage format. With reference to the fivestage drying technology of the cigar leaves, the leaf images were collected at the wilting, yellowing, browning, colour fixing, and dry stages, five times in total. As a result, an image dataset containing 1 454 samples was constructed. The wilting stage consisted of 275 samples, with 269 originating from the yellowing stage, 273 from the browning stage, 271 from the colour fixing stage, and 366 from the dry stage.
The originally collected image had too much background information to be directly used for feature extraction. The processing of the original images involved the following steps: image segmentation, gray scale conversion, and image filtering.
The background area affected the quality of feature extraction; therefore, the original image was segmented into the background and cigar leaf area. The image segmentation device of MATLAB was used for this experiment.
In image acquisition, noise is inevitably generated due to the long-term camera operation and the influence of the surrounding environment. Therefore, grayscale transformation for the segmented image was performed according to Eq.
(2). Then, this gray image was smoothed to reduce noise. The image size was 20 × the Gaussian filter. Figs 1a-3c shows examples of images obtained through this preprocessing step: where: c1 = 0.2989 × R, c2 = 0.5870 ×G, and c3 = 0.1140 × B; R, G, and B are components of the RGB colour channel.
In this experiment, three features of cigar leaf images, colour, texture, and shape, were used as prediction features for the moisture content. The extraction methods for these are described below.
A histogram of the processed image was obtained, as shown in Fig. 2a-e. It was subsequently found that with the exception of the histogram of the yellowing and browning periods, the gray level histogram of the other three periods showed a single peak change. In comparing the peak positions of the histograms across five periods, it was found that these peak positions differed, which provided a basis for the extraction of the colour features. MATLAB was then used to extract the colour sets of RGB, HSV, and Lab, and also the YcrCb colour channels as the colour features for moisture content prediction.
Texture is a visual feature that reflects the homogeneity of images, it shows the common attributes of surfaces, and contains information about the surface structure arrangement and the surrounding environment. The most frequently used research method is a spatial gray level co-occurrence matrix (GLCM). The dimensions of GLCM are determined by the gray level. The gray level number of this study image was 256, including 0. Upon moving any point (x, y) in the tobacco image (M × N) in the four directions of 0°, 45°, 90° or 135°, various (g1, g2) values were obtained. There were 256 × 256 combinations of (g1, g2). Thus, GLCM may be obtained in four directions. The mathematical calculation formula for GLCM is described by Eq. (3) (Wang et al., 2017): where: x and y are image pixel coordinates, i and j are the gray level, dx and dy are the position offsets, d is the GLCM step size, and θ is the optional direction of GLCM, which was (0°, 45°, 90°, 135°). According to GLCM, four texture features may be calculated: correlation (Cl), contrast (Ct), energy (E), and identity (Hg). Cl is the correlation measurement between pixels in GLCM and the adjacent pixels in the whole image, and the value of this was (-1 1); Ct reflects the contrast measurement of the GLCM pixels and their adjacent pixels in the whole image. This typically has a higher value for the rough textures and a lower value for the sharp textures; the range was [0 (size (GLCM,1)-1) 2 ]. E is the sum of the squares of each pixel in GLCM, and the range was [0 1]. Hg was used to measure the distance from the element distribution in GLCM to the diagonal of GLCM, thereby reflecting the uniformity of the texture distribution; the range was [0 1]. The calculation formulae used were Eqs 4-7 (Haralick et al., 1973).
The calculating moment is one of the methods used to describe the shape features of an image and to obtain the geometric features of any image. The shape invariant moment is a parameter that expresses the geometric shape information of an image. This includes the stability of rota-tion, translation, scale, and other transformations. Adding invariant moments to image recognition can be used to significantly improve prediction accuracy. The Hu invariant, Zernike, and wavelet are three of the most common invariant moments. In this study, an attempt was made to use the Hu invariant moment as the predicted shape feature using the calculation process described below.
The grayscale image of the colour image of tobacco leaf was calculated using Eq. (2) before the image was binarized, and subsequently, the (u+v) order image moment was obtained using Eq. (8) (Hu, 1962) where: and are the centroids of the image. When the image changes, MT UV also changes, although the central moment α uv is related to the image centre, which is not affected by the image translation change but is sensitive to the rotation transformation. Thus, the normalized central moment of the image was calculated using Eq. (10) (Ghosh and Roy, 2022) where: p = (u + v)/2 + 1, (u, v) 2,3. The Hu invariant moment uses the second moment and the third central moment (u + v = 2, 3) to obtain seven invariant moments M1-M7, which are invariant to rotation, scaling and translation, and can be used to represent the shape changes of cigar leaf images at different drying stages. The calculations were based on Eqs 11-17 (Gornale et al., 2020): , , , , , , .
The architecture of the CNN model is shown in Fig. 3, it includes ten convolution layers, nine pooling layers, and one full connection layer. The input of CNN comprised 23 characters, i.e., 23 × 1 × 1 × the four-dimensional matrix image of 1 163, of which 1 163 was 80% of the sample data after it was scrambled, whilst the other 20% were used for testing. The first convolution layer adopted a size of 2 × 1. The 10 convolution cores were 2, 4, 8, 16, 32, 64, 128, 256, 512, and 1 024 in size. The pool layer core size was 2 × 2, whilst the step size was [1,1]; the maximum pooling function was used to replace the average pooling function. The weight matrix and offset vector corresponding to each output neuron were calculated in the full connection layer for the water content response. The stochastic gradient descent with momentum (SGDM) then replaced the adaptive moment estimation (ADAM) and root mean square prop (EMSPROP) to optimize the weight coefficients. The training discard rate was 0.1, the initial learning rate was 0.001, the mini-batch size was 10, the maximum training cycle was 15, and the learning rate decline cycle was 35.
In order to evaluate the prediction performance of the CNN, artificial neural network (ANN), SVM, and extreme learning machine (ELM) were used to estimate the moisture content of cigar leaves, this was due to the fact that these three methods have been reported to perform well when predicting the moisture content of flue-cured tobacco. The training input for the three classifiers was 1 163 samples randomly scrambled which corresponded to 80% of the samples, whilst the output was the corresponding moisture content; the test part corresponded to the remaining 20% of the samples. Table 2 shows the image and the data division of tobacco leaves during the five drying stages.

RESULTS
In this study, MATLAB 2021a (Matrix Laboratory, USA) was used to achieve image processing, feature extraction, and model building. The software environment used was Windows 10 Professional Edition, the hardware environment used was Inter i5-12400f CPU single processor, and the GeForce GTX1650 is unique.
The results for the colour, texture, and shape feature extraction of cigar leaves in different drying stages are shown in Fig. 4. The changes in R, G, and B showed a trend of an initial increase before decreasing throughout the five stages and reaching a peak during the yellowing stage. H decreased gradually, S and V first increased and then decreased, of which S was the highest in the colour fixing stage and V was highest in the yellowing stage. In the Lab colour space, the changes in L and b were similar to the changes in R, G, and B. The value of a increased gradually and reached its highest point during the colour fixing and drying stages. In YcrCb, the values of Y and Cb first increased before decreasing, while Y and Cb reached their peak during the yellowing stage and browning stage, respectively. The energy (E) of the texture features continued to rise throughout the five drying stages, while the correlation, identity, and contrast changes were all low. In terms of the shape characteristics, M1 showed a trend of increasing first before decreasing, it reached its peak value during the browning stage. Meanwhile, M2-M7 had a relatively low change range.
The decline in the error gradient over the course of the training process of the CNN model is shown in Fig. 5. The root mean square error (RMSE) declined continuously throughout the training process while the prediction accuracy improved and remained generally stable. After training, the test dataset was used to test the estimation effect of the CNN. The fitting between the estimated value and the measured value is then shown in Fig. 6. The R 2 and the RMSE values indicated that the predicted results were in close agreement with the experimentally measured value.
Three traditional shallow machine learning network models, SVM, ANN, and ELM were established using the extracted colour, texture, and shape features. The fitting between the estimated and the measured values of the test set samples using the three classifiers is shown in Fig. 7. The R 2 and RMSE of ANN were 0.8297 and 0.1039, respectively. The estimation accuracy of the overall moisture content was higher than that of SVM and ELM. Furthermore, the estimation accuracy of ELM was the lowest, while the R 2 and RMSE values were 0.7069 and 0.1364, respectively.
Comparison between the prediction effects of CNN and traditional machine learning at each drying stage.  Table 3 shows the calculation of the prediction accuracy and RMSE for each model during each drying stage. In general terms, ANN showed the best estimation effect among the three shallow classifiers, this was followed by ELM, with SVM having the lowest estimation accuracy. However, the prediction effect of CNN was better than that of the other three shallow classifiers, showing a higher average accuracy and R 2 , alongside a lower RMSE. From the perspective of each drying stage, the prediction accuracy of the four classifiers for the dry gluten period and colour fixing period was low, while the prediction accuracy of SVM for the dry stage was only 54.73%. Although the prediction accuracy of ELM for the dry reinforcement period was higher than that of CNN, its RMSE was 49.7% higher. Considering its accuracy and R 2 value the CNN model was shown to be superior to SVM, ANN, and ELM in estimating water content.
The proposed CNN prediction method was evaluated using images of cigar leaves of different varieties and from different drying rooms during the drying stage, therefore they will enhance the generalization and practicability of the model. Thus, the pre-trained CNN model was directly applied to the cigar leaf images of another drying room for the generalization test. The cigar leaves used under the generalization test and those used under model training were from the same harvest season of July, whilst the variety used was Chuanxue No. 2, with a uniform pole weaving method, number, and structure of the drying room. Images of each drying stage from another drying room were collected. These images were then processed according to the previous method, and the image, colour, shape, and texture features were all extracted as a feature data set for the prediction of water content. Using the same shooting   The fitting between the estimated and the measured values is then shown in Fig. 8 while the accuracy of each stage is shown in Table 4. The results show that the estimated results using CNN were in close agreement with the actual measured results. For the wilting stage, the accuracy of CNN reached 97.06%, whereas it was 93.38% and 88.44% for the yellowing and browning stages, respectively. However, the prediction accuracies for the colour fixing and drying stages were comparatively low, at 80.90 and 74.27%, respectively. By combining the average accuracy and R 2 of each stage, the prediction method showed a substantial generalization ability for the estimation of the results produced by different drying rooms and varieties.

DISCUSSION
Cigar leaf drying is an important part of agricultural processing. Closely and accurately monitoring changes in the moisture content during the drying process of cigar leaves is crucial in the management of drying rooms. Direct detection methods can no longer meet the needs of adjusting the temperature and humidity and so on due to their low efficiencies and the damage caused to the cigar leaves. Nondestructive testing has therefore become a research focus for moisture content monitoring. As a result, computer vision technology is being widely used for non-destructive testing due to its high degree of efficiency, the wide range of data obtained, and other advantages, which provide a great deal of convenience from the point of view machine learning (Okamura et al., 2001;Qin et al., 2021;Sai et al., 2022;Shimomachi et al., 2004). Gong et al. (2021) established a linear model between the gap ratio and moisture content by collecting ginkgo fruit images, with R 2 reaching 0.95 and RMSECV at 4.06%. Furthermore, Erawan et al. (2021) created a multiple linear regression and neural network model for predicting the water contents of dry seaweed by creating 54 image texture features and resistance-capacitance characteristics datasets. The neural network based on these 54 texture features had the best effect, with the correlation coefficient and RMSE reaching 0.89 and 9.11, respectively. Ding et al. (2019) proposed an ANN using RGB images to predict the water potential of greenhouse potatoes, which showed an ideal prediction effect. In the present study, digital images of cigar leaves during drying were collected using machine vision technology. The shape, colour, and texture features were extracted for the prediction of the moisture content of the cigar leaves, which proved that the CNN model could be used as a convenient and accurate tool for the estimation of the moisture content in cigar leaves during drying. Compared with traditional machine learning techniques, the proposed CNN in the present study showed a superior estimation performance. Furthermore, the generalization test results for CNN showed that it had excellent applicability and could still achieve the ideal estimation effect when applied to other tobacco leaves of different varieties in the drying room. This study found that although CNN produced an excellent estimation effect for the whole drying stage, the estimation results of the dry stage and the colour fixing stage had large errors. The estimation accuracy of the dry stage was only 74.31%, which may be because this experiment uses extracted image features as the input. Moreover, the image information has been dimensionally reduced to a certain extent, thereby ignoring the underlying details contained therein. This result may also be attributed to the similarity in the colour, shape, and texture of tobacco leaves in the dry gluten and colour fixing stages. Additionally, the total number of tobacco samples was only 1 163, which led to large errors. Although the error between these two periods was large, the colour fixing period and dry stage were the late stages of drying, and the colour of the tobacco leaves had been fixed, thus resulting in a low impact to the overall quality. In future research, we should further subdivide the drying stages of the cigar tobacco leaves, for example, by using the early, middle, and late dry stages. Using these techniques a dataset may be established for a full-stage estimation to improve estimation accuracy.
The shooting environment for this experiment is a manually built dark box, which reduces the interference from external light, wind, and other factors. Based on this, factors such as equipment specifications, light sources, and shooting parameters can be optimized. Professional equipment that integrates image shooting and moisture content recognition can be customized to achieve the real-time detection of moisture content in cigar tobacco leaves during the drying process, thereby meeting the needs of agricultural processing. CONCLUSIONS 1. The estimated moisture content using Convolution Neural Network is highly consistent with the measured values, with an R 2 value of 0.9044 and an average accuracy of 87.34%, which proves that this technique has a practical application value.
2. Compared with traditional machine learning models such as support vector machine, Artificial Neural Network, and extreme learning machine, Convolution Neural Network has a better average prediction accuracy.
3. The digital images of different varieties of cigar leaves in other drying rooms were collected and verified. The results showed that the proposed Convolution Neural Network estimation method had a favourable generalization ability, a robust prediction performance, and that it was less affected by differences between the drying rooms and varieties. Convolution Neural Network was shown to be a reliable method for the estimation of the moisture content in drying rooms, while its accurate monitoring ability has the potential to provide support for scientific management and decision-making in drying rooms.