Traditional Chinese medicine decoction piece quality evaluation method based on big data
Through multi-dimensional correlation analysis and image feature area division, the color gradient, texture direction consistency and structural symmetry data of Chinese herbal medicines were extracted to generate differences indicators, which solved the problem of environmental risks and finished product quality separation in the quality assessment of Chinese herbal medicines, and achieved efficient and accurate quality assessment.
Patent Information
- Application Number
- CN202511076825.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-01
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2045-08-01
AI Technical Summary
The quality evaluation methods of traditional Chinese herbal medicines in the prior art have poor correlation between environmental data and finished product characteristics, and have not built a multi-dimensional dynamic risk prediction mechanism. Image feature extraction is limited to a single area, and the quality evaluation indicators lack hierarchical fusion, which is difficult to reflect the overall coordination of the morphology of the decoction.
Through multi-dimensional correlation analysis of planting environment data and finished product trait characteristics, dividing the decoction image into grid units and positioning the characteristic areas, extracting color gradient, texture direction consistency and structural symmetry data, generating differences indexes, and combining with neural network models for comprehensive quality evaluation.
It has achieved accurate quantification of environmental risks and finished product quality, improved early warning capabilities for quality deviation risks, reduced the rate of misjudgment, and improved the comprehensiveness and accuracy of the evaluation.
Smart Images

Figure CN120579901A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method for evaluating the quality of Chinese herbal medicine slices based on big data. Background Art
[0002] Currently, the industry's quality assessment of TCM slices primarily relies on manual judgment combined with some physical and chemical testing, such as observation of appearance (color, texture, morphology), microscopic identification, and chemical composition analysis. However, while some studies have attempted to incorporate computer vision or big data technologies, such as analyzing the color of slices using color histograms or using texture feature classification algorithms for initial quality screening, some still face the following issues: For example, the correlation modeling between environmental data and finished product characteristics is not detailed 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 relationship between multiple feature areas has not been constructed, making it difficult to reflect the overall coordination of the medicinal material morphology; quality assessment indicators lack hierarchical integration, and fail to effectively integrate the combined impact of environmental risks and real-time detection data. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method for evaluating the quality of Chinese herbal medicine slices based on big data, which can improve the accuracy of the evaluation.
[0004] In order to solve the above technical problems, the technical solutions of the present invention are as follows: In a first aspect, a method for evaluating the quality of Chinese herbal medicine slices based on big data is provided, the method comprising: Step 1: Perform multi-dimensional correlation analysis on the medicinal slice data set, and generate an initial quality deviation risk value by calculating the correlation between the planting environment data and the finished product characteristics; Step 2: Divide the surface image of the medicinal piece into uniform grid units, and locate three characteristic regions using a segmentation algorithm: the color transition zone at the edge of the medicinal piece, the texture-intensive area in the center, and the wrinkle area; select a detection point in each characteristic region, and construct a polygon with the three detection points as vertices; Step 3: Based on the polygon vertex distribution, extract the color gradient change data from the color transition zone detection points in the edge area, extract the texture direction consistency data from the texture dense area detection points in the center area, and extract the structural symmetry data from the wrinkle area detection points; Step 4: Compare the color gradient change data with the preset standard color gradient threshold to generate a first difference index, compare the texture direction consistency data with the texture direction distribution range of historical qualified batches to generate a second difference index, and compare the structural symmetry data with the pharmacopoeial morphological standard to generate a third difference index; Step 5: Based on the first difference index, the second difference index and the third difference index, combined with the initial quality deviation risk value, calculate the quality assessment value, and obtain the quality grade judgment result of the Chinese herbal medicine slices according to the interval matching relationship between the quality assessment value and the preset risk threshold.
[0005] The above solution of the present invention includes at least the following beneficial effects: By modeling the correlation between planting environment data (heavy metals, pesticide residues) and finished medicinal material properties (color, texture, and morphology), the potential impact of environmental factors on quality characteristics is quantified, solving the problem of the separation between environmental risks and finished product quality in traditional methods and improving the early warning capability of quality deviation risks.
[0006] Based on image grid division and feature area positioning technology, the local features of the edge color transition zone, the central texture dense area and the wrinkle area are jointly analyzed, and spatial correlation analysis is realized through polygon vertex construction, which overcomes the limitations of single area detection and significantly improves the comprehensiveness and accuracy of morphological evaluation.
[0007] Through a differentiated comparison mechanism of preset standards, historical data distribution and pharmacopoeial morphological standards, difference indices of color gradient, texture direction consistency and structural symmetry are generated respectively. Combined with sliding window matching, KL divergence and graph matching algorithms, dynamic threshold adaptability and accurate quantification of multi-dimensional deviations are achieved.
[0008] Environmental risk values are weighted and fused with multi-dimensional difference indicators using the entropy method. A comprehensive quality assessment is generated through a neural network model, effectively integrating environmental factors with real-time test data, reducing reliance on manual experience and reducing the repeatability of judgment results. By comparing the dynamic distribution range of historical qualified batch data and dividing risk threshold intervals, it can automatically adapt to the natural characteristic variations of medicinal pieces from different origins and batches, reducing the error rate. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 The present invention provides a flowchart of a method for evaluating the quality of Chinese herbal medicine slices based on big data.
[0010] Figure 2 This is a flow chart of step 1 in a method for evaluating the quality of Chinese herbal medicine slices based on big data provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0011] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0012] like Figure 1 As shown, an embodiment of the present invention proposes a method for evaluating the quality of Chinese herbal medicine slices based on big data, the method comprising the following steps: Step 1: Perform multi-dimensional correlation analysis on the medicinal slice dataset, and generate an initial quality deviation risk value by calculating the correlation between the planting environment data and the finished product characteristics. The medicinal slice dataset includes soil heavy metal content detection data and pesticide residue screening data of Chinese medicinal materials during the Chinese medicinal plant planting process, medicinal slice surface images, and medicinal slice surface color and texture feature data. Step 2: Divide the surface image of the medicinal piece into uniform grid units, and locate three characteristic regions using a segmentation algorithm: the color transition zone at the edge of the medicinal piece, the texture-intensive area in the center, and the wrinkle area; select a detection point in each characteristic region, and construct a polygon with the three detection points as vertices; Step 3: Based on the polygon vertex distribution, extract the color gradient change data from the color transition zone detection points in the edge area, extract the texture direction consistency data from the texture dense area detection points in the center area, and extract the structural symmetry data from the wrinkle area detection points; Step 4: Compare the color gradient change data with the preset standard color gradient threshold to generate a first difference index, compare the texture direction consistency data with the texture direction distribution range of historical qualified batches to generate a second difference index, and compare the structural symmetry data with the pharmacopoeial morphological standard to generate a third difference index; Step 5: Based on the first difference index, the second difference index and the third difference index, combined with the initial quality deviation risk value, calculate the quality assessment value, and obtain the quality grade judgment result of the Chinese herbal medicine slices according to the interval matching relationship between the quality assessment value and the preset risk threshold.
[0013] In this embodiment of the present invention, the system integrates cultivation environment data (heavy metals in soil, pesticide residues) with finished product characteristics (surface image, color and texture) to identify quality-influencing factors throughout the entire supply chain (from source cultivation to finished product processing), overcoming the limitations of single-dimensional assessment. By meshing the image and locating characteristic regions (edge color transition zones, central texture-intensive areas, and wrinkled areas), the system combines multi-dimensional data on color, texture, and structure to cover key assessment indicators for the appearance quality of medicinal slices, avoiding omissions of core quality features. An "initial quality deviation risk value" is generated through correlation calculation, digitizing the cultivation environment risk. Combined with difference indicators (color gradient, texture consistency, and structural symmetry), the system achieves a quantitative derivation from "data-indicator-risk," reducing the subjectivity of manual assessments. Comparisons to preset thresholds (such as standard color gradient, historical qualified texture distribution, and pharmacopoeial morphological standards) make the assessment results traceable and verifiable, meeting the requirements of standardized quality control. Specific regions (such as edge color transition zones) are located through meshing and segmentation algorithms, avoiding redundancy in global analysis and improving detection efficiency. Structured feature point data is extracted using polygonal modeling, providing standardized input for subsequent algorithms. Abstract quality attributes such as color, texture, and structure are converted into quantifiable data such as gradient changes, directional consistency, and symmetry, making it easier to visually display quality differences through charts or models, assisting quality inspectors in quickly locating problems. A comprehensive quality assessment value is calculated by combining the initial risk value with the difference index, and quality levels are divided into qualified, warning, and unqualified levels using preset threshold intervals to implement risk classification management, facilitating targeted quality improvement measures (such as tracing the planting environment and adjusting processing technology). Correlation analysis between planting environment data and finished product characteristics provides data support for tracing the source of quality issues (e.g., excessive heavy metal content can be traced back to soil contamination, and texture anomalies can be associated with processing defects), helping to build a quality traceability system with "traceable sources and traceable destinations."
[0014] like Figure 2 As shown, in another preferred embodiment of the present invention, step 1, performing multi-dimensional correlation analysis on the medicinal slice data set, and generating an initial quality deviation risk value by calculating the correlation between the planting environment data and the finished product characteristics, includes: Step 11: Concentration vectors are established for soil heavy metal content detection data according to the categories of arsenic, cadmium, and lead elements, and residue vectors are established for pesticide residue screening data according to the categories of organophosphorus and pyrethroid compounds; the surface color characteristics of the medicinal slices are quantified into a three-dimensional vector consisting of hue angle, lightness value, and saturation value using the HSV color space; Step 12: Perform cross-dimensional correlation analysis on the concentration vector and the residue vector with the three-dimensional vector, i.e., calculate the correlation coefficient matrix between each element of the heavy metal concentration vector and the hue angle dimension, and the correlation coefficient matrix between each compound of the pesticide residue vector and the lightness value dimension; Step 13: extracting correlation items with an absolute value of a correlation coefficient greater than 0.3, establishing a hue pollution influencing factor based on the positive or negative characteristics of the heavy metal-hue relationship, and establishing a brightness attenuation factor based on the pesticide-brightness relationship; and calculating the hue shift and brightness attenuation based on the actual detected heavy metal concentration and pesticide residue and the corresponding hue pollution influencing factor and brightness attenuation factor; Step 14: Calculate the standard deviation multiple of the hue offset outside the hue distribution range of qualified samples as the first risk component, and the part of the brightness attenuation that exceeds 30% of the historical normal attenuation rate curve as the second risk component. Perform entropy weighted fusion on the first risk component and the second risk component to generate an initial quality deviation risk value.
[0015] In the embodiment of the present invention, when it is specifically applied, the specific implementation process of the above step 11 is as follows: Heavy metal concentration vector, which arranges the detection concentration values of arsenic, cadmium, and lead in the soil in the order of sample batches or detection points to form a one-dimensional numerical vector (such as [As concentration 1, Cd concentration 1, Pb concentration 1, As concentration 2, …]).
[0016] Pesticide residue vector, the residue detection values of organophosphates and pyrethroids are arranged by compound category and sample order to form a one-dimensional numerical vector (such as [organophosphate 1 residue, pyrethroid 1 residue, organophosphate 2 residue, ...]).
[0017] Color three-dimensional vector: for each pixel or area of the surface image of the medicinal material, the hue angle (H), lightness value (V), and saturation value (S) of the HSV color space are extracted, and integrated into a three-dimensional vector (such as [H1, V1, S1, H2, V2, S2, ...]) according to the pixel position or regional mean. By converting multi-source heterogeneous data (heavy metals, pesticide residues, color) into standardized vectors, the conversion from "qualitative description" to "quantitative data" can be achieved.
[0018] When applied in practice, the above step 12 is implemented as follows: Heavy metal-color correlation: each element in the heavy metal concentration vector (such as As concentration) is matched sample by sample with the hue angle dimension (H) in the color vector, and the correlation coefficient between the two is calculated (such as reflecting the synchronization of concentration changes and hue changes), forming a "heavy metal-hue" correlation coefficient matrix (each row corresponds to a heavy metal element, and each column corresponds to a hue angle data point).
[0019] Pesticide-brightness correlation: each compound in the pesticide residue vector (such as organophosphorus) is matched sample by sample with the brightness value dimension (V) in the color vector, and the correlation coefficient is calculated to form a "pesticide-brightness" correlation coefficient matrix (each row corresponds to a pesticide category, and each column corresponds to a brightness value data point).
[0020] The present invention quantifies the correlation between pollutants in the planting environment and the color characteristics of medicinal pieces to identify key factors affecting quality (such as whether an increase in the concentration of a certain heavy metal directly leads to abnormal hue), thereby avoiding subjective judgment.
[0021] When applied in practice, the above step 13 is specifically implemented as follows: Traverse the correlation coefficient matrix and read the values in the "heavy metal-hue" and "pesticide-lightness" correlation coefficient matrices row by row (element / compound) and column by column (color dimension) (such as the correlation coefficient between As concentration and H, and the correlation coefficient between organophosphorus residue and V).
[0022] Threshold filtering was performed to retain coefficient items with absolute values ≥ 0.3 (e.g., correlation coefficients of -0.4, 0.5, etc.), and to eliminate weak correlation items with absolute values < 0.3 (e.g., 0.2, -0.1).
[0023] Mark the direction of the association and record the positive and negative signs of the retained items (positive correlation indicates synchronous increase and decrease, and negative correlation indicates reverse change). For example: if the correlation coefficient between Cd concentration and H is +0.35, mark it as "Cd concentration↑→H↑" (positive correlation); if the correlation coefficient between pyrethroid residue and V is -0.4, mark it as "residue↑→V↓" (negative correlation). Redundant associations are filtered out through statistical thresholds, focusing on environmental factors that have a substantial impact on the color of medicinal materials, thereby reducing invalid calculations.
[0024] Based on the absolute value of the correlation coefficient, it is proportionally mapped to a weight in the range of 0-1 (for example, the absolute value of the correlation coefficient is 0.3, which corresponds to a factor of 0.3, 0.5 to 0.5, and 1 to 1). Positive correlation (such as a coefficient of +0.4): the factor is positive, indicating that an increase in heavy metal concentration will cause the hue angle to shift in a certain direction (such as redder); negative correlation (such as a coefficient of -0.4): the factor is negative, indicating that an increase in concentration will cause the hue angle to shift in the opposite direction (such as greener).
[0025] Example: The correlation coefficient between As concentration and H is -0.4 → the factor is assigned to -0.4; the correlation coefficient between Pb concentration and H is +0.5 → the factor is assigned to +0.5.
[0026] Brightness attenuation factor (for pesticide-brightness correlation): Assignment rules: The factor baseline value is based on the absolute value of the correlation coefficient and is proportionally mapped to a rate value in the range of 0-1 (for example, an absolute value of the correlation coefficient of 0.3 corresponds to a decay rate of 30% / unit concentration, and 0.6 corresponds to 60% / unit concentration).
[0027] Direction correction: Positive correlation (e.g., a coefficient of +0.3): indicates that the higher the pesticide residue, the faster the brightness decreases (a positive factor, such as +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, because pesticide residue generally causes darker colors and reduced brightness, so a positive correlation is assumed by default).
[0028] Example: The correlation coefficient between organophosphorus residue and V is +0.5 → the factor value is assigned to +0.5 (i.e., each unit of residue causes a 0.5 unit decrease in brightness), which converts the abstract correlation into a calculable impact weight and quantifies the mapping relationship between "pollution degree-color change".
[0029] Before calculating the offset, normalize the measured heavy metal concentration and the color pollution impact factor to ensure that their dimensions are consistent. The specific steps are as follows: Find the maximum and minimum values of all measured heavy metal concentrations and the maximum and minimum values of the hue pollution influencing factors, and normalize the measured heavy metal concentrations and the hue pollution influencing factors.
[0030] Normalization is performed to each measured heavy metal concentration and the corresponding hue pollution influencing factor, respectively, to obtain new normalized concentration values and factor values.
[0031] For each strongly correlated heavy metal element (such as As and Pb), its normalized concentration was multiplied by the corresponding normalized impact factor (such as normalized As concentration 0.6 × normalization factor -0.4 = -0.24).
[0032] The product results of all strongly correlated elements are accumulated to obtain the comprehensive offset (e.g., As contribution -0.24, Pb contribution +0.3 → total offset +0.06). A positive value indicates that the hue angle is offset to the right of the reference value (e.g., redder), and a negative value indicates that it is offset to the left (e.g., greener). The larger the absolute value, the more obvious the deviation from the normal color.
[0033] Calculation of brightness attenuation: For each strongly correlated pesticide compound (such as organophosphorus and pyrethroids), multiply its residue (unit: mg / kg) by the corresponding attenuation factor (such as organophosphorus residue 3.0 mg / kg × factor + 0.5 = +1.5), and add up the product results of all strongly correlated compounds to obtain the comprehensive attenuation (such as organophosphorus contribution +1.5, pyrethroid contribution +1.2 → total attenuation +2.7). A positive value indicates the degree of decrease in brightness compared with the baseline value (such as the baseline brightness is 50, the attenuation of 2.7 means the measured brightness is 47.3). The larger the value, the darker the color.
[0034] Through normalization processing, the problem of inconsistent units between measured heavy metal concentrations and influencing factors is solved, calculation deviations caused by dimensional differences are avoided, and the offset calculation results are made more accurate and comparable. The normalized data distribution is more balanced, which is conducive to the stable operation of subsequent risk assessment models, reduces the interference of extreme values on the assessment results, and improves the generalization ability of the model. After unifying the dimensions, the contribution of each influencing factor to the offset is clearer, which facilitates accurate judgment of the actual impact of different pollution sources on the quality of medicinal materials, and provides a more reliable decision-making basis for quality control.
[0035] The present invention focuses on strong correlation factors and quantifies the specific impact of pollutants on the appearance of medicinal pieces (such as the degree of yellowish hue caused by arsenic contamination), providing a traceable causal relationship basis for quality risks and facilitating targeted control of pollution sources.
[0036] When applied in practice, the above step 14 is implemented as follows: The first risk component is to calculate the hue angle distribution interval of qualified samples (such as mean ± standard deviation) and calculate the standard deviation multiple of the current sample hue offset exceeding the interval (such as the offset is twice the standard deviation of the qualified samples, then the risk component is 2).
[0037] The second risk component is to establish a "normal brightness decay rate curve" based on historical data (such as the brightness change trend with storage time or processing steps), and calculate the part of the current brightness decay that exceeds 30% of the curve (such as the normal decay is 10%, the measured decay is 15%, then the risk component is 5%).
[0038] Entropy method weighted fusion, the entropy method is used to calculate the weights of the two risk components (the weights reflect the uncertainty of the data, the smaller the entropy value, the higher the weight), and the components are superimposed according to the weights to generate a comprehensive "initial quality deviation risk value".
[0039] This invention converts abstract risks into quantifiable values (e.g., a higher risk value indicates a greater probability of quality problems), facilitates hierarchical management (e.g., setting thresholds to distinguish between low, medium, and high risks), and uses the entropy method to avoid the subjectivity of manual weighting. It automatically assigns weights based on the characteristics of the data itself, thereby improving the credibility of risk values.
[0040] In a preferred embodiment of the present invention, step 2 is to divide the surface image of the slice into uniform grid units, and locate three characteristic areas by a segmentation algorithm, namely, the color transition zone of the edge area of the slice, the texture-intensive area in the center area, and the wrinkle area, including: Adaptive grid partitioning algorithm is used to divide the surface of the slices into square grid units with a side length of 5-8 pixels according to the image resolution; Perform edge gradient detection on each grid cell, and mark the area where the edge gradient change rate exceeds 50% within three consecutive grid cells as a color transition zone; Gray-level co-occurrence matrix analysis is performed on the grids in the central area, and adjacent grids with texture contrast greater than a set threshold are clustered as texture-dense areas; The fracture and wrinkle features were connected through morphological dilation operations, and the continuous areas with a curvature change rate of more than 30% were identified as wrinkle areas. The final detection point position was determined by expanding two grid units outward from the geometric center points of the three feature areas.
[0041] In the embodiment of the present invention, the pixel size of the surface image of the slice is obtained (e.g., width × height = 1000 × 800 pixels). If the resolution is ≥ 800 × 600 pixels, the grid side length is set to 5-6 pixels (e.g., 5 pixels), ensuring that each grid corresponds to about 0.1-0.2 mm of the slice surface. 2 area; if the resolution is less than 800×600 pixels, set the side length to 7-8 pixels (e.g., 8 pixels) to avoid feature loss due to too small a grid; starting from the upper left corner of the image, divide the image into non-overlapping square grids in row priority order until the entire image is covered (e.g., a 1000×800 pixel image is divided into 200×160 5×5 pixel grids). Dynamically adjust the grid density according to the image clarity to ensure consistent feature analysis accuracy for images of different resolutions and avoid missing details due to too large a grid or introducing noise due to too small a grid.
[0042] For each grid unit, an edge detection operator (such as the Sobel operator) is used to calculate the pixel grayscale gradient value, and the mean gradient within the grid is taken as the "edge gradient value" of the grid. For each row and column of adjacent grids, the rate of change of the gradient value between the latter grid and the previous grid is calculated. If the rate of change of three consecutive grids is greater than 50% (such as the rate of change of grids n, n+1, and n+2 are 60%, 55%, and 58% respectively), then these three grids are marked as "color transition zones" (usually corresponding to the color gradient area at the edge of the medicinal piece). The color mutation area is quantified by the gradient change rate, and the transition zone at the edge of the medicinal piece (such as the color difference caused by drying at the edge of the slice) is accurately located to avoid the ambiguity of manual visual judgment.
[0043] The central area is delineated by dividing the image into nine grids, and the central grid is taken as the "central area" (for example, the central grid of a 1000×800 image is 400-600 rows and 300-500 columns). For each grid in the central area, the "contrast" feature of the grayscale co-occurrence matrix (reflecting the intensity of the light and dark changes in the texture) is calculated, and a contrast threshold is set (such as an empirical value of 80). The areas in adjacent grids with a contrast greater than the threshold are merged to form a "texture-intensive area" (such as the texture concentration area in the center of the medicinal piece due to the dense cell structure). The grayscale co-occurrence matrix is used to quantify the texture complexity, and the characteristic texture area in the center of the medicinal piece is quickly located through threshold clustering, providing a target area for subsequent texture direction analysis.
[0044] The image is dilated (using a 3×3 circular structure element), the broken wrinkle edge pixels are connected, and the continuous areas are enhanced. For each pixel, the curvature value is calculated by fitting a local quadratic curve (the larger the curvature, the more obvious the wrinkles), and the curvature change rate of adjacent pixels is calculated (such as the difference ratio between the current pixel curvature and the neighborhood average curvature). If the change rate in the continuous area is greater than 30% and the number of pixels is ≥5, it is marked as a "wrinkle area" (such as wrinkles formed by drying and shrinkage of medicinal materials). The broken features are repaired through morphological operations, and the wrinkle area is accurately identified in combination with the curvature change rate to avoid false detection due to image noise.
[0045] For each characteristic area (transition zone, texture-intensive area, wrinkle area), calculate the coordinate mean of all grids to obtain the center of mass of the area. With the center of mass as the center, expand 2 grid units in all directions (for example, if the original grid side length is 5 pixels, the expansion range is 10 pixels). Take the center of the expanded area as the final detection point (make sure the detection point is located in the core position of the characteristic area). By expanding the center of mass, avoid the detection point being located at the edge of the area or at a noise point, ensure that the extracted color, texture, and structure data are representative of the region, and reduce accidental errors.
[0046] Based on the gradient change rate to quantify the edge color mutation, it is suitable for edge quality detection of different medicinal materials (such as whether the edge of the slice has abnormal color due to overheating during processing). Through GLCM contrast clustering, it can quickly lock the characteristic texture area in the center of the medicinal material (such as the texture density of the woody part of root medicinal materials), and assist in authenticity identification. Combined with morphological and curvature analysis, it can effectively identify the structural wrinkles generated during drying and storage, and evaluate the rationality of the processing technology (such as whether the drying temperature causes excessive shrinkage of the medicinal material). The geometric center expansion positioning ensures that the position of the detection point is fixed, and the feature extraction position of different batches of images is consistent, which improves data comparability (for example, the detection points of different samples of the same medicinal material are all located in the center of the texture-dense area). Automated grid division and area detection replace manual labeling. The time consumption of single image analysis can be controlled in seconds, which is suitable for large-scale rapid quality inspection of medicinal materials.
[0047] In a preferred embodiment of the present invention, a detection point is selected in each feature area, and a polygon is constructed with three detection points as vertices, including: At the color transition zone detection point, extend 3 pixels along the edge tangent direction to establish a baseline, and select the midpoint of the baseline as the first vertex; Calculate the main texture direction at the detection point in the texture dense area, and move the distance of 1 / 2 of the texture period along the main texture direction to determine the second vertex; Identify the symmetry axis at the detection point of the wrinkle area, and select the intersection of the symmetry axis and the wrinkle edge as the third vertex; Connect the first vertex, the second vertex, and the third vertex in a clockwise direction to form a triangle, and calculate the internal angle distribution of the triangle as a morphological feature benchmark.
[0048] In an embodiment of the present invention, the direction of the edge tangent is determined. At the detection point of the color transition zone (the position after the centroid is expanded), the tangent direction of the edge where the point is located is identified by an edge detection operator (such as the Canny operator) (such as the angle between the tangent and the horizontal axis is θ), and 3 pixels are extended to both sides along the tangent direction to form a baseline with a length of 6 pixels (such as the detection point coordinates are (x, y), the tangent direction is θ, then the extension point coordinates are (x±3cosθ, y±3sinθ)), and the midpoint of the baseline is taken as the first vertex (the midpoint after the coordinates (x, y) are extended 3 pixels along the tangent direction, that is, the original detection point position). Using the edge tangent direction as a reference, ensure that the first vertex is located in the main gradient direction of the color transition zone, so as to facilitate the subsequent extraction of color gradient change data along the edge.
[0049] To calculate the main texture direction, a 5×5 pixel neighborhood is selected around the detection point in the texture-dense area, and the direction with the largest "energy" or "correlation" is calculated through the gray-level co-occurrence matrix (GLCM), which is used as the main texture direction (such as horizontal, vertical or diagonal direction). The neighborhood pixels are scanned along the main texture direction, and the interval distance of repeated changes in grayscale values is counted as the texture period (such as the spacing between adjacent texture units is T pixels). The detection point is moved to one side by a distance of T / 2 along the main texture direction (such as the main texture direction is horizontal to the right, the period T, = 8 pixels, then move 4 pixels), and the second vertex position is determined. The vertex is positioned based on the texture periodicity feature, so that the second vertex is located at the position where the texture change is most significant (such as the center or edge of the texture unit), which facilitates the extraction of texture direction consistency data.
[0050] Symmetry axis identification: Around the detection point of the wrinkle area, the symmetry axis of the wrinkle (such as the central axis along the longest direction of the wrinkle) is determined through morphological skeleton extraction algorithm or connecting curvature extreme points. The symmetry axis is extended to both sides and intersects with the edge contour of the wrinkle area. The intersection point farther away from the detection point is taken as the third vertex (such as the intersection point of the symmetry axis with the left and right edges of the fold, the right intersection point is selected). The vertex is located at the intersection of the symmetry axis and the edge to ensure that the third vertex reflects the symmetry characteristics of the wrinkle structure, which is convenient for subsequent analysis of the structural symmetry data.
[0051] Arrange three vertices in a clockwise direction: the first vertex (color transition zone) → the second vertex (texture-dense area) → the third vertex (wrinkle area) → the first vertex to form a closed triangle. Use the vector cross product to calculate the internal angles of the triangle (such as the internal angles corresponding to 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 maximum angle and the minimum angle, whether it is an isosceles triangle, etc.) as the geometric feature benchmark of the medicinal piece's morphology. Quantify the morphological symmetry and structural characteristics of the medicinal piece through the distribution of the triangle's internal angles. For example: the normal medicinal piece's triangle internal angle distribution is relatively uniform (such as each angle is about 60°); processed deformed medicinal pieces may have abnormal angles (such as an angle > 90°, reflecting abnormal edge or wrinkle structure).
[0052] The characteristic points of the three dimensions of color (edge transition zone), texture (central dense area), and structure (folds) are linked through geometric shapes (triangles) to form a three-dimensional evaluation model of "position-feature-morphology". For example, a triangle with an excessively long side may reflect an abnormal expansion of the edge color transition zone, while a triangle with an excessively small angle may correspond to excessively compact structure in the fold area. The internal angle distribution converts abstract morphological features into comparable numerical indicators (such as angle deviation thresholds), making it easier for computers to automatically determine whether medicinal pieces meet morphological standards (such as shape descriptions specified in pharmacopoeias) and quickly identify defects in the medicinal piece cutting process (such as uneven slice thickness causing texture vertex offset, and excessively high drying temperatures causing abnormal angles of wrinkle vertices).
[0053] The triangle construction rules are unified (clockwise order, vertex positioning logic) to ensure the comparability of the morphological characteristics of medicinal pieces from different batches and varieties. The positions of the triangle vertices are bound to the characteristic areas (such as edges, centers, and folds). If the morphological characteristics are abnormal, they can be directly traced back to the quality problems in the corresponding areas (such as the offset of the second vertex reflects the abnormality of the texture-dense area, which may be related to the mixing of medicinal material varieties). The geometric parameters such as the internal angle and side length of the triangle can be directly input into the machine learning model (such as SVM, neural network) as the feature vector of morphological classification, thereby improving the accuracy of automated quality inspection.
[0054] In a preferred embodiment of the present invention, step 3, based on the polygon vertex distribution, extracts color gradient change data from the color transition zone detection points in the edge area, extracts texture direction consistency data from the texture dense area detection points in the center area, and extracts structural symmetry data from the wrinkle area detection points, including: At the color transition zone detection point, along the polygon edge direction, HSV color space values are collected with a step size of 1 pixel, and the standard deviation of the hue angle difference between adjacent pixels is calculated as the gradient change data; Extract the 8-directional Gabor filter responses at the detection points in the texture-dense area, and count the area proportion where the main response direction accounts for more than 70% as the direction consistency data; Mirror sampling is performed along the polygonal symmetry axis at the detection points in the wrinkle area, and the matching degree of the number of curvature extreme points and the distribution spacing of the areas on both sides is calculated as the structural symmetry data.
[0055] In an embodiment of the present invention, a sampling path is defined along the edge of the polygon (e.g., the edge from the first vertex to the second vertex) with the color transition zone detection point (the first vertex) as the starting point. The path length is the edge pixel length (e.g., the edge length is 20 pixels). With a step size of 1 pixel, the HSV color value (hue angle H, lightness V, saturation S) of each pixel on the path is collected to form a sequence (H1, H2, ..., Hn).
[0056] Difference calculation, calculate the hue angle difference of adjacent pixels and obtain a difference sequence.
[0057] Standard deviation calculation: calculate the standard deviation of the difference sequence as the "color gradient change data" (the larger the standard deviation, the more drastic the hue change and the worse the edge color uniformity). By quantifying the spatial variation amplitude of the edge color, it is possible to identify whether there is color unevenness (such as burnt edges or oxidative discoloration) on the edge of the medicinal material due to processing (such as frying, drying) or storage.
[0058] An 11×11 pixel area is selected around the detection point (the second vertex) in the texture-dense area, and the area is convolved using Gabor filters in eight directions (0°, 22.5°, 45°, …, 337.5°) to obtain the response intensity map in each direction.
[0059] Main response direction identification: For each pixel, compare its response values in 8 directions and take the direction with the largest response intensity as the "main texture direction" of the pixel.
[0060] Consistency statistics are performed by counting the number of pixels whose main response direction is consistent with the overall main direction (such as the direction with the largest response intensity in the entire area), and calculating their proportion to the total area of the region (for example, if the main direction is 45°, 85% of the pixels in this direction indicate high consistency in texture direction). Gabor filters are used to simulate the human eye's perception of texture direction and quantify the orderliness of texture arrangement (for example, the duct texture of root medicinal materials should be arranged vertically, and poor consistency may indicate adulteration or abnormal cutting direction).
[0061] Structural symmetry data extraction (wrinkle area), operation process: The symmetry axis is determined by taking the symmetry axis of the polygon where the wrinkle area detection point (the third vertex) is located as the reference line (such as the line connecting the third vertex and the midpoint of the opposite side in a triangle).
[0062] Mirror sampling is performed, and sampling areas are selected equidistantly on both sides of the symmetry axis (such as area A on the left and area B on the right, both 5 pixels away from the symmetry axis), and the curvature extreme points in the area (i.e., the most curved points of the wrinkles) are extracted.
[0063] Matching calculation: Quantity matching: compare the number of curvature extreme points in area A and area B (e.g., A has 8, B has 7, and the difference rate is 12.5%); spacing matching: calculate the spacing difference of the extreme points on both sides in order, and take the weighted average of the quantity difference rate and the spacing difference rate (e.g., 50% each) as the structural symmetry data (the higher the matching degree, the better the symmetry, and the more stable the structure of the medicinal piece). The stability of the physical structure of the medicinal piece is evaluated by the symmetrical distribution of the curvature extreme points (e.g., poor symmetry of wrinkles may be caused by uneven force or uneven drying speed during cutting, affecting the appearance of the medicinal piece and the uniformity of its efficacy).
[0064] Directed sampling is performed along the edges of polygons, focusing on the paths with the most significant edge color changes, avoiding the redundancy of global sampling (such as only analyzing the color transition zone of the cut edge of the medicinal piece, rather than the complete outline). Multi-directional response analysis based on Gabor filters accurately captures the dominant direction of the texture (such as the direction of the veins of leaf-type medicinal pieces), which is more comprehensive than single-direction detection. Mirror sampling is performed based on the polygonal symmetry axis, converting the symmetry evaluation of the fold structure into a quantifiable geometric matching problem, avoiding subjective judgment.
[0065] Color gradient standard deviation can directly correlate with the growing environment (e.g., color deviation caused by heavy metal contamination) or processing techniques (e.g., degree of scorching). Grain direction consistency can reflect the authenticity of the medicinal material (e.g., different grain orientations between varieties) or the cutting process (e.g., differences in grain orientation between horizontal and vertical cuts). Structural symmetry can reveal processing machinery parameters (e.g., slicer blade flatness) or storage conditions (e.g., wrinkling and deformation caused by moisture). Each indicator is based on a clear calculation logic (e.g., standard deviation, ratio, and matching), allowing for industry-standard thresholds (e.g., a color gradient standard deviation >5° is considered abnormal, and texture consistency <70% is considered unqualified), promoting the digitalization of quality inspection standards. Color, texture, and structure data correspond to chemical contamination (Step 1), morphological characteristics (Step 2), and physical structure (Step 3), respectively, forming a three-dimensional quality assessment system based on "environment-appearance-structure," reducing the risk of misjudgment based on a single indicator (e.g., normal color but disordered texture may indicate a mixed variety).
[0066] In a preferred embodiment of the present invention, step 4, comparing the color gradient change data with a preset standard color gradient threshold to generate a first difference index, comparing the texture direction consistency data with the texture direction distribution range of historical qualified batches to generate a second difference index, and comparing the structural symmetry data with the pharmacopoeial morphological standard to generate a third difference index, includes: Perform sliding window matching on the color gradient change data and the standard threshold, and calculate the cumulative duration of the data points in the window exceeding the threshold as the first difference; A directional distribution probability model of qualified batches is established for texture directional consistency data, and the KL divergence is used to measure the deviation between the current data distribution and the model as the second difference; The structural symmetry data is mapped to the topological structure described by the pharmacopoeial morphological standard, and the matching error of the node correspondence is calculated as the third difference degree through the graph matching algorithm.
[0067] In an embodiment of the present invention, a preset standard threshold is determined, and a standard deviation threshold of color gradient change is set based on historical data of qualified medicinal pieces (such as a threshold of 3°, indicating an allowable fluctuation range of hue angle change).
[0068] Sliding window settings: Window length: Take 10 consecutive data points (such as the standard deviation of the hue angle difference of 10 pixels); Sliding step size: 5 data points (move half the window length each time to ensure data overlap).
[0069] Window matching and statistics: Starting from the starting point of the color gradient data sequence, slide each window one by one to check whether the data points in each window exceed the threshold; calculate the proportion of the number of data points exceeding the threshold in each window to the total number of points in the window (for example, if there are 4 points in the window > 3°, the proportion is 40%).
[0070] For difference generation, the average proportion of all sliding windows is taken as the first difference index (for example, if the average is 25%, it means that the abnormal duration of color gradient accounts for 25%). The local anomalies of color gradient are captured dynamically through sliding windows to avoid single global statistics from covering up local defects (such as sudden color changes in a certain area on the edge of the medicinal piece), thereby improving the accuracy of anomaly positioning.
[0071] The second difference index (texture direction comparison), operation process: Historical Qualified Data Modeling: Collect texture direction consistency data of more than 1,000 batches of qualified medicinal pieces, count the frequency of occurrence of each direction (0°, 22.5°...), and construct a probability distribution model (such as a bar chart representing the proportion of each direction).
[0072] The current data distribution calculation is to calculate the texture direction consistency data of the current medicinal material and count the pixel ratios of each main texture direction (e.g. 45° direction accounts for 60%, 90° direction accounts for 30%).
[0073] KL divergence calculation compares the difference between the current distribution and the historical qualified distribution, and calculates the KL divergence value (the smaller the value, the closer the distribution, such as KL = 0.1 means the difference is small, and KL = 0.8 means the difference is significant).
[0074] Difference mapping: Normalize the KL divergence value to the range of 0-100 (for example, KL=0 corresponds to difference 0, and KL=1 corresponds to difference 100). This is used as the second difference indicator to quantify the consistency deviation of texture direction based on the big data probability model. This method can identify subtle texture anomalies (such as the discrete distribution of texture direction caused by the adulteration of a small amount of other varieties of medicinal materials), and is more sensitive than single threshold judgment.
[0075] The third difference index (structural symmetry comparison), operation process: Construction of pharmacopoeial morphological topology: The morphological characteristics of medicinal pieces described in the pharmacopoeia are abstracted into a topological graph, where nodes represent key structural points (e.g., wrinkle vertices, texture centers), and edges represent the spatial relationships between structural points (e.g., distances, angles). For example, the pharmacopoeial standard topological graph for a root-type medicinal piece contains five nodes, with edges representing the relative positions and symmetric relationships between nodes. The current structural data graph is generated, and the structural topological graph of the current medicinal piece is constructed based on the distribution of curvature extreme points in the wrinkle region (nodes represent extreme points, and edges represent the spacing and curvature differences between adjacent points).
[0076] Graph matching algorithm application: Use the maximum common subgraph algorithm to find the node correspondence between the current graph and the pharmacopoeia graph (for example, node A in the pharmacopoeia graph matches node X in the current graph); calculate the spatial relationship error between the matching nodes (such as distance deviation and angle deviation), and take the average error as the matching error (for example, the average distance deviation is 2 pixels, and the angle deviation is 5°).
[0077] Difference generation compares the matching error with the allowable error range (e.g., distance deviation ≤ 3 pixels, angle deviation ≤ 10°). The excess is converted proportionally into a difference (e.g., if the error exceeds 50%, the difference is 50). Through topological map matching, the abstract pharmacopoeial morphological standards are converted into calculable geometric errors, achieving precise mapping of "text description-digital indicators" (e.g., "edge neatness" in the pharmacopoeia corresponds to a matching error ≤ a certain threshold), solving the problem of ambiguous standards in traditional quality inspection.
[0078] In an embodiment of the present invention, the sliding window is combined with the spatial distribution of color gradient to detect both the overall trend and local anomalies (such as a sudden change in color in a certain area at the edge of a medicinal piece due to excessive frying); KL divergence evaluates the statistical distribution difference of texture direction, and graph matching verifies the compliance of structural topology to avoid single-dimensional misjudgment (such as normal texture direction distribution but structural asymmetry may indicate processing deformation). The preset threshold and historical probability model can be directly reused in the quality inspection of medicinal pieces of the same variety, reducing the cost of establishing enterprise quality inspection standards; the difference index can be directly input into the automated quality inspection system to realize unmanned "data collection-analysis-judgment" process (such as real-time detection of unqualified rate of production line), color difference anomalies can be traced back to the planting environment (such as heavy metal pollution) or processing temperature control; texture difference anomalies can indicate variety mixing or wrong cutting direction; structural difference anomalies can be located to the slicing machine accuracy or drying process parameter deviation, and the sliding window size, KL divergence model, and topological map nodes can be flexibly adjusted according to different medicinal piece varieties (such as leaf and root medicinal pieces use different structural topology standards).
[0079] In a preferred embodiment of the present invention, step 5, calculating the quality assessment value based on the first difference index, the second difference index, and the third difference index in combination with the initial quality deviation risk value, includes: A three-layer neural network model was established, with the first difference, second difference, and third difference as input layer nodes, and the initial quality deviation risk value as the bias term; The hidden layer uses the Sigmoid activation function for nonlinear transformation, and the output layer generates a quality assessment value in the range of 0-1 through weighted summation. The weight coefficient of the difference index is determined by back-propagation training of historical samples.
[0080] In an embodiment of the present invention, the neural network model construction operation process is as follows: Input layer settings: Define three input nodes, corresponding to the first difference (D1), the second difference (D2), and the third difference (D3), with a value range of 0-100 (such as D1=25, D2=18, D3=30); introduce the initial quality deviation risk value (R) as a bias term and pass it into the hidden layer together with the input node (the bias term can be understood as an additional input node, and its value is always R).
[0081] Hidden layer calculation: The number of hidden layer nodes is set to 5 (empirical value, which can be adjusted according to the model effect). Each node performs the following operations: Calculate the weighted sum, multiply the input value (D1, D2, D3, R) by the corresponding weight (w1, w2, w3, b), and sum them to obtain the weighted sum z; Activation function processing, using the Sigmoid function to process the weighted sum z to convert the weighted sum into a nonlinear output between 0 and 1 (such as σ(z) = 0.7 represents the activation strength of the hidden layer node).
[0082] Output layer calculation: The output layer has 1 node and receives the output values of the five hidden layer nodes. It performs a weighted sum to obtain the sum value Y. The sum value Y is normalized to the range of 0-1 to obtain the final quality assessment value Q (for example, Q = 0.6 indicates medium quality, and the closer Q is to 1, the higher the quality risk).
[0083] Weight training process operation process: Historical sample preparation: Collect more than 5,000 batches of medicinal material samples with complete test data and mark their actual quality levels (such as qualified, warning, and unqualified).
[0084] Backpropagation training: Input the D1, D2, D3 and R values of the sample and calculate the model prediction value Q_pred; calculate the error (such as mean square error MSE) between the predicted value and the actual grade (such as Qtrue=1 for unqualified and Qtrue=0 for qualified); reversely deduce from the output layer and adjust the weights (w1, w2, w3, whi, etc.) of the hidden layer and the output layer to gradually reduce the error (such as setting the learning rate to 0.01 and iterating 1000 times).
[0085] Weight determination: After training is completed, the weight of each difference indicator reflects its contribution to quality assessment (e.g., D1 weight is 0.4, D2 weight is 0.3, and D3 weight is 0.3, indicating that color difference has the greatest impact on quality).
[0086] This invention uses a nonlinear neural network to fuse the planting environment risk (R) and the finished product appearance difference (D1-D3), breaking through the limitations of traditional linear weighting (for example, in a high-risk environment, even small appearance differences may trigger a high assessment value). For example, if the R value of a batch of medicinal slices is high (heavy metal content in the soil exceeds the standard), but D1-D3 are all low, the model may still judge it as high risk due to the influence of the bias term R, avoiding the omission of "normal data but source pollution". The weights are automatically learned through historical data to avoid the subjectivity of manual weighting (for example, traditional methods may overestimate color differences, while the model has found through training that texture differences are more critical for a certain variety). The weights can be dynamically adjusted according to the variety (for example, root medicinal slices focus on texture difference weights, while leaf medicinal slices focus on color difference weights), improving the generalization ability of the model.
[0087] Modeling nonlinear relationships: The Sigmoid activation function can capture complex correlations between data (such as the synergistic effect of color and texture differences). For example, when D1>50 and D2>40, the model output Q may increase exponentially, reflecting the actual law that "double anomalies lead to significant quality degradation."
[0088] Quantitative grading and early warning: The quality assessment value Q converts multi-dimensional risks into a numerical value of a unified scale (e.g., Q = 0.3 is qualified, 0.5-0.7 is a warning, and ≥0.7 is unqualified), which facilitates rapid classification and disposal. It can be integrated into the production monitoring system and trigger early warnings in real time (e.g., when Q ≥ 0.5, the batch flow is automatically suspended and manual review is prompted).
[0089] Model interpretability optimization: Weight analysis can be used to trace the impact of each indicator (for example, a sudden increase in the weight of D3 may indicate an increase in abnormal wrinkling problems in recent times), helping companies identify systemic quality risks. It can also be combined with interpretable tools such as SHAP values to visually display the contribution of each sample's difference (for example, the Q=0.6 of a certain herbal medicine is mainly caused by D1=45 and R=0.8).
[0090] In a preferred embodiment of the present invention, the quality grade determination result of the Chinese herbal medicine slices is obtained according to the interval matching relationship between the quality assessment value and the preset risk threshold, including: Three risk threshold intervals are preset. When the quality assessment value is less than 0.25, it is judged as a first-class high-quality product; when it is in the range of 0.25-0.6, it is judged as a second-class qualified product; when it is greater than 0.6, it is judged as a third-class defective product; for samples within the range of ±0.03 of the interval critical value, the review mechanism is activated, and the assessment value is recalculated by increasing the number of detection points in the characteristic area, and the average of the two calculation results is taken as the basis for the final judgment.
[0091] In the embodiment of the present invention, the preset threshold and level mapping are as follows: Threshold interval definition: First-class quality products: quality assessment value Q < 0.25; Second-level qualified products: 0.25≤quality assessment value Q≤0.6; Grade 3 defective products: quality assessment value Q>0.6. For example: if the quality assessment value Q=0.18, it is judged as Grade 1; if the quality assessment value Q=0.45, it is judged as Grade 2; if the quality assessment value Q=0.7, it is judged as Grade 3.
[0092] Critical value review range: Define the critical value as the interval endpoint (0.25, 0.6), and the allowable error range is ±0.03: Primary and secondary critical regions: (0.22≤quality assessment value Q≤0.28); Secondary and tertiary critical regions: (0.57≤quality assessment value Q≤0.63); If the quality assessment value Q falls into the critical region, such as the quality assessment value Q=0.24) or the quality assessment value Q=0.61, the review mechanism is triggered.
[0093] Review mechanism execution process operation process: Feature area detection point encryption: Based on the detection points of the original three characteristic areas (color transition zone, texture-intensive area, and wrinkle area), new detection points are added to the surrounding grid: Three new detection points are added to each feature area (e.g., one grid each around the original detection point, up, down, left, and right), and the total number of detection points increases from 3 to 12 (4 in each area).
[0094] Example: The original detection point of the dense texture area is the center grid, and the center points of the four grids above, below, left and right are added as new detection points.
[0095] Recalculation of data from multiple detection points: For each newly added inspection point, the feature area is relocated, polygons are constructed, and color gradient, texture direction, and structural symmetry data are extracted; new difference indicators (D1', D2', D3') and quality assessment values (Q') are generated, and the average of the original assessment value (Q) and the re-assessment value (Q') is calculated. The average value is substituted into the preset threshold range to determine the final grade (e.g., the first time (Q = 0.28), the re-assessment (Q' = 0.24), the average value = 0.26), and it is judged as a second-level qualified product).
[0096] The quantitative threshold of the present invention transforms the quality grade from fuzzy qualitative to clear quantitative (such as "high-quality products" corresponding to a specific numerical range), avoiding subjective differences in manual judgment. The critical value review mechanism balances detection accuracy and efficiency (review is only initiated for controversial samples), reducing misjudgments and avoiding repeated testing of all samples. For "edge samples" close to the threshold (such as (Q=0.61)), local subtle differences (such as the sudden deterioration of wrinkle symmetry in a certain area) are captured by encrypting detection points, avoiding grade misjudgments caused by single-point detection errors.
[0097] Example: During the first inspection, the texture direction consistency was too high (Q=0.28) due to the angle of the slices. During the review, after adjusting the angle, it was found that the actual texture was disordered (Q'=0.32), and the final judgment was level 2 (originally level 1 critical).
[0098] The average of data from multiple detection points reduces the impact of accidental noise (for example, if the color gradient of a certain detection point is abnormal due to image noise, the newly added point can balance the error). The review mechanism makes the model more inclusive of morphological variations in medicinal materials (such as irregular slices), and improves the reliability of the results through multi-angle detection. The first-class product standard is strictly limited (quality assessment value Q < 0.25).
[0099] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.
Claims
1. A method for evaluating the quality of Chinese herbal medicine slices based on big data, characterized in that: The method comprises: Step 1: Perform multi-dimensional correlation analysis on the medicinal slice data set, and generate an initial quality deviation risk value by calculating the correlation between the planting environment data and the finished product characteristics; Step 2: Divide the surface image of the medicinal piece into uniform grid units, and locate three characteristic regions using a segmentation algorithm: the color transition zone at the edge of the medicinal piece, the texture-intensive area in the center, and the wrinkle area; select a detection point in each characteristic region, and construct a polygon with the three detection points as vertices; Step 3: Based on the polygon vertex distribution, extract the color gradient change data from the color transition zone detection points in the edge area, extract the texture direction consistency data from the texture dense area detection points in the center area, and extract the structural symmetry data from the wrinkle area detection points; Step 4: Compare the color gradient change data with the preset standard color gradient threshold to generate a first difference index, compare the texture direction consistency data with the texture direction distribution range of historical qualified batches to generate a second difference index, and compare the structural symmetry data with the pharmacopoeial morphological standard to generate a third difference index; Step 5: Based on the first difference index, the second difference index and the third difference index, combined with the initial quality deviation risk value, calculate the quality assessment value, and obtain the quality grade judgment result of the Chinese herbal medicine slices according to the interval matching relationship between the quality assessment value and the preset risk threshold.
2. The method for evaluating the quality of Chinese herbal medicine slices based on big data according to claim 1, wherein: The medicinal slice dataset includes soil heavy metal content detection data and pesticide residue screening data of Chinese medicinal materials during the Chinese medicinal material planting process, medicinal slice surface images, and medicinal slice surface color and texture feature data.
3. The method for quality assessment of Chinese herbal medicine slices based on big data according to claim 2, characterized in that: Step 1: Perform multi-dimensional correlation analysis on the medicinal slice dataset, and generate an initial quality deviation risk value by calculating the correlation between the planting environment data and the finished product characteristics, including: Step 11: Concentration vectors are established for soil heavy metal content detection data according to the categories of arsenic, cadmium, and lead elements, and residue vectors are established for pesticide residue screening data according to the categories of organophosphorus and pyrethroid compounds; the surface color characteristics of the medicinal slices are quantified into a three-dimensional vector consisting of hue angle, lightness value, and saturation value using the HSV color space; Step 12: Perform cross-dimensional correlation analysis on the concentration vector and the residue vector with the three-dimensional vector, i.e., calculate the correlation coefficient matrix between each element of the heavy metal concentration vector and the hue angle dimension, and the correlation coefficient matrix between each compound of the pesticide residue vector and the lightness value dimension; Step 13: extracting correlation items with an absolute value of a correlation coefficient greater than 0.3, establishing a hue pollution influencing factor based on the positive or negative characteristics of the heavy metal-hue relationship, and establishing a brightness attenuation factor based on the pesticide-brightness relationship; and calculating the hue shift and brightness attenuation based on the actual detected heavy metal concentration and pesticide residue and the corresponding hue pollution influencing factor and brightness attenuation factor; Step 14: Calculate the standard deviation multiple of the hue offset outside the hue distribution range of qualified samples as the first risk component, and the part of the brightness attenuation that exceeds 30% of the historical normal attenuation rate curve as the second risk component. Perform entropy weighted fusion on the first risk component and the second risk component to generate an initial quality deviation risk value.
4. The method for quality assessment of Chinese herbal medicine slices based on big data according to claim 3, characterized in that: Step 2: Divide the surface image of the medicinal piece into uniform grid units and locate three characteristic areas through segmentation algorithm, namely the color transition zone in the edge area of the medicinal piece, the texture-intensive area in the center area, and the wrinkle area, including: Adaptive grid partitioning algorithm is used to divide the surface of the slices into square grid units with a side length of 5-8 pixels according to the image resolution; Perform edge gradient detection on each grid cell, and mark the area where the edge gradient change rate exceeds 50% within three consecutive grid cells as a color transition zone; Gray-level co-occurrence matrix analysis is performed on the grids in the central area, and adjacent grids with texture contrast greater than a set threshold are clustered as texture-dense areas; The fracture and wrinkle features were connected through morphological dilation operations, and the continuous areas with a curvature change rate of more than 30% were identified as wrinkle areas. The final detection point position was determined by expanding two grid units outward from the geometric center points of the three feature areas.
5. The method for quality assessment of Chinese herbal medicine slices based on big data according to claim 4, characterized in that: Select a detection point in each feature area and construct a polygon with three detection points as vertices, including: At the color transition zone detection point, extend 3 pixels along the edge tangent direction to establish a baseline, and select the midpoint of the baseline as the first vertex; Calculate the main texture direction at the detection point in the texture dense area, and move the distance of 1 / 2 of the texture period along the main texture direction to determine the second vertex; Identify the symmetry axis at the detection point of the wrinkle area, and select the intersection of the symmetry axis and the wrinkle edge as the third vertex; Connect the first vertex, the second vertex, and the third vertex in a clockwise direction to form a triangle, and calculate the internal angle distribution of the triangle as a morphological feature benchmark.
6. The method for quality assessment of Chinese herbal medicine slices based on big data according to claim 5, characterized in that: Step 3, based on the polygon vertex distribution, extracts color gradient change data from the color transition zone detection points in the edge area, extracts texture direction consistency data from the texture dense area detection points in the center area, and extracts structural symmetry data from the wrinkle area detection points, including: At the color transition zone detection point, along the polygon edge direction, HSV color space values are collected with a step size of 1 pixel, and the standard deviation of the hue angle difference between adjacent pixels is calculated as the gradient change data; Extract the 8-directional Gabor filter responses at the detection points in the texture-dense area, and count the area proportion where the main response direction accounts for more than 70% as the direction consistency data; Mirror sampling is performed along the polygonal symmetry axis at the detection points in the wrinkle area, and the matching degree of the number of curvature extreme points and the distribution spacing of the areas on both sides is calculated as the structural symmetry data.
7. The method for evaluating the quality of Chinese herbal medicine slices based on big data according to claim 6, characterized in that: Step 4: Compare the color gradient change data with the preset standard color gradient threshold to generate a first difference index, compare the texture direction consistency data with the texture direction distribution range of historical qualified batches to generate a second difference index, and compare the structural symmetry data with the pharmacopoeial morphological standard to generate a third difference index, including: Perform sliding window matching on the color gradient change data and the standard threshold, and calculate the cumulative duration of the data points in the window exceeding the threshold as the first difference; A directional distribution probability model of qualified batches is established for texture directional consistency data, and the KL divergence is used to measure the deviation between the current data distribution and the model as the second difference; The structural symmetry data is mapped to the topological structure described by the pharmacopoeial morphological standard, and the matching error of the node correspondence is calculated as the third difference degree through the graph matching algorithm.
8. The method for evaluating the quality of Chinese herbal medicine slices based on big data according to claim 7, characterized in that: Step 5, based on the first difference index, the second difference index, and the third difference index, combined with the initial quality deviation risk value, calculates the quality assessment value, including: A three-layer neural network model was established, with the first difference, second difference, and third difference as input layer nodes, and the initial quality deviation risk value as the bias term; The hidden layer uses the Sigmoid activation function for nonlinear transformation, and the output layer generates a quality assessment value in the range of 0-1 through weighted summation. The weight coefficient of the difference index is determined by back-propagation training of historical samples.
9. The method for evaluating the quality of Chinese herbal medicine slices based on big data according to claim 8, characterized in that: According to the interval matching relationship between the quality assessment value and the preset risk threshold, the quality grade determination results of the Chinese herbal medicine slices are obtained, including: Three risk threshold intervals are preset. When the quality assessment value is less than 0.25, it is judged as a first-class high-quality product; when it is in the range of 0.25-0.6, it is judged as a second-class qualified product; when it is greater than 0.6, it is judged as a third-class defective product; for samples within the range of ±0.03 of the interval critical value, the review mechanism is activated, and the assessment value is recalculated by increasing the number of detection points in the characteristic area, and the average of the two calculation results is taken as the basis for the final judgment.
Citation Information
Patent Citations
Tablet quality detection method in medicine production process based on image data
CN117274251A
Transform and CNN-based Chinese herbal medicine image recognition system
CN118279907A
Angelica dahurica decoction piece quality grade detection method
CN118464893A
Method and system for evaluating harm of pesticide residue and heavy metal pollution to Chinese wolfberry
CN119993308A
Method for constructing medicinal material identification model based on image technology
CN120126107A
Cited By
Intelligent traditional Chinese medicine decoction piece screening method based on multi-modal data fusion
CN120831338A