A method and system for extracting and classifying characteristics of Chinese medicinal materials

By capturing images of Gastrodia elata medicinal materials with a high-resolution camera and combining them with edge detection and multi-scale feature extraction technology, the problem of time-consuming, labor-intensive and inaccurate Gastrodia elata medicinal material detection in existing technologies has been solved. Accurate identification of mold and cavity defects has been achieved, improving detection efficiency and the reliability of results.

CN120198717BActive Publication Date: 2025-09-30BEIJING CHINESE MEDICINE HOSPITAL AFFILIATED CAPITAL MEDICAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510212330.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-02-25
Publication Date
2025-09-30
Estimated Expiration
2045-02-25

AI Technical Summary

Technical Problem

Existing quality inspection methods for traditional Chinese medicine mainly rely on manual visual inspection, which is time-consuming, labor-intensive and easily affected by subjective factors. It is difficult to accurately identify mold and cavity defects in Gastrodia elata, making it difficult to ensure the accuracy and consistency of the test results.

Method used

A high-resolution camera is used to capture medicinal material images. Edge detection and multi-scale feature extraction techniques are combined. The edge strength and direction are calculated using the Sobel operator. The edge gradient threshold is set to filter edge pixels. Multi-scale mold feature fusion is performed by combining texture and color features. Cavity defects are identified using a support vector machine.

Benefits of technology

It achieves accurate identification of mold and cavity defects in Gastrodia elata medicinal materials, improves the accuracy and efficiency of detection, reduces the probability of missed detection and false detection, and ensures the reliability and consistency of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198717B_ABST
    Figure CN120198717B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for extracting and classifying characteristics of Chinese medicinal materials. The method includes the following steps: collecting an image of a medicinal material of Gastrodia elata, preprocessing the image of the medicinal material of Gastrodia elata to obtain an image of the medicinal material to be detected; performing edge detection on the image of the medicinal material to be detected to extract contour information to obtain an edge image to be detected; extracting multi-scale mold features from the edge image to be detected, and identifying abnormal defects in the medicinal material image of Gastrodia elata using the multi-scale mold features. By extracting multiple features from abnormal areas of the edge image to be detected, not only can mold be determined, but also holes can be identified to prevent missed detections.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of quality identification of traditional Chinese medicines, and in particular to a method and system for extracting and classifying characteristics of traditional Chinese medicines. Background Art

[0002] Researchers have found that the quality and appearance of traditional Chinese medicines (TCMs) play a crucial role in their efficacy. Generally speaking, practitioners can identify the quality of most TCMs (or medicinal materials) with the naked eye, eliminating the need for chemical identification and verification. Therefore, it is crucial to compile and organize commonly used TCMs, analyze common quality issues in TCMs, and identify their quality and authenticity.

[0003] For example, in the field of traditional Chinese medicine, Gastrodia elata is a medicinal plant (Gastrodia elata is neutral in nature, sweet in taste, and enters the liver meridian. Its main effects are to calm wind and stop spasms, calm liver yang, and dispel wind and dredge meridians). Its quality and appearance directly affect the efficacy and market value of the medicinal material. Gastrodia elata is the dried tuber of the orchid plant Gastrodia elata. Gastrodia elata is made by taking the bright-colored and firm tubers of Gastrodia elata, washing, cutting, steaming, drying until 70% dry, and then shaving or cutting into thin slices (forming Gastrodia elata slices); however, in the actual production, storage and processing process, Gastrodia elata slices often face a variety of typical defects, among which mildew and voids are the two most common defects. These defects not only reduce the quality of the medicinal material, but may also affect its medicinal effect and safety, posing a considerable challenge to the traditional Chinese medicine industry.

[0004] Mildew is a common problem with Gastrodia elata during storage. High humidity, poor ventilation, or improper temperature control can easily lead to mold growth on and within the material, causing it to mold. Mildewed Gastrodia elata exhibits darker skin, wrinkled texture, and loss of gloss, with cross-sections appearing dark, seriously affecting its appearance and quality. More importantly, the mycotoxins produced during this process can pose a potential threat to the medicinal efficacy and safety of the material.

[0005] In addition to mold, cavities are another common defect in Gastrodia elata. These cavities are typically caused by poor growth, water loss, or pest infestation. These cavities not only reduce the density and weight of the medicinal material but can also damage its internal structure, compromising its efficacy and stability. Furthermore, cavities can become a habitat for mold and pests, further exacerbating the degradation of the medicinal material.

[0006] Traditional methods for testing the quality of Gastrodia elata rely primarily on manual visual inspection, a time-consuming and labor-intensive process that is susceptible to subjective influences, making it difficult to ensure the accuracy and consistency of test results. With the advancement of computer vision and image processing technologies, image-based methods for identifying Gastrodia elata defects have become a research hotspot. However, existing image recognition methods still have many shortcomings when dealing with mold and cavity defects in Gastrodia elata, such as low recognition accuracy and inadequate feature extraction. Summary of the Invention

[0007] Therefore, there is an urgent need for a classification and processing method based on the extraction of medicinal material characteristics that can accurately and quickly identify mold and cavity defects in Gastrodia elata medicinal materials, providing strong support for quality control in the traditional Chinese medicine industry. This invention is proposed based on this need. It aims to accurately identify mold and cavity defects in Gastrodia elata medicinal materials by capturing medicinal material images with a high-resolution camera and combining image processing techniques such as edge detection and multi-scale feature extraction.

[0008] The purpose of the present invention is to provide a method and system for extracting and classifying Chinese medicinal materials phase characteristics, which solves the above-mentioned technical problems pointed out in the prior art.

[0009] The present invention provides a method for extracting and classifying Chinese medicinal material phase features, comprising the following steps: collecting a medicinal material image of Gastrodia elata, pre-processing the medicinal material image of Gastrodia elata to obtain a medicinal material image to be detected; performing edge detection on the medicinal material image to be detected to extract contour information to obtain an edge image to be detected; extracting multi-scale mildew features from the edge image to be detected, and identifying abnormal defects in the medicinal material image of Gastrodia elata through the multi-scale mildew features.

[0010] Preferably, the abnormal defects include: mold abnormality and cavity abnormality.

[0011] Preferably, edge detection is performed on the medicinal material image to be detected to extract contour information to obtain the edge image to be detected. The specific operation steps are as follows: the horizontal edge strength and the vertical edge strength of the medicinal material image to be detected are calculated using the Sobel operator; the gradient amplitude of each pixel point of the medicinal material image to be detected is calculated using the horizontal edge strength and the vertical edge strength. The calculation formula is:

[0012] Where Gx and Gy are the edge strength in the horizontal direction and the edge strength in the vertical direction respectively; the edge direction of the medicinal material image to be detected is calculated by the inverse tangent function using the horizontal edge strength and the vertical edge strength, and the calculation formula is: θ = atan2(G y , G x);wherein, θ represents the edge direction of the medicinal material image to be detected; traverse each pixel point of the medicinal material image to be detected; quantize each pixel point in four main directions according to the edge direction; search two adjacent pixel points for each pixel point in each main direction, and detect whether the gradient amplitude of each pixel point is the maximum value of the two adjacent pixel points in each main direction; if not, the pixel point of the medicinal material image to be detected is eliminated; if so, the pixel point is retained in the medicinal material image to be detected as the pixel point to be selected; preset a strong edge gradient threshold h and a weak edge gradient threshold j; determine whether the gradient amplitude of each pixel point to be selected is greater than the strong edge gradient threshold h; if so, then The pixel to be selected is retained as a strong edge pixel; if not, the gradient amplitude of the remaining pixel to be selected is judged to be between the strong edge gradient threshold h and the threshold range less than the weak edge gradient threshold j; if so, the pixel to be selected that meets the requirements between the threshold range among the remaining pixel to be selected is used as a weak edge pixel; if not, the last remaining pixel to be selected is treated as a non-edge pixel, and the non-edge pixel is removed; all weak edge pixels are traversed by the connection algorithm, and the weak edge pixel points connected to the strong edge pixel points are retained as connected edge pixel points; all connected edge pixel points are connected with all strong edge pixels to obtain an edge image to be detected.

[0013] Correspondingly, the present invention also proposes a Chinese medicinal material appearance feature extraction and classification processing system, including: an acquisition module; an identification module; the acquisition module is used to acquire the medicinal material image of Gastrodia elata, pre-process the medicinal material image of Gastrodia elata, and obtain the medicinal material image to be detected; the identification module is used to perform edge detection on the medicinal material image to be detected to extract contour information, and obtain the edge image to be detected; multi-scale mildew features are extracted from the edge image to be detected, and abnormal defects of the medicinal material image of Gastrodia elata are identified through the multi-scale mildew features.

[0014] Compared with the prior art, the embodiments of the present invention have at least the following technical advantages:

[0015] Analysis of the above-mentioned method for extracting and classifying the characteristics of Chinese medicinal materials provided by the present invention shows that, in specific applications, images of Gastrodia elata at different angles and under different lighting conditions are collected to obtain more comprehensive characteristics of the medicinal materials, and pre-processing such as denoising and smoothing is performed to obtain images of the medicinal materials to be detected, so that the images of the medicinal materials to be detected can be more accurate during the recognition process;

[0016] Furthermore, the Sobel operator is used to calculate the edge strength in the horizontal direction and the edge strength in the vertical direction of the medicinal material image to be detected. The edge strength can identify the pixel points of the edge of the medicinal material image to be detected, and can also calculate the gradient amplitude and edge direction of each pixel point of the medicinal material image to be detected. Not only can the edges in the image be effectively detected, but also representative (i.e., maximum) pixels in the neighborhood range can be found as pixels to be selected. Only the most significant edges can be retained, thereby improving the clarity of the edge of the medicinal material image to be detected; then, by setting the edge gradient threshold, strong edge pixels and weak edge pixels are screened out, and non-edge pixels are removed. Then, useful pixels are extracted from the weak edge pixels as connecting edge pixels and strong edge pixels to form an edge image to be detected. This not only improves the overall coherence and accuracy of the edge of the edge image to be detected, but also makes the edge image to be detected more complete and clear; the edge image to be detected is divided into multiple square local areas to be detected, and the abnormal area is judged by the grayscale mean. In this way, the areas where abnormalities may exist can be judged by different grayscale change differences, thereby improving the detection efficiency;

[0017] Furthermore, the texture distribution features of different scales in multiple abnormal areas are firstly analyzed to capture the directional features of the texture. Various texture changes can be better identified through the distribution of texture. At the same time, the direction of mildew can be determined. The directional features are then fused with the texture distribution features to obtain the final texture features, thereby reflecting the abnormality of mildew in the abnormal area. Each abnormal area is converted into HSV space, and the color histogram is calculated to obtain the color features. This can eliminate the influence caused by the change of image size and illumination, ensure the consistency and comparability of the features, and effectively observe mildew through these surface features. The actual area of ​​the square-shaped abnormal area is calculated, and then the image is passed through the image. The pixel density of the abnormal region is obtained by dividing the number of pixels by the actual area of ​​the abnormal region, which can be used to quantify the severity of mold in each abnormal region. The square shape of the abnormal region and the pixel density of the abnormal region are normalized, and the features are fused to obtain a comprehensive feature vector, which can be used to understand the distribution of mold in the abnormal region. The texture features are fused with the color features and the comprehensive feature vector to obtain multi-scale mold features. By comprehensively considering different features, moldy areas can be identified more effectively, reducing the probability of missed detection or false detection. The texture features, color features, and the comprehensive feature vector are normalized and then weighted and summed to obtain a mold index, which can quickly identify abnormal defects in the medicinal material images to be tested.

[0018] Furthermore, abnormal defects also include void abnormalities; the texture features and color features are calculated to obtain a preliminary mildew index, and a counter-intuitive judgment is made through the preliminary mildew index to determine whether there are other defects (i.e., void defects) in the abnormal area. In this way, the suspicious abnormal area can be focused on to prevent missed detection; the texture features and color features are fused to form a surface feature vector, and the voids on the surface of the abnormal area are better observed; the support vector machine is used to calculate the surface feature vector to predict the void credibility score to determine whether the void defect actually exists; if the credibility threshold t2 is used to determine whether there is a void, the actual area of ​​the abnormal area and the comprehensive feature vector of the shape features are added to directly calculate the mildew index. This not only simplifies the processing flow, but also reduces the errors that may be caused by the fusion of multi-scale mildew features. Finally, it is determined whether an abnormality occurs to obtain the final result. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is an overall flow chart of a method for extracting and classifying Chinese medicinal material phase features according to the first embodiment of the present invention;

[0020] Figure 2 A schematic diagram of the surface of a normal Gastrodia elata according to a method for extracting and classifying Chinese medicinal materials according to embodiment 1 of the present invention;

[0021] Figure 3 A schematic diagram of a cross section of a normal Gastrodia elata according to a method for extracting and classifying Chinese medicinal materials according to embodiment 1 of the present invention;

[0022] Figure 4 This is a schematic diagram showing the comparison of abnormal Gastrodia elata caused by various reasons in a method for extracting and classifying Chinese medicinal materials phase characteristics according to the first embodiment of the present invention;

[0023] Figure 5 This is a flowchart of anomaly recognition in a method for extracting and classifying characteristics of Chinese medicinal materials according to the first embodiment of the present invention;

[0024] Figure 6 This is a flow chart of screening connected edge pixels in a method for extracting and classifying characteristics of Chinese medicinal materials according to the first embodiment of the present invention;

[0025] Figure 7 This is a schematic diagram of an edge image to be detected that is connected by correctly selected weak edge pixels in a method for extracting and classifying characteristics of Chinese medicinal materials according to the first embodiment of the present invention;

[0026] Figure 8 A schematic diagram of an edge image to be detected that filters out erroneous weak edge pixel connections in a method for extracting and classifying characteristics of Chinese medicinal materials according to the first embodiment of the present invention;

[0027] Figure 9 This is a flow chart of a method for extracting and classifying Chinese medicinal materials phase features to identify moldy Gastrodia elata according to the first embodiment of the present invention;

[0028] Figure 10 This is a flow chart of identifying Gastrodia elata cavities in a method for extracting and classifying Chinese medicinal material appearance features according to the first embodiment of the present invention;

[0029] Figure 11 This is a flow chart of a method for extracting and classifying Chinese medicinal material phase features and integrating multi-scale mildew features according to the first embodiment of the present invention;

[0030] Figure 12 This is a schematic diagram of the principle structure of a system for extracting and classifying Chinese medicinal material characteristics according to the second embodiment of the present invention;

[0031] Labels: collection module 10; identification module 20; epidermis B; transverse ring mark H; cross section Q; cavity U; raw material erosion G; raw material insect infestation O; incomplete processing K. DETAILED DESCRIPTION

[0032] The technical solution of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0033] The present invention will be further described in detail below through specific embodiments in conjunction with the accompanying drawings.

[0034] Example 1

[0035] Embodiment 1 of the present invention provides a method for extracting and classifying Chinese medicinal material appearance features, including the following operating steps: S1: collecting medicinal material images of Gastrodia elata, and preprocessing the medicinal material images of Gastrodia elata to obtain medicinal material images to be detected; it should be noted that, when using a high-resolution camera to collect image data of Gastrodia elata medicinal materials, the collection process should include images under different angles and different lighting conditions to obtain more comprehensive medicinal material features; a Gaussian filtering algorithm is used to remove random noise in the image, and grayscale processing is performed to ensure that the image is smoother and clearer; S2: edge detection is performed on the medicinal material image to be detected to extract contour information to obtain an edge image to be detected; multi-scale mildew features are extracted from the edge image to be detected, and abnormal defects of the medicinal material image of Gastrodia elata are identified through the multi-scale mildew features; the abnormal defects include: mildew abnormality and cavity abnormality.

[0036] It should be noted that, first, the Haar feature extraction algorithm is applied to extract the contour information of the medicinal material image to be tested, so that the abnormal area can be found more accurately. The texture, color and other features of the abnormal area are further extracted to form a multi-scale mold feature. The multi-scale mold feature can reflect the contribution of different mold conditions under different features (see Figure 2 as well as Figure 3 The researchers found that the normal appearance image of Gastrodia elata was not moldy. The outer skin color of the front side of Gastrodia elata was light yellow to yellow-brown. At the same time, the skin B was shiny and the texture was relatively clear (multiple horizontal ring lines H were visible). At the same time, its cross-section Q (the cross-section is the cut surface of the Gastrodia elata tuber) was yellow-white to light brown. The cross-section surface was also shiny. However, the skin texture of moldy Gastrodia elata was wrinkled and dark black, and the overall color was dull and matte. At the same time, the cross-section surface was also dark black and matte. Therefore, extracting multi-scale mold features is crucial for the identification of mold indicators, so as to better identify mold or voids. And the mold index was calculated based on the multi-scale mold features to determine whether the medicinal material image of Gastrodia elata has mold defects. The causes of mold are generally improper storage, voids U, raw material erosion G, raw material insect infestation O. Defects in the raw material itself or incomplete processing K may also cause mold, and also lead to the appearance of voids (i.e., see Figure 2 、 Figure 3 See also Figure 4 , comparison between the intact Gastrodia elata image and the defective Gastrodia elata image), which will not be described in detail.

[0037] Specifically, if Figure 5 As shown, in step S2, edge detection is performed on the medicinal material image to be detected to extract contour information to obtain the edge image to be detected; multi-scale mildew features are extracted from the edge image to be detected, and abnormal defects of the medicinal material image of Gastrodia elata are identified by the multi-scale mildew features. The specific operation steps are as follows: S21: The horizontal edge strength and the vertical edge strength of the medicinal material image to be detected are calculated by the Sobel operator; the gradient amplitude of each pixel point of the medicinal material image to be detected is calculated by the horizontal edge strength and the vertical edge strength, and the calculation formula is:

[0038]

[0039] Wherein, Gx and Gy are the edge strength in the horizontal direction and the edge strength in the vertical direction, respectively. The edge direction of the medicinal material image to be detected is calculated by using the inverse tangent function through the edge strength in the horizontal direction and the edge strength in the vertical direction. The calculation formula is:

[0040] θ=atan2(G y , G x );

[0041] Where θ represents the edge direction of the medicinal material image to be detected (that is, the gradient direction of the medicinal material image to be detected);

[0042] It should be noted that the Sobel operator is an image processing operator used for edge detection. It detects edges by calculating the change in pixel intensity in an image. By calculating the square root of the sum of the squares in these two directions, the overall gradient amplitude of each pixel in the medicinal material image to be detected can be obtained, indicating the edge intensity of the pixel (i.e., the horizontal edge of the medicinal material image to be detected is enhanced by calculating the intensity difference between each pixel and its left and right neighbors; and the vertical edge of the medicinal material image to be detected is emphasized by calculating the intensity difference between each pixel and its upper and lower neighbors). The gradient amplitude indicates the intensity of the edge of the medicinal material image to be detected and reflects the degree of brightness change in the medicinal material image to be detected. Using the Sobel operator to calculate the gradient amplitude and direction of the medicinal material image to be detected can not only effectively detect the edge in the image, but also provide necessary information for subsequent processing.

[0043] S22: Traversing each pixel of the image of the medicinal material to be detected;

[0044] Quantizing each pixel in four main directions according to the edge direction;

[0045] Searching for two adjacent pixels in each main direction for each pixel point, and detecting whether the gradient amplitude of each pixel point is the maximum value between the two adjacent pixels in each main direction;

[0046] If not, the pixel point of the medicinal material image to be detected is removed;

[0047] If so, the pixel point is retained in the image of the medicinal material to be detected as the pixel point to be selected;

[0048] It should be noted that the four main directions of each pixel are determined according to the edge direction θ of the medicinal material image to be detected. The four main directions include: 0° (i.e., 0° represents a horizontal edge, specifically, a higher gradient level, indicating that the edge is horizontal), 45° (i.e., 45° represents a diagonal edge, specifically, a higher gradient presents an oblique direction, indicating that the edge forms a 45-degree angle with the horizontal and vertical directions), 90° (i.e., 90° represents a vertical edge, specifically, a higher gradient is vertical, meaning that the edge is vertical), and 135° (i.e., 135° represents a reverse diagonal edge, specifically, a higher gradient corresponds to a reverse oblique line, indicating that the edge direction is opposite to 45 degrees). Quantifying the direction into four main directions is to simplify calculation and comparison. Only these directions need to be focused on, rather than every possible angle. This helps to quickly determine the relationship between adjacent pixels in subsequent steps, thereby improving processing efficiency.

[0049] After determining the direction of each pixel, the Sobel operator will find the two adjacent pixels in that direction. This is because on the edge, the gradient magnitude of a pixel should be greater than the gradient magnitudes of the two adjacent pixels before and after it. In this way, the Sobel operator can further confirm whether the pixel is a "local maximum" (that is, whether it is the strongest edge point in its direction).

[0050] If the pixel is a local maximum, it is retained as an edge pixel. If the gradient magnitude of the current pixel is not the maximum in its neighborhood, its gradient magnitude is set to 0, indicating that the pixel does not belong to the edge. This ensures that only pixels with obvious edge features are retained, making the final edge image clearer and removing fuzzy and unimportant edge information. In this way, only the most significant edges are retained, thereby improving the edge clarity of the medicinal material image to be detected.

[0051] S23: Preset a strong edge gradient threshold h and a weak edge gradient threshold j;

[0052] Determine whether the gradient amplitude of each pixel to be selected is greater than the strong edge gradient threshold h (that is, the gradient amplitude of each pixel to be selected is greater than the strong edge gradient threshold h);

[0053] If yes, keep the pixel to be selected as a strong edge pixel;

[0054] If not, the gradient amplitude of the remaining pixels to be selected is determined to see whether it is between the strong edge gradient threshold h and the threshold value less than the weak edge gradient threshold j (i.e., the strong edge gradient threshold h < the gradient amplitude of the pixel to be selected < the weak edge gradient threshold j);

[0055] If yes, the remaining pixels to be selected that meet the threshold range requirements are taken as weak edge pixels;

[0056] If not, the last remaining pixel to be selected is regarded as a non-edge pixel and is eliminated (that is, after step-by-step screening by judging the gradient amplitude of all the pixels to be selected and determining the gradient amplitude of the pixel to be selected > the strong edge gradient threshold h and the strong edge gradient threshold h < the gradient amplitude of the pixel to be selected < the weak edge gradient threshold j, the gradient amplitude of the last remaining pixel to be selected will be less than the weak edge gradient threshold j, and the pixel to be selected that is less than the weak edge gradient threshold j has the weakest gradient amplitude and is not at the edge of the medicinal material image to be detected, so the last remaining pixel to be selected is determined as a non-edge pixel);

[0057] It should be noted that the strong edge gradient threshold h and the weak edge gradient threshold j are preset. In the edge gradient dual threshold detection, the strong edge gradient threshold h (i.e., the high threshold) is used to identify obvious strong edge pixels, while the weak edge gradient threshold j (i.e., the low threshold) is used to identify possible weak edge pixels and non-edge pixels.

[0058] Determine whether the gradient amplitude of all the pixels to be selected exceeds the high threshold strong edge gradient threshold h. The pixels to be selected whose gradient amplitude exceeds the threshold are marked as strong edge pixels, which means that these pixels to be selected represent the most obvious edge parts of the medicinal material image to be detected; these strong edge pixels will be retained and used in the subsequent step of forming the contour;

[0059] The remaining pixels whose gradient amplitudes do not exceed the strong edge gradient threshold h are further judged to be between the weak edge gradient threshold j and the strong edge gradient threshold h. The pixels whose gradient amplitudes are between the ranges are marked as weak edge pixels. Although these pixels are not the strongest edges, they may be part of important edges. It is necessary to further check whether they are connected to the pixels of the strong edge.

[0060] All pixels to be selected whose gradient amplitude is lower than the weak edge gradient threshold j are marked as non-edge pixels; these non-edge pixels are considered to have no significant edge features and no edge relationship, so they will be removed in subsequent processing; after this processing, only weak edge pixels connected to strong edge pixels will be retained in the final edge image, thereby improving the overall coherence and accuracy of the edge (which is crucial for determining and extracting clear edge textures);

[0061] S24: traversing all weak edge pixels using a connection algorithm, and retaining weak edge pixels connected to the strong edge pixels as connected edge pixels;

[0062] Connect all connected edge pixels with all strong edge pixels to obtain the edge image to be detected;

[0063] It should be noted that in edge detection, strong edge pixels usually represent significant boundaries in the image, while weak edge pixels may be noise or less obvious boundaries. By separately identifying strong and weak edge pixels, dual threshold detection can effectively improve edge connectivity and ensure the integrity of edge information. Specifically, the presence of strong edge pixels can help confirm whether weak edge pixels are part of important edge structures.

[0064] In the edge connection step, the connection algorithm will check each weak edge pixel to determine whether it is connected to any strong edge pixel. The purpose of this step is to determine which weak edge pixels are reasonable and worth preserving edge parts because they may form a complete edge structure together with the strong edge pixels.

[0065] Use a connection algorithm such as the flood fill algorithm or depth-first search (DFS) to traverse each weak edge pixel in the image; through the traversal, check the neighborhood of each weak edge pixel to determine whether there are strong edge pixels connected to it; if a connected strong edge pixel is found, the weak edge pixel is retained and determined as a connected edge pixel; otherwise, it is deleted from the edge map; after this processing, only those weak edge pixels that are connected to strong edge pixels are retained in the final edge image to be detected, thereby improving the overall coherence and accuracy of the edge;

[0066] S25: dividing the edge image to be detected into a plurality of square local areas to be detected, and calculating the grayscale mean value of each local area to be detected;

[0067] And set the abnormal threshold r; traverse each local area to be detected to see if the grayscale mean is greater than the abnormal threshold r;

[0068] If not, the local area to be detected has no abnormal area;

[0069] If so, the local area to be detected is determined to be an abnormal area;

[0070] It should be noted that the edge image to be detected is divided into multiple local areas to be detected, and then the grayscale mean is calculated and the possible abnormal areas are judged; and according to the set abnormal threshold r, the grayscale mean of each local area to be detected is traversed to see if it is greater than the abnormal threshold r. If the grayscale mean of the local area to be detected exceeds this range, it is marked as an abnormal area;

[0071] S26: extracting multi-scale mold features from the multiple abnormal areas, quantitatively evaluating the degree of mold on the multi-scale mold features to obtain a mold index; and determining abnormal defects in the image of the medicinal material to be detected based on the mold index;

[0072] It should be noted that multi-scale feature extraction can capture the diversity of mold anomalies by analyzing abnormal areas at different scales, including subtle local changes and overall trends in larger areas. Using different scales can extract features at different levels, including texture, color, and shape, enhancing the ability to identify mold features. Quantitative assessment makes mold detection results operational, helping users quickly identify the degree of mold and setting clear standards for different degrees of mold, thereby improving the consistency and comparability of assessments. Through mold indicators, abnormal defects in the images of the medicinal materials to be tested can be quickly identified. Through rapid identification and classification (i.e., subsequent mold identification and subsequent cavity identification), the efficiency of handling abnormal medicinal materials can be significantly improved, reducing losses.

[0073] Specifically, if Figure 6 As shown, in step S24, all weak edge pixels are traversed by a connection algorithm, and weak edge pixels connected to the strong edge pixels are retained as connected edge pixels. The specific operation steps are as follows:

[0074] S241: traverse each weak edge pixel's neighborhood to see if there is a strong edge pixel;

[0075] If not, the weak edge pixel is removed;

[0076] If yes, the weak edge pixel is retained; and the direction difference between the direction of the weak edge pixel and the direction of the strong edge pixel in the neighborhood is further calculated;

[0077] S242: Preset a direction difference threshold z, and determine whether the direction difference between the edge direction of the weak edge pixel and the edge direction of the strong edge pixel in the neighborhood is less than the preset direction difference threshold z;

[0078] If not, the weak edge pixel is removed;

[0079] If yes, the weak edge pixel is retained; and the Euclidean distance between the weak edge pixel and the strong edge pixel is further calculated;

[0080] S243: Preset a Euclidean distance threshold f, and determine whether the Euclidean distance between the weak edge pixel and the strong edge pixel is less than the Euclidean distance threshold f;

[0081] If not, the weak edge pixel is removed;

[0082] If so, the weak edge pixel is regarded as a connecting edge pixel;

[0083] It should be noted that before determining whether the weak edge pixels meet the connection conditions with the strong edge pixels, several conditions need to be judged;

[0084] First, whether there is a strong edge pixel in the neighborhood of the weak edge pixel point, if not, the connection condition of the weak edge pixel point cannot be met at all, and errors are likely to occur; if there is a strong edge pixel point in the neighborhood, it is necessary to further determine whether the weak edge pixel point and the strong edge pixel point have the same direction (that is, step S22 has described the edge direction of each pixel point to be selected, and then the strong edge pixel point and the weak edge pixel point are determined according to the gradient amplitude of the pixel point to be selected, so it will not be repeated in this step); by calculating the edge direction difference between the weak edge pixel point and the strong edge pixel point, it is determined whether it is less than the Euclidean distance threshold f. If it is greater than or equal to the Euclidean distance threshold f, the inconsistent direction may cause the overall shape of the final connection to change (that is, the edge pixels at different positions or directions are different, and the corresponding Interconnection may cause the shape of Gastrodia elata to change, resulting in misjudgment of abnormal areas in post-recognition); if the direction difference is less than the Euclidean distance threshold f, it means that the two directions are consistent, and it is necessary to judge the Euclidean distance of the weak edge pixel and the strong edge pixel again to determine whether the Euclidean distance of the weak edge pixel and the strong edge pixel exceeds the distance range. If it exceeds the distance range (that is, the preset Euclidean distance threshold f), it means that the distance between the two is too far, which may cause the shape of the edge image to be detected to change; if so, it means that the weak edge pixel is within the distance range and meets the connection conditions; by screening weak edge pixels by neighborhood, direction, and Euclidean distance step by step, the final connected edge image to be detected can be prevented from changing the region and the error of the edge image can be reduced. Figure 7 The correct weak edge pixels are screened as shown in Figure 8 A comparative schematic diagram of an edge image to be detected formed by filtering out erroneous weak edge pixels is shown;

[0085] Specifically, if Figure 9 As shown, in step S26, multi-scale mold features are extracted from multiple abnormal areas, and the mold degree is quantitatively evaluated for the multi-scale mold features to obtain a mold index; the abnormal defects of the medicinal material image to be detected are determined by the mold index. The specific operation steps are as follows:

[0086] S261: performing multi-scale calculation of the local binary pattern (LBP) value for each pixel point in the multiple abnormal areas to extract texture distribution features (i.e., local texture features) at different scales;

[0087] Calculate the gray level co-occurrence matrix of the four main directions to capture the directional characteristics of the texture;

[0088] Fusing the directional feature with the texture distribution feature to obtain a final texture feature;

[0089] It should be noted that LBP (Local Binary Pattern) compares the grayscale values ​​of each pixel and its neighborhood, capturing local texture features. These local features are effective in identifying moldy areas when describing the surface, texture patterns, and shape of objects. By calculating LBP at different scales (such as 3x3, 5x5, and 7x7), multi-level texture features can be extracted. The distribution of textures allows for better identification of various texture changes, adapting to texture patterns of varying sizes, and enhancing sensitivity to moldy details.

[0090] The Gray Level Co-occurrence Matrix (GLCM) is a statistical method used to describe the spatial relationship between pixel grayscale values ​​in an image. By calculating the GLCM in four directions (0°, 45°, 90°, and 135°), the directional characteristics of textures in abnormal areas can be captured. This is very important for analyzing textures with specific directional characteristics (such as stripes and grids) and can determine the direction of mold.

[0091] Directly concatenate the feature vectors extracted from the directional features and the texture distribution features to form a new feature vector, perform weighted fusion based on the importance of the features, reduce the dimensionality of the fused features, remove redundant information, retain the most representative texture features, and improve computational efficiency;

[0092] S262: Convert each abnormal region into HSV space, calculate a color histogram for each abnormal region in the HSV space, and obtain a color feature;

[0093] It should be noted that converting the grayscale image of the abnormal area into HSV space (i.e., hue (H), saturation (S), and value (V)) can more effectively distinguish the brightness and saturation of the color, thereby enhancing the sensitivity to color changes when processing moldy areas, thereby improving the recognition rate of color features; independently analyzing the hue, saturation, and value channels can provide a deep understanding of the distribution characteristics of colors in different dimensions, which helps to more clearly identify the color features of moldy areas; by calculating the color histogram, the effects of image size and lighting changes can be eliminated, ensuring the consistency and comparability of features, and thus obtaining color features;

[0094] S263: Counting the number of edge pixels on one side of the edge of the square shape of the abnormal area, calculating the distances of all edge pixels on the side of the square shape of the abnormal area, and calculating the sum of the distances of all edge pixels to calculate the actual area of ​​the abnormal area;

[0095] Dividing the number of pixels by the actual area of ​​the abnormal area to obtain the pixel density of the abnormal area;

[0096] Normalizing the square shape of the abnormal area and the pixel density of the abnormal area, and performing weighted averaging on the square shape of the abnormal area (i.e., shape feature) and the pixel density of the abnormal area to form a comprehensive feature vector;

[0097] It should be noted that in step S25, the edge image to be detected is divided into squares into abnormal regions. Therefore, the shape of the abnormal region is a square, and the sides of the square are equilateral. Therefore, it is only necessary to calculate the number of pixels on one side and the total length of the pixels on the side (that is, the Euclidean distance can be used for calculation) to calculate the area of ​​the abnormal region. The pixel density of each abnormal region can be further evaluated based on the area of ​​the abnormal region to quantify the severity of the mold.

[0098] Furthermore, the square shape of the abnormal area and the pixel density of the abnormal area are normalized to ensure that they are within the same dimensional range. This allows the two to be fused to obtain a comprehensive feature vector, which is the distribution of mold in the abnormal area.

[0099] S264: Fuse texture features with color features and comprehensive feature vectors to obtain multi-scale mildew features;

[0100] Normalizing the texture features, color features, and comprehensive feature vectors in the multi-scale mildew features and performing weighted sum calculations to obtain a mildew index;

[0101] The calculation formula is:

[0102] MI=α1D norm +α2R norm +α3Texture norm +α4Color norm ;

[0103] Where D norm is the pixel density of the abnormal area in the standardized comprehensive feature vector;

[0104] Rnorm is the square shape of the abnormal region in the standardized comprehensive feature vector (i.e., shape feature);

[0105] Texture norm is the texture feature of the abnormal area after normalization;

[0106] Color norm is the color feature of the abnormal area after normalization;

[0107] α i is the corresponding weight;

[0108] It should be noted that the texture features, color features, and comprehensive feature vectors are standardized to eliminate the dimensionality effect and ensure that each feature can be used to calculate the final mold index. The mold index is used to make a final judgment on the abnormal area, thereby obtaining the mold result.

[0109] S265: Preset an abnormal threshold o; determine whether the mold index is greater than the abnormal threshold o;

[0110] If not, it is determined that the abnormal area has no abnormal defects, and each abnormal area is traversed. If all of them are not moldy, it is determined that the Gastrodia elata in the medicinal material image has no abnormal defects;

[0111] If so, it is determined that the abnormal region has an abnormal defect. If one of the abnormal regions has an abnormal defect, then the Gastrodia elata in the medicinal material image has a quality problem.

[0112] It should be noted that by presetting the mold threshold o, the calculated mold index is judged to determine whether there is a quality problem with the Gastrodia elata, thereby determining whether the Gastrodia elata can be sold;

[0113] Further research found that after a certain degree of mold, cavities will appear in the abnormal area. The brightness of the cavities is high, which can easily lead to misjudgment of their glossiness and misjudgment of them as normal areas. Figure 4 As shown (i.e., the schematic image of the hollow part of Gastrodia elata); therefore, in step S26, as Figure 10 As shown, abnormal defects also include void abnormalities. The specific operation steps are as follows:

[0114] S261′: Calculating the texture feature and the color feature to obtain a preliminary mildew index (i.e., the preliminary mildew index can only identify mildew anomalies, and the abnormality of cavities needs to be further determined later);

[0115] Preset a counter-intuitive threshold t1; determine whether the preliminary mildew index is greater than the preset counter-intuitive threshold t;

[0116] If so, it is determined that the abnormal area is suspected of having mold abnormality, and the said area is directly subjected to step S265' to determine whether there is abnormal defect;

[0117] If not, the surface of the abnormal area is suspected to have a cavity feature, and step S262' is performed on the abnormal area to further extract the features of the abnormal area to determine whether there is a cavity abnormality;

[0118] It should be noted that the mold index is preliminarily calculated through texture features and color features (i.e., the method of obtaining texture features and color features is described in steps S261 and S262 and will not be repeated here), and a counter-intuitive design is used to judge whether there are other problems and defects in the Gastrodia elata in addition to the possibility of mold, such as Gastrodia elata cavities; the traditional method is usually "alarm if it is above the threshold and release if it is below the threshold", but it does the opposite: "in-depth inspection is carried out if it is below the threshold";

[0119] If there are obvious mold spots on the surface (above the counter-intuitive threshold t), there is a high probability of mold, and the process directly proceeds to step S265' to determine mold. If the surface looks fresh (below the counter-intuitive threshold t), a thorough inspection of the internal condition is necessary to prevent the situation where the surface appears fresh but the interior is already deteriorated.

[0120] Therefore, the texture features and color features of the abnormal area obtained above alone cannot effectively identify the presence of cavities in Gastrodia elata, so it is necessary to further extract the features of the abnormal area in step S262' to calculate the mildew index; this can focus on suspicious abnormal areas, reduce abnormal areas that may have disguised abnormal defects, and prevent missed detection of areas that appear normal but are actually problematic;

[0121] S262': Fusing the texture feature with the color feature to form a surface feature vector; and calculating a hole credibility score for the surface feature vector using a support vector machine;

[0122] It should be noted that texture features and color features are both features of the surface of the abnormal area. They can be fused into a surface feature vector, which can better observe the holes on the surface of the abnormal area. Because the brightness of the hole is high, it is easy to misjudge its glossiness. Therefore, the surface features of texture features and color features are very helpful for identifying holes with low brightness.

[0123] Furthermore, support vector machines are used to train historical data (i.e., collect historical data, including known moldy and non-moldy cavity samples), mark the cavities, and perform surface feature vector analysis to obtain the cavity credibility score. In this way, the score is used to determine whether the abnormal area actually has a cavity.

[0124] S263': Preset; determine whether the credibility score of the hole is greater than the credibility threshold t2;

[0125] If so, it is determined that there is a hole in the abnormal area; and the texture features and color features are dynamically weighted according to the credibility score of the hole, and the mold index is recalculated. Step S265' is performed on the mold index to determine whether there is an abnormal defect;

[0126] If not, then further executing step S264′ adds the comprehensive feature vector of the actual area and shape features of the abnormal region to determine whether there is an abnormal defect;

[0127] It should be noted that, due to the counterintuitive design, the initial mold index did not show the ability to identify void anomalies. Therefore, the void credibility score was needed to recalculate the mold index. The void credibility score was used to dynamically adjust the weights of texture and color features to calculate a new mold index (that is, a mold index that can identify void anomalies). By incorporating credibility into the calculation of the mold index, the final result can be more reliable and prevent the misassessment of anomalies.

[0128] When the hole credibility score is less than or equal to the credibility threshold t2, it indicates that the abnormal region with a low hole credibility score is still affected by the relatively obvious hole glossiness. In this case, step S264′ is executed to identify holes on the surface of the abnormal region based on the pixel density and shape characteristics (i.e., the square shape of the abnormal region).

[0129] S264′: recalculating the mildew index using the texture features, color features, and comprehensive feature vector (i.e., the mildew index is determined to be a cavity defect; and the method for obtaining the comprehensive feature vector has been described in detail in step S263 and will not be repeated here);

[0130] It should be noted that by directly calculating the mold index from the feature vector (rather than calculating the multi-scale mold features), the processing flow can be simplified, and the severity or probability of the cavity can be directly extracted from features such as texture features and color features, without the need for complex segmentation, detection, or subsequent verification steps. This direct prediction method also allows mold anomalies to be identified primarily through the surface features of the abnormal area, so they need to be fused into multi-scale mold features. Cavity anomalies, on the other hand, require a close connection between surface features, density, and shape to reflect errors caused by glossiness in the cavity, preventing misidentification due to the complexity of the fused features, so they do not need to be fused into multi-scale mold features.

[0131] By adding comprehensive feature vectors to the support vector machine for retraining, the mold index can be recalculated;

[0132] S265': Preset an abnormal threshold o; determine whether the mold index is greater than the abnormal threshold o;

[0133] If not, it is determined that no abnormal defects appear in the abnormal area, and each abnormal area is traversed. If no abnormal defects appear in all of them, it is determined that no abnormal defects appear in the Gastrodia elata of the medicinal material image;

[0134] If yes, it is determined that an abnormal defect occurs in the abnormal region. If an abnormal defect occurs in one of the abnormal regions, the Gastrodia elata in the medicinal material image has a quality problem (ie, step S265' is the same as step S265);

[0135] Specifically, such as Figure 11 As shown, in step S264, the texture feature is fused with the color feature and the comprehensive feature vector to obtain a multi-scale mildew feature. The specific operation steps are as follows:

[0136] S2641: normalizing the texture features, color features, and comprehensive feature vectors to form a preliminary feature vector;

[0137] It should be noted that the dimensions of different features may cause some features to affect the efficiency of fusion or fail, so standardization ensures that all features are compared at the same scale to improve the efficiency of preliminary fusion (that is, the preliminary feature vector is a feature vector formed by merging the texture features, color features, shape features and pixel density after standardization; it represents the basic feature information of the moldy sample and is usually extracted at a single scale or global scale); and by merging features from different sources to form a comprehensive information carrier, it can more comprehensively describe the moldy phenomenon; different types of features provide multi-angle information, which enables a better understanding of the moldy characteristics, so that the calculation of the moldy index after obtaining the multi-scale moldy features can be more stable and accurate.

[0138] S2642: Perform a downsampling operation on the abnormal area to generate image pyramids of multiple scales;

[0139] Extracting features of multiple scales of a preliminary feature vector for each layer of the image pyramid; fusing the extracted features to form a multi-scale mildew feature vector (i.e., a multi-scale mildew feature);

[0140] It should be noted that the extracted features include texture features, color features, shape features, pixel density features, and some detailed features. For example, extracting larger-scale rough texture and color features is suitable for capturing overall mold trends. Detailed features include medium-scale features, suitable for more refined structural analysis. Detailed-level features can identify mold patterns within a smaller range. Extracting the most subtle features is suitable for detecting local mold. By fusing different extracted features, a multi-scale mold feature vector is formed.

[0141] Example 2

[0142] like Figure 12 As shown, the present invention also provides a Chinese medicinal material phase feature extraction and classification processing system, comprising: a collection module 10; an identification module 20;

[0143] The acquisition module 10 is used to acquire the medicinal material image of Gastrodia elata, pre-process the medicinal material image of Gastrodia elata, and obtain the medicinal material image to be detected;

[0144] The recognition module 20 is used to perform edge detection on the medicinal material image to be detected to extract contour information to obtain the edge image to be detected; extract multi-scale mildew features from the edge image to be detected, and identify abnormal defects in the medicinal material image of Gastrodia elata through the multi-scale mildew features.

[0145] In summary, the method for extracting and classifying the characteristics of Chinese medicinal materials proposed in the present invention can be seen to acquire more comprehensive medicinal material characteristics by collecting images of Gastrodia elata at different angles and under different lighting conditions, and performing pre-processing such as denoising and smoothing to obtain the image of the medicinal material to be detected, so that the image of the medicinal material to be detected can be more accurate in the recognition process;

[0146] Furthermore, the Sobel operator is used to calculate the edge strength in the horizontal direction and the edge strength in the vertical direction of the medicinal material image to be detected. The edge strength can identify the pixel points of the edge of the medicinal material image to be detected, and can also calculate the gradient amplitude and edge direction of each pixel point of the medicinal material image to be detected. Not only can the edges in the image be effectively detected, but also representative (i.e., maximum) pixels in the neighborhood range can be found as pixels to be selected. Only the most significant edges can be retained, thereby improving the clarity of the edge of the medicinal material image to be detected; then, by setting the edge gradient threshold, strong edge pixels and weak edge pixels are screened out, and non-edge pixels are removed. Then, useful pixels are extracted from the weak edge pixels as connecting edge pixels and strong edge pixels to form an edge image to be detected. This not only improves the overall coherence and accuracy of the edge of the edge image to be detected, but also makes the edge image to be detected more complete and clear; the edge image to be detected is divided into multiple square local areas to be detected, and the abnormal area is judged by the grayscale mean. In this way, the areas where abnormalities may exist can be judged by different grayscale change differences, thereby improving the detection efficiency;

[0147] Furthermore, the texture distribution features of different scales in multiple abnormal areas are firstly analyzed to capture the directional features of the texture. Various texture changes can be better identified through the distribution of texture. At the same time, the direction of mildew can be determined. The directional features are then fused with the texture distribution features to obtain the final texture features, thereby reflecting the abnormality of mildew in the abnormal area. Each abnormal area is converted into HSV space, and the color histogram is calculated to obtain the color features. This can eliminate the effects caused by changes in image size and illumination, ensure the consistency and comparability of the features, and effectively observe mildew through these surface features. The actual area of ​​the square-shaped abnormal area is calculated, and then the pixel The pixel density of the abnormal region is obtained by dividing the number of points by the actual area of ​​the abnormal region, which can be used to quantify the severity of mold in each abnormal region. The square shape of the abnormal region and the pixel density of the abnormal region are normalized, and the features are fused to obtain a comprehensive feature vector, which can be used to understand the distribution of mold in the abnormal region. The texture features are fused with the color features and the comprehensive feature vector to obtain multi-scale mold features. By comprehensively considering different features, moldy areas can be identified more effectively, reducing the probability of missed detection or false detection. The texture features, color features and the comprehensive feature vector are normalized and then weighted and summed to obtain a mold index, which can quickly identify abnormal defects in the image of the medicinal material to be tested.

[0148] Furthermore, abnormal defects also include void abnormalities; the texture features and color features are calculated to obtain a preliminary mildew index, and a counter-intuitive judgment is made through the preliminary mildew index to determine whether there are other defects (i.e., void defects) in the abnormal area. In this way, the suspicious abnormal area can be focused on to prevent missed detection; the texture features and color features are fused to form a surface feature vector, and the voids on the surface of the abnormal area are better observed; the support vector machine is used to calculate the surface feature vector to predict the void credibility score to determine whether the void defect actually exists; if the credibility threshold t2 is used to determine whether there is a void, the actual area of ​​the abnormal area and the comprehensive feature vector of the shape features are added to directly calculate the mildew index. This not only simplifies the processing flow, but also reduces the errors that may be caused by the fusion of multi-scale mildew features. Finally, it is determined whether an abnormality occurs to obtain the final result.

[0149] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. A person skilled in the art may modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for extracting and classifying Chinese medicinal materials phase characteristics, characterized in that: The following steps are included: Collecting a medicinal material image of Gastrodia elata, and preprocessing the medicinal material image of Gastrodia elata to obtain a medicinal material image to be detected; Performing edge detection on the medicinal material image to be detected to extract contour information to obtain an edge image to be detected; Dividing the edge image to be detected into a plurality of square local areas to be detected, and calculating the grayscale mean of each local area to be detected; And set the abnormal threshold r; traverse each local area to be detected to see if the grayscale mean is greater than the abnormal threshold r; If not, the local area to be detected has no abnormal area; If so, the local area to be detected is determined to be an abnormal area; The number of edge pixels on one side of the edge of the square shape of the abnormal area is counted, and the distance between adjacent edge pixels on the side of the square shape of the abnormal area is calculated. The distance between all adjacent edge pixels is calculated as the sum of the distances to calculate the actual area of ​​the abnormal area; Dividing the number of pixels by the actual area of ​​the abnormal area to obtain the pixel density of the abnormal area; Normalizing the square shape of the abnormal area and the pixel density of the abnormal area, and performing weighted averaging on the square shape of the abnormal area and the pixel density of the abnormal area to fuse them into a comprehensive feature vector; The texture features, color features and comprehensive feature vectors in the abnormal area are fused to obtain multi-scale mildew features; The multi-scale mildew features are quantitatively evaluated for a mildew degree to obtain a mildew index; and abnormal defects of the medicinal material image to be detected are determined based on the mildew index.

2. A method for extracting and classifying Chinese medicinal materials according to claim 1, characterized in that: The abnormal defects include: mold abnormality and cavity abnormality.

3. A method for extracting and classifying Chinese medicinal materials according to claim 2, characterized in that: Perform edge detection on the medicinal material image to be detected to extract contour information to obtain the edge image to be detected. The specific operation steps are as follows: Calculating the horizontal and vertical edge strengths of the image of the medicinal material to be detected by using the Sobel operator; The gradient amplitude of each pixel of the medicinal material image to be detected is calculated by the horizontal edge intensity and the vertical edge intensity, and the calculation formula is: ; Where Gx and Gy are the edge strength in the horizontal direction and the edge strength in the vertical direction respectively; The edge direction of the medicinal material image to be detected is calculated using the inverse tangent function through the horizontal edge strength and the vertical edge strength. The calculation formula is: ; Where, θ represents the edge direction of the medicinal material image to be detected; Traversing each pixel of the medicinal material image to be detected; Quantizing each pixel in four main directions according to the edge direction; Searching for two adjacent pixels in each main direction for each pixel point, and detecting whether the gradient amplitude of each pixel point is the maximum value between the two adjacent pixels in each main direction; If not, the pixel point of the medicinal material image to be detected is removed; If so, the pixel point is retained in the image of the medicinal material to be detected as the pixel point to be selected; Preset strong edge gradient threshold h and weak edge gradient threshold j; Determine whether the gradient amplitude of each pixel to be selected is greater than the strong edge gradient threshold h; If yes, keep the pixel to be selected as a strong edge pixel; If not, the gradient amplitude of the remaining pixels to be selected is determined to be between the strong edge gradient threshold h and the threshold value less than the weak edge gradient threshold j; If yes, the remaining pixels to be selected that meet the threshold range requirements are taken as weak edge pixels; If not, the last remaining pixel to be selected is treated as a non-edge pixel and is removed; Traversing all weak edge pixels through a connection algorithm, and retaining weak edge pixels connected to the strong edge pixels as connected edge pixels; Connect all connected edge pixels with all strong edge pixels to obtain the edge image to be detected.

4. A method for extracting and classifying Chinese medicinal materials according to claim 3, characterized in that: All weak edge pixels are traversed by the connection algorithm, and weak edge pixels connected to the strong edge pixels are retained as connected edge pixels. The specific operation steps are as follows: Traverse the neighborhood of each weak edge pixel to see if there is a strong edge pixel; If not, the weak edge pixel is removed; If yes, the weak edge pixel is retained; and the direction difference between the direction of the weak edge pixel and the direction of the strong edge pixel in the neighborhood is further calculated; A direction difference threshold z is preset to determine whether the direction difference between the edge direction of the weak edge pixel and the edge direction of the strong edge pixel in the neighborhood is less than the preset direction difference threshold z; If not, the weak edge pixel is removed; If yes, the weak edge pixel is retained; and the Euclidean distance between the weak edge pixel and the strong edge pixel is further calculated; A Euclidean distance threshold f is preset, and it is determined whether the Euclidean distance between the weak edge pixel and the strong edge pixel is less than the Euclidean distance threshold f; If not, the weak edge pixel is removed; If so, the weak edge pixel is regarded as a connecting edge pixel.

5. A method for extracting and classifying Chinese medicinal materials according to claim 4, characterized in that: The method further includes quantitatively evaluating the degree of mold on the multi-scale mold features to obtain a mold index; and determining abnormal defects in the image of the medicinal material to be detected based on the mold index. The specific operation steps are as follows: Normalizing the texture features, color features, and comprehensive feature vectors in the multi-scale mildew features and performing weighted sum calculations to obtain a mildew index; The calculation formula is: ; Where, is the pixel density of the abnormal area in the standardized comprehensive feature vector; Rnorm is the square shape of the abnormal region in the standardized integrated feature vector; is the texture feature of the abnormal area after normalization; is the color feature of the abnormal area after normalization; is the corresponding weight; Preset abnormal threshold o; Determine whether the mildew index is greater than an abnormal threshold value o; If not, it is determined that the abnormal area has no abnormal defects, and each abnormal area is traversed. If no mold is found in any of them, it is determined that the Gastrodia elata in the medicinal material image has no abnormal defects; If so, it is determined that an abnormal defect occurs in the abnormal area. When an abnormal defect occurs in one of the abnormal areas, there is a quality problem with the Gastrodia elata in the medicinal material image.

6. A method for extracting and classifying Chinese medicinal materials according to claim 4, characterized in that: Abnormal defects also include void abnormalities. The specific operation steps are as follows: The texture features and color features are calculated to obtain a preliminary mildew index; Preset a counter-intuitive threshold t1; determine whether the preliminary mildew index is greater than the preset counter-intuitive threshold t; If yes, the abnormal area is suspected to have mold abnormality, and the area is directly subjected to the subsequent final step to determine whether there is abnormal defect; If not, the surface of the abnormal area is suspected to have a cavity feature, and the abnormal area is further extracted to determine whether there is a cavity abnormality; The texture feature and the color feature are integrated to form a surface feature vector; and a support vector machine is used to calculate a hole credibility score for the surface feature vector; Preset a credibility threshold t2; determine whether the credibility score of the hole is greater than the credibility threshold t2; If so, it is determined that there is a hole in the abnormal area; and the texture features and color features are dynamically weighted according to the credibility score of the hole, and the mold index is recalculated. The subsequent final step is performed on the mold index to determine whether there is an abnormal defect; If not, the next step is to add the actual area and shape characteristics of the abnormal area into the comprehensive feature vector to determine whether there is an abnormal defect; Recalculate the mildew index by using texture features, color features and comprehensive feature vectors; Preset an abnormal threshold o; determine whether the mold index is greater than the abnormal threshold o; If not, it is determined that the abnormal area has no abnormal defects, and each abnormal area is traversed. If no mold is found in any of them, it is determined that the Gastrodia elata in the medicinal material image has no abnormal defects; If so, it is determined that an abnormal defect occurs in the abnormal area. When an abnormal defect occurs in one of the abnormal areas, there is a quality problem with the Gastrodia elata in the medicinal material image.

7. A method for extracting and classifying Chinese medicinal materials according to claim 6, characterized in that: The texture features are integrated with the color features and the comprehensive feature vector to obtain the multi-scale mildew features. The specific steps are as follows: Normalizing the texture features, color features, and comprehensive feature vectors, and combining them to form a preliminary feature vector; Performing a downsampling operation on the abnormal area to generate image pyramids of multiple scales; Performing preliminary feature extraction of multiple scales of feature vectors on each layer of the image pyramid; The extracted features are fused to form a multi-scale mildew feature vector.

8. A Chinese medicinal material phase feature extraction and classification processing system, characterized in that: include: Acquisition module; Identification module; The acquisition module is used to acquire the medicinal material image of Gastrodia elata, pre-process the medicinal material image of Gastrodia elata, and obtain the medicinal material image to be detected; The recognition module is used to perform edge detection on the medicinal material image to be detected to extract contour information and obtain an edge image to be detected; Dividing the edge image to be detected into a plurality of square local areas to be detected, and calculating the grayscale mean of each local area to be detected; And set the abnormal threshold r; traverse each local area to be detected to see if the grayscale mean is greater than the abnormal threshold r; If not, the local area to be detected has no abnormal area; If so, the local area to be detected is determined to be an abnormal area; The number of edge pixels on one side of the edge of the square shape of the abnormal area is counted, and the distance between adjacent edge pixels on the side of the square shape of the abnormal area is calculated. The distance between all adjacent edge pixels is calculated as the sum of the distances to calculate the actual area of ​​the abnormal area; Dividing the number of pixels by the actual area of ​​the abnormal area to obtain the pixel density of the abnormal area; Normalizing the square shape of the abnormal area and the pixel density of the abnormal area, and performing weighted averaging on the square shape of the abnormal area and the pixel density of the abnormal area to fuse them into a comprehensive feature vector; The texture features, color features and comprehensive feature vectors in the abnormal area are fused to obtain multi-scale mildew features; The multi-scale mildew features are quantitatively evaluated for a mildew degree to obtain a mildew index; and abnormal defects of the medicinal material image to be detected are determined based on the mildew index.

Citation Information

Patent Citations

  • Quality evaluation method, equipment and medium for traditional Chinese medicinal materials

    CN108732172A

  • Tablet quality detection method in medicine production process based on image data

    CN117274251A