A traditional chinese medicine decoction piece quality evaluation method based on big data
By using multi-dimensional correlation analysis and image feature region segmentation, data on color gradient, texture direction consistency, and structural symmetry of Chinese herbal medicine slices are extracted to generate quality assessment values. This solves the problem of the separation between environmental risk and finished product quality in the quality assessment of Chinese herbal medicine slices, and achieves accurate assessment and traceable quality control.
Patent Information
- Application Number
- CN202511076825.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-01
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-08-01
AI Technical Summary
Existing technologies for the quality assessment of Chinese herbal medicine decoction pieces suffer from several shortcomings: imprecise modeling of the correlation between environmental data and finished product characteristics; lack of a multi-dimensional dynamic risk prediction mechanism; limited image feature extraction to a single region; and a lack of hierarchical integration of quality assessment indicators, making it difficult to reflect the overall coordination of the decoction piece morphology.
By analyzing the relationship between planting environment data and finished product characteristics through multi-dimensional correlation analysis, the images of medicinal slices are divided into grid units and feature regions are located. Data on color gradient, texture direction consistency and structural symmetry are extracted, and combined with difference index and risk value, a quality assessment value is generated.
It has enabled accurate assessment of the quality of Chinese herbal medicine slices, improved early warning capabilities, reduced the misjudgment rate, reduced reliance on human experience, and built a traceable quality traceability system.
Smart Images

Figure CN120579901B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a traditional Chinese medicine decoction piece quality evaluation method based on big data. BACKGROUND
[0002] At present, the quality evaluation of traditional Chinese medicine decoction pieces in the industry mainly relies on artificial experience judgment combined with part of physical and chemical detection, such as appearance observation (color, texture, morphology), microscopic identification and chemical component analysis. However, although some studies have tried to introduce computer vision or big data technology, such as analyzing the color of decoction pieces through color histogram or using texture feature classification algorithm for quality preliminary screening, there are still the following problems:
[0003] For example, the correlation modeling of environmental data and product characteristics is not fine enough, and a multi-dimensional dynamic risk prediction mechanism has not been established; image feature extraction is mostly limited to a single area, and the spatial correlation of multi-feature areas has not been constructed, making it difficult to reflect the overall coordination of decoction piece morphology; the quality evaluation index lacks hierarchical fusion, and the comprehensive influence of environmental risk and real-time detection data cannot be effectively integrated. SUMMARY
[0004] The technical problem to be solved by the present application is to provide a traditional Chinese medicine decoction piece quality evaluation method based on big data, which can improve the accuracy of evaluation.
[0005] To solve the above technical problems, the technical scheme of the present application is as follows:
[0006] In a first aspect, a traditional Chinese medicine decoction piece quality evaluation method based on big data, the method comprising:
[0007] Step 1, performing multi-dimensional correlation analysis on the decoction piece data set, calculating the correlation degree between planting environment data and product characteristic, and generating an initial quality deviation risk value;
[0008] Step 2, dividing the decoction piece surface image into uniform grid units, locating three feature areas through segmentation algorithm, namely the color transition zone of the edge area of the decoction piece, the texture dense area of the center area and the wrinkle area; selecting a detection point in each feature area, and constructing a polygon with the three detection points as vertices;
[0009] Step 3, based on the polygon vertex distribution, extracting color gradient change data from the color transition zone detection point of the edge area, extracting texture direction consistency data from the texture dense area detection point of the center area, and extracting structure symmetry data from the wrinkle area detection point;
[0010] Step 4, the color gradient data is compared with preset standard color gradient threshold to generate a first difference index, the texture direction consistency data is compared with the historical qualified batch texture direction distribution range to generate a second difference index, and the structure symmetry data is compared with the pharmacopoeia standard to generate a third difference index;
[0011] Step 5, based on the first difference index, the second difference index and the third difference index, the initial quality deviation risk value is combined to calculate a quality evaluation value, and according to the interval matching relationship between the quality evaluation value and the preset risk threshold, the quality grade determination result of the traditional Chinese medicine decoction piece is obtained.
[0012] The above scheme of the present application at least includes the following beneficial effects:
[0013] Through the correlation modeling of planting environment data (heavy metals, pesticide residues) and decoction piece product properties (color, texture, morphology), the potential influence of environmental factors on quality characteristics is quantified, and the problem of environmental risk and product quality being separated in the traditional method is solved, and the early warning ability of quality deviation risk is improved.
[0014] Based on the image grid division and feature region positioning technology, the local features of the edge color transition zone, the center texture dense area and the wrinkle area are jointly analyzed, the spatial correlation analysis is realized through the polygon vertex construction, and the limitations of single area detection are overcome, and the comprehensiveness and accuracy of morphological evaluation are significantly improved.
[0015] Through the differentiated comparison mechanism of preset standards, historical data distribution and pharmacopoeia standard, the difference indexes of color gradient, texture direction consistency and structure symmetry are generated respectively, the sliding window matching, KL divergence and graph matching algorithm are combined to realize the adaptive dynamic threshold and accurate quantization of multi-dimensional deviation.
[0016] The environmental risk value and the multi-dimensional difference index are weighted and fused by entropy method, the comprehensive quality evaluation value is generated through the neural network model, the environmental factors and real-time detection data are effectively integrated, the dependence on artificial experience is reduced, and the repeatability of the determination result is reduced. Through the dynamic distribution range comparison of the historical qualified batch data and the risk threshold interval division, the natural characteristic variation of different origin and batch decoction pieces can be automatically adapted, and the misjudgment rate is reduced. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 is a flowchart of a traditional Chinese medicine decoction piece quality evaluation method based on big data provided by an embodiment of the present application.
[0018] Figure 2 is a flowchart of step 1 in a traditional Chinese medicine decoction piece quality evaluation method based on big data provided by an embodiment of the present application. DETAILED DESCRIPTION
[0019] Exemplary embodiments of the present disclosure will be described in greater detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure can be thoroughly understood and fully conveyed to those skilled in the art.
[0020] As Figure 1 shown, an embodiment of the present application proposes a method for evaluating the quality of traditional Chinese medicine decoction pieces based on big data, which comprises the following steps:
[0021] Step 1, multi-dimensional correlation analysis is performed on the decoction piece data set, and the initial quality deviation risk value is generated by calculating the correlation degree between the planting environment data and the finished product characteristics, and the decoction piece data set is the soil heavy metal content detection data and the pesticide residue screening data of traditional Chinese medicine planting link, the surface image of decoction piece, and the surface color and texture feature data of decoction piece;
[0022] Step 2, the surface image of decoction piece is divided into uniform grid units, and three feature areas are located by segmentation algorithm, which are color transition zone of decoction piece edge area, texture dense area and wrinkle area in center area; a detection point is selected in each feature area, and a polygon is constructed with the three detection points as vertices;
[0023] Step 3, based on the distribution of polygon vertices, color gradient change data is extracted from the detection point of color transition zone of edge area, texture direction consistency data is extracted from the detection point of texture dense area of center area, and structure symmetry data is extracted from the detection point of wrinkle area;
[0024] Step 4, the color gradient change data is compared with the preset standard color gradient threshold to generate the first difference index, the texture direction consistency data is compared with the historical qualified batch texture direction distribution range to generate the second difference index, and the structure symmetry data is compared with the pharmacopoeia form standard to generate the third difference index;
[0025] Step 5, based on the first difference index, the second difference index and the third difference index, the initial quality deviation risk value is combined to calculate the quality evaluation value, and according to the interval matching relationship between the quality evaluation value and the preset risk threshold, the quality grade determination result of traditional Chinese medicine decoction piece is obtained.
[0026] In the embodiments of the present application, the planting environment data (soil heavy metals, pesticide residues) is fused with the characteristics of the finished product (surface image, color and texture), the quality influencing factors are excavated from the whole chain of "source planting-processing finished product", and the limitations of single dimension evaluation are broken through. Through image grid division and feature area positioning (edge color transition zone, center texture dense area, wrinkle area), combined with color, texture, structure multi-dimensional data, the key evaluation indexes of the appearance quality of the medicinal slice are covered, and the core quality characteristics are avoided to be missed. The initial quality deviation risk value is generated by correlation calculation, and the planting environment risk is digitized; combined with the difference index (color gradient, texture consistency, structure symmetry), the quantitative derivation from "data-index-risk" is realized, and the subjectivity of manual evaluation is reduced. Compared with the preset threshold (such as standard color gradient, historical qualified texture distribution, pharmacopoeia form standard), the evaluation result is traceable and verifiable, which meets the standardized quality control requirements. Through grid division and segmentation algorithm to position specific areas (such as edge color transition zone), the redundancy of global analysis is avoided, and the detection efficiency is improved; the feature point data is structured by polygon modeling, which provides standardized input for subsequent algorithms. Abstract quality attributes such as color, texture and structure are converted into quantifiable gradient changes, direction consistency and symmetry, which can be intuitively displayed through charts or models, and can help quality inspectors quickly locate problems. The comprehensive quality evaluation value is calculated by combining the initial risk value and the difference index, the quality level (such as qualified, warning, unqualified) is divided by the preset threshold interval, the risk classification management is realized, and targeted quality improvement measures (such as tracing the planting environment and adjusting the processing technology) can be taken. The correlation analysis of planting environment data and finished product characteristics provides data support for quality problem tracing (such as exceeding the heavy metal standard can be traced back to soil pollution, and texture abnormalities can be associated with processing defects), and helps to build a quality tracing system with "traceable source and traceable destination".
[0027] As shown in Figure 2 In another preferred embodiment of the present application, step 1, multidimensional correlation analysis is performed on the medicinal slice data set, the initial quality deviation risk value is generated by calculating the correlation between the planting environment data and the finished product characteristics, including:
[0028] Step 11, the soil heavy metal content detection data is established as a concentration vector according to the categories of arsenic, cadmium and lead elements, and the pesticide residue screening data is established as a residue vector according to the categories of organophosphorus and pyrethroid compounds; the surface color characteristics of the medicinal slice are quantified as a three-dimensional vector composed of hue angle, lightness value and saturation value through HSV color space;
[0029] Step 12, cross-dimension correlation analysis is performed on the concentration vector and the residue vector respectively with the three-dimensional vector, that is, the correlation coefficient matrix of each element of the heavy metal concentration vector with the hue angle dimension is calculated, and the correlation coefficient matrix of each compound of the pesticide residue vector with the lightness value dimension is calculated.
[0030] Step 13, extract the correlation items with the absolute value of the correlation coefficient greater than 0.3, establish the color phase pollution influence factor according to the positive or negative characteristics of the heavy metal-color correlation, and establish the lightness attenuation factor according to the pesticide-brightness relationship; calculate the color phase shift and lightness attenuation according to the actual detected heavy metal concentration and pesticide residue and the corresponding color phase pollution influence factor and lightness attenuation factor;
[0031] Step 14, calculate the standard deviation multiple of the color phase shift outside the color phase distribution interval of the qualified sample as the first risk component, and the part of the lightness attenuation exceeding the historical normal attenuation rate curve by 30% as the second risk component, and the first risk component and the second risk component are fused to generate an initial quality deviation risk value by entropy method.
[0032] In the embodiment of the application, when specifically applied, the specific implementation process of the above step 11 is as follows:
[0033] Heavy metal concentration vector, arrange the detected concentration values of arsenic, cadmium and lead in the soil according to the sample batch or detection point order to form a one-dimensional numerical vector (such as [As concentration 1, Cd concentration 1, Pb concentration 1, As concentration 2, …]).
[0034] Pesticide residue vector, arrange the residual detection values of organophosphorus and pyrethroid pesticides according to the compound category and sample order to form a one-dimensional numerical vector (such as [organophosphorus 1 residue, pyrethroid 1 residue, organophosphorus 2 residue, …]).
[0035] Color three-dimensional vector, for each pixel or region of the surface image of the decoction piece, extract the color phase angle (H), lightness value (V) and saturation value (S) of the HSV color space, and integrate them into a three-dimensional vector (such as [H1, V1, S1, H2, V2, S2, …]) according to the pixel position or region average. By converting multi-source heterogeneous data (heavy metals, pesticide residues, color) into standardized vectors, the conversion from "qualitative description" to "quantitative data" can be realized.
[0036] When specifically applied, the specific implementation process of the above step 12 is as follows:
[0037] Heavy metal-color association, each element (such as As concentration) in the heavy metal concentration vector is corresponded to the color phase angle dimension (H) in the color vector sample by sample, and the correlation coefficient (such as reflecting the synchronism of concentration change and color phase change) is calculated, forming a "heavy metal-color phase" correlation coefficient matrix (each row corresponds to a heavy metal element, and each column corresponds to a color phase angle data point).
[0038] Pesticide-brightness correlation, each compound (such as organophosphorus) in the pesticide residue vector is corresponded with the brightness value dimension (V) in the color vector sample by sample, the correlation coefficient is calculated, and a "pesticide-brightness" correlation coefficient matrix is formed (each row corresponds to a pesticide category, and each column corresponds to a brightness value data point).
[0039] The present application quantifies the correlation between planting environment pollutants and herb color characteristics, identifies key factors affecting quality (such as whether the increase of a certain heavy metal concentration directly leads to abnormal hue), and avoids subjective judgment.
[0040] When specifically applied, the specific implementation process of the above step 13 is as follows:
[0041] Traverse the correlation coefficient matrix, read the values in the "heavy metal-hue" and "pesticide-brightness" correlation coefficient matrix row by row (elements / compounds) and column by column (color dimensions) (for example, the correlation coefficient of As concentration and H, and the correlation coefficient of organophosphorus residue and V).
[0042] Threshold filtering, retaining coefficient items with absolute value ≥0.3 (for example, correlation coefficients of -0.4, 0.5, etc.), and eliminating weak correlation items with absolute value <0.3 (for example, 0.2, -0.1).
[0043] Mark the correlation direction and record the sign of the retained item (positive correlation indicates synchronous increase and decrease, and negative correlation indicates reverse change), for example: if the correlation coefficient of Cd concentration and H is +0.35, it is marked as "Cd concentration ↑→H ↑" (positive correlation); if the correlation coefficient of pyrethroid residue and V is -0.4, it is marked as "residue amount ↑→V ↓" (negative correlation). Through statistical threshold filtering of redundant correlations, environmental factors that have a substantial impact on the color of the herb are focused on, and the amount of invalid calculation is reduced.
[0044] Based on the absolute value of the correlation coefficient, the weight in the 0-1 interval is proportionally mapped (for example: correlation coefficient absolute value 0.3 corresponds to factor 0.3, 0.5 corresponds to 0.5, and 1 corresponds to 1), positive correlation (such as a coefficient of +0.4): the factor is positive, indicating that the increase of heavy metal concentration will cause the hue angle to deviate in a certain direction (such as red); negative correlation (such as a coefficient of -0.4): the factor is negative, indicating that the increase of concentration will cause the hue angle to deviate in the opposite direction (such as green).
[0045] Example: the correlation coefficient of As concentration and H is -0.4→the factor is assigned a value of -0.4; the correlation coefficient of Pb concentration and H is +0.5→the factor is assigned a value of +0.5.
[0046] Brightness attenuation factor (for pesticide-brightness correlation):
[0047] Assignment rules:
[0048] Factor base value, rate value mapped to 0-1 interval based on correlation coefficient absolute value (e.g. correlation coefficient absolute value 0.3 corresponds to decay rate 30% / unit concentration, 0.6 corresponds to 60% / unit concentration).
[0049] Direction correction:
[0050] Positive correlation (e.g. coefficient +0.3): indicates that the higher the pesticide residue, the faster the brightness decreases (factor is positive, e.g. +0.3 means that for every 1 mg / kg increase in residue, the brightness decreases by 0.3 units); negative correlation (usually not true in this scenario, as pesticide residues generally cause color to darken, reducing brightness, so the default is positive correlation).
[0051] Example:
[0052] The correlation coefficient between organophosphorus residues and V is +0.5 → the factor is assigned a value of +0.5 (i.e. every unit of residue causes a decrease in brightness of 0.5 units), converting the abstract correlation into a calculable impact weight, quantifying the mapping relationship between "pollution level-color change".
[0053] Before calculating the offset, normalize the measured heavy metal concentrations and the color phase pollution influence factor to ensure that the two have the same dimension. The specific steps are as follows:
[0054] Find the maximum and minimum values of all measured heavy metal concentrations and the maximum and minimum values of the color phase pollution influence factor, and normalize the measured heavy metal concentrations and the color phase pollution influence factor.
[0055] Perform normalization, and for each measured heavy metal concentration and corresponding color phase pollution influence factor, perform normalization processing to obtain new normalized concentration values and factor values.
[0056] For each strongly associated heavy metal element (such as As, Pb), multiply its normalized concentration by the corresponding normalized influence factor (e.g. normalized As concentration 0.6 x normalized factor -0.4 = -0.24).
[0057] Add the product results of all strongly associated elements to obtain the comprehensive offset (e.g. As contribution -0.24, Pb contribution +0.3 → total offset +0.06), positive values indicate that the color phase angle is offset to the right of the reference value (e.g. red), negative values indicate that it is offset to the left (e.g. green), and the larger the absolute value, the more obvious the deviation from normal color.
[0058] Brightness decay amount calculation:
[0059] For each strongly associated pesticide compound (such as organophosphorus and pyrethroid), multiply its residual amount (unit: mg / kg) by the corresponding attenuation factor (such as organophosphorus residual 3.0 mg / kg x factor +0.5 = +1.5), and accumulate the product results of all strongly associated compounds to obtain the comprehensive attenuation amount (such as organophosphorus contribution +1.5, pyrethroid contribution +1.2 → total attenuation amount +2.7), a positive value indicates the magnitude of the decrease in brightness from the reference value (such as the reference brightness is 50, and the attenuation amount is 2.7, indicating that the measured brightness is 47.3), and the larger the value, the darker the color.
[0060] By normalization processing, the problem of inconsistent units of measured heavy metal concentration and influencing factors is solved, the calculation deviation caused by dimensional difference is avoided, the offset calculation result is more accurate and comparable, the data distribution after normalization is more balanced, which is helpful for stable operation of subsequent risk assessment model, reduces the interference of extreme value on the evaluation result, improves the generalization ability of the model, after unifying the dimension, the contribution degree of each influencing factor to the offset is more clear, which is convenient for accurately judging the actual influence of different pollution sources on the quality of the decoction pieces, and provides more reliable decision basis for quality control.
[0061] The present application focuses on strong correlation factors, quantifies the specific influence of pollutants on the appearance of decoction pieces (such as the degree of yellow color caused by arsenic pollution), provides traceable causal relationship basis for quality risk, and facilitates targeted control of pollution sources.
[0062] When specifically applied, the specific implementation process of the above step 14 is as follows:
[0063] The first risk component is to statistically determine the hue angle distribution interval (such as mean ± standard deviation) of the qualified samples, and calculate the standard deviation multiple of the current sample hue offset amount exceeding the interval (such as the offset amount is 2 times the standard deviation of the qualified samples, then the risk component is 2).
[0064] The second risk component is to establish a "normal brightness attenuation rate curve" (such as the trend of brightness change with storage time or processing steps) according to historical data, and calculate the part exceeding 30% of the curve (such as normal attenuation 10%, measured attenuation 15%, then the risk component is 5%) of the current brightness attenuation amount.
[0065] Entropy method weighted fusion, the weight of the two risk components is calculated by entropy method (the weight reflects the data uncertainty, the smaller the entropy value, the higher the weight), the components are superimposed according to the weight, and the comprehensive "initial quality deviation risk value" is generated.
[0066] The present application converts abstract risk into quantifiable value (such as higher risk value indicates higher probability of quality problem), which is convenient for hierarchical management (such as setting threshold to distinguish low, medium and high risk), and avoids the subjectivity of artificial weighting by using entropy method, automatically assigns weight according to the characteristics of data itself, and improves the credibility of risk value.
[0067] In a preferred embodiment of the present application, step 2, the surface image of the medicinal material piece is divided into uniform grid cells, and three feature regions are located by a segmentation algorithm, namely the color transition zone of the edge region of the medicinal material piece, the texture dense area of the center region, and the wrinkle region, including:
[0068] An adaptive grid division algorithm is used to divide the surface of the medicinal material piece into square grid cells with a side length of 5-8 pixels according to the image resolution;
[0069] Edge gradient detection is performed on each grid cell, and the region in which the edge gradient change rate of the three consecutive grid cells exceeds 50% is marked as a color transition zone;
[0070] Gray level co-occurrence matrix analysis is performed on the center region grid, and adjacent grids with a texture contrast greater than a set threshold are clustered as a texture dense area;
[0071] The broken wrinkle features are connected through a morphological dilation operation, and the continuous region with a curvature change rate exceeding 30% is identified as a wrinkle region; the final detection point position is determined by expanding 2 grid units outward from the geometric center point of each of the three feature regions.
[0072] In an embodiment of the present application, the pixel size (such as width x height = 1000 x 800 pixels) of the surface image of the medicinal material piece is obtained, if the resolution is ≥800 x 600 pixels, the grid side length is set to 5-6 pixels (such as 5 pixels), ensuring that each grid corresponds to about 0.1-0.2 mm 2 region of the surface of the medicinal material piece; if the resolution is <800 x 600 pixels, the side length is set to 7-8 pixels (such as 8 pixels) to avoid feature loss due to too small grid; starting from the top left corner of the image, square grids that do not overlap each other are divided in row priority order until the entire image is covered (such as 1000 x 800 pixel image divided into 200 x 160 5 x 5 pixel grids), the grid density is dynamically adjusted according to the image clarity to ensure consistent feature analysis accuracy of images with different resolutions, and to avoid missing details due to too large grid or introducing noise due to too small grid.
[0073] For each grid cell, the pixel gray level gradient value is calculated using an edge detection operator (such as the Sobel operator), and the average gradient value in the grid is taken as the "edge gradient value" of the grid. For adjacent grids in each row and each column, the gradient value change rate of the next grid to the previous grid is calculated. If the change rates of the three consecutive grids are all >50% (such as the change rates of grids n, n+1, and n+2 are 60%, 55%, and 58%, respectively), the three grids are marked as a "color transition zone" (which usually corresponds to the color gradient region of the edge of the medicinal material piece). The color transition zone of the edge of the medicinal material piece is accurately located by quantifying the color abrupt change region through the gradient change rate, avoiding the ambiguity of manual visual judgment.
[0074] The center region is determined, the image is divided into nine grids, the center grid is taken as the "center region" (such as the center grid of a 1000x800 image is 400-600 rows and 300-500 columns), for each grid in the center region, the "contrast" feature of the gray level co-occurrence matrix is calculated (reflecting the degree of change in texture brightness), a contrast threshold is set (such as an empirical value of 80), regions with a contrast greater than the threshold in adjacent grids are merged to form a "texture dense area" (such as a texture concentrated area in the center of a decoction piece due to dense cell structure), the texture complexity is quantified using the gray level co-occurrence matrix, and the characteristic texture area of the center of the decoction piece is quickly located through threshold clustering, providing a target area for subsequent texture direction analysis.
[0075] An inflation operation is performed on the image (using a 3x3 circular structural element), connecting broken wrinkle edge pixels, enhancing continuous regions, for each pixel, the curvature value is calculated by fitting a local quadratic curve (the greater the curvature, the more obvious the wrinkle), the curvature change rate of adjacent pixels is calculated (such as the difference ratio of the current pixel curvature and the average curvature of the neighborhood), if the change rate in the continuous region is greater than 30% and the number of pixels is greater than or equal to 5, it is marked as a "wrinkle region" (such as a wrinkle formed by drying and shrinking of a decoction piece), the broken features are repaired through morphological operation, and the wrinkle region is accurately identified by combining the curvature change rate, avoiding false detection caused by image noise.
[0076] For each feature region (transition zone, texture dense area, wrinkle area), the coordinate mean value of all grids is calculated to obtain the region centroid, and the centroid is expanded by 2 grid units in all directions (such as an original grid length of 5 pixels, the expansion range is 10 pixels), and the center of the expanded region is taken as the final detection point (to ensure that the detection point is located at the core position of the feature region), the centroid expansion avoids the detection point being located at the edge of the region or a noise point, ensures that the extracted color, texture and structure data are representative of the region, and reduces accidental errors.
[0077] The edge color mutation is quantified based on the gradient change rate, which is suitable for edge quality detection of different decoction pieces (such as whether the slice edge is abnormal in color due to overheating during processing), the characteristic texture area of the center of the decoction piece is quickly locked through GLCM contrast clustering (such as the dense texture of the wood part of root medicinal materials), which assists in identifying authenticity, and effectively identifies structural wrinkles generated during drying and storage by combining morphological and curvature analysis, to evaluate the rationality of the processing technology (such as whether the drying temperature causes the decoction piece to shrink excessively), and the geometric center expansion positioning ensures that the detection point position is fixed, the feature extraction position of different batches of images is consistent, and the data comparability is improved (such as the detection points of different samples of the same decoction piece are located at the center of the texture dense area), the automatic grid division and region detection replace manual annotation, the single image analysis time can be controlled within seconds, and it is suitable for large-scale decoction piece rapid quality inspection.
[0078] In a preferred embodiment of the present application, a detection point is selected in each feature area, and a polygon is constructed with the three detection points as vertices, including:
[0079] A reference line is established by extending 3 pixels along the edge tangent direction at the color transition zone detection point, and the midpoint of the reference line is selected as the first vertex;
[0080] The main texture direction is calculated at the texture dense area detection point, and a second vertex is determined by moving a distance of 1 / 2 of the texture period along the main texture direction;
[0081] The symmetry axis is identified at the wrinkle area detection point, and the intersection of the symmetry axis and the wrinkle edge is selected as the third vertex;
[0082] The first vertex, the second vertex and the third vertex are connected in a clockwise direction to form a triangle, and the internal angle distribution of the triangle is calculated as the morphological feature reference.
[0083] In the embodiment of the present application, the edge tangent direction is determined, and at the color transition zone detection point (the position after the centroid expansion), the tangent direction of the edge where the point is located is identified through an edge detection operator (such as the Canny operator) (such as the tangent and the horizontal axis included angle θ), and 3 pixels are extended to both sides along the tangent direction to form a reference line with a length of 6 pixels (such as the detection point coordinates are (x, y), the tangent direction θ, and the extension point coordinates are (x±3cosθ, y±3sinθ)), and the midpoint of the reference line is taken as the first vertex (the coordinates are (x, y) after the midpoint of the 3 pixels extended along the tangent direction, that is, the original detection point position), and the edge tangent direction is taken as the reference to ensure that the first vertex is located on the main gradient direction of the color transition zone, which is convenient for subsequent extraction of the color gradient change data along the edge.
[0084] The main texture direction is calculated, a 5x5 pixel neighborhood is selected around the texture dense area detection point, the direction with the maximum "energy" or "correlation" is calculated as the main texture direction (such as the horizontal, vertical or diagonal direction) through the gray level co-occurrence matrix (GLCM), the interval distance of the repeated change of the gray value is counted as the texture period (such as the interval distance of the adjacent texture units is T pixels) by scanning the neighborhood pixels along the main texture direction, the second vertex position is determined by moving T / 2 distance (such as the main texture direction is horizontal right, the period T = 8 pixels, and then 4 pixels are moved) from the detection point to one side along the main texture direction, the vertex is positioned based on the periodic characteristics of the texture to make the second vertex located at the most significant position of the texture change (such as the center or edge of the texture unit), which is convenient for extracting the texture direction consistency data.
[0085] Symmetry axis recognition: around the detection point in the fold region, the symmetry axis of the fold (such as the central axis along the longest direction of the fold) is determined by a morphological skeleton extraction algorithm or a curvature extreme point connection line. The symmetry axis is extended to both sides and intersects with the edge profile of the fold region. The intersection point farther from the detection point is taken as the third vertex (such as the right intersection point among the left and right edge intersection points of the symmetry axis). The vertex is positioned by the intersection of the symmetry axis and the edge, ensuring that the third vertex reflects the symmetry characteristics of the fold structure, facilitating subsequent analysis of structural symmetry data.
[0086] Arrange the three vertices in a clockwise direction: first vertex (color transition zone) → second vertex (texture dense area) → third vertex (fold region) → first vertex, forming a closed triangle. Use vector cross product to calculate the angles of the three internal angles of the triangle (such as the internal angles of vertices A, B, and C are ∠A, ∠B, and ∠C). Record the degrees and distribution of the three internal angles (such as the difference between the largest and smallest angles, whether it is an isosceles triangle, etc.), as the geometric feature reference of the decoction piece shape. Quantify the shape symmetry and structural characteristics of the decoction piece through the internal angle distribution of the triangle, for example: the internal angle distribution of a normal decoction piece is relatively uniform (such as each angle is about 60°); a processed and deformed decoction piece may have abnormal angles (such as an angle > 90°, reflecting abnormal edge or fold structure).
[0087] Correlate the feature points of color (edge transition zone), texture (center dense area), and structure (fold) through geometric figures (triangle) to form a three-dimensional evaluation model of "position-feature-shape". For example: an excessively long side of the triangle may reflect an abnormal expansion of the edge color transition zone, an excessively small angle may correspond to an excessively high compactness of the fold region, and the internal angle distribution converts abstract shape characteristics into comparable numerical indicators (such as angle deviation threshold), facilitating automatic judgment of whether the decoction piece meets the shape standard (such as the shape description specified in the pharmacopoeia) by the computer, and quickly identifying defects in the decoction piece cutting process (such as uneven slice thickness leading to texture vertex displacement, and excessively high drying temperature leading to abnormal fold vertex angle).
[0088] The triangle construction rules are unified (clockwise order, vertex positioning logic), ensuring that the shape characteristics of decoction pieces of different batches and different varieties are comparable. The triangle vertex position is bound to the feature area (such as edge, center, and fold), and if the shape characteristics are abnormal, the quality problem of the corresponding area can be directly traced back (such as second vertex displacement reflecting abnormal texture dense area, which may be related to the mixing of medicinal materials of different varieties). The geometric parameters of the triangle, such as internal angles and side lengths, can be directly input into machine learning models (such as SVM and neural networks) as feature vectors for shape classification, improving the accuracy of automatic quality inspection.
[0089] In a preferred embodiment of the present application, step 3, based on the distribution of polygon vertices, color gradient change data is extracted from the color transition zone detection point of the edge region, texture direction consistency data is extracted from the texture dense area detection point of the central region, and structure symmetry data is extracted from the wrinkle region detection point, including:
[0090] In the color transition zone detection point, the HSV color space value is collected along the direction of the polygon edge line with a step length of 1 pixel, and the standard deviation of the hue angle difference between adjacent pixels is calculated as the gradient change data.
[0091] In the texture dense area detection point, the 8-direction Gabor filter response is extracted, and the area ratio of the region where the main response direction accounts for more than 70% is calculated as the direction consistency data.
[0092] In the wrinkle region detection point, mirror sampling is performed along the polygon symmetry axis, and the matching degree of the number and distribution interval of curvature extreme points on both sides of the region is calculated as the structure symmetry data.
[0093] In an embodiment of the present application, the color transition zone detection point (first vertex) is taken as the starting point, and the sampling path is determined along the polygon edge line (such as the edge line from the first vertex to the second vertex), the path length is the pixel length of the edge line (such as 20 pixels), and the HSV color value (hue angle H, brightness V, and saturation S) of each pixel on the path is collected with a step length of 1 pixel to form a sequence (H1, H2, …, Hn).
[0094] Difference calculation, the hue angle difference between adjacent pixels is calculated to obtain the difference sequence.
[0095] Standard deviation calculation, the standard deviation of the difference sequence is calculated as the "color gradient change data" (the larger the standard deviation, the more intense the color change, and the worse the edge color uniformity), which quantifies the spatial variation amplitude of the edge color and identifies whether the edge of the medicinal material exists color unevenness caused by processing (such as frying, drying) or storage (such as edge blackening, oxidation discoloration).
[0096] In the texture dense area detection point (second vertex), an 11x11 pixel region is selected around the detection point, and an 8-direction (0°, 22.5°, 45°, …, 337.5°) Gabor filter is used to convolve the region to obtain the response intensity map of each direction.
[0097] Main response direction identification, for each pixel, the response values in 8 directions are compared, and the direction with the maximum response intensity is taken as the "main texture direction" of the pixel.
[0098] Consistency statistics, the number of pixels whose main response direction is consistent with the overall main direction (e.g., the direction with the strongest response in the entire region), and the proportion of the total area of the region (e.g., if the main direction is 45°, the proportion of pixels in this direction is 85%, indicating high consistency of texture direction). Simulate human eye perception of texture direction through Gabor filter, quantify the orderliness of texture arrangement (e.g., the vascular texture of root medicinal materials should be arranged vertically, poor consistency may indicate adulteration or abnormal cutting direction).
[0099] Structure symmetry data extraction (wrinkle area), operation process:
[0100] Symmetry axis determination, take the symmetry axis of the polygon where the wrinkle area detection point (third vertex) is located as the reference line (e.g., the line connecting the third vertex and the midpoint of the opposite side in a triangle).
[0101] Mirror sampling, select sampling areas equidistant from the symmetry axis on both sides (e.g., area A on the left and area B on the right, both 5 pixels away from the symmetry axis), and extract the curvature extreme points (i.e., the most curved points of the wrinkles) in the areas.
[0102] Matching degree calculation:
[0103] Number matching, compare the number of curvature extreme points in area A and area B (e.g., A has 8, B has 7, the difference rate is 12.5%); interval matching, calculate the interval difference between the extreme points on both sides in order, and weight average the number difference rate and the interval difference rate (e.g., each accounts for 50%), as the structure symmetry data (the higher the matching degree, the better the symmetry, the more stable the physical structure of the decoction piece), evaluate the stability of the physical structure of the decoction piece through the symmetric distribution of the curvature extreme points (e.g., poor symmetry of wrinkles may be caused by uneven force during cutting or uneven drying speed, affecting the appearance and uniformity of the medicinal effect of the decoction piece).
[0104] Directional sampling along polygon edges, focusing on the path with the most significant color and shade changes, avoiding the redundancy of global sampling (e.g., only analyzing the color and shade transition zone of the cutting edge of the decoction piece, not the complete contour), multi-directional response analysis based on Gabor filter, accurately capturing the dominant direction of the texture (e.g., the direction of leaf veins in leaf decoction pieces), more comprehensive than single direction detection, mirror sampling based on the symmetry axis of the polygon, converting the symmetry evaluation of the wrinkle structure into a quantifiable geometric matching problem, avoiding subjective judgment.
[0105] The color gradient standard deviation can be directly related to the planting environment (such as abnormal color caused by heavy metal pollution) or processing technology (such as the degree of roasting); the texture direction consistency can reflect the authenticity of medicinal materials (such as different texture arrangement directions of different varieties) or cutting process (such as the difference in texture direction between horizontal and vertical cutting); the structure symmetry matching degree can reveal the processing mechanical parameters (such as the flatness of the cutting machine blade) or storage conditions (such as the deformation of the wrinkles caused by dampness), and each index is based on a clear calculation logic (such as standard deviation, proportion, and matching degree), and a unified threshold can be set in the industry (such as color gradient standard deviation > 5° is abnormal, and texture consistency < 70% is unqualified), which promotes the digitalization of quality inspection standards. The color, texture and structure data correspond to chemical pollution (step 1), morphological characteristics (step 2) and physical structure (step 3) respectively, forming a three-dimensional quality evaluation system of "environment-appearance-structure", which reduces the risk of misjudgment of a single index (such as normal color but disordered texture may indicate mixed varieties).
[0106] In a preferred embodiment of the present application, step 4, the color gradient change data is compared with the preset standard color gradient threshold to generate a first difference index, the texture direction consistency data is compared with the historical qualified batch texture direction distribution range to generate a second difference index, and the structure symmetry data is compared with the pharmacopoeia morphological standard to generate a third difference index, comprising:
[0107] The color gradient change data is matched with the standard threshold in a sliding window, and the cumulative length proportion of the data points exceeding the threshold in the window is calculated as the first difference degree;
[0108] A direction distribution probability model of the qualified batch is established for the texture direction consistency data, and the deviation degree between the current data distribution and the model is measured by KL divergence as the second difference degree;
[0109] The structure symmetry data is mapped into the topological structure described in the pharmacopoeia morphological standard, and the matching error of the node corresponding relationship is calculated by a graph matching algorithm as the third difference degree.
[0110] In the embodiment of the present application, the preset standard threshold is determined, and according to the historical data of the qualified decoction pieces, the standard deviation threshold of the color gradient change is set (such as the threshold is 3°, indicating the allowable hue angle change fluctuation range).
[0111] Sliding window setting:
[0112] Window length: take 10 consecutive data points (such as 10 pixel hue angle difference standard deviation);
[0113] Sliding step: 5 data points (move half the window length each time to ensure data overlap coverage).
[0114] Window matching and statistics:
[0115] From the beginning of the color gradient data sequence, slide window by window, check if each window data point exceeds the threshold; Calculate the proportion of the number of data points exceeding the threshold in the total number of points in each window (such as 4 points > 3° in the window, the proportion is 40%).
[0116] Difference generation, take the average of the proportion of all sliding windows as the first difference index (such as the average is 25%, which means that the color gradient abnormal duration accounts for 25%), dynamically capture local anomalies of color gradient through sliding windows, avoid single global statistics to cover up local defects (such as color mutation in a certain area of the edge of the decoction piece), and improve the positioning accuracy of anomalies.
[0117] The second difference index (texture direction contrast), the operation process is:
[0118] Historical qualified data modeling:
[0119] Collect texture direction consistency data of more than 1000 batches of qualified decoction pieces, and count the frequency of each direction (0°, 22.5°…) to construct a probability distribution model (such as a column chart showing the proportion of each direction).
[0120] Current data distribution calculation, the texture direction consistency data of the current decoction piece, the pixel proportion of each main texture direction (such as 45° direction accounts for 60%, 90° direction accounts for 30%).
[0121] KL divergence calculation, compare the difference between the current distribution and the historical qualified distribution, and calculate the KL divergence value (the smaller the value, the closer the distribution, such as KL=0.1 indicates less difference, KL=0.8 indicates significant difference).
[0122] Difference mapping: normalize the KL divergence value to the 0-100 interval (such as KL=0 corresponds to a difference of 0, and KL=1 corresponds to a difference of 100), as the second difference index, based on the big data probability model Quantify the consistency deviation of the texture direction, it can identify subtle texture abnormalities (such as adding a small amount of other varieties of decoction pieces leading to texture direction distribution dispersion), more sensitive than single threshold judgment.
[0123] The third difference index (structure symmetry contrast), the operation process is:
[0124] Pharmacopoeia form topology construction:
[0125] The morphological characteristics of the medicinal pieces described in the pharmacopoeia are abstracted into a topological graph, with nodes representing key structural points (such as wrinkle vertices, texture center points), and edges representing the spatial relationship between structural points (such as distance, angle). Example: The topological graph of a certain root medicinal piece standard in the pharmacopoeia contains 5 nodes, and the edges represent the relative position and symmetry relationship between the nodes. The current structure data graph is generated, and based on the distribution of the curvature extreme points of the wrinkle area, the structural topological graph of the current medicinal piece is constructed (the nodes are extreme points, and the edges are the distance and curvature difference between adjacent points).
[0126] Graph matching algorithm application:
[0127] Using the maximum common subgraph algorithm, the node correspondence between the current graph and the pharmacopoeia graph is found (such as pharmacopoeia graph node A matching current graph node X); the spatial relationship error between the matching nodes (such as distance deviation, angle deviation) is calculated, and the average error is taken as the matching error (such as the average distance deviation is 2 pixels, and the angle deviation is 5°).
[0128] Difference degree generation, compare the matching error with the allowed error range (such as distance deviation ≤3 pixels, angle deviation ≤10°), the part exceeding is converted into difference degree in proportion (such as error exceeding 50% then difference degree is 50), through topological graph matching, the abstracted pharmacopoeia morphological standard is converted into calculable geometric error, realizing the precise mapping of "text description - numerical index" (such as "edge neatness" in the pharmacopoeia corresponding to matching error ≤ a certain threshold), solving the problem of standard ambiguity in traditional quality inspection.
[0129] In the embodiment of the present application, the sliding window combines the spatial distribution of color and luster gradient, detecting both overall trend and local anomalies (such as color and luster mutation in a certain area of the medicinal piece edge due to excessive frying); KL divergence evaluates the statistical distribution difference of texture direction, and graph matching verifies the compliance of structural topology, avoiding single-dimensional misjudgment (such as normal texture direction distribution but asymmetric structure may indicate processing deformation), and the preset threshold and historical probability model can be directly reused in the quality inspection of the same variety of medicinal pieces, reducing the establishment cost of enterprise quality inspection standards; the difference degree index can be directly input into the automatic quality inspection system, realizing the whole process of "data collection - analysis - judgment" without human intervention (such as real-time detection of unqualified rate on the production line), and color and luster difference degree anomaly can be traced back to planting environment (such as heavy metal pollution) or processing temperature control; texture difference degree anomaly can indicate variety mixing or cutting direction error; structural difference degree anomaly can be located to the cutting mechanical precision or drying process parameter deviation, and the sliding window size, KL divergence model, and topological graph nodes can be flexibly adjusted according to different medicinal piece varieties (such as different structural topological standards for leaf and root medicinal pieces).
[0130] In a preferred embodiment of the present application, step 5, based on the first difference degree index, the second difference degree index, and the third difference degree index, and combined with the initial quality deviation risk value, a quality evaluation value is calculated, including:
[0131] A three-layer neural network model is established, the first difference degree, the second difference degree and the third difference degree are taken as input layer nodes, and the initial quality deviation risk value is taken as a bias term.
[0132] The hidden layer adopts a Sigmoid activation function for nonlinear transformation, and the output layer generates a quality evaluation value in the interval of 0-1 through weighted summation, wherein the weight coefficient of the difference degree index is determined through back propagation training of historical samples.
[0133] In the embodiment of the application, the neural network model construction operation process is as follows:
[0134] The input layer is set as follows:
[0135] Three input nodes are defined, corresponding to the first difference degree (D1), the second difference degree (D2) and the third difference degree (D3), and the value range is 0-100 (for example, D1=25, D2=18 and D3=30); the initial quality deviation risk value (R) is introduced as a bias term, which is transmitted to the hidden layer together with the input nodes (the bias term can be understood as an additional input node, and the value is always R).
[0136] The hidden layer is calculated as follows:
[0137] The number of hidden layer nodes is set to 5 (an empirical value, which can be adjusted according to the model effect), and each node performs the following operations: calculating a weighted sum, multiplying the input values (D1, D2, D3 and R) by the corresponding weights (w1, w2, w3 and b) to obtain the weighted sum z.
[0138] The activation function is processed, and the weighted sum z is processed by a Sigmoid function to convert the weighted sum into a nonlinear output between 0 and 1 (for example, σ(z)=0.7 represents the activation intensity of the hidden layer node).
[0139] The output layer is calculated as follows:
[0140] The number of output layer nodes is 1, which receives the output values of the 5 nodes of the hidden layer, performs weighted summation to obtain a sum value Y, and maps the sum value Y to the interval of 0-1 through normalization to obtain the final quality evaluation value Q (for example, Q=0.6 represents medium quality, and the closer Q is to 1, the higher the quality risk is).
[0141] The weight training process is as follows:
[0142] The historical samples are prepared as follows:
[0143] 5000 batches or more of decoction piece samples containing complete detection data are collected, and their actual quality grades (such as qualified, pre-warning and unqualified) are labeled.
[0144] The back propagation training is as follows:
[0145] Input D1, D2, D3 and R values of the sample, calculate the model prediction value Q_pred; Calculate the error (such as mean square error MSE) between the prediction value and the actual grade (such as Qtrue=1 for unqualified and Qtrue=0 for qualified); Backward derivation from the output layer to adjust the weights (w1, w2, w3, whi, etc.) of the hidden layer and the output layer, so that the error gradually decreases (such as learning rate set to 0.01, iteration 1000 times).
[0146] Weight determination:
[0147] After training, the weight of each difference index reflects its contribution to quality evaluation (such as D1 weight 0.4, D2 weight 0.3, D3 weight 0.3, indicating that color difference has the greatest impact on quality).
[0148] The present application combines planting environment risk (R) and finished product appearance difference (D1-D3) through neural network nonlinear fusion, breaking through the limitation of traditional linear weighting (such as high risk environment, even if the appearance difference is small, it may trigger high evaluation value), example: a batch of drinking pieces R value is high (soil heavy metal exceeds standard), but D1-D3 is low, the model may still determine high risk due to the influence of bias term R, avoiding "data normal but source pollution" missed detection. Through automatic learning of weight from historical data, the subjectivity of artificial weighting is avoided (such as traditional method may overestimate color difference, and model finds that texture difference is more critical for certain varieties), weight can be dynamically adjusted according to varieties (such as root type drinking pieces focus on texture difference weight, leaf type drinking pieces focus on color difference weight), which improves the generalization ability of the model.
[0149] Nonlinear relationship modeling:
[0150] Sigmoid activation function can capture the complex correlation between data (such as the synergistic effect of color difference and texture difference), for example: when D1>50 and D2>40, the model output Q may increase exponentially, reflecting the actual law that "double abnormality leads to significant quality decline".
[0151] Quantitative grading and early warning:
[0152] Quality evaluation value Q converts multi-dimensional risk into a unified scale value (such as Q=0.3 is qualified, 0.5-0.7 is pre-warning, and ≥0.7 is unqualified), which is convenient for rapid grading and disposal, and can be integrated into production monitoring system to trigger real-time pre-warning (such as Q≥0.5 automatically suspends the flow of this batch, prompting manual review).
[0153] Model interpretability optimization:
[0154] The weight analysis can trace the influence degree of each indicator (such as the sudden increase of D3 weight, which may indicate that the abnormal problem of wrinkle increases recently), assist enterprises in positioning systematic quality risk, support the combination with SHAP value and other explainable tools, and visualize the difference contribution of each sample (such as a decoction piece Q=0.6 mainly caused by D1=45 and R=0.8).
[0155] In a preferred embodiment of the present application, according to the interval matching relationship between the quality evaluation value and the preset risk threshold value, the quality grade determination result of the traditional Chinese medicine decoction piece is obtained, including:
[0156] Three preset risk threshold intervals are determined, when the quality evaluation value is less than 0.25, it is determined as a first-class high-quality product, the interval of 0.25-0.6 is determined as a second-class qualified product, and greater than 0.6 is determined as a third-class defective product; for the samples within the range of interval critical value ±0.03, the review mechanism is started, the evaluation value is recalculated by increasing the number of feature area detection points, and the average value of the two calculation results is taken as the final determination basis.
[0157] In the embodiment of the present application, the preset threshold value is mapped with the grade, and the operation process is:
[0158] Threshold interval definition:
[0159] First-class high-quality product: quality evaluation value Q<0.25;
[0160] Second-class qualified product: 0.25≤quality evaluation value Q≤0.6;
[0161] Third-class defective product: quality evaluation value Q>0.6, for example: if the quality evaluation value Q=0.18, it is determined as the first class; the quality evaluation value Q=0.45, it is determined as the second class; the quality evaluation value Q=0.7, it is determined as the third class.
[0162] Critical value review range:
[0163] The critical value is defined as the interval end point (0.25, 0.6), and the allowable error range is ±0.03:
[0164] First-class and second-class critical zone: (0.22≤quality evaluation value Q≤0.28);
[0165] Second-class and third-class critical zone: (0.57≤quality evaluation value Q≤0.63);
[0166] If the quality evaluation value Q falls into the critical zone, such as quality evaluation value Q=0.24) or quality evaluation value Q=0.61, the review mechanism is triggered.
[0167] Review mechanism execution process operation process:
[0168] Feature area detection point encryption:
[0169] On the basis of the detection points of the original three feature areas (color transition zone, texture dense area, and wrinkle area), new detection points are added to the surrounding grid:
[0170] Each feature area adds 3 detection points (such as 1 grid above, below, left and right of the original detection point), and the total detection points increase from 3 to 12 (4 in each area).
[0171] Example: The original texture dense area detection point is the center grid, and the center points of the 4 grids above, below, left and right are added as new detection points.
[0172] Multi-detection point data recalculation:
[0173] For each new detection point, the feature area is repositioned, the polygon is constructed, the color gradient, texture direction, and structure symmetry data are extracted, and new difference indicators (D1', D2', D3') and quality evaluation values (Q') are generated. The average of the original evaluation value (Q) and the review evaluation value (Q') is calculated, the average is substituted into the preset threshold interval, and the final grade is determined (such as first (Q=0.28), review (Q'=0.24), average=0.26), and it is determined as a second-class qualified product).
[0174] The quantitative threshold of the present application converts the quality grade from fuzzy qualitative to clear quantitative (such as "high-quality product" corresponding to a specific numerical range), avoids the subjective difference of artificial judgment, and balances the detection accuracy and efficiency (only for controversial samples to start review), which reduces misjudgment and avoids repeated detection of all samples. For "edge samples" close to the threshold (such as (Q=0.61)), local subtle differences are captured through encrypted detection points (such as sudden deterioration of wrinkle symmetry in a certain area), which avoids grade misjudgment caused by single-point detection error.
[0175] Example: The first detection caused by the angle of the decoction piece placement leads to high texture direction consistency (Q=0.28), and after adjusting the angle during review, it is found that the real texture is chaotic (Q'=0.32), and finally it is determined as a second-class (original first-class critical).
[0176] The average of multi-detection point data reduces the influence of accidental noise (such as color gradient anomaly caused by image noise at a certain detection point, which can balance the error through new points), and the review mechanism makes the model more inclusive to decoction piece shape variation (such as irregular slices), and improves the reliability of the results through multi-angle detection. The first-class product standard is strictly limited (quality evaluation value Q<0.25).
[0177] The above is a preferred embodiment of the present application. It should be noted that for ordinary skilled persons in the technical field, without departing from the principles of the present application, a number of improvements and refinements can be made, which should also be considered within the scope of protection of the present application.
Claims
1. A method for quality evaluation of traditional Chinese medicine decoction pieces based on big data, characterized in that, The method comprises: Step 1, multidimensional correlation analysis is performed on the medicinal piece data set, an initial quality deviation risk value is generated by calculating the correlation degree between planting environment data and finished product characteristics; Step 2, the surface image of the decoction piece is divided into uniform grid cells, three feature regions are located by segmentation algorithm, respectively, the color transition zone of the edge region of the decoction piece, the texture dense area of the center region and the wrinkle region; a detection point is selected in each feature region, and a polygon is constructed with the three detection points as vertices, including: an adaptive grid division algorithm is used, and the surface of the decoction piece is divided into square grid cells with a side length of 5-8 pixels according to the image resolution; the edge gradient of each grid cell is detected, and the region with a continuous three grid cells and an edge gradient change rate exceeding 50% is marked as a color transition zone; the gray level co-occurrence matrix analysis is performed on the center region grid, and the adjacent grids with a texture contrast greater than a set threshold are clustered as a texture dense area; the morphological dilation operation is used to connect the broken wrinkle features, and the continuous region with a curvature change rate exceeding 30% is identified as a wrinkle region; the final detection point position is determined by expanding 2 grid units outward from the geometric center point of the three feature regions respectively; a reference line is established by extending 3 pixels along the edge tangent direction at the color transition zone detection point, and the midpoint of the reference line is selected as the first vertex; the main texture direction is calculated at the texture dense area detection point, and the second vertex is determined by moving a distance equivalent to 1 / 2 of the texture period along the main texture direction; the symmetry axis is identified at the wrinkle region detection point, and the intersection of the symmetry axis and the wrinkle edge is selected as the third vertex; the first vertex, the second vertex and the third vertex are connected in a clockwise direction to form a triangle, and the internal angle distribution of the triangle is calculated as the morphological feature reference. Specifically, the edge tangent direction is determined, the tangent direction of the edge at the color transition zone detection point is identified by using an edge detection operator, 3 pixels are extended to both sides along the tangent direction to form a reference line with a length of 6 pixels, the tangent direction is θ, and the extended point coordinates are (x±3cosθ, y±3sinθ). The midpoint of the reference line after extending 3 pixels along the tangent direction is taken as the first vertex. The edge tangent direction is taken as the reference, the first vertex is located on the main gradient direction of the color transition zone, which is convenient for subsequent extraction of color gradient change data along the edge; the main texture direction is calculated, a 5*5 pixel neighborhood is selected around the texture dense area detection point, the direction with the maximum energy or correlation calculated by the gray level co-occurrence matrix is taken as the main texture direction, the interval distance of repeated gray value changes is counted by scanning the neighborhood pixels along the main texture direction, which is taken as the texture period, and the second vertex position is determined by moving T / 2 distance from the detection point to one side along the main texture direction. The vertex is located based on the periodic feature of the texture, so that the second vertex is located at the position with the most significant texture change, which is convenient for extracting texture direction consistency data; the symmetry axis is identified, the symmetry axis of the wrinkle is determined by using a morphological skeleton extraction algorithm or a curvature extreme point connection line around the wrinkle region detection point, the symmetry axis is extended to both sides, intersects with the edge profile of the wrinkle region, and the intersection point far from the detection point is taken as the third vertex. The symmetry axis and the edge intersection point are used to locate the vertex, which ensures that the third vertex reflects the symmetry feature of the wrinkle structure, which is convenient for subsequent analysis of structure symmetry data;The three vertices were arranged in clockwise direction to form a closed triangle, and the inner angles of the triangle were calculated by using the vector cross product. The degrees and distribution of the three inner angles were recorded as the geometric characteristic reference of the medicinal material shape, and the shape symmetry and structure characteristics of the medicinal material were quantified by the distribution of the triangle inner angles. Step 3, based on the polygon vertex distribution, the color and luster gradient change data is extracted from the color and luster transition zone detection points in the edge area, the texture direction consistency data is extracted from the texture dense area detection points in the center area, and the structure symmetry data is extracted from the wrinkle area detection points, including: collecting the HSV color space values along the polygon edge line direction at the color and luster transition zone detection points with a step of 1 pixel, calculating the standard deviation of the hue angle difference value between adjacent pixels as the gradient change data; extracting the 8-direction Gabor filter response at the texture dense area detection points, and calculating the area proportion of the region where the main response direction accounts for more than 70% as the direction consistency data; mirror sampling is performed along the polygon symmetry axis at the wrinkle area detection points, and the matching degree of the number and distribution interval of curvature extreme points on both sides is calculated as the structure symmetry data; Step 4, the color and luster gradient change data is compared with the preset standard color and luster gradient threshold to generate a first difference degree index, the texture direction consistency data is compared with the texture direction distribution range of the historical qualified batches to generate a second difference degree index, and the structure symmetry data is compared with the pharmacopoeia form standard to generate a third difference degree index, including: sliding window matching is performed on the color and luster gradient change data and the standard threshold, and the cumulative length proportion of the data points exceeding the threshold in the window is calculated as the first difference degree; a direction distribution probability model of the qualified batches is established for the texture direction consistency data, and the deviation degree between the current data distribution and the model is calculated by using the KL divergence as the second difference degree; the structure symmetry data is mapped into the topological structure described in the pharmacopoeia form standard, and the matching error of the node corresponding relationship is calculated by a graph matching algorithm as the third difference degree; Step 5, based on the first difference degree index, the second difference degree index and the third difference degree index, the initial quality deviation risk value is combined to calculate a quality evaluation value, and according to the interval matching relationship between the quality evaluation value and the preset risk threshold, a quality grade judgment result of the medicinal piece is obtained.
2. The big data-based traditional Chinese medicine decoction piece quality evaluation method according to claim 1, characterized in that, The medicinal piece data set is soil heavy metal content detection data and pesticide residue screening data of medicinal plant planting link, medicinal piece surface image, and medicinal piece surface color and texture feature data.
3. The big data-based traditional Chinese medicine decoction piece quality evaluation method according to claim 2, characterized in that, Step 1, multidimensional correlation analysis is performed on the medicinal piece data set, an initial quality deviation risk value is generated by calculating the correlation degree between planting environment data and finished product characteristics, including: Step 11, the soil heavy metal content detection data is classified according to arsenic, cadmium and lead elements to establish a concentration vector, and the pesticide residue screening data is classified according to organophosphorus and pyrethroid compound categories to establish a residue vector; the medicinal piece surface color feature is quantified into a three-dimensional vector composed of hue angle, brightness value and saturation value through an HSV color space; Step 12, cross-dimensional correlation analysis is performed on the concentration vector and the residue vector and the three-dimensional vector, that is, the correlation coefficient matrix of each element of the heavy metal concentration vector and the hue angle dimension is calculated, and the correlation coefficient matrix of each compound of the pesticide residue vector and the brightness value dimension is calculated. Step 13, extract the correlation items with absolute correlation coefficient greater than 0.3, establish the hue pollution influence factor according to the positive or negative characteristics of heavy metal-hue correlation, and establish the lightness attenuation factor according to the pesticide-lightness relationship; calculate the hue shift and lightness attenuation according to the actual detected heavy metal concentration and pesticide residue and the corresponding hue pollution influence factor and lightness attenuation factor; Step 14, calculate the standard deviation multiple of the hue shift outside the color phase distribution interval of the qualified sample as the first risk component, and the part of the lightness attenuation exceeding the historical normal attenuation rate curve by 30% as the second risk component, and perform entropy value weighting fusion on the first risk component and the second risk component to generate an initial quality deviation risk value.
4. The big data-based traditional Chinese medicine decoction piece quality evaluation method according to claim 3, characterized in that, Step 5, based on the first difference index, the second difference index and the third difference index, and combined with the initial quality deviation risk value, calculate the quality evaluation value, including: Establish a three-layer neural network model, the first difference, the second difference and the third difference as input layer nodes, and the initial quality deviation risk value as the bias term; The hidden layer adopts Sigmoid activation function for nonlinear transformation, and the output layer generates a quality evaluation value in the interval of 0-1 through weighted summation, wherein the weight coefficients of the difference indexes are determined through back propagation training of historical samples.
5. The big data-based traditional Chinese medicine decoction piece quality evaluation method according to claim 4, characterized in that, According to the interval matching relationship between the quality evaluation value and the preset risk threshold value, the quality grade determination result of the traditional Chinese medicine decoction pieces is obtained, including: Three preset risk threshold intervals, when the quality evaluation value is less than 0.25, it is determined as a first-class high-quality product, in the interval of 0.25-0.6, it is determined as a second-class qualified product, and greater than 0.6 is determined as a third-class defective product; for the samples within the interval critical value ±0.03 range, start the review mechanism, recalculate the evaluation value by increasing the number of feature area detection points, and take the average value of the two calculation results as the final determination basis.
Citation Information
Patent Citations
Method and system for evaluating harm of pesticide residue and heavy metal pollution to Chinese wolfberry
CN119993308A
Intelligent screening method and system for traditional Chinese medicine decoction pieces
CN120352592A