Automated Grading of Angelica sinensis Using Computer Vision and Machine Learning Techniques

: Angelica sinensis ( Oliv. ) Diels , a member of the Umbelliferae family, is commonly known as Danggui ( Angelica sinensis , AS). AS has the functions of blood tonic, menstrual pain relief, and laxatives. Accurate classification of AS grades is crucial for efficient market management and consumer health. The commonly used method to classify AS grades depends on the evaluator’s observation and experience. However, this method has issues such as unquantifiable parameters and inconsistent identification results among different evaluators, resulting in a relatively chaotic classification of AS in the market. To address these issues, this study introduced a computer vision-based approach to intelligently grade AS. Images of AS at five grades were acquired, denoised, and segmented, followed by extraction of shape, color, and texture features. Thirteen feature parameters were selected based on difference and correlation analysis, including tail area, whole body area, head diameter, G average, B average, R variances, G variances, B variances, R skewness, G skewness, B skewness, S average, and V average, which exhibited significant differences and correlated with grades. These parameters were then used to train and test both the traditional back propagation neural network (BPNN) and the BPNN model improved with a growing optimizer (GOBPNN). Results showed that the GOBPNN model achieved significantly higher average testing precision, recall, F-score, and accuracy (97.1%, 95.9%, 96.5%, and 95.0%, respectively) compared to the BPNN model. The method combining machine vision technology with GOBPNN enabled efficient, objective, rapid, non-destructive, and cost effective AS grading.


Introduction
Angelica sinensis (Oliv.)Diels is a plant belonging to the Umbelliferae family.Its root is a widely used medicine-food Chinese medicinal herb known as Danggui (Angelica sinensis, AS) [1,2].AS is rich in polysaccharides, essential oils, flavonoids, and organic acids [3,4].AS is often used to treat blood deficiency, menstrual disorders, and constipation due to its properties as a blood tonic, menstrual pain reliever, and laxative [5][6][7].
The grade of Chinese medicinal herbs plays an important role in evaluating its quality as well as determining its market price [8].The "Specifications and Grading Standards for Chinese Medicinal Materials" provides grading criteria for AS.The standard indicates that, under the conditions of no mildew, no insect damage, no oil exudation, impurities less than 3%, and meeting specific appearance characteristics (the upper main root is cylindrical, or has several distinct protruding rhizome scars, with multiple lateral roots in the lower part, and the root tip diameter is 0.3~1 cm.The surface is brownish-yellow or yellow-brown, with longitudinal wrinkles and pore-like protrusions, which may be inconspicuous or absent, and the texture is soft and flexible).The quantity of AS per kilogram and the weight of each AS are used as indicators for grading [9].The commonly used method for classifying AS commodity grades is a traditional method based on the observation and experience of the evaluator.This method has issues such as high subjectivity, unquantifiable parameters, inconsistent identification results among different evaluators, and a long learning curve to master this skill, resulting in a relatively chaotic grading of AS in the market.The disordered grades fail to meet the demands of consumers for both the quality and safety of Chinese medicinal herbs [10].Additionally, the process of determining the grade of AS based on the observer's observation and experience is time-consuming, labor-intensive, and subjective.
To address the issue of high subjectivity in this method, many scientists have conducted research on the classification of AS grades based on chemical composition.Xin et al. used a dual-wavelength thin film scanning method to determine the ferulic acid content of different grades of AS [11].Their findings revealed notable variations in the ferulic acid content among different AS grades, with higher grades exhibiting higher levels of ferulic acid.Zhao found that the commodity grade of AS could be determined on the basis of its chemical composition [12].His results showed that chlorogenic acid was significantly negatively correlated with the commodity grade of AS, while ferulic acid and Z-ligustilide were significantly positively correlated with the commodity grade of AS.The aforementioned studies suggested that chemical composition appeared to be a viable indicator for grading by a quantitative method.However, Ruan et al. found that polysaccharide and ferulic acid had a very weak negative correlation with AS commodity grade, indicating that the content of these compounds could not be considered good indicators of the commodity grade of AS [13].In conclusion, the content of a specific chemical component may not necessarily be a reliable indicator for grading AS products.Moreover, the cost of testing the chemical composition is relatively high, and it takes a long time to obtain results, which makes it difficult to widely apply this method for classifying the grades of AS.For this reason, it is necessary to develop a simpler, faster, and more effective method.
Machine vision technology enables an objective evaluation of Chinese medicinal material quality, significantly reducing the time, costs, and labor required for analyses [14].In recent years, machine vision technology has been widely applied in the fields of medicine and food [15][16][17][18][19]. Kim et al. used image processing technology and an artificial neural network to divide ginseng into three grades based on its color and shape features.The classification error was about 26% [20].Cui et al. developed a vision system that took into account the color features of Cornus officinalis.They used discriminant analysis, least squares support vector machine, partial least squares discriminant analysis, and principal component discriminant analysis to evaluate the grade of Cornus officinalis, and the accuracy was 86.21%, 89.66%, 81.03%, and 91.38%, respectively [21].Wang et al. used a backpropagation neural network (BPNN) to classify rhubarb grades based on color features extracted from images and achieved an overall accuracy of 92.3% [22].Zhu et al. used an improved IRIV-GWO-SVM (IRIV: iterative retaining information variables; GWO: gray wolf optimizer; SVM: support vector machine) model to classify the taproot of Notoginseng based on the color, texture, and shape features from computer vision, and the accuracy reached 98.70% [23].These results indicated that machine vision technologies combined with machine learning had the potential to classify the grades of some Chinese medicinal materials.However, there are no studies using these techniques to classify the grades of AS.
Considering the limitation of sample data size, this study chose a three-layer BPNN model with good generalization ability in small sample data for the identification of AS grades [24,25].The BPNN model was proposed by a scientific team led by Rumelhart and McClelland [26].It has been largely used for classification due to its high non-linear mapping, self-learning, and adaptability, and has achieved satisfactory results [27].Unfortunately, the standard version of BPNN has its limitations, such as a tendency to fall into local minima and slow convergence [28].To overcome these problems, this study used a growth optimizer (GO) developed in 2023 to optimize the weights (w) and deviations (b) of BPNN to obtain better results in the classification of AS grades [29].The primary design inspiration for GO originates from the learning and reflective mechanisms of humans during the course of social development [29].Through the mathematical modeling of learning and reflection behaviors, GO is categorized into two phases: The learning stage and the reflection stage.The learning stage of GO dynamically balances four types of directional information by incorporating fitness values and Euclidean distance.This adaptive balancing is crucial in mitigating the impact of incorrect directional information, significantly diminishing the likelihood of the algorithm succumbing to local optima.The reflection stage of GO uses distinct computation methods for each dimension of the individual, thereby augmenting the overall convergence performance of GO.These advantages of GO are helpful in overcoming the shortcomings of BPNN.In this study, the BPNN model optimized by using the GO algorithm was named GOBPNN.
In order to address the limitations of the method of classifying AS grades based on the evaluator's observation and experience, such as high subjectivity, unquantifiable parameters, inconsistent identification results among different evaluators, and a long learning curve to master this skill, this study combined computer vision with the GOBPNN model to achieve intelligent recognition of AS grades through image analysis.The findings of this study will facilitate efficient, objective, fast, non-destructive, and low-cost classification of the grades of AS, which could help consumers and market regulatory authorities to quickly and accurately identify the grade of AS.

Materials and Methods
The image recognition system was divided into four stages: (a) image acquisition; (b) image pre-processing; (c) image feature extraction; and (d) classification decision.

Samples Preparation
Standard samples of AS were purchased from Minxian County, Gansu Province, in 2021.They were divided into five commodity grades according to industry association standards [9] and the experience of Chinese herbal medicine experts, who has gained recognition from relevant companies and consumers.The original AS images representing five grades are shown in Figure 1.These standard samples (Figure 1) exhibit distinctive external characteristics, primarily comprising color, shape, and texture features.The number of AS for each grade and the weight of individual AS samples for each grade are shown in Table 1.
growth optimizer (GO) developed in 2023 to optimize the weights (w) and deviations (b) of BPNN to obtain better results in the classification of AS grades [29].The primary design inspiration for GO originates from the learning and reflective mechanisms of humans during the course of social development [29].Through the mathematical modeling of learning and reflection behaviors, GO is categorized into two phases: The learning stage and the reflection stage.The learning stage of GO dynamically balances four types of directional information by incorporating fitness values and Euclidean distance.This adaptive balancing is crucial in mitigating the impact of incorrect directional information, significantly diminishing the likelihood of the algorithm succumbing to local optima.The reflection stage of GO uses distinct computation methods for each dimension of the individual, thereby augmenting the overall convergence performance of GO.These advantages of GO are helpful in overcoming the shortcomings of BPNN.In this study, the BPNN model optimized by using the GO algorithm was named GOBPNN.
In order to address the limitations of the method of classifying AS grades based on the evaluator's observation and experience, such as high subjectivity, unquantifiable parameters, inconsistent identification results among different evaluators, and a long learning curve to master this skill, this study combined computer vision with the GOBPNN model to achieve intelligent recognition of AS grades through image analysis.The findings of this study will facilitate efficient, objective, fast, non-destructive, and low-cost classification of the grades of AS, which could help consumers and market regulatory authorities to quickly and accurately identify the grade of AS.

Materials and Methods
The image recognition system was divided into four stages: (a) image acquisition; (b) image pre-processing; (c) image feature extraction; and (d) classification decision.

Samples Preparation
Standard samples of AS were purchased from Minxian County, Gansu Province, in 2021.They were divided into five commodity grades according to industry association standards [9] and the experience of Chinese herbal medicine experts, who has gained recognition from relevant companies and consumers.The original AS images representing five grades are shown in Figure 1.These standard samples (Figure 1) exhibit distinctive external characteristics, primarily comprising color, shape, and texture features.The number of AS for each grade and the weight of individual AS samples for each grade are shown in Table 1.

Image Acquisition
In order to obtain high-quality images, an image acquisition system was designed, and its structure diagram is shown in Figure 2. The image acquisition system mainly included a charge-coupled device (CCD) camera (Basler AG, Arnsberg, Germany, aca250014-gc), FA lens (Computar, Tokyo, Japan, M1214-MP2), and LED light (Shanghai Jia Ken Photoelectric Technology Co., Ltd., Shanghai, China, JKVR-170W).The Basler camera used for the current work was 2.2-megapixel RGB camera with a resolution of 2590 × 1942, a CMOS sensor, full resolution at a maximum frame rate of 14 fps, and an effective operating temperature range of 0 to 50 • C. Non-reflective black fabric was used to completely wrap the outside of the frame of the whole collecting system, and another side was left open to place the AS samples.OpenCV (version 3.0) was used to capture and save sample images.

Image Acquisition
In order to obtain high-quality images, an image acquisition system was designed, and its structure diagram is shown in Figure 2. The image acquisition system mainly included a charge-coupled device (CCD) camera (Basler AG, Arnsberg, Germany, aca250014-gc), FA lens (Computar, Tokyo, Japan, M1214-MP2), and LED light (Shanghai Jia Ken Photoelectric Technology Co., Ltd., Shanghai, China, JKVR-170W).The Basler camera used for the current work was 2.2-megapixel RGB camera with a resolution of 2590 × 1942, a CMOS sensor, full resolution at a maximum frame rate of 14 fps, and an effective operating temperature range of 0 to 50 °C.Non-reflective black fabric was used to completely wrap the outside of the frame of the whole collecting system, and another side was left open to place the AS samples.OpenCV (version 3.0) was used to capture and save sample images.During the image acquisition process, in order to ensure that images of AS of different sizes could be fully captured and to ensure the clarity of the photos, the samples were placed at a distance of 40 cm from the camera.In order to ensure a uniform background, white paper was placed on the loading platform.Then, the samples were arranged horizontally on the white background.To ensure accurate measurement of the length and area of AS, a ruler with a scale was placed to the right of AS at a specified distance.To obtain the appropriate lighting conditions, the brightness of the LED lamp was set at 1210 lm.Both the images of the front and back sides of each AS sample were acquired using the image acquisition system.A total of 794 images were collected.The image size was 2590 pixels by 1942 pixels.The file format for the images was tiff.To ensure consistency in the number of images across each grade, 80 images were randomly selected for each grade.Among these, 70% of the data is allocated for the training set, 15% for the validation set, and the remaining 15% for the test set.The training set was utilized to "teach" the model to recognize data, the validation set was utilized to "tune" the model parameters during training and prevent overfitting, and the test set was utilized to "evaluate" the generalization ability and final performance of the model after the model development was complete [30].During the image acquisition process, in order to ensure that images of AS of different sizes could be fully captured and to ensure the clarity of the photos, the samples were placed at a distance of 40 cm from the camera.In order to ensure a uniform background, white paper was placed on the loading platform.Then, the samples were arranged horizontally on the white background.To ensure accurate measurement of the length and area of AS, a ruler with a scale was placed to the right of AS at a specified distance.To obtain the appropriate lighting conditions, the brightness of the LED lamp was set at 1210 lm.Both the images of the front and back sides of each AS sample were acquired using the image acquisition system.A total of 794 images were collected.The image size was 2590 pixels by 1942 pixels.The file format for the images was tiff.To ensure consistency in the number of images across each grade, 80 images were randomly selected for each grade.Among these, 70% of the data is allocated for the training set, 15% for the validation set, and the remaining 15% for the test set.The training set was utilized to "teach" the model to recognize data, the validation set was utilized to "tune" the model parameters during training and prevent overfitting, and the test set was utilized to "evaluate" the generalization ability and final performance of the model after the model development was complete [30].

Pre-Processing and Segmentation
Image pre-processing is an essential step in pattern recognition systems.The process involves a series of steps, such as reducing noise and image segmentation.In this work, a relatively effective mean filter was used for image denoising.Image segmentation is an important element of the system, as it allows for advanced image analysis and understanding.In this work, the denoised image underwent binarization and an opening operation using the OTSU method [31].Next, the original RGB image was multiplied by the processed binarization matrix to extract the background area.Finally, the background area was subtracted from the original RGB image, and an accurate AS image segmentation was obtained, which was used in further analysis.

Feature Extraction
After performing the segmentation step, AS images without the white background were obtained.From the segmented images of AS, shape features, color features, and texture features could be extracted.

Extraction of Shape Features
The whole body of AS consists of the head and the tail, as shown in Figure 3.The various parts of AS exhibit distinct differences in their efficacy and medicinal properties, as reported by Chen et al. [32].Therefore, when extracting the shape features of AS, the shape features of the head, the tail, and the whole body were all extracted.

Pre-Processing and Segmentation
Image pre-processing is an essential step in pattern recognition systems.The process involves a series of steps, such as reducing noise and image segmentation.In this work, a relatively effective mean filter was used for image denoising.Image segmentation is an important element of the system, as it allows for advanced image analysis and understanding.In this work, the denoised image underwent binarization and an opening operation using the OTSU method [31].Next, the original RGB image was multiplied by the processed binarization matrix to extract the background area.Finally, the background area was subtracted from the original RGB image, and an accurate AS image segmentation was obtained, which was used in further analysis.

Feature Extraction
After performing the segmentation step, AS images without the white background were obtained.From the segmented images of AS, shape features, color features, and texture features could be extracted.

Extraction of Shape Features
The whole body of AS consists of the head and the tail, as shown in Figure 3.The various parts of AS exhibit distinct differences in their efficacy and medicinal properties, as reported by Chen et al. [32].Therefore, when extracting the shape features of AS, the shape features of the head, the tail, and the whole body were all extracted.To extract the shape features of the head, tail, and whole body, the widely adopted DeepLabv3+ semantic segmentation [33], which has high segmentation accuracy and precision, was first used to distinguish the head and tail of AS, and then the area, length, and diameter of the head, tail, and whole body were calculated.Additionally, the number of tail roots and average diameter of tail roots were also calculated.The operating system and environment were Microsoft Windows 10 and Python3.6 compilation, respectively, and the deep learning frameworks CUDAToolkit9.0and Paddle-GPU2.2.0 were also installed.
A total of 794 images were collected to construct the semantic segmentation dataset.Using the image annotation tool Labelme, manual annotations were performed on the heads, tails, and individual tail roots of each image.For each AS image, two types of annotation images were created: The first annotation image, as shown in Figure 4B, annotated the heads and tails, with the remaining parts as background, used to train the model for segmentation of heads and tails.The second annotation image, illustrated in Figure 4C, annotated recognizable and relatively complete roots in Angelica images and was used to train the model for segmentation of each root.In the first annotation image, the To extract the shape features of the head, tail, and whole body, the widely adopted DeepLabv3+ semantic segmentation [33], which has high segmentation accuracy and precision, was first used to distinguish the head and tail of AS, and then the area, length, and diameter of the head, tail, and whole body were calculated.Additionally, the number of tail roots and average diameter of tail roots were also calculated.The operating system and environment were Microsoft Windows 10 and Python3.6 compilation, respectively, and the deep learning frameworks CUDAToolkit9.0and Paddle-GPU2.2.0 were also installed.
A total of 794 images were collected to construct the semantic segmentation dataset.Using the image annotation tool Labelme, manual annotations were performed on the heads, tails, and individual tail roots of each image.For each AS image, two types of annotation images were created: The first annotation image, as shown in Figure 4B, annotated the heads and tails, with the remaining parts as background, used to train the model for segmentation of heads and tails.The second annotation image, illustrated in Figure 4C, annotated recognizable and relatively complete roots in Angelica images and was used to train the model for segmentation of each root.In the first annotation image, the AS tail was annotated as a whole, while in the second annotation image, each root was individually marked instead of treating the AS tail as a whole.
Agriculture 2024, 14, x FOR PEER REVIEW 6 of 21 AS tail was annotated as a whole, while in the second annotation image, each root was individually marked instead of treating the AS tail as a whole.The labeled data were randomly divided into training set, validation set, and test set at a ratio of 6:2:2, where the training set contained 476 images and the validation set and test set contained 159 images, respectively.In order to ensure that the number of input images of the deep learning network met the requirements, data enhancement was performed on the training set images, including random distortion, brightness adjustment, saturation adjustment, and contrast adjustment.
The training process was designed using the PaddlePaddle framework, the optimizer uses SGD, and the loss function was the cross-entropy loss function.After repeated tests, the parameters were set as follows: Learning rate = 0.001, momentum = 0.1, weight decay = 0.00001, batch size = 10, and the number of training iterations was 400.The training results showed that the intersection-over-union (IoU) and recall rate of both the tail and single-branched tail root exceeded 80%, indicating effective recognition.AS images were randomly selected from the test set for specific semantic segmentation effect verification, and the results are shown in Figure 5. From the recognition effect in Figure 5, it was evident that the trained model performs well in recognizing the head and tail (comparing B with C in Figure 5) and the single tail root (comparing D with E in Figure 5).Therefore, this trained model can be applied to segment the heads, tails, and single-tail roots of other AS images.
The extraction steps for the diameter, length, and area of the head, tail, and whole body of AS are shown in Figure 6.Taking the head of AS as an example, the quantification process of its length, diameter, and area was presented as follows: (1) The semantic segmentation results of the head and tail (Figure 6B) were first grayscaled (Figure 6C); (2) since the grayscale values of the head, tail, and background pixels are different, the gray The labeled data were randomly divided into training set, validation set, and test set at a ratio of 6:2:2, where the training set contained 476 images and the validation set and test set contained 159 images, respectively.In order to ensure that the number of input images of the deep learning network met the requirements, data enhancement was performed on the training set images, including random distortion, brightness adjustment, saturation adjustment, and contrast adjustment.
The training process was designed using the PaddlePaddle framework, the optimizer uses SGD, and the loss function was the cross-entropy loss function.After repeated tests, the parameters were set as follows: Learning rate = 0.001, momentum = 0.1, weight decay = 0.00001, batch size = 10, and the number of training iterations was 400.The training results showed that the intersection-over-union (IoU) and recall rate of both the tail and single-branched tail root exceeded 80%, indicating effective recognition.AS images were randomly selected from the test set for specific semantic segmentation effect verification, and the results are shown in Figure 5.
Agriculture 2024, 14, x FOR PEER REVIEW 6 of 21 AS tail was annotated as a whole, while in the second annotation image, each root was individually marked instead of treating the AS tail as a whole.The labeled data were randomly divided into training set, validation set, and test set at a ratio of 6:2:2, where the training set contained 476 images and the validation set and test set contained 159 images, respectively.In order to ensure that the number of input images of the deep learning network met the requirements, data enhancement was performed on the training set images, including random distortion, brightness adjustment, saturation adjustment, and contrast adjustment.
The training process was designed using the PaddlePaddle framework, the optimizer uses SGD, and the loss function was the cross-entropy loss function.After repeated tests, the parameters were set as follows: Learning rate = 0.001, momentum = 0.1, weight decay = 0.00001, batch size = 10, and the number of training iterations was 400.The training results showed that the intersection-over-union (IoU) and recall rate of both the tail and single-branched tail root exceeded 80%, indicating effective recognition.AS images were randomly selected from the test set for specific semantic segmentation effect verification, and the results are shown in Figure 5. From the recognition effect in Figure 5, it was evident that the trained model performs well in recognizing the head and tail (comparing B with C in Figure 5) and the single tail root (comparing D with E in Figure 5).Therefore, this trained model can be applied to segment the heads, tails, and single-tail roots of other AS images.
The extraction steps for the diameter, length, and area of the head, tail, and whole body of AS are shown in Figure 6.Taking the head of AS as an example, the quantification process of its length, diameter, and area was presented as follows: (1) The semantic segmentation results of the head and tail (Figure 6B) were first grayscaled (Figure 6C); (2) since the grayscale values of the head, tail, and background pixels are different, the gray From the recognition effect in Figure 5, it was evident that the trained model performs well in recognizing the head and tail (comparing B with C in Figure 5) and the single tail root (comparing D with E in Figure 5).Therefore, this trained model can be applied to segment the heads, tails, and single-tail roots of other AS images.
The extraction steps for the diameter, length, and area of the head, tail, and whole body of AS are shown in Figure 6.Taking the head of AS as an example, the quantification process of its length, diameter, and area was presented as follows: (1) The semantic segmentation results of the head and tail (Figure 6B) were first grayscaled (Figure 6C); (2) since the grayscale values of the head, tail, and background pixels are different, the gray level of the head pixels was set to 255 and the gray level of all other pixels was set to zero (Figure 6D); (3) a binary image of the AS head was obtained (Figure 6E), the number of pixels in the area occupied by the head was obtained, and the head area could be calculated by multiplying the area of each pixel (6.0279 × 10 −5 cm 2 ) by the pixel count; (4) based on the binary image of the AS head, a minimum bounding rectangle of the AS head was created (Figure 6F); (5) the diameter of the head was equal to the number of horizontal pixels of the bounding rectangle multiplied by the length of each pixel (0.00776397 cm), and the length of the head was equal to the number of pixels in the vertical direction of the bounding rectangle multiplied by the length of each pixel.
level of the head pixels was set to 255 and the gray level of all other pixels was set to zer (Figure 6D); (3) a binary image of the AS head was obtained (Figure 6E), the number o pixels in the area occupied by the head was obtained, and the head area could be calcu lated by multiplying the area of each pixel (6.0279 × 10 −5 cm 2 ) by the pixel count; (4) base on the binary image of the AS head, a minimum bounding rectangle of the AS head wa created (Figure 6F); ( 5) the diameter of the head was equal to the number of horizonta pixels of the bounding rectangle multiplied by the length of each pixel (0.00776397 cm and the length of the head was equal to the number of pixels in the vertical direction o the bounding rectangle multiplied by the length of each pixel. The quantification methods for the diameter, length, and area of the tail of AS wer the same as the quantification methods used for the head, as shown in Figure 6G-I.Th quantification methods for the diameter, length, and area of the whole body of AS wer the same as the quantification methods used for the head, as shown in Figure 6J,K,L.The steps of extraction of the number and average diameter of tail roots in AS ar shown in Figure 7. First, the semantic recognition of the tail roots of AS was carried ou The semantic segmentation result (Figure 7B) was converted to a gray-scale image (Figur 7C) and then a binary image (Figure 7D).All the identified tail roots were treated as single entity, and the minimum bounding rectangle was created for this entity (Figure 7E A horizontal line was drawn at the upper quarter of this rectangle in the vertical directio (Figure 7F).A logical AND operation was performed between the horizontal line and th tail roots of AS to obtain overlapping line segments (Figure 7G).The number of overlap ping line segments represented the number of tail roots, and the average number of pixel in the horizontal direction of these segments multiplied by the actual length of each pixe (0.00776397 cm) was the average diameter of the tail roots.The quantification methods for the diameter, length, and area of the tail of AS were the same as the quantification methods used for the head, as shown in Figure 6G-I.The quantification methods for the diameter, length, and area of the whole body of AS were the same as the quantification methods used for the head, as shown in Figure 6J-L.
The steps of extraction of the number and average diameter of tail roots in AS are shown in Figure 7. First, the semantic recognition of the tail roots of AS was carried out.The semantic segmentation result (Figure 7B) was converted to a gray-scale image (Figure 7C) and then a binary image (Figure 7D).All the identified tail roots were treated as a single entity, and the minimum bounding rectangle was created for this entity (Figure 7E).A horizontal line was drawn at the upper quarter of this rectangle in the vertical direction (Figure 7F).A logical AND operation was performed between the horizontal line and the tail roots of AS to obtain overlapping line segments (Figure 7G).The number of overlapping line segments represented the number of tail roots, and the average number of pixels in the horizontal direction of these segments multiplied by the actual length of each pixel (0.00776397 cm) was the average diameter of the tail roots.A total of 19 shape feature parameters were extracted, including head length, tail length, whole body length, head diameter, tail diameter, whole body diameter, head area, tail area, whole body area, head diameter-to-length ratio (i.e., the ratio of head diameter to head length), tail diameter to length ratio, whole body diameter to length ratio, head to tail length ratio (i.e., the ratio of head length to tail length), head to whole body length ratio, head to tail diameter ratio (i.e., the ratio of head diameter to tail diameter), head to tail area ratio (i.e., the ratio of head area to tail area), head to whole body area ratio, mean diameter of tail roots and number of tail roots.

Extraction of Color Features
In the "Chinese Medicinal Materials Commercial Specifications and Grade Standards" [9], the surface color of first-grade AS ranges from brownish-yellow to yellowbrown.The color features should be quantified.
Color features are pixel-level features of images with advantages such as rotation, scale, and translation invariance.This study selected the common digital image color spaces RGB (red, green, blue) and HSV (hue, saturation, value) as the spatial descriptors for color features.The color moment fully represented the color distribution features of the image, and the color distribution information was mainly concentrated in the firstorder moment (Mi1), second-order moment (Mi2), and third-order moment (Mi3).The formulas for calculating the first three color moments are as follows: where i1 represented R and H component; i2 represented G and S component; i3 represented B and V component; Pij represented the color value of the j-th pixel on the i-th color channel; and N represented the number of pixels in the image.A total of 18 color feature parameters were extracted, including R average, G average, B average, R variance, G variance, B variance, R skewness, G skewness, B skewness, H average, S average, V average, H variance, S variance, V variance, H skewness, S skewness, and V skewness.A total of 19 shape feature parameters were extracted, including head length, tail length, whole body length, head diameter, tail diameter, whole body diameter, head area, tail area, whole body area, head diameter-to-length ratio (i.e., the ratio of head diameter to head length), tail diameter to length ratio, whole body diameter to length ratio, head to tail length ratio (i.e., the ratio of head length to tail length), head to whole body length ratio, head to tail diameter ratio (i.e., the ratio of head diameter to tail diameter), head to tail area ratio (i.e., the ratio of head area to tail area), head to whole body area ratio, mean diameter of tail roots and number of tail roots.

Extraction of Color Features
In the "Chinese Medicinal Materials Commercial Specifications and Grade Standards" [9], the surface color of first-grade AS ranges from brownish-yellow to yellow-brown.The color features should be quantified.
Color features are pixel-level features of images with advantages such as rotation, scale, and translation invariance.This study selected the common digital image color spaces RGB (red, green, blue) and HSV (hue, saturation, value) as the spatial descriptors for color features.The color moment fully represented the color distribution features of the image, and the color distribution information was mainly concentrated in the first-order moment (M i1 ), second-order moment (M i2 ), and third-order moment (M i3 ).The formulas for calculating the first three color moments are as follows: (2) where i1 represented R and H component; i2 represented G and S component; i3 represented B and V component; P ij represented the color value of the j-th pixel on the i-th color channel; and N represented the number of pixels in the image.A total of 18 color feature parameters were extracted, including R average, G average, B average, R variance, G variance, B variance, R skewness, G skewness, B skewness, H average, S average, V average, H variance, S variance, V variance, H skewness, S skewness, and V skewness.

Extraction of Texture Features
In the "Chinese Medicinal Materials Commercial Specifications and Grade Standards" [9], first-grade AS displays the following characteristics: The head exhibits clear root and rhizome marks; the body presents longitudinal wrinkles, with inconspicuous or absent pore-like elevations; and it possesses a soft and flexible texture.These texture features should be quantified as well.
The texture feature is a measure of roughness, contrast, directivity, linearity, and regularity [34].The gray-level co-occurrence matrix (GLCM) is used to extract texture features [35].The GLCM algorithm is easy to implement and has been proven to give very good results in a wide range of applications.GLCM has the following advantages: (1) It can capture spatial relationships between pixels, extracting texture information; (2) it is sensitive to grayscale variations, distinguishing subtle differences in different textures; (3) the algorithm is relatively simple and easy to implement; (4) it performs well in many application domains.Second-order statistics provide more in-depth information about the spatial distribution of pixel grayscale values, helping analyze the texture structure of images.For example, energy (ASM) reflects the degree of contrast of grayscale levels in the image, entropy (ENT) characterizes the complexity of image texture, correlation (COR) measures the degree of correlation of grayscale levels in the image, while contrast (CON) indicates the degree of difference in grayscale levels in the image.
where i, j represented the grayscale of the pixel; L represented the gray level of the image; d represented the spatial position relationship between two pixels; and P d (i, j) represented frequency of occurrence of two pixels with spatial position relation d and grayscale of i and j, respectively.The texture analysis comprised eight distinct parameters, namely the average and standard deviation of ASM, ENT, COR, and CON, which were computed across four different directions, namely 0, 30, 60, and 90 degrees.A total of 8 texture feature parameters were extracted, including ASM average, ENT average, COR average, CON average, ASM standard deviation, ENT standard deviation, COR standard deviation, and CON standard deviation.By statistically analyzing these second-order statistics, a more precise understanding and description of the texture features in AS images can be achieved, establishing a stronger foundation for subsequent image analysis and processing.

Classification Model for AS Grades 2.5.1. The BPNN Model
The BPNN was a multi-layer perceptron trained with incremental learning rules, consisting of an input layer, one or more hidden layers, with each hidden layer containing several hidden nodes, and an output layer.The sigmoidal function was used as the activation function between the hidden and output layers.The gradient descent method was used to minimize the loss function, which was designed to measure the disparity between the model's predicted results and the actual labels.

The GO Algorithm
The primary design inspiration for GO originates from the learning and reflective mechanisms of humans during the course of social development [29].Learning is the process by which individuals assimilate knowledge from the external milieu and undergo personal development.Reflection entails scrutinizing individual limitations, adjusting learning methodologies, and fostering personal advancement.Through the mathematical modeling of learning and reflection behaviors, GO is categorized into two phases: the learning stage and the reflection stage.
During the learning stage, four hierarchical individuals were defined: Leader ( , where it was the current iteration count, and learning quality changes are determined by P 2 and Equation (14).
During the reflection stage, individuals were allowed to examine and remedy deficiencies.Positive aspects were retained, and when certain aspects were irremediable, past knowledge was discarded for a systematic relearning process.The reflection process of GO was mathematically modeled by Equations ( 15) and ( 16).
where ub and lb represented the upper and lower bounds of the search space, r 2 , r 3 , r 4 , r 5 were random numbers uniformly distributed in the range [0, 1].The parameter P 3 governed the probability of reflection and was typically set to 0.3.The decay factor AF was determined by the current evaluation count (FEs) and the maximum evaluation count (MaxFEs)).Over the course of algorithm iterations, the value of AF gradually converged to 0.01.This convergence signified that as individuals made progress, frequent reinitializations were used to prevent unnecessary time consumption.In the reflection phase, the j-th aspect of the i-th individual was influenced by certain superior individuals ( → R).Here, → R denoted individuals at a higher level, serving as guides for reflective learning in the context of the current individual i.

The GOBPNN Model
The proposed GOBPNN model utilized the GO algorithm to explore the parameter space of BPNN for seeking a broad global optimum, concurrently using the gradient descent algorithm to finely tune local regions, in order to optimize the parameter weights (w) and thresholds (b) of the BPNN, thereby accelerating model convergence and enhancing solution accuracy.The detailed procedure for implementing the GOBPNN model in AS grade classification is depicted in Figure 8. determined by the current evaluation count (FEs) and the maximum evaluation count (MaxFEs)).Over the course of algorithm iterations, the value of AF gradually converged to 0.01.This convergence signified that as individuals made progress, frequent reinitializations were used to prevent unnecessary time consumption.In the reflection phase, the j-th aspect of the i-th individual was influenced by certain superior individuals ( ⃗ ).Here,  ⃗ denoted individuals at a higher level, serving as guides for reflective learning in the context of the current individual i.

The GOBPNN Model
The proposed GOBPNN model utilized the GO algorithm to explore the parameter space of BPNN for seeking a broad global optimum, concurrently using the gradient descent algorithm to finely tune local regions, in order to optimize the parameter weights (w) and thresholds (b) of the BPNN, thereby accelerating model convergence and enhancing solution accuracy.The detailed procedure for implementing the GOBPNN model in AS grade classification is depicted in Figure 8.  Recorded the number of evaluations using FEs.(6) Reflection phase: For the j-th dimension of the i-th individual, the algorithm refined the dimension using three specific methods.The first maintained the original dimension, the second involved a higher-level individual guiding the j-th dimension of the i-th individual, and the third reconstructed the j-th dimension with a small probability based on the second method.Updated the i-th individual and real-time updated the global optimal solution gbestX.(7) Termination criterion: If the current iteration count (Fes) equaled the maximum iteration count (MaxFEs), the program stopped, and the output global optimal solution was fed into the BPNN for training and testing.Otherwise, returned to step (4).
This study addressed model overfitting by adopting the Trainbr method.Trainbr, a training approach grounded in Bayesian regularization, facilitates complexity control within the model through the integration of regularization parameters, thereby mitigating overfitting risks.

Evaluation of Recognition Performance
The performance of BPNN and GOBPNN in the classification of AS grades was evaluated by calculating the precision, recall, F-score, and accuracy, which were presented in Equations ( 17)- (20).Precision = TP/(TP + FP) Recall = TPR = TP/(TP + FN) F-score = 2 × precision × recall/(precision + recall) where TP represented true positive, which meant that the data that were supposed to be true for a certain category were actually true; FP represented false positive, which meant that the data that were predicted to be true for a certain category were actually false; FN represented false negative, which meant that the data that were predicted to be false for a certain category were actually true; TN represented true negative, which meant that the data that were supposed to be false for a certain category were actually false; n represented the total number of data points.

Statistical Analyses
SPSS 26.0 (IBM Corporation, New York, NY, USA) statistical software was used for one-way analysis of variance or non-parametric tests among the study groups and multiple comparisons of color, shape, and texture feature parameters among different grades of AS.In the case of homogeneity of variances, the method for multiple comparisons is Duncan, while in the case of heterogeneity of variances, the method for multiple comparisons is Tamhane's T2.SPSS 26.0 was also used to analyze the Spearman correlation between commodity grade and appearance feature parameters of AS.

Selection of Feature Parameters of AS Images
To explore potential disparities in the visual attributes among five grades of AS, we conducted one-way analysis of variance and subsequent multiple comparisons on 19 shape feature parameters, 18 color feature parameters, and 8 texture feature parameters of AS across five grades.One-way analysis of variance revealed that, among the 19 shape feature parameters, only the tail diameter to length ratio exhibited no statistically significant difference across different grades (p > 0.05).Among the 18 color feature parameters, solely H skewness displayed no significant difference across different grades (p > 0.05).All 8 texture feature parameters demonstrated no significant differences across different grades (p > 0.05).In summary, among all the appearance feature parameters, a total of 35 feature parameters (comprising 18 shape feature parameters and 17 color feature parameters) showed significant differences among different grades of AS (p < 0.05).Consequently, a more in-depth multiple comparison analysis was imperative for the 35 feature parameters to precisely discern variations among different grades.

Difference Analysis of Appearance Feature Parameters among Different Grades
The multiple comparison results for 18 shape feature parameters of AS among different grades are shown in Figure 9.
feature parameters, only the tail diameter to length ratio exhibited no statistically significant difference across different grades (p > 0.05).Among the 18 color feature parameters, solely H skewness displayed no significant difference across different grades (p > 0.05).All 8 texture feature parameters demonstrated no significant differences across different grades (p > 0.05).In summary, among all the appearance feature parameters, a total of 35 feature parameters (comprising 18 shape feature parameters and 17 color feature parameters) showed significant differences among different grades of AS (p < 0.05).Consequently, a more in-depth multiple comparison analysis was imperative for the 35 feature parameters to precisely discern variations among different grades.

Difference Analysis of Appearance Feature Parameters among Different Grades
The multiple comparison results for 18 shape feature parameters of AS among different grades are shown in Figure 9. From Figure 9, it can be seen that three shape feature parameters showed significant differences between any two grades, including tail area (Figure 9A), whole body area (Figure 9B), and head diameter (Figure 9F).Conversely, the remaining 15 shape feature parameters did not meet the condition of significant differences between any two grades, including head area, tail diameter, whole body diameter, head length, tail length, whole body length, head to tail area ratio, head to whole body area ratio, head to tail diameter ratio, head to tail length ratio, head to whole body length ratio, head diameter to length ratio, whole body diameter to length ratio, average tail diameter, and the number of tail roots (Figure 9).
The multiple comparison results for 17 color feature parameters of AS among different grades are shown in Figure 10.From Figure 9, it can be seen that three shape feature parameters showed significant differences between any two grades, including tail area (Figure 9A), whole body area (Figure 9B), and head diameter (Figure 9F).Conversely, the remaining 15 shape feature parameters did not meet the condition of significant differences between any two grades, including head area, tail diameter, whole body diameter, head length, tail length, whole body length, head to tail area ratio, head to whole body area ratio, head to tail diameter ratio, head to tail length ratio, head to whole body length ratio, head diameter to length ratio, whole body diameter to length ratio, average tail diameter, and the number of tail roots (Figure 9).
The multiple comparison results for 17 color feature parameters of AS among different grades are shown in Figure 10.From Figure 10, it can be seen that ten color feature parameters showed significant differences between any two grades, including G average (Figure 10B), B average (Figure 10C), R variances (Figure 10D), G variances (Figure 10E), B variances (Figure 10F), R skewness (Figure 10G), G skewness (Figure 10H), B skewness (Figure 10I), S average (Figure 10K), and V average (Figure 10L).Conversely, the remaining seven color feature parameters, specifically the R average, H average, H variances, S variances, V variances, S skewness, and V skewness, did not meet the condition of significant differences between any two grades.
In summary, the feature parameters that showed significant differences between any two grades include three shape feature parameters (3S: tail area, whole body area, and head diameter) and ten color feature parameters (10C: G average, B average, R variances, G variances, B variances, R skewness, G skewness, B skewness, S average, and V average).

Correlation Analysis
In order to determine key appearance feature parameters that distinguish the grades of AS, we analyzed the correlation between AS grades and 13 appearance feature parameters that showed significant differences between any two grades.AS grades, categorized as first through fifth, were numerically denoted as 1, 2, 3, 4, and 5.All feature parameters underwent standardization to eliminate dimensional influence during correlation calculation.The standardization method entailed subtracting the mean and dividing by the standard deviation.
Spearman correlation analysis, facilitated by SPSS 26.0 statistical software, was used to scrutinize the correlation between the 13 appearance feature parameters of AS and its grades.Correlation analysis results (Table 2) revealed a significant negative correlation between the 13 appearance feature parameters of AS and its grades (r < 0, p < 0.01).In simpler terms, higher values of the 13 appearance feature parameters corresponded to lower grades.Notably, the correlation between whole body area and grades stood out as the strongest (r = 0.976).This result aligned with the traditional understanding that a larger size of AS correlates with better quality.

Determination of the Optimal Number of Hidden Neurons
In this study, the hidden number empirical formula as well as the trial and error method were used to determine the number of hidden neurons using Equation (21): where n indicated the number of hidden neurons, a indicated the number of input nodes, b indicated the number of output nodes, and c was an integer between 1 and 10.
Using the BPNN model, training was conducted with different numbers of hidden neurons, based on three shape feature parameters (3S), ten color feature parameters (10C), and the combined thirteen feature parameters (13CS).Since not all 13 appearance feature parameters (13CS) were necessarily the best features, this study also used three shape feature parameters (3S) and ten color feature parameters (10C) as two types of features for training and testing.The results of training accuracy with different numbers of hidden neurons are shown in Table 3.For different input parameters, the optimal number of hidden neurons of 3S, 10C, and 13CS was 10, 4 and 7, respectively, and the corresponding accuracies were 77.1%, 62.5%, and 90.3% (Table 3).Therefore, the number of hidden neurons for the input cases of 3S, 10C, and 13CS was defined as 10, 4, and 7, respectively.To compare the effectiveness of the BPNN and GOBPNN models, the number of hidden nodes for both models was set to the same value.Note: 3S represented three shape feature parameters (i.e., tail area, whole body area, and head diameter); 10C were ten color feature parameters (i.e., G average, B average, R variances, G variances, B variances, R skewness, G skewness, B skewness, S average, and V average); 13CS represented the combination of three shape feature and ten color feature parameters.

Determination of the Optimal Feature
To determine which kind of feature is the best among 3S, 10C, and 13CS, BPNN and GOBPNN with the optimal number of hidden neurons were used to train and test these three kinds of features.The training accuracy and testing accuracy were illustrated in Figure 11 and Table 4. cause the differences in shape feature parameters among different grades were higher than the differences in color feature parameters among different grades, which can be seen from the basis of AS grade division [9].When training the same model, the three input features lasted approximately the same time (Table 4).The test result was generally similar to the training result (Figure 11B).Therefore, 13CS was selected as the input feature for further research.To determine if the improved BPNN (GOBPNN) model has better grade recognition performance than the traditional BPNN model, this study conducted training and testing for AS grade recognition using BPNN and GOBPNN with 13CS as the feature.The testing results are shown in Figure 12 and Table 5.
Based on Figure 12A, the classification of AS by the BPNN model revealed that all tests in grade one AS were accurate.In grade two AS, 95.5% of images were accurately judged, with only one image incorrectly classified as grade three AS.In grade three AS, three-quarters of the images were correctly judged, with three images and one image incorrectly classified as grade two and grade four, respectively.In grade four AS, 66.7% of images were correctly judged, with a few incorrectly classified as grade three (33.3%).In  For the training process, regardless of which model was used, 13CS as an input feature had the best recognition effect (accuracy higher than 90%), 10C had the worst recognition effect (accuracy less than 70%), and 3S was in the middle (Figure 11A).The results suggested that the simultaneous use of the three shape feature parameters and the ten color feature parameters could relatively accurately distinguish different grades of AS.Both shape and color were essential factors for grading AS.This was due to the significant variations in grades observed in AS grown in different soil types [36].Various factors, including soil type, structure, moisture content, nutrient distribution, oxygen levels, environmental pressure, and adaptation mechanisms, impacted the shape of AS [37,38].And soil mineral content, pH levels, and microbial activity played a role in determining its color [39].The combination of these factors contributed to the diversity of AS grades.Notably, the contribution of shape features surpassed that of color features.This may be because the differences in shape feature parameters among different grades were higher than the differences in color feature parameters among different grades, which can be seen from the basis of AS grade division [9].When training the same model, the three input features lasted approximately the same time (Table 4).The test result was generally similar to the training result (Figure 11B).Therefore, 13CS was selected as the input feature for further research.

Determination of the Optimal Model
To determine if the improved BPNN (GOBPNN) model has better grade recognition performance than the traditional BPNN model, this study conducted training and testing for AS grade recognition using BPNN and GOBPNN with 13CS as the feature.The testing results are shown in Figure 12 and Table 5.
GOBPNN model yielded accurate results across grades one, two, and four.In grade three AS, only 11.8% of images were erroneously classified as grade two, while in grade five AS, only 8.3% of images were misclassified as grade three.
It was evident that the GOBPNN exhibited superior performance, particularly in substantially enhancing the recognition accuracy of grade four AS.Perhaps due to the tendency of grade four AS samples to fall into local minima in the BPNN model, GOBPNN can effectively solve this problem, thus greatly improving its accuracy.It can also be seen from Table 5 that GOBPNN achieved higher average precision (97.1%), recall (95.9%),F-score (96.5%), and accuracy (95.0%), while the average precision, recall, F-score, and accuracy for BPNN were 82.5%, 83.2%, 82.4%, and 85.0%, respectively.Notably, compared to BPNN, GOBPNN increased precision, recall, F-score, and accuracy by 17.7%, 15.4%, 17.1%, and 11.8%, respectively.These results indicated that the method based on a computer vision system combined with GOBPNN had proven to be effective in classifying the grades of AS.Compared to traditional empirical identification, this method effectively inherited its convenience, non-destructiveness to samples, and timely  Based on Figure 12A, the classification of AS by the BPNN model revealed that all tests in grade one AS were accurate.In grade two AS, 95.5% of images were accurately judged, with only one image incorrectly classified as grade three AS.In grade three AS, three-quarters of the images were correctly judged, with three images and one image incorrectly classified as grade two and grade four, respectively.In grade four AS, 66.7% of images were correctly judged, with a few incorrectly classified as grade three (33.3%).In grade five AS, 78.6% of images were correctly judged, with images incorrectly classified as grade one and grade three accounting for 7.1% and 14.3%, respectively.
Based on Figure 12B, it was evident that the classification of AS images using the GOBPNN model yielded accurate results across grades one, two, and four.In grade three AS, only 11.8% of images were erroneously classified as grade two, while in grade five AS, only 8.3% of images were misclassified as grade three.
It was evident that the GOBPNN exhibited superior performance, particularly in substantially enhancing the recognition accuracy of grade four AS.Perhaps due to the tendency of grade four AS samples to fall into local minima in the BPNN model, GOBPNN can effectively solve this problem, thus greatly improving its accuracy.
It can also be seen from Table 5 that GOBPNN achieved higher average precision (97.1%), recall (95.9%),F-score (96.5%), and accuracy (95.0%), while the average precision, recall, F-score, and accuracy for BPNN were 82.5%, 83.2%, 82.4%, and 85.0%, respectively.Notably, compared to BPNN, GOBPNN increased precision, recall, F-score, and accuracy by 17.7%, 15.4%, 17.1%, and 11.8%, respectively.These results indicated that the method based on a computer vision system combined with GOBPNN had proven to be effective in classifying the grades of AS.Compared to traditional empirical identification, this method effectively inherited its convenience, non-destructiveness to samples, and timely conclusions.Additionally, it avoided the drawbacks of non-quantifiable indicators, subjective results, and difficulties in inheritance.
In terms of recognition performance, the results of this study proved to be more effective than those of the recognition of ginseng grades based on images, which had an accuracy of only 74% [20].In addition, the classification results of this work turned out to be better than the results of the grade identification of the Cornus officinae based on the analysis of color features, using discrimination analysis, least squares support vector machine, and partial least squares discriminant analysis, where the accuracies of the assessment were 86.21%, 89.66%, and 89.66%, respectively [40].The results of this study were comparable to the results of rhubarb grade recognition based on color features and the BPNN model, where the highest accuracy was 92.3% [22].
From the perspective of time and economic cost, the training time for BPNN and GOBPNN in this study did not exceed 15 min, and the testing time was less than 1 s.It only required taking a photo to obtain the results, which was extremely simple, fast, and cheap.However, through the classification of chemical components, it took several hours just to dissolve powder and extract chemical components, not to mention the time and money used in the long, fumbling conditions to detect chemical component content.Moreover, this method also had other advantages: (1) It could quantify evaluation parameters, making the results relatively objective; (2) the results were stable and not influenced by different evaluators; (3) it did not require damaging AS; (4) the method could be quickly mastered without requiring a long learning period.Based on the above analysis, it can be concluded that the method proposed in this study, which combined machine vision technology with the GOBPNN model, was a convenient and promising approach for classifying the grades of AS.
The training duration of the proposed GOBPNN model in this study may be somewhat prolonged.Future research endeavors could investigate approaches to mitigate model training time or explore alternative models with superior performance to enhance the discrimination of AS grades.Furthermore, the 13 selected feature parameters (tail area, whole body area, head diameter, G average, B average, R variances, G variances, B variances, R skewness, G skewness, B skewness, S average, and V average) identified in this study possess significant value; they can be used for estimating the weight of irregularly shaped AS from images and for researching and refining the quality standards of AS.

Conclusions
In this study, we first obtained images of AS at five commodity grades and extracted 19 shape feature parameters, 18 color feature parameters, and eight texture feature parameters from the images.Then, through difference analysis and correlation analysis, we selected three shape feature parameters and 10 color feature parameters for image recognition of AS grades.In order to accurately classify AS grades, the traditional BPNN model was optimized using a growing optimizer (GO).The modeling results showed that the GOBPNN model achieved the highest classification efficiency, expressed as average test precision, recall, F-score and accuracy, amounting to 97.1%, 95.9%, 96.5%, and 95.0%, respectively.Compared to the traditional BPNN model, GOBPNN increased the average test precision, recall, F-score, and accuracy by 17.7%, 15.4%, 17.1%, and 11.8%, respectively.The results indicated that the method combining machine vision technology with GOBPNN enabled efficient, objective, fast, non-destructive, and low-cost classification of the grades of AS, which could help consumers and market regulatory authorities quickly and accurately identify the grade of AS when purchasing it.

Figure 1 .
Figure 1.Original images of AS samples at five grades.The five images from left to right represent grade one, grade two, grade three, grade four, and grade five, respectively.

Figure 1 .
Figure 1.Original images of AS samples at five grades.The five images from left to right represent grade one, grade two, grade three, grade four, and grade five, respectively.

Figure 2 .
Figure 2. Structure diagram of image acquisition system.

Figure 2 .
Figure 2. Structure diagram of image acquisition system.

Figure 3 .
Figure 3. Diagram of the head, tail, and whole body of AS.The portion inside the red box was the head of AS.The portion inside the green box was the tail of AS.The head and tail together formed the whole body of AS.Each branch of the AS tail was referred to as a tail root of AS.

Figure 3 .
Figure 3. Diagram of the head, tail, and whole body of AS.The portion inside the red box was the head of AS.The portion inside the green box was the tail of AS.The head and tail together formed the whole body of AS.Each branch of the AS tail was referred to as a tail root of AS.

Figure 4 .
Figure 4. Labeled images for training semantic segmentation model.(A) AS image; (B) the first labeled image; (C) the second labeled image.

Figure 5 .
Figure 5. Semantic recognition effect of AS head, tail, and each root.(A) Original image; (B) manually labeled images of AS head and tail; (C) model prediction result of AS head and tail; (D) manually labeled image of each root of AS; (E) prediction result of the second labeled image.

Figure 4 .
Figure 4. Labeled images for training semantic segmentation model.(A) AS image; (B) the first labeled image; (C) the second labeled image.

Figure 4 .
Figure 4. Labeled images for training semantic segmentation model.(A) AS image; (B) the first labeled image; (C) the second labeled image.

Figure 5 .
Figure 5. Semantic recognition effect of AS head, tail, and each root.(A) Original image; (B) manually labeled images of AS head and tail; (C) model prediction result of AS head and tail; (D) manually labeled image of each root of AS; (E) prediction result of the second labeled image.

Figure 5 .
Figure 5. Semantic recognition effect of AS head, tail, and each root.(A) Original image; (B) manually labeled images of AS head and tail; (C) model prediction result of AS head and tail; (D) manually labeled image of each root of AS; (E) prediction result of the second labeled image.

Figure 6 .
Figure 6.Procedure for extracting the diameter, length, and area of the head, tail, and whole bod of AS. (A) The original image; (B) semantic segmentation image of the head (green section) and ta (yellow section) of AS; (C) gray-level image; (D) the pixel gray level of the AS head was set to 25 (E) binary image of the AS head; (F) minimum bounding rectangle of the AS head; (G) the pixel gra level of the AS tail was set to 255; (H) binary image of the AS tail; (I) minimum bounding rectang of the AS tail; (J) the pixel gray level of the whole body of AS was set to 255; (K) binary image of th whole body of AS; (L) minimum bounding rectangle of the whole body of AS.

Figure 6 .
Figure 6.Procedure for extracting the diameter, length, and area of the head, tail, and whole body of AS. (A) The original image; (B) semantic segmentation image of the head (green section) and tail (yellow section) of AS; (C) gray-level image; (D) the pixel gray level of the AS head was set to 255; (E) binary image of the AS head; (F) minimum bounding rectangle of the AS head; (G) the pixel gray level of the AS tail was set to 255; (H) binary image of the AS tail; (I) minimum bounding rectangle of the AS tail; (J) the pixel gray level of the whole body of AS was set to 255; (K) binary image of the whole body of AS; (L) minimum bounding rectangle of the whole body of AS.

Figure 7 .
Figure 7. Procedure of extraction of the number and average diameter of the tail roots of AS. (A) The original image; (B) semantic segmentation image of the tail roots of AS; (C) gray-level image; (D) binary image; (E) minimum bounding rectangle of the entity of tail roots; (F) a horizontal line at the upper quarter of this rectangle in the vertical direction; (G) overlap between the horizontal line and the tail roots.

Figure 7 .
Figure 7. Procedure of extraction of the number and average diameter of the tail roots of AS. (A) The original image; (B) semantic segmentation image of the tail roots of AS; (C) gray-level image; (D) binary image; (E) minimum bounding rectangle of the entity of tail roots; (F) a horizontal line at the upper quarter of this rectangle in the vertical direction; (G) overlap between the horizontal line and the tail roots.

Figure 8 .
Figure 8. Flowchart of the GOBPNN model.And the steps of GOBPNN implementation can be summarized as follows: (1) Collected the AS images, and extracted features of AS images.Then selected features that were used for model training.Defined the architecture of the BPNN and network training parameters were configured, such as the maximum number of training epochs (epochs), learning rate (lr), target error (goal), display frequency (show), momentum factor (mc), minimum performance gradient (min_grad), and maximum number of failures (max_fail).(2) Initialized parameters, including population size (N), population dimension (D), iteration count (FEs), maximum iteration count (MaxFEs), upper bound of the search space (ub), and lower bound of the search space (lb).(3) Initialized the population (X) based on N, D, ub, and lb.The population represented a set of individuals, where an individual's elements denoted crucial parameters (e.g., weights and biases).An individual was a row vector with D columns, forming an N row by D column matrix.The error between the output value and the target value of the neural network was used to calculate the fitness.The individual with the minimum fitness was defined as the optimal individual, gbestX.(4) Commenced the iterative process.Calculated the fitness of each individual in the population, sorted the fitness to find the current best individual (Best_X) and worst

Figure 8 .
Figure 8. Flowchart of the GOBPNN model.And the steps of GOBPNN implementation can be summarized as follows: (1) Collected the AS images, and extracted features of AS images.Then selected features that were used for model training.Defined the architecture of the BPNN and network training parameters were configured, such as the maximum number of training epochs (epochs), learning rate (lr), target error (goal), display frequency (show), momentum factor (mc), minimum performance gradient (min_grad), and maximum number of failures (max_fail).(2) Initialized parameters, including population size (N), population dimension (D), iteration count (FEs), maximum iteration count (MaxFEs), upper bound of the search space (ub), and lower bound of the search space (lb).(3) Initialized the population (X) based on N, D, ub, and lb.The population represented a set of individuals, where an individual's elements denoted crucial parameters (e.g., weights and biases).An individual was a row vector with D columns, forming an N row by D column matrix.The error between the output value and the target value of the neural network was used to calculate the fitness.The individual with the minimum fitness was defined as the optimal individual, gbestX.(4) Commenced the iterative process.Calculated the fitness of each individual in the population, sorted the fitness to find the current best individual (Best_X) and worst individual (Worst_X), continuously updated the best individual (Best_X) during iteration, and updated gbestX after each evaluation.(5) Learning phase: For the i-th individual, selected Better_X and Worst_X to participate in the learning process.Additionally, Best_X contributed to the learning process

Figure 9 .
Figure 9. Differences in 18 shape feature parameters among different grades of AS.Note: abcde represent different levels of significance.Different letters indicate significant differences, while the same letter implies no significant difference.

Figure 9 .
Figure 9. Differences in 18 shape feature parameters among different grades of AS.Note: abcde represent different levels of significance.Different letters indicate significant differences, while the same letter implies no significant difference.

Figure 10 .
Figure 10.Differences in 17 color feature parameters among different grades of AS.Note: abcde represent different levels of significance.Different letters indicate significant differences, while the same letter implies no significant difference.

Figure 11 .
Figure 11.Training (A) and testing (B) accuracy of BPNN and GOBPNN based on different kinds of features.

Figure 11 .
Figure 11.Training (A) and testing (B) accuracy of BPNN and GOBPNN based on different kinds of features.

Table 1 .
The number of AS for each grade and the weight of individual AS for each grade.

Table 1 .
The number of AS for each grade and the weight of individual AS for each grade.

Table 2 .
Correlation coefficient between appearance feature parameters and grades of AS.

Table 3 .
Training accuracy of different number of hidden neurons.

Table 4 .
The training time and testing time of BPNN and GOBPNN based on different kinds of features.

Table 4 .
The training time and testing time of BPNN and GOBPNN based on different kinds of features.

Table 5 .
The testing results of BPNN and GOBPNN at five grades.

Table 5 .
The testing results of BPNN and GOBPNN at five grades.