Barley variety identification method, system, electronic device and storage medium
By converting RGB images to the HSV color space and extracting the Hue channel, and combining color prior center adaptive enhancement and deep convolutional networks, the problem of insufficient recognition accuracy of highly similar barley varieties is solved, achieving high-precision, low-cost, and rapid industrial barley variety screening.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGNAN UNIV
- Filing Date
- 2026-06-09
- Publication Date
- 2026-07-14
AI Technical Summary
Existing barley variety identification methods lack sufficient accuracy in identifying highly similar varieties and are easily affected by factors such as changes in light intensity, surface reflection, and uneven maturity, resulting in a high misclassification rate. This makes it difficult to meet the needs of large-scale, low-cost, and rapid screening in industrial settings.
The RGB image is converted to the HSV color space, the Hue channel is extracted and clustered, and key regions are adaptively enhanced based on color prior centers to form four-channel fusion features. A deep convolutional classification network is used for feature extraction and classification.
It improves the accuracy of identifying highly similar barley varieties, reduces the misclassification rate, enhances anti-interference capabilities, adapts to the needs of large-scale screening in industrial settings, and extends to fine-grained identification scenarios for agricultural products such as wheat and rice.
Smart Images

Figure CN122391759A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method, system, electronic device, and storage medium for identifying barley varieties, and belongs to the field of non-destructive testing technology for agricultural products. Background Technology
[0002] Barley is the core raw material for beer brewing. Different varieties of barley have significant differences in protein content, enzyme activity, germination uniformity, extraction rate and saccharification performance, which directly determine the stability of malting and the quality of finished beer. Therefore, rapid, accurate and non-destructive identification of barley varieties before raw materials enter the factory, are stored and processed is of great industrial value to ensure stable production and product quality.
[0003] Among the existing methods for identifying barley varieties, molecular markers, protein electrophoresis, and physicochemical detection have high accuracy, but they require specialized equipment, complex pretreatment, and have long detection cycles. Some methods can also damage samples, making it difficult to meet the needs of large-scale, low-cost, and rapid screening in industrial settings.
[0004] Computer vision recognition methods based on visible light images are well-suited for barley variety screening in actual production due to their advantages of being non-destructive, efficient, low-cost, and easy to deploy. However, existing methods combining conventional RGB images with general convolutional neural networks have fundamental shortcomings for fine-grained image classification of highly similar barley varieties. The differences between highly similar barley varieties in seed coat color, ventral groove region, embryo region, and seed coat edge region are very subtle and easily affected by factors such as light variations, surface reflection, maturity differences, and storage oxidation. Conventional RGB representation simultaneously mixes brightness, color, and texture information, making it difficult to consistently highlight subtle tonal differences that are significant for discrimination. Furthermore, general neural networks tend to focus more on high-frequency structural features such as edges, shapes, and surface textures during feature extraction, while the key differences between highly similar barley varieties are more often reflected in subtle changes in low-frequency color regions. During the downsampling process of the network layer by layer, this weak color information is easily compressed or ignored, resulting in insufficient feature spacing between difficult-to-distinguish varieties. Therefore, current barley variety identification and classification methods based on network models cannot reliably extract and utilize the subtle color differences that exist between varieties. Under interference from light changes, uneven grain maturity, storage oxidation, and surface reflection, key color information is easily weakened or lost, ultimately leading to insufficient identification accuracy and a high misclassification rate for highly similar varieties. Summary of the Invention
[0005] To improve barley identification accuracy and reduce misclassification rate, this invention provides a barley variety identification method, system, electronic device, and storage medium, the specific technical solutions of which are as follows: In a first aspect, the present invention provides a method for identifying barley varieties, comprising: Step 1: Acquire RGB images of the barley seeds to be identified and perform preprocessing; Step 2: Convert the RGB image to the HSV color space, and then extract the Hue channel pixels; Step 3: Cluster the Hue channel pixels to obtain a set of color prior centers; Step 4: Based on the relative relationship between Hue pixels and the color prior center, enhance the color regions close to the prior center, including: For any pixel in the Hue channel Calculate the relative difference between the pixel and the nearest color prior center, and enhance the Hue feature map based on the relative difference. The enhanced Hue feature map is represented as follows:
[0006] in, This indicates the relative difference. Indicates the gain coefficient. This represents the Sigmoid activation function; Step 5: Concatenate the enhanced Hue feature map with the original RGB image along the channel dimension to form a four-channel fused feature; Step 6: Use a deep convolutional classification network to extract the four-channel fusion features and obtain the classification results.
[0007] Thus, this invention converts RGB images to the HSV color space and extracts the Hue channel, effectively separating hue and brightness information and reducing interference from changes in lighting, surface reflection, and uneven maturity, making subtle color differences more stable and discernible. By clustering Hue channel pixels to obtain color prior centers, key color regions with varietal differentiation significance, such as the seed coat, ventral groove, and embryo, can be accurately located, providing a reliable basis for adaptive enhancement. Adaptive nonlinear enhancement of key color gamuts based on color prior centers can amplify subtle hue differences between highly similar varieties, preventing weak color features from being weakened or lost during network downsampling. The enhanced Hue features are directly concatenated with the original RGB image in the channel dimension to form a four-channel fusion feature, allowing the model to simultaneously utilize texture structure information and enhanced color information in the early stages of feature extraction, ensuring that discriminative information is fully learned from the input level.
[0008] This invention employs a deep convolutional classification network adapted to four-channel input for feature extraction and classification, further enhancing the ability to perceive subtle varietal differences. Compared with existing methods, this invention significantly improves the accuracy of identifying highly similar barley varieties while maintaining the advantages of being non-destructive, fast, low-cost, and easy to deploy. It also significantly reduces the number of misclassifications among easily confused varieties, exhibits stronger anti-interference capabilities, and is more suitable for large-scale screening needs in industrial settings. It can be widely used for barley raw material inspection upon arrival at the factory, purity screening in storage, and quality control of brewing raw materials. Furthermore, it can be extended to fine-grained identification scenarios for agricultural products such as wheat, rice, and corn.
[0009] Optionally, step 4, which enhances the Hue feature map, can be replaced with: The responses of Hue pixels relative to multiple color prior centers are calculated separately, and the multiple responses are aggregated to obtain the final enhanced Hue feature map:
[0010] in, express The Hue pixel at position relative to the first k Color Priority Center Enhanced response, This represents the enhanced Hue feature map after aggregation. K This indicates the number of color prior centers.
[0011] Thus, by employing a multi-color prior center parallel computation and response aggregation enhancement approach, the ability to extract subtle color differences among highly similar barley varieties is further strengthened. Compared to enhancement using only the nearest single center, this scheme comprehensively covers the color features of multiple regions and levels of barley seeds by calculating the response of each Hue pixel to all color prior centers and aggregating the mean values, avoiding omissions of key discrimination color domains. This method can more evenly and stably amplify the tonal differences in multiple key regions such as the seed coat, ventral groove, embryo, and seed coat edge, making color enhancement more comprehensive and robust, and effectively suppressing fluctuations caused by uneven light, reflection, and maturity. Through multi-center collaborative enhancement, weak color features are more fully preserved and highlighted, significantly reducing the misclassification rate of easily confused varieties and further improving the model's recognition accuracy and classification reliability.
[0012] Optionally, step 6 uses an improved EfficientNet-B4 network as the backbone network to extract the four-channel fusion features, while retaining the convolution weights corresponding to the RGB channels in the original pre-trained model. , , And add the convolution weights corresponding to the new Hue channel. Initialize as the mean of the RGB three-channel weights:
[0013] in, This represents the convolution weights of the newly added Hue channel.
[0014] Thus, through EfficientNet The B4 backbone network undergoes a four-channel modification, initializing the convolutional weights of the newly added Hue channel to the average of the RGB three-channel weights. This approach fully inherits the mature texture, contour, and structural feature extraction capabilities of the pre-trained model on RGB images while stably adapting to the four-channel input fused with RGB and enhanced Hue. This avoids model instability, convergence difficulties, or feature extraction failures caused by the addition of a new channel. This initialization method allows the network to simultaneously learn RGB texture information and enhanced color discrimination information in the early stages of training, effectively preserving and transmitting weak color difference features in shallow layers, preventing them from being weakened during network downsampling. Compared to direct random initialization or training from scratch, this solution significantly improves model convergence speed and feature extraction efficiency, further enhancing the perception and differentiation of subtle color differences in highly similar barley varieties, and significantly improving recognition accuracy and model stability.
[0015] Optionally, the number of color prior centers K =6.
[0016] Thus, the number of color prior centers is set to K =6, which accurately matches the main color regions actually present in barley seeds. It can completely cover six key color regions: dark brown lesions, light yellow seed coat, grayish-white ventral groove, golden yellow embryo, light brown seed coat edge, and black background, ensuring comprehensive color feature extraction without increasing computational overhead or causing feature redundancy due to excessive cluster centers. This number is determined by the elbow rule, achieving an optimal balance between feature expression accuracy and computational efficiency. This makes color prior mining more stable and adaptive hue enhancement more targeted, effectively improving the model's ability to capture subtle color differences, further ensuring the accuracy of identifying highly similar barley varieties and the efficiency of model operation.
[0017] Optionally, the gain coefficient .
[0018] In this way, the optimal nonlinear stretching intensity can be achieved during adaptive hue enhancement. This effectively amplifies subtle hue differences in areas such as the seed coat, ventral groove, and embryo among highly similar barley varieties, making key discriminative features more prominent, while avoiding oversaturation and loss of detail due to excessive gain. Experimental verification shows that this value stably suppresses interference from light, reflection, and uneven maturity, resulting in a more uniform distribution and stronger discriminative power of the enhanced Hue features. When fused with RGB features, it significantly improves the model's ability to distinguish difficult-to-classify varieties, further reducing the misclassification rate, while ensuring stable model training and smooth convergence, balancing enhancement effectiveness with system robustness. Optionally, the barley variety identification model can be trained using the cross-entropy loss function.
[0019] In this way, the difference between the predicted probability and the true label can be effectively measured, adapting to multi-classification tasks. The training is stable and the convergence speed is fast, enabling the model to accurately learn the feature distribution of different barley varieties, improve the classification and discrimination ability, ensure reliable recognition results, and meet the needs of high-precision variety recognition.
[0020] Optionally, step 3 uses the K-means clustering method to cluster the Hue pixel set, optimizing it by minimizing the intra-cluster squared error. The objective function is as follows:
[0021] in, Indicates being assigned to the first k The set of Hue pixels at each cluster center This represents the Euclidean distance between Hue pixels and their corresponding cluster centers.
[0022] Thus, using K Means clustering, optimized with the goal of minimizing the squared error within clusters, can accurately mine the core color distribution of the Hue channel in barley seeds, obtaining compact and representative color prior centers. This ensures that subsequent hue enhancement is more in line with real color features, improves the accuracy and stability of key color gamut extraction, and provides reliable support for high-precision recognition.
[0023] In a second aspect, the present invention provides a barley variety identification system, the system being configured to implement the barley variety identification method as described in any of the preceding claims, comprising: The image preprocessing module is configured to acquire and preprocess RGB images of the barley seeds to be identified. The Hue channel extraction module is configured to convert the RGB image to the HSV color space and then extract the Hue channel pixels. The color prior mining module is configured to cluster the Hue channel pixels to obtain a set of color prior centers; The target color stretching module is configured to enhance color regions close to the prior center based on the relative relationship between Hue pixels and the color prior center, including: For any pixel in the Hue channel Calculate the relative difference between the pixel and the nearest color prior center, and enhance the Hue feature map based on the relative difference. The enhanced Hue feature map is represented as follows:
[0024] in, This indicates the relative difference. Indicates the gain coefficient. This represents the Sigmoid activation function; The input-level fusion module is configured to concatenate the enhanced Hue feature map with the original RGB image along the channel dimension to form a four-channel fusion feature. The four-channel depth feature extraction module is configured to use a deep convolutional class network to extract the four-channel fused features; The classification output module is configured to classify and output the classification results.
[0025] Thus, through modular design, image preprocessing, Hue channel extraction, color prior mining, target color stretching, input-level fusion, four-channel feature extraction, and classification output are organically integrated, enabling fully automated recognition throughout the entire process. The system is stable, logically clear, and easy to deploy and maintain. It can separate hue and brightness information, resist interference from lighting, reflection, and uneven maturity, accurately locate and adaptively enhance the key color gamut of barley seeds, and fully integrate texture and color information in the early stages of feature extraction, significantly improving the ability to distinguish highly similar varieties. Compared to traditional detection systems, this system requires no complex equipment or sample preprocessing, maintaining its advantages of being non-destructive, fast, and low-cost. It can be directly applied to large-scale raw material screening scenarios in industrial settings, significantly reducing misclassification rates and improving recognition accuracy. It also has good scalability, easily adaptable to fine-grained recognition tasks for other agricultural products such as wheat and rice, making it more practical and versatile.
[0026] Thirdly, the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, performs the barley variety identification steps as described in any of the preceding claims.
[0027] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, it implements the steps of the barley variety identification method as described in any of the preceding claims. Attached Figure Description
[0028] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a schematic diagram of the barley variety identification method model structure in Embodiment 4 of the present invention.
[0030] Figure 2 This is a schematic diagram of the color prior mining and target color stretching module in Embodiment 4 of the present invention.
[0031] Figure 3 This is a schematic diagram of the RGB image and enhanced Hue feature input-level fusion and four-channel network structure in Embodiment 4 of the present invention.
[0032] Figure 4 This is a comparison chart of the number of misclassifications of the difficult-to-distinguish varieties Yangnongpi 7 and Yanmai 7 in the experiment of Example 4 of this invention.
[0033] Figure 5 This is a comparison chart of the overall classification accuracy of different comparison models on the test set in the experiment of Embodiment 4 of the present invention. Detailed Implementation
[0034] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0035] Example 1: This embodiment provides a barley variety identification method based on color prior and adaptive hue enhancement, including: Step 1: Acquire RGB images of the barley seeds to be identified and perform preprocessing; Step 2: Convert the RGB image to the HSV color space, and then extract the Hue channel pixels; Step 3: Cluster the pixels in the Hue channel to obtain the set of color prior centers; Step 4: Based on the relative relationship between Hue pixels and the color prior center, enhance the color regions close to the prior center, including: For any pixel in the Hue channel Calculate the relative difference between the pixel and the nearest color prior center, and enhance the Hue feature map based on the relative difference. The enhanced Hue feature map is represented as:
[0036] in, Indicates relative differences. Indicates the gain coefficient. This represents the Sigmoid activation function; Step 5: Concatenate the enhanced Hue feature map with the original RGB image along the channel dimension to form a four-channel fused feature; Step 6: Use a deep convolutional classification network to extract the four-channel fusion features and obtain the classification results.
[0037] Thus, this embodiment converts RGB images to the HSV color space and extracts the Hue channel, effectively separating hue and brightness information and reducing interference from changes in lighting, surface reflection, and uneven maturity, making subtle color differences more stable and discernible. By clustering Hue channel pixels to obtain color prior centers, key color regions with varietal differentiation significance, such as seed coat, ventral groove, and embryo, can be accurately located, providing a reliable basis for adaptive enhancement. Adaptive nonlinear enhancement of key color gamuts based on color prior centers can amplify subtle hue differences between highly similar varieties, preventing weak color features from being weakened or lost during network downsampling. The enhanced Hue features are directly concatenated with the original RGB image in the channel dimension to form a four-channel fusion feature, allowing the model to simultaneously utilize texture structure information and enhanced color information in the early stages of feature extraction, ensuring that discriminative information is fully learned from the input level.
[0038] This embodiment employs a deep convolutional classification network adapted to four-channel input for feature extraction and classification, further enhancing the ability to perceive subtle varietal differences. Compared with existing methods, this embodiment significantly improves the accuracy of identifying highly similar barley varieties while maintaining the advantages of being non-destructive, fast, low-cost, and easy to deploy. It also significantly reduces the number of misclassifications among easily confused varieties, exhibits stronger anti-interference capabilities, and is more suitable for large-scale screening needs in industrial settings. It can be widely used for barley raw material inspection upon arrival at the factory, purity screening in storage, and quality control of brewing raw materials. Furthermore, it can be extended to fine-grained identification scenarios for agricultural products such as wheat, rice, and corn.
[0039] Example 2: This embodiment provides a barley variety identification method based on color prior and adaptive hue enhancement. Building upon Embodiment 1, step 4, which enhances the Hue feature map, is replaced with: The responses of Hue pixels relative to multiple color prior centers are calculated separately, and the multiple responses are aggregated to obtain the final enhanced Hue feature map:
[0040] in, express The Hue pixel at position relative to the first k Color Priority Center Enhanced response, This represents the enhanced Hue feature map after aggregation. K This indicates the number of color prior centers.
[0041] This embodiment employs a multi-color prior center parallel computation and response aggregation enhancement approach to further strengthen the extraction capability of subtle color differences among highly similar barley varieties. Compared to enhancement using only the nearest single center, this scheme comprehensively covers the color features of multiple regions and levels of barley seeds by calculating the response of each Hue pixel to all color prior centers and aggregating the mean values, thus avoiding omissions of key discrimination color domains. This method can more evenly and stably amplify the tonal differences in multiple key regions such as the seed coat, ventral groove, embryo, and seed coat edge, making color enhancement more comprehensive and robust, and effectively suppressing fluctuations caused by uneven light, reflection, and maturity. Through multi-center collaborative enhancement, weak color features are more fully preserved and highlighted, significantly reducing the misclassification rate of easily confused varieties and further improving the model's recognition accuracy and classification reliability.
[0042] Example 3: This embodiment provides a barley variety identification method based on color prior and adaptive hue enhancement. Building upon any of the above embodiments, it employs an improved EfficientNet-B4 network as the backbone to extract the four-channel fusion features, while retaining the convolutional weights corresponding to the RGB channels in the original pre-trained model. , , And add the convolution weights corresponding to the new Hue channel. Initialize as the mean of the RGB three-channel weights:
[0043] in, This represents the convolution weights of the newly added Hue channel.
[0044] This embodiment uses EfficientNet... The B4 backbone network undergoes a four-channel modification, initializing the convolutional weights of the newly added Hue channel to the average of the RGB three-channel weights. This approach fully inherits the mature texture, contour, and structural feature extraction capabilities of the pre-trained model on RGB images while stably adapting to the four-channel input fused with RGB and enhanced Hue. This avoids model instability, convergence difficulties, or feature extraction failures caused by the addition of a new channel. This initialization method allows the network to simultaneously learn RGB texture information and enhanced color discrimination information in the early stages of training, effectively preserving and transmitting weak color difference features in shallow layers, preventing them from being weakened during network downsampling. Compared to direct random initialization or training from scratch, this solution significantly improves model convergence speed and feature extraction efficiency, further enhancing the perception and differentiation of subtle color differences in highly similar barley varieties, and significantly improving recognition accuracy and model stability.
[0045] Example 4: This embodiment provides a barley variety identification method based on color prior and adaptive hue enhancement, such as... Figure 1 As shown, it includes the following steps.
[0046] Step 1: Acquire RGB images of the barley seeds to be identified and perform preprocessing.
[0047] The image acquisition device can be a smartphone camera, an industrial camera, an area scan camera, or other visible light imaging devices. Preferably, a single barley seed is placed on a black or low-reflection background, and the distance between the camera and the seed is fixed to reduce background interference and scale variations.
[0048] The acquired images undergo preprocessing, specifically including: (1) Remove redundant background areas and retain the main body of the barley seed; (2) Adjust the images to the preset size; (3) Normalize the image pixel values; (4) Convert the RGB image to the HSV color space and extract the Hue channel.
[0049] In this embodiment, the input image is adjusted to 380×380 pixels to match the input resolution of the EfficientNet-B4 backbone network. The normalization formula is as follows:
[0050] in, Represents the pixel values of the input image. This represents the average pixel value of the training set images. This represents the standard deviation of pixels in the training set images. This represents the normalized image.
[0051] Step 2: Convert the RGB image to the HSV color space, and then extract the Hue channel as the color enhancement object.
[0052] The main discriminative differences between highly similar barley varieties often manifest in subtle tonal variations in the seed coat, ventral groove, embryo, and marginal areas, while RGB images are easily affected by brightness variations. The Hue channel can separate tonal information from brightness information to some extent, making it more suitable for describing subtle color differences in barley seeds.
[0053] The extracted Hue channel can be represented as:
[0054] in, This represents the original Hue channel image. In this embodiment, the Hue channel size is:
[0055] To facilitate subsequent calculations, Hue pixel values can be normalized to a fixed range.
[0056] Step 3: Cluster the pixels in the Hue channel to obtain the set of color prior centers.
[0057] The Hue pixel set is represented as:
[0058] in, Indicates the first i Hue pixel value, This represents the total number of Hue pixels in the training set.
[0059] The K-means clustering method was used to cluster the Hue pixel set to obtain the color prior center set:
[0060] in, Indicates the first k A color prior center, K This indicates the number of color prior centers.
[0061] K-means clustering optimizes by minimizing the within-cluster squared error, and its objective function is as follows:
[0062] in, Indicates being assigned to the first K The set of Hue pixels at each cluster center This represents the Euclidean distance between Hue pixels and their corresponding cluster centers.
[0063] In this embodiment, to reduce computational costs, a subset of pixels can be sampled from the training set of Hue pixels for clustering, while maintaining the dominant Hue distribution unchanged. (Number of color prior centers) K This can be determined according to the elbow rule. Preferably, when K When the cluster size is 6, the decreasing trend of the intra-cluster squared error slows down significantly, and further increasing the number of cluster centers results in limited error reduction. Therefore, this embodiment selects... K =6 is used as the number of color prior centers.
[0064] The obtained color prior centers correspond to the main color regions in the barley seed image, including dark brown lesion areas, light yellow normal seed coat areas, grayish-white ventral groove areas, golden yellow embryo areas, light brown seed coat edge areas, and black background areas. These color prior centers serve as color anchor points for the subsequent target color stretching module, guiding the Hue branch to enhance color regions with discriminative significance.
[0065] Step 4: Based on the relative relationship between Hue pixels and the color prior center, enhance the color areas close to the prior center to amplify the subtle but discriminative tonal differences between highly similar barley varieties.
[0066] For any pixel in the Hue channel The relative difference between the pixel and the color prior center is calculated. In this embodiment, the color prior center closest to the pixel is selected. The relative difference is defined as follows:
[0067] The enhanced response definition for the target color stretching module is as follows:
[0068] in, Indicates position The enhanced response of the Hue pixel relative to the color prior center. This represents the Sigmoid activation function. This represents the gain coefficient, used to control nonlinear tensile strength.
[0069] The Sigmoid function is defined as follows:
[0070] To fully utilize multiple color prior centers, the responses of Hue pixels relative to each color prior center can be calculated separately, and these responses can be aggregated to obtain the final enhanced Hue feature map.
[0071] in, Indicates the Hue pixel relative to the 1st pixel. k Enhanced response of a color prior center This represents the enhanced Hue feature map after aggregation.
[0072] Gain coefficient The choice can be made based on the performance of the dataset. Preferably, The value range is 5 to 30. This embodiment sets... This is to enhance key color gamut differences while avoiding oversaturation in the response.
[0073] Step 5: Concatenate the enhanced Hue feature map from Step 4 with the original RGB image along the channel dimension to form a four-channel fused input:
[0074] in, This indicates a channel splicing operation. This represents the fused input tensor.
[0075] The fusion input size in this embodiment is:
[0076] Unlike later feature fusion methods, this embodiment uses input-level fusion, which allows the network to simultaneously receive RGB texture structure information and color prior enhancement information in the earliest feature extraction stage, thereby avoiding the premature weakening of weak color differences during the downsampling process of deep networks.
[0077] Step 6: Use a deep convolutional classification network to extract the four-channel fusion features and obtain the classification results.
[0078] This embodiment uses EfficientNet-B4 as the backbone network to achieve a good balance between recognition accuracy and computational complexity.
[0079] Since the first convolutional layer of the original EfficientNet-B4 is typically adapted to three-channel RGB input, while the fused input in this embodiment is four-channel, the first convolutional layer needs to be modified. Specifically, the convolutional weights corresponding to the three RGB channels in the original pre-trained model are retained. , , And add the convolution weights corresponding to the new Hue channel. Initialize as the mean of the RGB three-channel weights:
[0080] in, This represents the convolution weights for the newly added Hue channel. This initialization method preserves the original RGB texture representation capabilities of the pre-trained model while enabling the network to stably adapt to RGB-Hue four-channel fused input.
[0081] After feature extraction via a four-channel backbone network, a deep feature map with 1792 channels is obtained. Subsequently, this feature map is processed by a global average pooling layer to obtain a 1792-dimensional feature vector, which is then passed through a Dropout layer and a fully connected classification layer to output the probability distribution of barley samples belonging to various variety categories.
[0082] This embodiment models barley variety identification as a multi-classification task. If the identification task includes 10 barley varieties, the classification output layer outputs a 10-dimensional probability distribution.
[0083] The model uses the cross-entropy loss function for supervised training, and its expression is as follows:
[0084] in, Indicates the first The true label indicator value for each category, This indicates that the model predicts the sample belongs to the first... The probability of each category.
[0085] After training, the barley seed image to be identified is input into the model, and it goes through image preprocessing, Hue channel extraction, color prior enhancement, RGB-Hue input-level fusion, deep feature extraction and classification output in sequence to obtain the final barley variety identification result.
[0086] To verify the technical effectiveness of the barley variety identification method in this embodiment, an experiment was conducted, and the experimental process is as follows.
[0087] 1. Experimental Environment and Main Instruments The algorithm implementation in this embodiment is based on the PyTorch deep learning framework. To ensure the efficiency of model training and inference, the experiment was conducted on a high-performance computing workstation.
[0088] Main hardware instruments: Graphics Processing Unit (GPU): It uses two NVIDIA GeForce RTX 5080 graphics cards, each with 16GB of video memory.
[0089] Central Processing Unit (CPU): Intel Core i9-13900K processor.
[0090] Memory: 64GB DDR5 memory with a frequency of 5600MHz.
[0091] Storage device: 2TB NVMe SSD.
[0092] Image acquisition device: The iQOO13 smartphone is equipped with a 50MP CMOS sensor.
[0093] Shooting aids: A fixed bracket is used to maintain a stable shooting height, which is set to 15cm.
[0094] Shooting background: Use a pure black light-absorbing background to reduce background reflection and environmental interference.
[0095] Software environment: Operating system: Linux 6.8.0.
[0096] Programming language: Python.
[0097] Deep learning framework: PyTorch 2.8.0.
[0098] Parallel computing library: CUDA 12.8.
[0099] Data processing tools: NumPy 2.3.4, OpenCV 4.12.0.
[0100] Performance evaluation tool: Scikit-learn 1.7.2.
[0101] Visualization tool: Matplotlib 3.10.6.
[0102] 2. Dataset Preparation and Filtering Methods This embodiment uses a self-built barley seed image dataset for experimental verification.
[0103] Barley varieties: Ten barley varieties were selected in this example, including Supi 3, Supi 8, Supi 9, Supi 12, Supi 13, Supi 14, Salt 12133, Salt Barley 6, Salt Barley 7, and Yangnong Beer 7.
[0104] Sample selection: Approximately 300 whole barley seeds of each variety were randomly selected, and severely damaged, deformed or severely damaged seeds were removed.
[0105] Image acquisition method: Barley seeds were placed on a pure black light-absorbing background, and visible light images were acquired using a smartphone. The acquired images include top-view and side-view images.
[0106] Dataset size: This embodiment obtained a total of 14,810 images of single barley seeds, including 11,969 top-view images and 2,841 side-view images.
[0107] Data partitioning: The dataset was divided into training, validation, and test sets in a 70%:15%:15% ratio. The training set contains 10,361 images, the validation set contains 2,218 images, and the test set contains 2,231 images.
[0108] Image preprocessing: All images undergo background cropping, size unification, and normalization. Input images are uniformly adjusted to 380×380 pixels.
[0109] Color prior construction: The training set images are converted to the HSV color space, the Hue channels are extracted, and color prior centers are constructed using the K-means clustering method. In this embodiment, the number of color prior centers is set to 6.
[0110] 3. Training hyperparameter settings Input image size: uniformly adjusted to 380×380 pixels.
[0111] Input channels: 4-channel input using RGB image and enhanced Hue channel fusion.
[0112] Backbone network: The improved EfficientNet-B4 network is adopted.
[0113] Number of categories: Set to 10.
[0114] Training epochs: Set to 100 epochs.
[0115] Batch size: Set to 16.
[0116] Loss function: Cross-entropy loss function is used.
[0117] Optimizer: A stochastic gradient descent optimizer with momentum is used.
[0118] Initial learning rate: set to 0.01.
[0119] Momentum coefficient: set to 0.9.
[0120] Weight decay coefficient: set to .
[0121] Learning rate adjustment strategy: A cosine learning rate decay strategy is adopted.
[0122] Target color stretching module parameters: gain coefficient Set to 20.
[0123] Model saving strategy: During training, the best model is saved based on the performance on the validation set, and the best model is used for evaluation on the test set.
[0124] 4. Experimental Results and Verification This embodiment uses accuracy, precision, recall, F1 score, and confusion matrix as evaluation metrics. For multi-class recognition tasks, precision, recall, and F1 score are calculated using a macro-average method.
[0125] (1) Test results on a self-built barley seed image dataset: Experimental results show that the method in this embodiment achieved good recognition performance on the task of identifying 10 types of barley varieties. The overall classification accuracy reached 98.25%, the macro average recall reached 98.24%, and the macro average F1 score reached 98.24%.
[0126] Compared with the baseline model EfficientNet-B4, which has an overall accuracy of 97.27%, the accuracy of the method in this invention is improved by 0.98 percentage points.
[0127] (2) Validation results on highly similar and difficult-to-distinguish varieties: like Figure 4 As shown, for the most easily confused pair of varieties, Yangnongpi 7 and Yanmai 7, the baseline model EfficientNet-B4 had 14 misclassifications. The method in this embodiment (AHE-Net) reduced this number of misclassifications to 2, a reduction of 85.7%.
[0128] (3) Ablation test results: Experimental results show that when only the RGB image is linearly fused with the original Hue channel, the model accuracy reaches 97.67%, and the number of misclassifications of difficult-to-distinguish variety pairs is reduced from 14 to 4.
[0129] After further incorporating the target color stretching module, the accuracy of the method of this invention reached 98.25%, and the number of misclassifications of difficult-to-distinguish variety pairs was further reduced to 2. This result indicates that both the introduction of the Hue channel and the enhancement of target color stretching can improve recognition performance, with the target color stretching module further enhancing the subtle color differences between highly similar barley varieties.
[0130] (4) Comparison results with other models: like Figure 5As shown, under the same dataset and experimental conditions, the method in this embodiment (AHE-Net) outperforms the comparative models such as ResNet-50, DenseNet-121, ResNeXt-50, MobileNetV3-Large, MobileNetV4-Medium, MambaOut-Kobe, and EfficientNet-B4. Specifically, the accuracy of this embodiment reaches 98.25%, which is the best performance among all the comparative models.
[0131] The above experimental results demonstrate that this embodiment can achieve low-cost, non-destructive identification of highly similar barley varieties based on ordinary RGB images, and can effectively reduce the number of misclassifications between difficult-to-distinguish varieties. It is suitable for application scenarios such as barley raw material inspection upon arrival at the factory, variety purity screening, and quality control of beer brewing raw materials.
[0132] Example 5: This embodiment provides a barley variety identification system, the system being configured to implement the barley variety identification method as described in any of the preceding embodiments, including: The image preprocessing module is configured to acquire and preprocess RGB images of the barley seeds to be identified. The Hue channel extraction module is configured to convert the RGB image to the HSV color space and then extract the Hue channel pixels. The color prior mining module is configured to cluster the Hue channel pixels to obtain a set of color prior centers; The target color stretching module is configured to enhance color regions close to the prior center based on the relative relationship between Hue pixels and the color prior center, including: For any pixel in the Hue channel Calculate the relative difference between the pixel and the nearest color prior center, and enhance the Hue feature map based on the relative difference. The enhanced Hue feature map is represented as follows:
[0133] in, This indicates the relative difference. Indicates the gain coefficient. This represents the Sigmoid activation function; The input-level fusion module is configured to concatenate the enhanced Hue feature map with the original RGB image along the channel dimension to form a four-channel fusion feature. The four-channel depth feature extraction module is configured to use a deep convolutional class network to extract the four-channel fused features; The classification output module is configured to classify and output the classification results.
[0134] This embodiment, through modular design, organically integrates image preprocessing, Hue channel extraction, color prior mining, target color stretching, input-level fusion, four-channel feature extraction, and classification output, achieving complete automated recognition across the entire process. It boasts stable operation, clear logic, and ease of deployment and maintenance. The system can separate hue and brightness information, resisting interference from lighting, reflection, and uneven maturity. It accurately locates and adaptively enhances the key discriminative color gamut of barley seeds, fully fusing texture and color information in the early stages of feature extraction, significantly improving the ability to distinguish highly similar varieties. Compared to traditional detection systems, this system requires no complex equipment or sample preprocessing, maintaining its advantages of being non-destructive, fast, and low-cost. It can be directly applied to large-scale raw material screening scenarios in industrial settings, significantly reducing misclassification rates and improving recognition accuracy. Furthermore, it possesses excellent scalability, easily adaptable to fine-grained recognition tasks for other agricultural products such as wheat and rice, making it more practical and versatile.
[0135] Some steps in the embodiments of the present invention can be implemented using software, and the corresponding software program can be stored in a readable storage medium, such as an optical disc or a hard disk.
[0136] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for identifying barley varieties, characterized in that, The method includes: Step 1: Acquire RGB images of the barley seeds to be identified and perform preprocessing; Step 2: Convert the RGB image to the HSV color space, and then extract the Hue channel pixels; Step 3: Cluster the Hue channel pixels to obtain a set of color prior centers; Step 4: Based on the relative relationship between Hue pixels and the color prior center, enhance the color regions close to the prior center, including: For any pixel in the Hue channel Calculate the relative difference between the pixel and the nearest color prior center, and enhance the Hue feature map based on the relative difference. The enhanced Hue feature map is represented as follows: in, This indicates the relative difference. Indicates the gain coefficient. This represents the Sigmoid activation function; Step 5: Concatenate the enhanced Hue feature map with the original RGB image along the channel dimension to form a four-channel fused feature; Step 6: Use a deep convolutional classification network to extract the four-channel fusion features and obtain the classification results.
2. The barley variety identification method according to claim 1, characterized in that, The process of enhancing the Hue feature map in step 4 is replaced by: The responses of Hue pixels relative to multiple color prior centers are calculated separately, and the multiple responses are aggregated to obtain the final enhanced Hue feature map: in, express The Hue pixel at position relative to the first k Color Priority Center Enhanced response, This represents the enhanced Hue feature map after aggregation. K This indicates the number of color prior centers.
3. The barley variety identification method according to claim 1, characterized in that, Step 6 uses an improved EfficientNet-B4 network as the backbone to extract the four-channel fused features, while retaining the convolution weights corresponding to the RGB channels in the original pre-trained model. , , And add the convolution weights corresponding to the new Hue channel. Initialize as the mean of the RGB three-channel weights: in, This represents the convolution weights of the newly added Hue channel.
4. The barley variety identification method according to claim 1, characterized in that, The number of color prior centers K =6.
5. The barley variety identification method according to any one of claims 1 or 2, characterized in that, The gain coefficient .
6. The barley variety identification method according to claim 1, characterized in that, The barley variety identification model was trained using the cross-entropy loss function.
7. The barley variety identification method according to claim 1, characterized in that, Step 3 uses the K-means clustering method to cluster the Hue pixel set, and optimizes it by minimizing the intra-cluster squared error. The objective function is as follows: in, Indicates being assigned to the first k The set of Hue pixels at each cluster center This represents the Euclidean distance between Hue pixels and their corresponding cluster centers.
8. A barley variety identification system, characterized in that, The system is configured to implement the barley variety identification method as described in any one of claims 1-7, comprising: The image preprocessing module is configured to acquire and preprocess RGB images of the barley seeds to be identified. The Hue channel extraction module is configured to convert the RGB image to the HSV color space and then extract the Hue channel pixels. The color prior mining module is configured to cluster the Hue channel pixels to obtain a set of color prior centers; The target color stretching module is configured to enhance color regions close to the prior center based on the relative relationship between Hue pixels and the color prior center, including: For any pixel in the Hue channel Calculate the relative difference between the pixel and the nearest color prior center, and enhance the Hue feature map based on the relative difference. The enhanced Hue feature map is represented as follows: in, This indicates the relative difference. Indicates the gain coefficient. This represents the Sigmoid activation function; The input-level fusion module is configured to concatenate the enhanced Hue feature map with the original RGB image along the channel dimension to form a four-channel fusion feature. The four-channel depth feature extraction module is configured to use a deep convolutional class network to extract the four-channel fused features; The classification output module is configured to classify and output the classification results.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it performs the barley variety identification step as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the steps of the barley variety identification method as described in any one of claims 1 to 7.