Machine vision-based traditional Chinese medicinal material production quality analysis system and method
By using a machine vision-based method for analyzing the production quality of Chinese medicinal materials, the shortcomings of traditional Chinese medicinal material testing in terms of texture, color, and deterioration have been addressed. This method enables efficient and accurate automated testing, adapts to medicinal materials with complex shapes, identifies quality defects, and improves production efficiency and quality reliability.
Patent Information
- Application Number
- CN202411835030.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2044-12-13
AI Technical Summary
Existing technologies fail to fully consider texture, color, and deterioration in the quality testing of Chinese medicinal materials. Furthermore, they are greatly affected by lighting and background interference in complex environments, making them unsuitable for Chinese medicinal herbs with complex shapes and high precision requirements, resulting in low testing efficiency and large errors.
A machine vision-based approach is adopted, which involves image preprocessing, morphological analysis, color and texture evaluation, combined with deterioration analysis, dynamically adjusting the edge detection scale, extracting the contour and convex hull of Chinese medicinal materials, calculating the minimum rectangle, evaluating their morphology, color, texture and deterioration, and finally performing quality assessment and classification.
It has achieved fully automated testing of Chinese medicinal materials, improved testing efficiency and accuracy, is adaptable to various forms of medicinal materials, identifies potential quality defects, reduces human error, and ensures the quality and efficacy of medicinal materials.
Smart Images

Figure CN119693343B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of traditional Chinese medicine quality analysis technology, specifically a system and method for analyzing the production quality of traditional Chinese medicine based on machine vision. Background Technology
[0002] With the advancement of modern industrial production, the production and processing of Chinese medicinal herbs are gradually moving towards automation and standardization. To ensure that the quality of these herbs meets standards, traditional quality testing methods are increasingly unable to meet the demands of large-scale production. The quality of Chinese medicinal herbs depends not only on their appearance but also on factors such as texture, color, and signs of spoilage. In this process, traditional manual quality testing faces problems such as high labor intensity, low efficiency, and human error.
[0003] With the rapid development of computer vision, image processing, and artificial intelligence technologies, machine vision systems, through high-definition camera equipment, image acquisition, processing, analysis, and artificial intelligence technologies, can automatically sort and screen Chinese medicinal materials, and assess whether their morphology meets quality standards. While these existing technologies can help improve the automation level of quality inspection, they also have the following problems: 1) Interference from lighting and background: In complex production environments, changes in lighting and background interference often lead to a decrease in image quality; 2) Lack of adaptability to medicinal materials with complex morphologies: Many Chinese medicinal materials (such as the roots, stems, and flowers of Chinese herbs) have complex and irregular morphologies; 3) High precision requirements: The quality analysis of Chinese medicinal materials requires extremely high precision.
[0004] For example, Chinese patent CN108982788B discloses a big data-based quality assessment system for Chinese medicinal materials. This system includes a data acquisition module, an image acquisition module, a raw material detection module, a server, and a display terminal. The server is connected to each of these modules. This invention, through the data acquisition module, image acquisition module, raw material detection module, and server, effectively analyzes basic data and image information of Chinese medicinal materials, as well as their moisture content, pesticide residues, aflatoxin content, and total heavy metal content. This allows for the assessment of the quality of each medicinal material, facilitating the screening and classification of medicinal materials. It avoids the waste of time, manpower, and resources in manual assessment, and features high accuracy and speed in evaluating medicinal materials. This greatly facilitates the selection of medicinal materials and ensures the consistency of evaluation standards.
[0005] The aforementioned patent has the following drawback: it does not take into account the characteristics of Chinese medicinal materials, such as texture, color, and deterioration. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention proposes a machine vision-based system and method for analyzing the production quality of Chinese medicinal materials. The aim is to comprehensively analyze the multi-dimensional characteristics of Chinese medicinal materials, such as shape, texture, and color, through image information, thereby achieving efficient, accurate, and automated quality detection of Chinese medicinal materials.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] The machine vision-based method for analyzing the production quality of Chinese medicinal materials includes the following specific steps:
[0009] Step S1: Acquire images of Chinese medicinal herbs and preprocess the acquired images;
[0010] Step S2: Perform morphological analysis on the preprocessed images of Chinese medicinal materials to analyze their morphology;
[0011] Step S3: Analyze the color, texture, and deterioration of the preprocessed images of Chinese medicinal materials;
[0012] Step S4: Evaluate and analyze the quality of the Chinese medicinal materials and classify them according to quality.
[0013] Step S5: Store the quality assessment and analysis data of each batch of Chinese medicinal materials in the database for quality traceability and analysis.
[0014] Specifically, the steps of step S2 are as follows:
[0015] Step S201: Extract the contour of the Chinese medicinal materials from the preprocessed image of the Chinese medicinal materials, and calculate the gradient magnitude of the preprocessed image of the Chinese medicinal materials at pixel (x,y). The calculation formula is as follows:
[0016] ,
[0017] Where G(x,y) represents the gradient magnitude of the preprocessed Chinese medicinal material image at pixel (x,y), and I(x,y) represents the grayscale value of the preprocessed Chinese medicinal material image at pixel (x,y). This represents the gradient in the horizontal direction of the preprocessed image of Chinese medicinal materials. This represents the gradient in the vertical direction of the preprocessed image of Chinese medicinal materials. This indicates the partial derivative;
[0018] Step S202: Dynamically adjust the scale of edge detection based on the range of gradient value changes, and set the scale factor. , ,in, The standard deviation represents the local area. This represents the overall standard deviation of the preprocessed images of Chinese medicinal materials.
[0019] Step S203: When the gradient magnitude at position (x,y) is greater than or equal to the scaling factor When a pixel (x, y) is determined to belong to an edge region, the outline of the Chinese medicinal material in the preprocessed image of the Chinese medicinal material is obtained.
[0020] Specifically, step S2 further includes:
[0021] Step S204: Define the set of contour points of the Chinese medicinal materials as P, P={p1,p2,...,p...} n}, p n Let H(P) represent the contour points of the nth Chinese medicinal herb, and let H(P) be the set of convex hull points of the Chinese medicinal herb. For any contour point p i Contour point p i Neighboring points satisfy the following constraints: , where p j and p k Represents the contour point p i neighborhood points, It means that the point p i p j and p k A given determinant, where the value of the determinant is greater than or equal to zero, determines that the three points form a convex shape;
[0022] Step S205: Calculate the area of the smallest rectangle based on the convex hull by rotation. The specific formula is as follows:
[0023] ,
[0024] Among them, A min This represents the area of the smallest rectangle that encloses the outline of the Chinese medicinal herb. Indicates the rotation angle. Represents the coordinates of the j-th point in the set of convex hull points of Chinese medicinal materials;
[0025] Step S206: According to A min The length and width of the smallest rectangle enclosing the outline of the Chinese medicinal herb are obtained, and the morphology of the herb is evaluated using the following formula: ,in, The value of r represents the morphological evaluation of Chinese medicinal materials. min r represents the aspect ratio of the smallest rectangle enclosing the outline of the Chinese medicinal herb. bz This represents the aspect ratio of the smallest rectangle in the standard Chinese medicinal materials.
[0026] Specifically, the steps of step S3 are as follows:
[0027] Step S301: Convert the preprocessed Chinese medicinal material image from RGB space to Lab space, and analyze the color deviation of the preprocessed Chinese medicinal material image. The specific formula is as follows:
[0028] ,
[0029] in, This indicates the color deviation in the preprocessed image of Chinese medicinal materials. , and , respectively represent the three component values of the Lab space of the preprocessed Chinese medicinal material image, and Lmean, amean and bmean represent the mean values of the three components of all pixels in the Lab space of the preprocessed Chinese medicinal material image;
[0030] Step S302: Statistically determine the gray levels of the preprocessed Chinese medicinal material image, set as Hd, and evaluate the texture of the preprocessed Chinese medicinal material image using the following formula: , Hdbz represents the texture evaluation value of Chinese medicinal materials, and Hdbz represents the gray level of standard Chinese medicinal materials.
[0031] Step S303: Evaluate the deterioration status of the Chinese medicinal materials based on the preprocessed images, using the following formula: ,in, Sbz represents the assessment value of the deterioration of Chinese medicinal materials, and Sz represents the total area of Chinese medicinal materials.
[0032] Specifically, the steps of step S4 are as follows:
[0033] Step S401: Based on the analysis results of the morphology, color, texture, and deterioration of the medicinal materials, the quality of the medicinal materials is evaluated. The specific formula is as follows:
[0034] ,
[0035] Where Zl represents the quality assessment value of the Chinese medicinal material, and exp represents the exponential function. represents the nonlinear weighting coefficient, and b represents the bias term;
[0036] Step S402: Based on the quality assessment results of the Chinese medicinal materials, the Chinese medicinal materials are divided into different quality grades. When Zl > 0.8, they are judged as high quality; when 0.6 ≤ Zl ≤ 0.8, they are judged as medium quality; and when Zl < 0.6, they are judged as low quality.
[0037] Specifically, the preprocessing in step S1 includes: noise reduction, color correction, and edge enhancement;
[0038] The denoising is used to remove noise from the image of Chinese medicinal materials;
[0039] The color correction is used to eliminate the influence of different lighting conditions on the color of Chinese medicinal materials images;
[0040] The edge enhancement is used to enhance edge information in the image.
[0041] The machine vision-based Chinese medicinal herb production quality analysis system is used to implement the machine vision-based Chinese medicinal herb production quality analysis method, including: an image acquisition module, a morphological analysis module, a quality analysis module, a quality assessment module, and a data storage module.
[0042] The image acquisition module is used to acquire images of Chinese medicinal materials and to preprocess the acquired images of Chinese medicinal materials.
[0043] The morphological analysis module is used to perform morphological analysis on the preprocessed images of Chinese medicinal materials and to analyze the morphology of the Chinese medicinal materials.
[0044] The quality analysis module is used to analyze the color, texture, and deterioration of the preprocessed images of Chinese medicinal materials.
[0045] The quality assessment module is used to assess and analyze the quality of Chinese medicinal materials and classify them according to quality.
[0046] The data storage module is used to store the quality assessment and analysis data of each batch of Chinese medicinal materials in the database for quality traceability and analysis.
[0047] Specifically, the morphology analysis module includes: a contour extraction unit, a minimum rectangle calculation unit, and a morphology evaluation unit;
[0048] The contour extraction unit is used to dynamically adjust the scale of edge detection and extract edge contours based on the range of gradient values in the preprocessed Chinese medicinal material image.
[0049] The minimum rectangle calculation unit is used to find the convex hull based on the extracted edge contour, and calculate the area of the minimum rectangle based on the convex hull.
[0050] The morphological evaluation unit is used to evaluate the morphology of Chinese medicinal materials based on the length and width of the smallest rectangle.
[0051] Specifically, the quality analysis module includes: a color deviation analysis unit, a texture evaluation unit, and a degradation evaluation unit;
[0052] The color deviation analysis unit is used to analyze the color deviation of the preprocessed Chinese medicinal material image;
[0053] The texture evaluation unit is used to evaluate the texture of the preprocessed Chinese medicinal material image;
[0054] The deterioration assessment unit is used to assess the deterioration status of Chinese medicinal materials based on the preprocessed images of the medicinal materials.
[0055] Compared with the prior art, the beneficial effects of the present invention are:
[0056] 1. This invention proposes a machine vision-based method for analyzing the production quality of Chinese medicinal materials, which can achieve fully automated detection, significantly reduce human intervention, improve production efficiency, and avoid the impact of human error. Especially in large-scale production, the machine vision system can quickly process a large amount of image data of medicinal materials, achieve real-time detection and classification, thereby improving the overall efficiency of the production line.
[0057] 2. This invention proposes a machine vision-based method for analyzing the production quality of Chinese medicinal materials. It can flexibly adapt to various forms of medicinal materials, including Chinese herbal medicines with complex and varied shapes, and medicinal materials with irregular surfaces after drying. It can also adapt to different batches and specifications of medicinal materials, thereby improving the universality and reliability of the detection system.
[0058] 3. This invention proposes a machine vision-based method for analyzing the production quality of Chinese medicinal materials. It can not only identify problems with the appearance of medicinal materials, but also detect potential quality defects, such as surface cracks, mold, impurities, and dimensional deviations. This allows unqualified medicinal materials to be screened out in a timely manner during the production process, reducing the risk of inferior medicinal materials entering the market and ensuring the quality and efficacy of Chinese medicinal materials. Attached Figure Description
[0059] Figure 1 Flowchart of the machine vision-based method for analyzing the production quality of Chinese medicinal materials provided by this invention;
[0060] Figure 2 The system architecture diagram of the machine vision-based Chinese medicinal herb production quality analysis system provided by this invention. Detailed Implementation
[0061] To facilitate understanding of the technical means, creative features, and achieved objectives and effects of this invention, it should be noted in the description of this invention that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "number one," "number two," and "number three" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. The invention will be further described below in conjunction with specific embodiments.
[0062] Example 1
[0063] Please see Figure 1 The present invention provides an embodiment of a machine vision-based method for analyzing the production quality of traditional Chinese medicinal materials, comprising the following specific steps:
[0064] Step S1: Use a high-resolution camera or industrial camera to acquire images of Chinese medicinal herbs and preprocess the acquired images.
[0065] When collecting images of Chinese medicinal herb samples, it is necessary to take pictures of the samples from multiple angles and all directions. During the shooting process, appropriate light source configuration should be used to ensure the uniformity and clarity of image quality.
[0066] The preprocessing includes steps such as denoising, color correction, and edge enhancement to ensure that the image data is suitable for subsequent analysis. The denoising is used to remove noise from the Chinese medicinal herb images (such as changes in lighting during the shooting process, equipment noise, or environmental interference), making the important information in the image clearer. The color correction is used to eliminate the influence of different lighting conditions on the color of the Chinese medicinal herb images. The edge enhancement is used to enhance the edge information in the image, making the outline, shape, and other features of the Chinese medicinal herbs more obvious, which is convenient for subsequent morphological analysis, feature extraction, and classification.
[0067] Preprocessing also includes operations such as grayscale conversion;
[0068] Commonly used denoising methods include median filtering, Gaussian filtering, and mean filtering, which aim to reduce unnecessary details (noise) by smoothing the image, thereby improving image quality. Color correction usually involves converting the image from one color space to another, commonly from RGB color space to HSV or Lab color space. Commonly used edge enhancement techniques include Sobel operator and Laplacian operator, which can highlight the edge parts of the image and reduce the influence of flat areas.
[0069] Step S2: Perform morphological analysis on the preprocessed images of Chinese medicinal materials to analyze their morphology;
[0070] The specific steps of step S2 are as follows:
[0071] Step S201: Extract the contour of the Chinese medicinal materials from the preprocessed image of the Chinese medicinal materials, and calculate the gradient magnitude of the preprocessed image of the Chinese medicinal materials at pixel (x,y). The calculation formula is as follows:
[0072] ,
[0073] Where G(x,y) represents the gradient magnitude of the preprocessed Chinese medicinal material image at pixel (x,y), describing the edge strength of the preprocessed Chinese medicinal material image at that location, and I(x,y) represents the grayscale value of the preprocessed Chinese medicinal material image at pixel (x,y). This represents the gradient of the preprocessed image of Chinese medicinal materials in the horizontal direction (x-direction). This represents the gradient of the preprocessed image of Chinese medicinal materials in the vertical direction (y-direction). This indicates the partial derivative;
[0074] Gradient magnitude represents the intensity of changes in image brightness (grayscale) and is key to image edge detection. When the grayscale values around a pixel change significantly, the gradient magnitude of that pixel is large, indicating that the location may be an edge of the image.
[0075] Step S202: Dynamically adjust the scale of edge detection based on the range of gradient value changes, and set the scale factor. , ,in, The standard deviation represents the local area, describing the degree of dispersion of pixel grayscale changes within that local area. It represents the overall standard deviation of the preprocessed Chinese medicinal material image, describing the range of grayscale variation in the entire image;
[0076] The purpose of adaptive scaling is to select an appropriate scale based on the gray-level changes in local areas of the image. If the gray-level changes in a local area are large (high contrast), a smaller scale is selected to capture details; if the changes in a local area are small (low contrast), a larger scale is selected to smooth the image.
[0077] Step S203: When the gradient magnitude at position (x,y) is greater than or equal to the scaling factor When the pixel (x,y) is determined to belong to the edge region, the outline of the Chinese medicinal material in the preprocessed Chinese medicinal material image is obtained;
[0078] Based on the obtained outline of the Chinese medicinal material, the background of the Chinese medicinal material can be removed to obtain a complete image of the Chinese medicinal material;
[0079] Step S204: Define the set of contour points of the Chinese medicinal materials as P, P={p1,p2,...,p...} n}, p n Let H(P) represent the contour points of the nth Chinese medicinal herb, and let H(P) be the set of convex hull points of the Chinese medicinal herb. For any contour point p i Contour point p i Neighboring points satisfy the following constraints: , where p j and p k Represents the contour point pi neighborhood points, It means that the point p i p j and p k A given determinant is used to determine whether the three points form a convex shape. If the determinant is greater than or equal to zero, the three points are considered to form a convex shape.
[0080] A convex hull is the smallest convex polygon that encloses a set of points. When calculating a convex hull, the determinant is used to determine whether three points are on the same plane and whether they can form a convex hull. If the determinant is negative, it means that the three points form a concave shape, so they need to be removed to preserve the convex boundary.
[0081] Step S205: Calculate the area of the smallest rectangle based on the convex hull by rotation. The specific formula is as follows:
[0082] ,
[0083] Among them, A min This represents the area of the smallest rectangle that encloses the outline of the Chinese medicinal herb. Indicates the rotation angle. Represents the coordinates of the j-th point in the set of convex hull points of Chinese medicinal materials;
[0084] We find a minimum rectangle that encloses the image's outline by rotating the point set of the convex hull. By rotating the rectangle at different angles, we calculate its width and height at each angle. The aspect ratio of this rectangle can be used to describe the shape characteristics of the medicinal material.
[0085] Step S206: According to A min The length and width of the smallest rectangle enclosing the outline of the Chinese medicinal herb are obtained, and the morphology of the herb is evaluated using the following formula: ,in, The value of r represents the morphological evaluation of Chinese medicinal materials. min r represents the aspect ratio of the smallest rectangle enclosing the outline of the Chinese medicinal herb. bz This represents the aspect ratio of the smallest rectangle in the standard Chinese medicinal materials.
[0086] By comparing the shape with that of standard Chinese medicinal materials, non-compliant Chinese medicinal materials can be detected. For example, if the length-to-width ratio of a certain Chinese medicinal material is much greater than the expected range, it may indicate that there is a problem with the processing and production of that Chinese medicinal material.
[0087] Step S3: Analyze the color, texture, and deterioration of the preprocessed images of Chinese medicinal materials;
[0088] The specific steps of step S3 are as follows:
[0089] Step S301: Convert the preprocessed Chinese medicinal material image from RGB space to Lab space, and analyze the color deviation of the preprocessed Chinese medicinal material image. The specific formula is as follows:
[0090] ,
[0091] in, This indicates the color deviation in the preprocessed image of Chinese medicinal materials. , and These represent the three component values of the Lab space in the preprocessed image of Chinese medicinal materials, L, L, and L. mean a mean and b mean These represent the mean values of the three components of all pixels in the Lab space of the preprocessed Chinese medicinal material image;
[0092] A smaller deviation value means better color consistency. When converting RGB values to Lab color space, the RGB values must first be normalized to the [0,1] range, and then Gamma correction and XYZ conversion are performed to finally obtain the three components of Lab space.
[0093] Step S302: Statistically determine the gray levels of the preprocessed Chinese medicinal material image, set as Hd, and evaluate the texture of the preprocessed Chinese medicinal material image using the following formula: , Hd represents the texture evaluation value of Chinese medicinal materials. bz Indicates the grayscale level of standard Chinese medicinal materials;
[0094] By analyzing the surface texture, we can extract the microstructure information of the surface of Chinese medicinal materials, which plays an important role in quality judgment. The surface texture of Chinese medicinal materials may be closely related to factors such as their growth environment and processing methods, and can reflect the authenticity and naturalness of the medicinal materials. The gray level represents the maximum number of different gray values in the image. When the texture quality of Chinese medicinal materials is relatively low, that is, when there are many blemishes, the gray level is relatively large, and when the texture of Chinese medicinal materials is relatively good, the gray level is relatively small.
[0095] Step S303: Evaluate the deterioration status of the Chinese medicinal materials based on the preprocessed images, using the following formula: ,in, S represents the assessment value of the deterioration status of Chinese medicinal materials. bz S represents the area of deterioration of Chinese medicinal materials. z This indicates the total area of Chinese medicinal herbs.
[0096] The total area here is the surface area obtained from the preprocessed image of the Chinese medicinal materials.
[0097] Step S4: Evaluate and analyze the quality of the Chinese medicinal materials and classify them according to quality.
[0098] The specific steps of step S4 are as follows:
[0099] Step S401: Based on the analysis results of the morphology, color, texture, and deterioration of the medicinal materials, the quality of the medicinal materials is evaluated. The specific formula is as follows:
[0100] ,
[0101] Where Zl represents the quality assessment value of the Chinese medicinal material, and exp represents the exponential function. represents the non-linear weighting coefficient, and b represents the bias term, which is used to adjust the output of the quality assessment value;
[0102] It can adaptively adjust the contribution of each feature to the final evaluation, making the relationship between features more consistent with the complexity of actual Chinese medicinal material quality evaluation.
[0103] Nonlinear weighting coefficients The results were obtained through experimental simulations by those skilled in the art or were set according to actual conditions.
[0104] Step S402: Based on the quality assessment results of the Chinese medicinal materials, the Chinese medicinal materials are divided into different quality grades. When Zl > 0.8, they are judged as high quality; when 0.6 ≤ Zl ≤ 0.8, they are judged as medium quality; and when Zl < 0.6, they are judged as low quality.
[0105] Step S5: Store the quality assessment and analysis data of each batch of Chinese medicinal materials in the database for quality traceability and analysis.
[0106] Example 2
[0107] Please see Figure 2 Another embodiment of the present invention provides a machine vision-based Chinese medicinal herb production quality analysis system, comprising: an image acquisition module, a morphological analysis module, a quality analysis module, a quality assessment module, and a data storage module;
[0108] The image acquisition module is used to acquire images of Chinese medicinal materials and to preprocess the acquired images of Chinese medicinal materials.
[0109] The morphological analysis module is used to perform morphological analysis on the preprocessed images of Chinese medicinal materials and to analyze the morphology of the Chinese medicinal materials.
[0110] The quality analysis module is used to analyze the color, texture, and deterioration of the preprocessed images of Chinese medicinal materials.
[0111] The quality assessment module is used to assess and analyze the quality of Chinese medicinal materials and classify them according to quality.
[0112] The data storage module is used to store the quality assessment and analysis data of each batch of Chinese medicinal materials in the database for quality traceability and analysis.
[0113] The morphology analysis module includes: a contour extraction unit, a minimum rectangle calculation unit, and a morphology evaluation unit;
[0114] The contour extraction unit is used to dynamically adjust the scale of edge detection and extract edge contours based on the variation range of gradient values in the preprocessed Chinese medicinal material image.
[0115] The minimum rectangle calculation unit is used to find the convex hull based on the extracted edge contour, and calculate the area of the minimum rectangle based on the convex hull.
[0116] The morphological evaluation unit is used to evaluate the morphology of Chinese medicinal materials based on the length and width of the smallest rectangle.
[0117] The quality analysis module includes: a color deviation analysis unit, a texture evaluation unit, and a degradation evaluation unit;
[0118] The color deviation analysis unit is used to analyze the color deviation of the preprocessed Chinese medicinal material image;
[0119] The texture evaluation unit is used to evaluate the texture of the preprocessed Chinese medicinal material image;
[0120] The deterioration assessment unit is used to assess the deterioration status of Chinese medicinal materials based on the preprocessed images of the medicinal materials.
[0121] In addition, the parts of the technical solutions provided in the embodiments of this application that are consistent with the implementation principles of the corresponding technical solutions in the prior art have not been described in detail, so as to avoid excessive elaboration.
[0122] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the invention. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for analyzing the production quality of traditional Chinese medicinal materials based on machine vision, characterized in that, The method comprises the following specific steps: Step S1: an image of the Chinese medicinal material is collected, and the collected image of the Chinese medicinal material is preprocessed; Step S2: morphological analysis is performed on the preprocessed image of the Chinese medicinal material, and the morphology of the Chinese medicinal material is analyzed; Step S3: the color, texture and deterioration of the preprocessed image of the Chinese medicinal material are analyzed; Step S4: the quality of the Chinese medicinal material is evaluated and analyzed, and quality classification is performed; Step S5: the quality evaluation and analysis data of each batch of Chinese medicinal material are stored in a database for quality tracing and analysis; The specific steps of step S2 are: Step S201: the contour of the Chinese medicinal material in the preprocessed image of the Chinese medicinal material is extracted, and the gradient amplitude of the preprocessed image of the Chinese medicinal material at the pixel point (x, y) is calculated, and the calculation formula is: , wherein G(x, y) represents the gradient amplitude of the preprocessed traditional Chinese medicinal material image at the pixel point (x, y), and I(x, y) represents the gray value of the preprocessed traditional Chinese medicinal material image at the pixel point (x, y), represents the gradient of the preprocessed traditional Chinese medicinal material image in the horizontal direction, represents the gradient of the preprocessed traditional Chinese medicinal material image in the vertical direction, represents the partial derivative; Step S202: dynamically adjust the scale of edge detection according to the change range of the gradient value, and set a scale factor , , , wherein, , wherein, , wherein, Step S203: When the gradient amplitude at the position (x, y) is greater than or equal to the scale factor , it is determined that the pixel point (x, y) belongs to the edge region, and the contour of the traditional Chinese medicinal material in the preprocessed traditional Chinese medicinal material image is obtained. Step S204: Define the set of contour points of the Chinese medicinal materials as P, P={p1,p2,...,p...} n }, p n Let H(P) represent the contour points of the nth Chinese medicinal herb, and let H(P) be the set of convex hull points of the Chinese medicinal herb. For any contour point p i Contour point p i Neighboring points satisfy the following constraints: , where p j and p k Represents the contour point p i neighborhood points, It means that the point p i p j and p k A given determinant, where the value of the determinant is greater than or equal to zero, determines that the three points form a convex shape; Step S205: the area of the minimum rectangle is calculated on the basis of the convex hull through rotation, and the specific formula is: , wherein A min represents an area of the smallest rectangle enclosing the contour of the traditional Chinese medicinal material, represents a rotation angle, represents the coordinates of the jth point in the convex hull point set of the traditional Chinese medicinal material; Step S206: According to A min The length and width of the smallest rectangle enclosing the outline of the Chinese herbal medicine are obtained to evaluate the shape of the Chinese herbal medicine, and the specific formula is: Wherein, The shape evaluation value of the Chinese herbal medicine is represented by r min The aspect ratio of the smallest rectangle enclosing the outline of the Chinese herbal medicine is represented by r bz The aspect ratio of the smallest rectangle of the standard Chinese herbal medicine is represented by r The specific steps of step S3 are: Step S301: the preprocessed image of the Chinese medicinal material is converted from RGB space to Lab space, and the color deviation of the preprocessed image of the Chinese medicinal material is analyzed, and the specific formula is: , wherein, represents the color deviation of the pre-processed image of Chinese medicinal material, , and respectively represent three component values of the pre-processed image of Chinese medicinal material in Lab space, , and respectively represent three component mean values of all pixels in the pre-processed image of Chinese medicinal material in Lab space. Step S302: count the gray level of the pre-processed traditional Chinese medicinal material image, set as Hd, and evaluate the texture of the pre-processed traditional Chinese medicinal material image, the specific formula is: , represents the texture evaluation value of the traditional Chinese medicinal material, represents the gray level of the standard traditional Chinese medicinal material; Step S303: evaluate the deterioration condition of the traditional Chinese medicinal material according to the pre-processed traditional Chinese medicinal material image, and the specific formula is: wherein, represents the deterioration condition evaluation value of the traditional Chinese medicinal material, represents the deterioration area of the traditional Chinese medicinal material, represents the total area of the traditional Chinese medicinal material; The specific steps of step S4 are: Step S401: according to the analysis results of the morphology, color, texture and deterioration of the Chinese medicinal material, the quality of the Chinese medicinal material is evaluated, and the specific formula is: , Wherein, Zl represents the quality evaluation value of traditional Chinese medicinal materials, exp represents the exponential function, represents a nonlinear weighting coefficient, and b represents a bias term. Step S402: according to the quality evaluation result of the Chinese medicinal material, the Chinese medicinal material is divided into different quality grades, when Zl>0.8, it is determined as high quality, when 0.6≤Zl≤0.8, it is determined as medium quality, and when Zl<0.6, it is determined as low quality.
2. The machine vision-based Chinese medicinal material production quality analysis method according to claim 1, characterized in that, The preprocessing in step S1 includes denoising, color correction and edge enhancement; The denoising is used to remove the noise in the image of the Chinese medicinal material; The color correction is used to eliminate the influence of different light conditions on the color of the image of the Chinese medicinal material; The edge enhancement is used to enhance the edge information in the image.
3. A machine vision-based production quality analysis system for Chinese medicinal materials, for implementing the machine vision-based production quality analysis method of any one of claims 1-2, characterized in that, It comprises: An image collection module, a morphology analysis module, a quality analysis module, a quality evaluation module and a data storage module; The image collection module is used to collect the image of the Chinese medicinal material, and the collected image of the Chinese medicinal material is preprocessed; The morphology analysis module is used to perform morphological analysis on the preprocessed image of the Chinese medicinal material, and analyze the morphology of the Chinese medicinal material; The quality analysis module is used to analyze the color, texture and deterioration of the preprocessed image of the Chinese medicinal material; The quality evaluation module is used to evaluate and analyze the quality of the Chinese medicinal material, and perform quality classification; The data storage module is used to store the quality evaluation and analysis data of each batch of Chinese medicinal material in a database for quality tracing and analysis. 4.The machine vision-based Chinese medicinal material production quality analysis system according to claim 3, characterized by, The morphology analysis module comprises a contour extraction unit, a minimum rectangle calculation unit and a morphology evaluation unit; The contour extraction unit is used to dynamically adjust the scale of edge detection according to the change range of the gradient value of the preprocessed image of the Chinese medicinal material, and extract the edge contour; The minimum rectangle calculation unit is used to find a convex hull according to the extracted edge contour, and calculate the area of the minimum rectangle on the basis of the convex hull; The morphology evaluation unit is used to evaluate the morphology of the Chinese medicinal material according to the length and width of the minimum rectangle. 5.The machine vision-based Chinese medicinal material production quality analysis system according to claim 4, characterized in that, The quality analysis module comprises a color deviation analysis unit, a texture evaluation unit and a deterioration evaluation unit. The color deviation analysis unit is configured to analyze the color deviation of the preprocessed traditional Chinese medicinal material image. The texture evaluation unit is configured to evaluate the texture of the preprocessed traditional Chinese medicinal material image. The deterioration evaluation unit is configured to evaluate the deterioration of the traditional Chinese medicinal material according to the preprocessed traditional Chinese medicinal material image.
Citation Information
Patent Citations
A Big Data-Based Quality Assessment System for Chinese Medicinal Herbs
CN108982788B
Traditional Chinese medicine decoction piece quality detection and analysis system and method based on machine vision
CN118045773A