An image recognition-based quality detection method and system for tortoise shell glue
By combining multi-branch parallel feature perception networks and graph neural networks, the problems of subjectivity, low efficiency, and low accuracy in the quality inspection of tortoise shell glue are solved, realizing automated, standardized, and intelligent inspection of tortoise shell glue quality, and improving inspection accuracy and consistency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2026-03-31
AI Technical Summary
Existing methods for testing the quality of tortoise shell glue suffer from problems such as high subjectivity, low efficiency, high cost, low accuracy, and lack of specialized network design, making it difficult to achieve automated, standardized, and intelligent testing of tortoise shell glue quality.
An image recognition-based approach is adopted, which uses a multi-branch parallel feature perception network and a graph neural network for feature extraction and fusion, including deep feature extraction of light transmission uniformity, color purity and internal micro-defects. The iterative inference and attention mechanism of the graph neural network are used to adaptively fuse the interrelationships between different features to generate a comprehensive feature representation.
It significantly improves the accuracy and efficiency of tortoise shell glue quality testing, realizes automated, standardized and intelligent testing of tortoise shell glue quality, improves testing accuracy and consistency, and avoids the subjectivity and limitations of traditional methods.
Smart Images

Figure CN120976170B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of tortoise shell glue quality testing, and in particular to a tortoise shell glue quality testing method and system based on image recognition. Background Technology
[0002] Tortoise shell glue, a precious traditional Chinese medicine, possesses important functions such as nourishing yin and suppressing yang, tonifying the kidneys and strengthening bones, and nourishing blood and stopping bleeding, occupying an important position in clinical applications of traditional Chinese medicine. With the rapid development of the traditional Chinese medicine industry and the continuous growth of market demand, the quality testing of tortoise shell glue has become a crucial link in ensuring the quality of medicinal materials and protecting consumer rights. The quality of tortoise shell glue directly affects its medicinal value and clinical efficacy; therefore, establishing scientific, accurate, and efficient quality testing methods is of great significance to the healthy development of the traditional Chinese medicine industry.
[0003] Traditional quality inspection of tortoise shell glue relies primarily on experienced traditional Chinese medicine practitioners who judge its quality by visual inspection. Inspectors need to comprehensively evaluate multiple aspects, including appearance, color, transparency, texture, hardness, and cross-sectional characteristics. This traditional method has several problems and limitations. First, it is highly subjective; different inspectors, due to differences in experience, cognition, and subjective judgment standards, often give different quality evaluations for the same sample, leading to a lack of consistency and repeatability. Second, it is inefficient; manual inspection requires significant time and manpower, making it difficult to meet the needs of rapid testing of large batches of samples, thus hindering the large-scale and industrialized development of the inspection work. In recent years, some researchers have attempted to use spectral analysis and chemical composition detection methods to evaluate the quality of tortoise shell glue. However, these methods typically require complex sample pretreatment processes, are costly, and primarily focus on chemical content, failing to comprehensively reflect the appearance quality characteristics of tortoise shell glue. While image processing-based inspection methods have improved objectivity to some extent, existing methods mostly employ simple image feature extraction techniques, such as color histograms and texture features—manually designed features. These features have limited expressive power and cannot accurately capture the complex quality characteristics of tortoise shell glue.
[0004] Existing image recognition methods for detecting the quality of tortoise shell glue suffer from limitations in feature fusion, often employing simplistic feature splicing or weighted fusion strategies. These methods fail to effectively model the complex relationships between different quality features, resulting in low detection accuracy. Furthermore, existing methods lack specialized network designs for specific quality indicators of tortoise shell glue, hindering the full utilization of deep learning technologies for precise quality analysis. Therefore, there is an urgent need to develop a tortoise shell glue quality detection method based on advanced image recognition technology to address the shortcomings of traditional methods and achieve automated, standardized, and intelligent detection of tortoise shell glue quality. Summary of the Invention
[0005] In view of this, the present invention provides a quality inspection method for tortoise shell glue based on image recognition, aiming to automate, standardize and accurately detect key quality indicators such as light transmittance uniformity, color purity and internal micro-defects of tortoise shell glue, and provide an objective and reliable technical means for the quality evaluation of tortoise shell glue.
[0006] To achieve the above objectives, the present invention provides a method for quality detection of tortoise shell glue based on image recognition, comprising the following steps:
[0007] A1: Obtain the tortoise shell glue sample to be tested, place the tortoise shell glue sample in a standardized image acquisition device for transmission imaging and preprocessing, and obtain a standardized tortoise shell glue transmission image.
[0008] A2: Perform image segmentation and size normalization on the standardized tortoise shell glue transmission image to obtain a standardized target region image;
[0009] A3: Input the standardized target area image into a multi-branch parallel feature perception network for feature extraction to obtain three depth feature vectors: light transmission uniformity, color purity, and internal micro-defects;
[0010] A4: The three deep feature vectors of light transmission uniformity, color purity, and internal micro-defects are constructed into a feature map. The relationships between different features are adaptively fused through iterative reasoning and attention mechanism of graph neural network, and end-to-end training and optimization are performed to generate a comprehensive feature representation for the quality detection of tortoise shell glue.
[0011] As a further improvement of the present invention:
[0012] Optionally, in step A1, the tortoise shell glue sample to be tested is obtained, and the tortoise shell glue sample is placed in a standardized image acquisition device for transmission imaging and preprocessing to obtain a standardized tortoise shell glue transmission image, including:
[0013] A11: Prepare a standardized image acquisition device; the standardized image acquisition device includes a backlight source, a sample stage, and a high-resolution digital camera;
[0014] A12: Under constant illumination conditions and fixed shooting parameters, control the high-resolution digital camera to perform transmission imaging on the tortoise shell glue sample to obtain the original transmission image. ;
[0015] A13: Regarding the original transmission image Preprocessing was performed, including noise reduction, brightness normalization, and color correction, to obtain a standardized tortoise shell resin transmission image. ;
[0016] The denoising process employs a Gaussian filter. When the tortoise shell glue sample has different thickness distributions, a thickness-aware adaptive filter is used for denoising. The filter parameters are dynamically adjusted based on the local transmission intensity gradient. These filter parameters are the standard deviation of the Gaussian filter, specifically:
[0017] ;
[0018] in, For thickness-aware adaptive filters at pixel positions The standard deviation at that point; Based on the basic filter parameters, For thickness sensitivity coefficient, Standardized transmission images of tortoise shell glue At pixel position The light intensity gradient vector at that location, Represents the 2-norm;
[0019] The brightness normalization process adjusts the average brightness value of the image to a preset target brightness value; the color correction process performs white balance correction based on a standard color reference chart.
[0020] Optionally, step A2 involves image segmentation and size normalization of the standardized tortoise shell glue transmission image to obtain a standardized target region image, including:
[0021] The standardized transmission image of the tortoise shell glue A grayscale image is obtained by performing grayscale conversion, wherein the grayscale conversion adopts a weighted average method;
[0022] The grayscale image is subjected to adaptive threshold segmentation processing. The adaptive threshold is calculated based on the local statistical characteristics of the image. The adaptive threshold is determined according to the average grayscale value and the grayscale standard deviation of the image.
[0023] The grayscale image is binarized based on the adaptive threshold to obtain a binary image. Pixels with grayscale values greater than or equal to the adaptive threshold are set to white, and pixels with grayscale values less than the adaptive threshold are set to black.
[0024] The binary image is subjected to morphological processing, including opening and closing operations, to eliminate noise points and fill holes; the opening operation uses a circular structuring element to remove small noisy connected regions; the closing operation uses a circular structuring element to fill small holes inside the tortoise shell glue body.
[0025] Connectivity analysis is performed on the morphologically processed binary image to identify all connected regions and calculate the area of each connected region.
[0026] Select the largest connected region as the main region of the tortoise shell glue, and determine the bounding rectangle of this region.
[0027] Based on the circumscribed rectangular bounding box, the standardized tortoise shell glue transmission image The target region image is obtained by cropping. ;
[0028] For the target region image The image is then scaled to a preset standard size to obtain a standardized target region image. .
[0029] Optionally, in step A3, the standardized target region is input into a multi-branch parallel feature perception network for feature extraction, including:
[0030] Standardize the target region image The input is fed into a multi-branch parallel feature perception network, which includes three independent branch structures: a light transmission uniformity feature extraction branch, a color purity feature extraction branch, and an internal microscopic defect feature extraction branch.
[0031] Transmittance uniformity feature extraction branch The calculation process for the feature map of a layer is as follows:
[0032] ;
[0033] in, The first branch representing the feature extraction of light transmission uniformity Feature map of the layer , The first branch representing the feature extraction of light transmission uniformity The convolution kernel weight matrix of the layer, This represents the convolution operation. The first branch representing the feature extraction of light transmission uniformity Layer bias vector, Represents the sigmoid activation function;
[0034] Color purity feature extraction branch The calculation process for the feature map of a layer is as follows:
[0035] ;
[0036] in, The first branch representing the feature extraction of color purity Feature map of the layer , The first branch representing the feature extraction of color purity The convolution kernel weight matrix of the layer, The first branch representing the feature extraction of color purity Layer bias vector;
[0037] Internal micro-defect feature extraction branch The calculation process for the feature map of a layer is as follows:
[0038] ;
[0039] in, The branch representing the extraction of internal micro-defect features Feature map of the layer , The branch representing the extraction of internal micro-defect features The convolution kernel weight matrix of the layer, The branch representing the extraction of internal micro-defect features Layer bias vector;
[0040] Global average pooling is used to reduce the dimensionality of the feature maps in the last layer of each of the three branches, resulting in the corresponding deep feature vectors. , and ;in, This represents the depth feature vector representing the uniformity of light transmission. This represents the depth feature vector representing color purity. This represents the depth feature vector of internal micro-defects.
[0041] The A3 step employs three independent branches to extract features for light transmission uniformity, color purity, and internal micro-defects, respectively. This avoids the problem of mutual interference between different features in traditional single network structures, ensuring that each branch can focus on feature learning for a specific quality dimension.
[0042] The parallel processing architecture of the A3 step can extract feature information from multiple dimensions simultaneously, significantly improving computational efficiency and shortening detection time compared to serial processing. Each branch adopts a deep convolutional neural network structure, which can extract richer and more abstract high-level feature representations from the original image through layer-by-layer feature abstraction. These deep features have stronger expressive power and generalization performance compared to traditional hand-designed features.
[0043] In step A3, each branch uses the same activation function and network depth design, ensuring that different feature vectors have the same dimension and numerical range, providing a good foundation for subsequent feature fusion. Global average pooling is used to reduce the dimensionality of the final feature map, which not only significantly reduces the number of parameters but also effectively suppresses overfitting and improves the model's generalization ability.
[0044] Optionally, in step A4, the three deep feature vectors of light transmission uniformity, color purity, and internal microscopic defects are constructed into a feature map. The relationships between different features are adaptively fused through iterative inference and attention mechanisms of a graph neural network, and end-to-end training and optimization are performed to generate a comprehensive feature representation for the quality detection of tortoise shell glue, including:
[0045] A41: The light transmittance uniformity depth feature vector Color purity depth feature vector and the depth feature vector of internal micro-defects Construct as a feature map The feature map From the set of nodes Sum of edges The graph is composed of a depth feature vector, where each depth feature vector is a node in the graph.
[0046] Constructing the adjacency matrix of the feature map The adjacency matrix Adjacency matrix is used to represent the association strength between different feature nodes. The initialization formula is:
[0047] ;
[0048] in, Represents a node and nodes Edge weights between them , and Representing nodes respectively and nodes The corresponding feature vector, Represents the L2 norm. Hyperparameters for controlling the distribution of adjacency weights;
[0049] When the condition number of the adjacency matrix is too large, a regularized stable algorithm is used to iteratively update the adjacency matrix:
[0050] ;
[0051] in, For global regularization parameters, It is the identity matrix. Here are the diagonal regularization parameters. Indicates extraction of adjacency matrix The regularization strength of the diagonal matrix, consisting of the main diagonal elements, is adaptively determined by the condition number:
[0052] ;
[0053] in, This is a maximum value function used to select the maximum value from the input values; for the adjacency matrix... Perform symmetric normalization to obtain the normalized adjacency matrix. ;
[0054] A42: Iterative inference and fusion of feature maps using graph neural networks:
[0055] A421: The first... of graph neural networks Layer unaggregated node feature matrix The calculation method is as follows:
[0056] ;
[0057] in, Indicates the first The node feature matrix of the layer Represents the initial node feature matrix. Indicates the first The learnable weight matrix of the layer, Indicates the first Layer bias vector;
[0058] A422: Introduces a feature relationship attention mechanism to calculate the dynamic relationship weights between different feature nodes. :
[0059] ;
[0060] in, Indicates the first Layer nodes For nodes Attention weights This is a learnable attention parameter vector. For matrix transpose, Indicates the first The linear transformation matrix of the layer, and They represent the first Nodes in the feature matrix of unaggregated nodes in the layer and nodes eigenvectors, This indicates a feature concatenation operation. For normalized exponential functions, It is a linear rectified activation function with leakage;
[0061] A423: Adaptive aggregation based on dynamic relation weights yields the... In the layer node feature matrix The feature vector of each node, the adaptive aggregation specifically is as follows:
[0062] ;
[0063] in, Represents a node In the Layer node feature matrix The feature vector in Represents a node The set of neighboring nodes, The range of values and Same but , Indicates the first The self-connection weight matrix of the layer; Indicates the first Layer nodes For nodes Attention weights Indicates the first Nodes in the feature matrix of unaggregated nodes in the layer eigenvectors;
[0064] right Repeat process A421 to A423 Next, the feature evolution sequence is obtained. ,go through After iterative inference in the layered graph neural network, a global pooling operation is performed on the feature matrix of the last layer's nodes to obtain a comprehensive feature representation. :
[0065] ;
[0066] in, This indicates a global pooling operation. These represent mean pooling, max pooling, and standard deviation pooling operations, respectively. This represents the feature matrix of the nodes in the last layer. Indicates feature concatenation operation;
[0067] A43: The graph neural network is trained end-to-end using samples of tortoise shell glue with quality labels. The training loss function is defined as cross-entropy loss. The network parameters are updated using the Adam optimizer to obtain the trained graph neural network. The standardized target region image of the tortoise shell glue sample to be detected is input into the multi-branch parallel feature perception network and the trained graph neural network to obtain a comprehensive feature representation. Based on the comprehensive feature representation, quality classification prediction is performed, and the quality grade and confidence score of the tortoise shell glue sample are output.
[0068] Step A4 constructs a graph structure from three depth feature vectors: light transmission uniformity, color purity, and internal micro-defects. This fully explores and utilizes the intrinsic correlation between different quality features, breaking through the limitations of simply splicing features in traditional methods and achieving more intelligent feature fusion.
[0069] Step A4 employs a message-passing mechanism from a graph neural network. Through a multi-layered iterative inference process, each feature node can perceive information from other nodes, achieving mutual enhancement and complementarity among features. This results in a final comprehensive feature representation that better reflects the overall quality of the tortoise shell glue. Compared to traditional feature fusion methods, this step adaptively learns the importance weights between different features, avoiding the subjectivity and limitations of manually designed weight coefficients.
[0070] The attention mechanism introduced in step A4 dynamically calculates the relational weights between different feature nodes, enabling the network to automatically adjust the feature fusion strategy based on the characteristics of specific samples, thus improving the model's flexibility and generalization ability. Through a combination of various pooling operations, this step extracts global features from three dimensions: mean, maximum, and standard deviation, ensuring the richness and completeness of the comprehensive feature representation.
[0071] This invention also discloses an image recognition-based quality inspection system for tortoise shell glue, comprising:
[0072] Imaging module: Acquires the tortoise shell glue sample to be tested, places the tortoise shell glue sample in a standardized image acquisition device for transmission imaging and preprocessing;
[0073] Segmentation and Size Standardization Module: Performs image segmentation and size standardization on the standardized tortoise shell glue transmission image to obtain a standardized target region image;
[0074] Deep feature extraction module: Inputs the standardized target region into a multi-branch parallel feature perception network for feature extraction;
[0075] Graph Neural Network Module: Constructs a feature map from the three deep feature vectors of light transmission uniformity, color purity, and internal micro-defects. Adaptively fuses the interrelationships between different features through iterative inference and attention mechanism of graph neural network, and performs end-to-end training and optimization to generate a comprehensive feature representation for the quality detection of tortoise shell glue.
[0076] Compared with the prior art, the present invention has at least the following beneficial effects:
[0077] This invention achieves specialized feature extraction for different quality dimensions of tortoise shell glue through a multi-branch parallel feature perception network, significantly improving the accuracy and richness of feature representation. Traditional methods often employ a single feature extraction strategy, which struggles to fully capture the complex quality characteristics of tortoise shell glue. This invention, however, designs three independent branches that perform deep learning for light transmittance uniformity, color purity, and internal microscopic defects, respectively. This avoids interference between different features and ensures that each branch can focus on feature learning for a specific quality dimension. The parallel processing architecture not only improves computational efficiency but also extracts more abstract and discriminative high-level features through deep convolutional neural networks, laying a solid foundation for subsequent feature fusion and quality assessment.
[0078] This invention employs graph neural networks to model the complex relationships between different features, achieving intelligent feature relationship reasoning and adaptive fusion. By constructing a graph structure from three deep feature vectors and utilizing the message passing mechanism of the graph neural network for multi-level iterative reasoning, each feature node can perceive and utilize information from other nodes, achieving mutual enhancement and complementarity between features. The introduced attention mechanism can dynamically calculate the relationship weights between different feature nodes and automatically adjust the feature fusion strategy according to the characteristics of specific samples, avoiding the subjectivity of manually designing weight coefficients in traditional methods. This graph-based feature fusion method can better uncover and utilize the intrinsic correlations between different quality features, generating a more accurate and complete comprehensive feature representation. Attached Figure Description
[0079] Figure 1 A flowchart illustrating a method for quality detection of tortoise shell glue based on image recognition provided by the present invention;
[0080] Figure 2 A schematic diagram of the multi-branch parallel feature perception network structure provided by the present invention;
[0081] Figure 3 This is a schematic diagram of t-SNE dimensionality reduction visualization according to an embodiment of the present invention. (a) is the t-SNE dimensionality reduction visualization result of the features extracted by the light transmission uniformity branch in the multi-branch parallel feature perception network, and (b) is the t-SNE dimensionality reduction visualization result of the features extracted by the ResNet-50 network. Detailed Implementation
[0082] The present invention will be further described below with reference to the accompanying drawings, but this is not intended to limit the present invention in any way. Any modifications or substitutions made based on the teachings of the present invention shall fall within the protection scope of the present invention.
[0083] Example 1: A method for quality inspection of tortoise shell glue based on image recognition, such as... Figure 1 As shown, it includes the following steps:
[0084] A1: Obtain the tortoise shell glue sample to be tested, place the tortoise shell glue sample in a standardized image acquisition device for transmission imaging and preprocessing, and obtain a standardized tortoise shell glue transmission image:
[0085] A11: Prepare a standardized image acquisition device; the standardized image acquisition device includes a backlight source, a sample stage, and a high-resolution digital camera;
[0086] A12: Under constant illumination conditions and fixed shooting parameters, control the high-resolution digital camera to perform transmission imaging on the tortoise shell glue sample to obtain the original transmission image. ;
[0087] A13: Regarding the original transmission image Preprocessing was performed, including noise reduction, brightness normalization, and color correction, to obtain a standardized tortoise shell resin transmission image. ;
[0088] The denoising process employs a Gaussian filter. In this embodiment, the filter kernel size is 5×5, and the standard deviation is 1.2. When the tortoise shell glue sample has different thickness distributions, a thickness-aware adaptive filter is used for denoising. Its filtering parameters are dynamically adjusted based on the local transmission intensity gradient. These filtering parameters are the standard deviation of the Gaussian filter, specifically:
[0089] ;
[0090] in, For thickness-aware adaptive filters at pixel positions The standard deviation at that point; Based on the basic filter parameters, For thickness sensitivity coefficient, Standardized transmission images of tortoise shell glue At pixel position The light intensity gradient vector at that location, Represents the 2-norm;
[0091] The brightness normalization process adjusts the average brightness value of the image to a preset target brightness value, which is 140 in this embodiment; the color correction process performs white balance correction based on a standard color reference chart.
[0092] A2: Perform image segmentation and size normalization on the standardized tortoise shell glue transmission image to obtain a standardized target region image:
[0093] The standardized transmission image of the tortoise shell glue A grayscale image is obtained by performing grayscale conversion. The grayscale conversion adopts a weighted average method. In this embodiment, the weights of the red channel, green channel and blue channel are 0.299, 0.587 and 0.114, respectively.
[0094] The grayscale image is subjected to adaptive threshold segmentation. In this embodiment, the Otsu algorithm is used to calculate the adaptive threshold based on the local statistical characteristics of the image. The adaptive threshold is determined according to the average grayscale value and the grayscale standard deviation of the image.
[0095] The grayscale image is binarized based on the adaptive threshold to obtain a binary image. Pixels with grayscale values greater than or equal to the adaptive threshold are set to white, and pixels with grayscale values less than the adaptive threshold are set to black.
[0096] The binary image is subjected to morphological processing, including opening and closing operations, to eliminate noise points and fill holes. The opening operation uses a circular structuring element, and in this embodiment, the radius of the circular structuring element for the opening operation is 3 pixels, which is used to remove small noisy connected regions. The closing operation uses a circular structuring element, and in this embodiment, the radius of the circular structuring element for the closing operation is 5 pixels, which is used to fill small holes inside the tortoise shell glue body.
[0097] Connectivity analysis is performed on the morphologically processed binary image to identify all connected regions and calculate the area of each connected region.
[0098] Select the largest connected region as the main region of the tortoise shell glue, and determine the bounding rectangle of this region.
[0099] Based on the circumscribed rectangular bounding box, the standardized tortoise shell glue transmission image The target region image is obtained by cropping. ;
[0100] For the target region image The image is then scaled to a preset standard size to obtain a standardized target region image. In this embodiment, the standardized size is 224×224.
[0101] A3: Input the standardized target region image into a multi-branch parallel feature perception network for feature extraction, such as... Figure 2 As shown, it includes:
[0102] Standardize the target region image The input is fed into a multi-branch parallel feature perception network, which includes three independent branch structures: a light transmission uniformity feature extraction branch, a color purity feature extraction branch, and an internal microscopic defect feature extraction branch.
[0103] Transmittance uniformity feature extraction branch The calculation process for the feature map of a layer is as follows:
[0104] ;
[0105] in, The first branch representing the feature extraction of light transmission uniformity Feature map of the layer , The first branch representing the feature extraction of light transmission uniformity The convolution kernel weight matrix of the layer, This represents the convolution operation. The first branch representing the feature extraction of light transmission uniformity Layer bias vector, Represents the sigmoid activation function;
[0106] Color purity feature extraction branch The calculation process for the feature map of a layer is as follows:
[0107] ;
[0108] in, The first branch representing the feature extraction of color purity Feature map of the layer , The first branch representing the feature extraction of color purity The convolution kernel weight matrix of the layer, The first branch representing the feature extraction of color purity Layer bias vector;
[0109] Internal micro-defect feature extraction branch The calculation process for the feature map of a layer is as follows:
[0110] ;
[0111] in, The branch representing the extraction of internal micro-defect features Feature map of the layer , The branch representing the extraction of internal micro-defect features The convolution kernel weight matrix of the layer, The branch representing the extraction of internal micro-defect features Layer bias vector;
[0112] Global average pooling is used to reduce the dimensionality of the feature maps of the last layer of each of the three branches, resulting in the corresponding deep feature vectors:
[0113] ;
[0114] in, This represents the depth feature vector representing the uniformity of light transmission. This represents the depth feature vector representing color purity. This represents the depth feature vector of internal micro-defects. These represent the global average pooling operations for the corresponding branches. These represent the feature maps of the last layer of the three branches, respectively, in this embodiment. .
[0115] A4: The three deep feature vectors of light transmission uniformity, color purity, and internal microscopic defects are used to construct a feature map. The relationships between different features are adaptively fused through iterative inference and attention mechanisms of a graph neural network, and end-to-end training and optimization are performed to generate a comprehensive feature representation for the quality detection of tortoise shell glue.
[0116] A41: The light transmittance uniformity depth feature vector Color purity depth feature vector and the depth feature vector of internal micro-defects Construct as a feature map The feature map From the set of nodes Sum of edges The graph is composed of a depth feature vector, where each depth feature vector is a node in the graph.
[0117] Constructing the adjacency matrix of the feature map The adjacency matrix Adjacency matrix is used to represent the association strength between different feature nodes. The initialization formula is:
[0118] ;
[0119] in, Represents a node and nodes Edge weights between them , and Representing nodes respectively and nodes The corresponding feature vector, Represents the L2 norm. To control the hyperparameter of the adjacency weight distribution, it is set to 0.9 in this embodiment;
[0120] When the condition number of the adjacency matrix is too large, a regularized stable algorithm is used to iteratively update the adjacency matrix:
[0121] ;
[0122] in, For global regularization parameters, It is the identity matrix. Here, is the diagonal regularization parameter, which is 0.2 in this embodiment. Indicates extraction of adjacency matrix The regularization strength of the diagonal matrix, consisting of the main diagonal elements, is adaptively determined by the condition number:
[0123] ;
[0124] in, This is a maximum value function used to select the maximum value from the input values;
[0125] For the adjacency matrix Perform symmetric normalization to obtain the normalized adjacency matrix. :
[0126] ;
[0127] in, For degree matrix, Represents a node The degree, Degree matrix The negative second power;
[0128] A42: Iterative inference and fusion of feature maps using graph neural networks:
[0129] A421: The first... of graph neural networks Layer unaggregated node feature matrix The calculation method is as follows:
[0130] ;
[0131] in, Indicates the first The node feature matrix of the layer Represents the initial node feature matrix. Indicates the first The learnable weight matrix of the layer, Indicates the first Layer bias vector;
[0132] A422: Introduces a feature relationship attention mechanism to calculate the dynamic relationship weights between different feature nodes. :
[0133] ;
[0134] in, Indicates the first Layer nodes For nodes Attention weights This is a learnable attention parameter vector. For matrix transpose, Indicates the first The linear transformation matrix of the layer, and They represent the first Nodes in the feature matrix of unaggregated nodes in the layer and nodes eigenvectors, This indicates a feature concatenation operation. For normalized exponential functions, It is a linear rectified activation function with leakage;
[0135] A423: Adaptive aggregation based on dynamic relation weights yields the... In the layer node feature matrix The feature vector of each node, the adaptive aggregation specifically is as follows:
[0136] ;
[0137] in, Represents a node In the Layer node feature matrix The feature vector in Represents a node The set of neighboring nodes, The range of values and Same but , Indicates the first The self-connection weight matrix of the layer; Indicates the first Layer nodes For nodes Attention weights Indicates the first Nodes in the feature matrix of unaggregated nodes in the layer eigenvectors;
[0138] right Repeat process A421 to A423 Next, the feature evolution sequence is obtained. ,go through After iterative inference in the layered graph neural network, a global pooling operation is performed on the feature matrix of the last layer's nodes to obtain a comprehensive feature representation. :
[0139] ;
[0140] in, This indicates a global pooling operation. These represent mean pooling, max pooling, and standard deviation pooling operations, respectively. This represents the final node feature matrix of the last layer, in this embodiment. , Indicates feature concatenation operation;
[0141] A43: The graph neural network is trained end-to-end using tortoise shell glue samples with quality labels. The training loss function is defined as cross-entropy loss. The Adam optimizer is used to update the network parameters, with a learning rate of 0.001, a training epoch count of 200, and a batch size of 32. The standardized target region image of the tortoise shell glue sample to be detected is then input into the trained multi-branch parallel feature perception network and graph neural network to obtain a comprehensive feature representation. Based on this comprehensive feature representation, quality classification prediction is performed, and the quality grade and confidence score of the tortoise shell glue sample are output. During the training phase, the graph neural network is trained end-to-end using tortoise shell glue samples with quality labels, and the training loss function is defined as cross-entropy loss. During the inference phase, the standardized target region image of the tortoise shell glue sample to be detected is input into the trained multi-branch parallel feature perception network and graph neural network to obtain a comprehensive feature representation. Based on this feature representation, quality classification prediction is performed, and the quality grade and confidence score of the tortoise shell glue sample are output.
[0142] This invention used samples of tortoise shell glue from different batches to establish a dataset containing 1200 samples, including 360 superior grade samples, 420 good grade samples, 300 medium grade samples, and 120 inferior grade samples. All samples were manually labeled by traditional Chinese medicine experts as authentic labels for experimental verification.
[0143] The standardized image acquisition device specifically includes an LED backlight source (color temperature 6500K, brightness uniformity >95%), a high-resolution digital camera (2048×1536 pixels), and a precision sample stage. The deep learning network uses the PyTorch 1.9.0 framework.
[0144] The feature extraction capability of multi-branch parallel feature-aware networks was verified through t-SNE dimensionality reduction visualization, compared to Figure 3 (b) shows the features extracted by the ResNet-50 network. Figure 3 (a) shows that the features extracted by the light transmission uniformity branch in the multi-branch parallel feature perception network exhibit more obvious clustering distribution among different quality levels.
[0145] The experimental results compared with existing methods are shown in Table 1:
[0146]
[0147] The method of this invention is significantly superior to the comparison method in all evaluation indicators, with an overall accuracy of 93.6%, which is 5.7 percentage points higher than the best comparison method.
[0148] Example 2: This invention also discloses an image recognition-based tortoise shell glue quality inspection system, comprising the following four modules:
[0149] Imaging module: Acquires the tortoise shell glue sample to be tested, places the tortoise shell glue sample in a standardized image acquisition device for transmission imaging and preprocessing;
[0150] Segmentation and Size Standardization Module: Performs image segmentation and size standardization on the standardized tortoise shell glue transmission image to obtain a standardized target region image;
[0151] Deep feature extraction module: Inputs the standardized target region into a multi-branch parallel feature perception network for feature extraction;
[0152] Quality inspection module: The three deep feature vectors of light transmission uniformity, color purity and internal micro-defects are constructed into a feature map. The relationship between different features is adaptively fused through iterative reasoning and attention mechanism of graph neural network, and end-to-end training and optimization are performed to generate a comprehensive feature representation for the quality inspection of tortoise shell glue.
[0153] It should be noted that the sequence numbers of the above embodiments of the present invention are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0154] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0155] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. An image recognition-based quality detection method for tortoise shell gel, characterized in that, The method comprises the following steps: A1: obtaining a sample to be detected, placing the sample in a standardized image acquisition device for transmission imaging and preprocessing to obtain a standardized tortoise shell transmission image; A2: image segmentation and size standardization of the standardized tortoise shell transmission image to obtain a standardized target area image; A3: inputting the standardized target area image into a multi-branch parallel feature perception network for feature extraction to obtain three depth feature vectors of light transmission uniformity, color purity and internal microscopic flaws; The step A3 comprises: standardized target region image is input to a multi-branch parallel feature perception network, which includes three independent branch structures: a light transmission uniformity feature extraction branch, a color purity feature extraction branch, and an internal microscopic flaw feature extraction branch; The light transmission uniformity feature extraction branch is configured to extract a light transmission uniformity feature of the image of the first layer The calculation process of the feature map of the layer is as follows: ; wherein, represents a light transmission uniformity feature extraction branch layer of the feature map, , represents a light transmission uniformity feature extraction branch a convolution kernel weight matrix of the layer, represents a convolution operation, represents a bias vector of the layer, represents a light transmission uniformity feature extraction branch represents a sigmoid activation function; The color purity feature extraction branch is divided into two parts The calculation process of the feature map of the layer is as follows: ; wherein, represents a convolution kernel weight matrix of the first layer of the color purity feature extraction branch, a feature map of the layer, , represents a convolution kernel weight matrix of the first layer of the color purity feature extraction branch, a bias vector of the first layer of the color purity feature extraction branch, a bias vector of the first layer of the color purity feature extraction branch, a bias vector of the first layer of the color purity feature extraction branch, The internal microscopic flaw feature extraction branch is divided into two parts The calculation process of the feature map of the layer is as follows: ; wherein, represents the first convolutional layer of the internal microscopic flaw feature extraction branch, the feature map of the layer, , represents the first convolutional layer of the internal microscopic flaw feature extraction branch, the convolution kernel weight matrix of the layer, represents the first convolutional layer of the internal microscopic flaw feature extraction branch, the bias vector of the layer. The feature maps of the last layers of the three branches are respectively reduced in dimension by a global average pooling operation to obtain corresponding depth feature vectors , and ; wherein, represents a light transmission uniformity depth feature vector, represents a color purity depth feature vector, represents an internal microscopic flaw depth feature vector; A4: constructing the three depth feature vectors of light transmission uniformity, color purity and internal microscopic flaws into a feature map, adaptively fusing the mutual relationship between different features through iterative reasoning and attention mechanism of the graph neural network, and performing end-to-end training and optimization to generate a comprehensive feature representation for tortoise shell quality detection; The step A4 comprises: A41: three depth feature vectors are constructed as a feature map , an adjacency matrix is constructed representing the association strength between different feature nodes, the adjacency matrix The initialization formula is: ; wherein, denotes the edge weight between nodes and nodes , , and denote the corresponding feature vectors of nodes and nodes , denotes the L2 norm, is a hyperparameter controlling the distribution of adjacency weights; An adjacency matrix Symmetric normalization is performed to obtain a normalized adjacency matrix ; A42: using a graph neural network to iteratively infer and fuse feature maps; introducing a feature relationship attention mechanism to calculate dynamic relationship weights; performing global pooling on the feature maps after layer-by-layer inference to obtain a comprehensive feature representation layer-by-layer inference to obtain a comprehensive feature representation A43: using a tortoise shell sample with a quality label to perform end-to-end training on the graph neural network, defining the training loss function as cross-entropy loss, updating the network parameters using the Adam optimizer, obtaining the trained graph neural network, inputting the standardized target area image of the sample to be detected into the multi-branch parallel feature perception network and the trained graph neural network, obtaining the comprehensive feature representation, and performing quality classification prediction based on the comprehensive feature representation to output the quality grade and confidence score of the tortoise shell sample.
2. The image recognition-based quality detection method of tortoise shell gum according to claim 1, characterized in that, The step A1 comprises: A11: preparing a standardized image acquisition device; the standardized image acquisition device comprises a backlight light source, a sample stage and a high-resolution digital camera; A12: controlling the high-resolution digital camera to perform transmission imaging on the tortoise shell sample under constant illumination conditions and fixed shooting parameters to obtain an original transmission image ; A13: preprocessing the original transmission image The preprocessing includes denoising processing, brightness standardization processing and color correction processing, to obtain a standardized transmission image of tortoise shell ; The denoising processing is performed using a Gaussian filter; the brightness standardization processing adjusts the average brightness value of the image to a preset target brightness value; and the color correction processing performs white balance correction based on a standard color reference board.
3. The image recognition-based quality detection method of tortoise shell according to claim 2, characterized in that, The step A2 comprises: The standardized tortoise shell glue transmission image is converted to grayscale to obtain a grayscale image; the grayscale image is then subjected to adaptive threshold segmentation, with an adaptive threshold calculated based on the local statistical characteristics of the grayscale image; binarization is performed based on the adaptive threshold to obtain a binary image; morphological processing, including opening and closing operations, is performed on the binary image to obtain a morphologically processed image; connected component analysis is performed on the morphologically processed image, and the connected region with the largest area is selected as the main region of the tortoise shell glue; the standardized tortoise shell glue transmission image is then segmented based on the bounding rectangle of the main region of the tortoise shell glue. The target region image is obtained by cropping. and the target area image Scale to a preset standard size to obtain a standardized target area image. .
4. The image recognition-based tortoise shell quality detection method according to claim 1, characterized in that: A421: the first layer of the graph neural network unaggregated node feature matrix The calculation is as follows: ; wherein, represents the i-th layer of nodes, represents the initial matrix of node features, represents the i-th layer of learnable weight matrices, represents the i-th layer of bias vectors; A422: Introduce feature relationship attention mechanism to calculate the dynamic relationship weight between different feature nodes : ; wherein, denotes the layer, node in the layer, is a learnable attention parameter vector, is the matrix transpose, denotes the linear transformation matrix of the and denote the feature vectors of node and node in the unpooled node feature matrix of the denotes the feature concatenation operation, is the normalized exponential function, is the Leaky ReLU activation function with leakage. A423: performing adaptive aggregation based on the dynamic relationship weight to obtain the first layer node feature matrix of each node in the feature vector of the node, and the adaptive aggregation is specifically: ; wherein, denotes a node In the first layer node feature matrix the feature vector in, denotes a node of the neighbor node set of, the value range is the same as but , denotes the self-connection weight matrix of the layer; denotes the attention weight of the node in the first layer to the node , denotes the feature vector of the node in the first layer un-aggregated node feature matrix; To Repeat the processes of A421 to A423 , get the feature evolution sequence , after After the iterative inference of the layer graph neural network, the global pooling operation is performed on the node feature matrix of the last layer to obtain the comprehensive feature representation : ; wherein, represents a global pooling operation, respectively represent mean-pooling, max-pooling and standard deviation pooling operations, represents the node feature matrix of the last layer, represents a feature concatenation operation.
5. An image recognition-based quality detection system for tortoise shell, characterized by, It comprises: An imaging module: obtaining a sample to be detected, placing the sample in a standardized image acquisition device for transmission imaging and preprocessing; A segmentation and size standardization module: image segmentation and size standardization of the standardized tortoise shell transmission image to obtain a standardized target area image; A depth feature extraction module: inputting the standardized target area into a multi-branch parallel feature perception network for feature extraction; A quality detection module: constructing three depth feature vectors of light transmission uniformity, color purity and internal microscopic flaws into a feature map, adaptively fusing the mutual relationship between different features through iterative reasoning and attention mechanism of the graph neural network, and performing end-to-end training and optimization to generate a comprehensive feature representation for tortoise shell quality detection; To realize the image recognition-based tortoise shell quality detection method according to any one of claims 1-4.
Citation Information
Patent Citations
A method and system for detecting transparency of tortoise shell glue based on multi-spectrum
CN119785063A
Method and system for measuring transparent dispensing volume, computer readable storage medium and computer program product
CN120212867A