A method and system for identifying the age of medicinal materials based on machine vision
By constructing a multi-dimensional image acquisition quality screening mechanism and a year discrimination model, combined with microstructure boundary recognition and color drift function, the year characteristics of the medicinal material sample images are calculated, which solves the problem of inaccurate identification of the medicinal material year and achieves a more accurate medicinal material year assessment.
Patent Information
- Application Number
- CN202510907084.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-02
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-07-02
AI Technical Summary
In the existing technology, the vision-based method for identifying the age of medicinal materials lacks accuracy, especially for medicinal materials with similar appearance. Environmental changes during storage and differences in image acquisition conditions lead to inaccurate year identification.
A method for identifying the age of medicinal materials using machine vision is adopted. By constructing a multi-dimensional image acquisition quality screening mechanism, integrating the age discrimination model of structural and color evolution characteristics, and utilizing the age benchmark inference mechanism of spot structure ratio, the identification accuracy is improved.
By obtaining medicinal material sample images through multiple sets of sampling angles and light intensities, and combining the microstructure boundary recognition algorithm and the color drift path difference function, the cell collapse index and sequential color drift index are generated, and the ratio of structural spots is calculated to improve the accuracy of medicinal material year assessment.
Smart Images

Figure CN120411095B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine vision technology, and more particularly to a method and system for identifying the age of medicinal materials based on machine vision. Background Art
[0002] In the process of quality assessment and storage management of traditional Chinese medicines, the storage age of the medicine is a key indicator affecting its efficacy, safety and market pricing. Traditional methods of identifying the age of the medicine mostly rely on manual experience, label records or chemical composition testing;
[0003] The existing technology has the following deficiencies:
[0004] At present, especially for medicinal materials with similar appearance (such as dried tangerine peel, angelica sinensis, white peony root, etc.), due to environmental changes during storage, differences in image acquisition conditions, and nonlinear evolution of microscopic features such as color and structure, vision-based year recognition lacks accuracy in existing methods. Therefore, a medicinal material year identification method and system based on machine vision is proposed. Summary of the Invention
[0005] In order to overcome the above-mentioned defects of the prior art, an embodiment of the present invention provides a method and system for identifying the age of medicinal materials based on machine vision, which solves the problems raised in the above-mentioned background technology by constructing a multi-dimensional image acquisition quality screening mechanism, a year discrimination model that integrates structural and color evolution characteristics, and a year benchmark inference mechanism based on spot structure ratio.
[0006] To achieve the above object, the present invention provides the following technical solutions:
[0007] A method for identifying the age of medicinal materials based on machine vision, comprising the following steps:
[0008] Step S1: setting multiple sets of sampling angles and light intensities to pre-sample medicinal material samples to obtain multiple sets of medicinal material sample images, detecting the medicinal material display area and noise level of each set of medicinal material sample images, and calculating the medicinal material field of view ratio of each set of medicinal material sample images based on the medicinal material display area;
[0009] Step S2: Calculate the application characteristics of each group of medicinal material sample images based on the noise level and the proportion of the medicinal material field of view, screen and mark the medicinal material sample images according to the application characteristics, and pass the marked medicinal material sample images into the year identification mechanism;
[0010] Step S3: In the year identification mechanism, the labeled medicinal material sample image is processed using a microstructure boundary recognition algorithm and a color drift path difference function to generate a cell collapse index and a sequential color drift index, and the year identification feature of the labeled medicinal material sample image is calculated;
[0011] Step S4: extract the structural spot ratio of the marked medicinal material sample image through the image enhancement method, call the medicinal material year interval corresponding to the structural spot ratio and calculate the year benchmark value, and output the medicinal material year according to the year identification characteristics and the year benchmark value.
[0012] In a preferred embodiment, in step S1, the medicinal material display area is the display area of the medicinal material sample in the medicinal material sample image, and the noise level is the image pixel value variance in the medicinal material sample image;
[0013] When calculating the variance of the image pixel values in each group of medicinal material sample images, the display position of the medicinal material sample in the corresponding group of medicinal material sample images is first extracted using edge computing technology, and the pixel values of all pixels in the display position are detected and the variance is calculated as the image pixel value variance in the corresponding group of medicinal material sample images;
[0014] Edge computing technology is a distributed computing architecture used to extract the display locations of medicinal material samples in the corresponding group of medicinal material sample images.
[0015] In a preferred embodiment, in step S1, when calculating the medicinal material field of view ratio, the total area of the medicinal material sample pictures is obtained, and the ratio of the medicinal material display area of each group of medicinal material sample pictures to the total area of the corresponding group of medicinal material sample pictures is used as the medicinal material field of view ratio of the corresponding group of medicinal material sample pictures.
[0016] In a preferred embodiment, in step S2, the image pixel value variance and the proportion of the medicinal material field of view in the comprehensive medicinal material sample image are used as input variables to construct a logistic regression model to calculate the application characteristics of each group of medicinal material sample images, and the application characteristics of each group of medicinal material sample images are compared. The medicinal material sample image with the largest application characteristic is screened out, marked, and passed into the year identification mechanism.
[0017] In a preferred embodiment, in step S2, the specific steps of constructing a logistic regression model to calculate the application characteristics of each group of medicinal material sample images are as follows:
[0018] Initialize input variables: Initialize the input variables by taking the variance of image pixel values and the logarithm of the proportion of the medicinal material field of view;
[0019] Calculate the logistic regression parameters: Divide the result after the initialization of the medicinal material field of view ratio and the result after the initialization of the image pixel value variance to obtain the logistic regression parameters and mark them as z;
[0020] Build a logistic regression model: , where e is the natural base, z is the logistic regression parameter, and L is the output result of the logistic regression model;
[0021] Determine the application features: Construct a logistic regression model for the image pixel value variance and the proportion of the medicinal material field of view in each group of medicinal material sample images, and calculate the output results of the logistic regression model. The output results of the logistic regression model are used as the application features of the corresponding group of medicinal material sample images.
[0022] In a preferred embodiment, in step S3, the year identification mechanism is entered, and the marked medicinal material sample image is processed by a microstructure boundary recognition algorithm and a color drift path difference function;
[0023] The medicinal material sample images were grayscaled, and the number of boundary points was counted through threshold processing. The average brightness of the low-grayscale area in the image was detected, and the average grayscale value of the dark area was obtained. The ratio relationship between the average grayscale value and the number of boundary points was established to obtain the cell collapse index.
[0024] The color space conversion of the marked medicinal material sample image is performed, and the RGB color space is mapped to the perceptually uniform Lab color space. The main color vector of the current image is extracted. Then, based on historical data, a standard main color vector sequence containing multiple year points is constructed to form the color evolution trajectory corresponding to the year. The deviation between the current main color vector and the corresponding point of the year standard trajectory is calculated according to the Euclidean distance formula. The corresponding point of the year with the smallest deviation is selected to obtain the sequential color drift index.
[0025] In a preferred embodiment, in step S3, the cell collapse index and the sequential color drift index are normalized and then substituted into the product amplification difference adjustment model to obtain the year identification feature of the marked medicinal material sample image. The specific formula is expressed as follows:
[0026] ;
[0027] Where, To mark the year identification characteristics of the medicinal material sample pictures, is the normalized cell collapse index, is the normalized sequential color drift index, is the nonlinear response tuning parameter.
[0028] In a preferred embodiment, in step S4, the structure intra-spot ratio of the marked medicinal material sample image is extracted by an image enhancement method;
[0029] The tissue boundary area is extracted by image enhancement, the total area of the spot area is counted, and the ratio of the spot area to the structural area is calculated to obtain the structural spot ratio of the marked medicinal material sample image;
[0030] By marking the structural inner spot ratio of the medicinal material sample image, calling the medicinal material year interval corresponding to the structural inner spot ratio, selecting the values of each year in the medicinal material year interval corresponding to the structural inner spot ratio for cumulative calculation, and calculating the ratio with the total number of years in the interval to obtain the year benchmark value.
[0031] In a preferred embodiment, the product calculation is performed based on the year identification feature and the year reference value. The specific formula is as follows:
[0032] ;
[0033] Where, For the medicinal material year, is the modulation parameter.
[0034] A medicinal material year identification system based on machine vision is used to implement the above-mentioned medicinal material year identification method based on machine vision, including a medicinal material photo taking module, a sample image screening module, a feature analysis module and a year prediction module, and each module is electrically connected;
[0035] The medicinal material photography module is used to set multiple groups of sampling angles and light intensities to photograph medicinal material samples to obtain medicinal material sample images, and detect the medicinal material display area and image pixel value of each group of medicinal material sample images and pass them to the sample image screening module;
[0036] The sample image screening module is used to receive the medicinal material display area and image pixel value of each medicinal material sample image, calculate the image pixel value variance based on the medicinal material display area and the medicinal material field of view, screen each group of medicinal material sample images and mark them, and send the marked medicinal material sample images to the feature analysis module;
[0037] The feature analysis module processes the labeled medicinal material sample image through a microstructure boundary recognition algorithm and a color drift path difference function, generates a cell collapse index and a sequential color drift index, and calculates the year identification feature of the labeled medicinal material sample image, and uploads the year identification feature of the labeled medicinal material sample image to the year prediction module;
[0038] The year prediction module extracts the structural inner spot ratio of the marked medicinal material sample image and calls the medicinal material year interval corresponding to the structural inner spot ratio. After calculating the year benchmark value based on the medicinal material year interval, it combines the year identification characteristics to predict the medicinal material year of the medicinal material sample and outputs the prediction result.
[0039] The technical effects and advantages of the machine vision-based medicinal material year identification method and system of the present invention are as follows:
[0040] The present invention samples medicinal materials in advance and obtains multiple groups of medicinal material sample images by setting multiple groups of sampling angles and light intensities, detects the medicinal material display area and noise level of each group of medicinal material sample images, screens and marks the medicinal material sample images according to the medicinal material display area and noise level, determines the medicinal material sample images for final medicinal material year identification, passes them into the year identification mechanism, processes the marked medicinal material sample images through a microstructure boundary recognition algorithm and a color drift path difference function, generates a cell collapse index and a sequential color drift index, calculates the year identification features of the marked medicinal material sample images, extracts the structural inner spot ratio of the marked medicinal material sample images through an image enhancement method, calls the corresponding medicinal material year interval and calculates the year benchmark value, and outputs the medicinal material year in the medicinal material sample images in combination with the year identification features, thereby improving the accuracy of medicinal material year assessment and reducing the problem of reduced efficiency caused by errors in medicinal material year assessment. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is a schematic diagram of a method for identifying the age of medicinal materials based on machine vision according to the present invention.
[0042] Figure 2 This is a flow chart of a medicinal material year identification system based on machine vision according to the present invention. DETAILED DESCRIPTION
[0043] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0044] The present invention pre-samples medicinal materials by setting multiple groups of sampling angles and light intensities and obtains multiple groups of medicinal material sample images, detects the medicinal material display area and noise level of each group of medicinal material sample images, screens and marks the medicinal material sample images according to the medicinal material display area and noise level, determines the medicinal material sample images for final medicinal material year identification, passes them into the year identification mechanism, processes the marked medicinal material sample images through a microstructure boundary recognition algorithm and a color drift path difference function, generates a cell collapse index and a sequential color drift index, calculates the year identification feature of the marked medicinal material sample images, extracts the structural inner spot ratio of the marked medicinal material sample images through an image enhancement method, calls the corresponding medicinal material year interval and calculates the year benchmark value, and outputs the medicinal material year in the medicinal material sample images in combination with the year identification feature, thereby improving the accuracy of medicinal material year assessment;
[0045] Example 1, a method and system for identifying the age of medicinal materials based on machine vision, such as Figure 1 As shown, the following steps are included:
[0046] Step S1: setting multiple sets of sampling angles and light intensities to pre-sample medicinal material samples to obtain multiple sets of medicinal material sample images, detecting the medicinal material display area and noise level of each set of medicinal material sample images, and calculating the medicinal material field of view ratio of each set of medicinal material sample images based on the medicinal material display area;
[0047] Step S2: Calculate the application characteristics of each group of medicinal material sample images based on the noise level and the proportion of the medicinal material field of view, screen and mark the medicinal material sample images according to the application characteristics, and pass the marked medicinal material sample images into the year identification mechanism;
[0048] Step S3: In the year identification mechanism, the labeled medicinal material sample image is processed using a microstructure boundary recognition algorithm and a color drift path difference function to generate a cell collapse index and a sequential color drift index, and the year identification feature of the labeled medicinal material sample image is calculated;
[0049] Step S4: extract the structural spot ratio of the marked medicinal material sample image through the image enhancement method, call the medicinal material year interval corresponding to the structural spot ratio and calculate the year benchmark value, and output the medicinal material year according to the year identification characteristics and the year benchmark value.
[0050] The specific implementation is as follows:
[0051] In step S1, the medicinal material sample is photographed by adjusting the parameters of the photographing device. The parameters of the photographing device are the photographing angle and the light intensity. Different photographing angles and light intensities will affect the display effect of the image.
[0052] Set multiple sets of lighting angles and intensities to sample medicinal materials in advance and obtain multiple sets of medicinal material sample images, record different labels for each set of medicinal material sample images, and test the medicinal material display area and noise level of each set of medicinal material sample images;
[0053] The medicinal material display area is the display area of the medicinal material sample in the medicinal material sample picture. Due to different photography angles, the display area of the medicinal material sample in the medicinal material sample picture will change when taking pictures. The larger the medicinal material display area, the less accurate the age assessment of the medicinal material sample.
[0054] For example, when a medicinal material sample is photographed from the front, the display area of the medicinal material sample in the medicinal material sample picture is 20 square centimeters; when a medicinal material sample is photographed from the side, the display area of the medicinal material sample in the medicinal material sample picture is 18 square centimeters, etc.
[0055] The noise level is the variance of the image pixel values in the medicinal material sample image. The higher the noise level, the greater the variance of the image pixel values in the medicinal material sample image, the worse the image quality, and the less accurate the age assessment of the medicinal material sample.
[0056] When calculating the variance of image pixel values in each group of medicinal material sample images, the display position of the medicinal material sample in the corresponding group of medicinal material sample images is first extracted through edge computing technology, and the pixel values of all pixel points in the display position are detected and the variance is calculated as the image pixel value variance of the corresponding group of medicinal material sample images.
[0057] When calculating the medicinal material field of view ratio, the total area of the medicinal material sample pictures is obtained, and the ratio of the medicinal material display area of each group of medicinal material sample pictures to the total area of the medicinal material sample pictures of the corresponding group is used as the medicinal material field of view ratio of the medicinal material sample pictures of the corresponding group.
[0058] It should be noted that edge computing technology is a distributed computing architecture used to extract feature locations in images. There is no unique device for taking photos of medicinal samples. For example, a digital camera can be used to take photos of medicinal samples, which will not be discussed here.
[0059] In step S2, when calculating the application characteristics of each group of medicinal material sample images, the image pixel value variance and the medicinal material field ratio in the medicinal material sample images are integrated as input variables to construct a logistic regression model. The application characteristics of each group of medicinal material sample images are determined according to the output results of the logistic regression model. The specific steps are as follows:
[0060] Initialize input variables: Initialize the input variables by taking the variance of image pixel values and the logarithm of the proportion of the medicinal material field of view;
[0061] Calculate the logistic regression parameters: Divide the result after the initialization of the medicinal material field of view ratio and the result after the initialization of the image pixel value variance to obtain the logistic regression parameters and mark them as z;
[0062] Build a logistic regression model: , where e is the natural base, z is the logistic regression parameter, and L is the output result of the logistic regression model;
[0063] Determine the application features: Construct a logistic regression model for the image pixel value variance and the proportion of the medicinal material field of view in each group of medicinal material sample images, and calculate the output results of the logistic regression model. The output results of the logistic regression model are used as the application features of the corresponding group of medicinal material sample images.
[0064] The application characteristics of each group of medicinal material sample images were compared, and the medicinal material sample images with the largest application characteristics were selected, marked, and introduced into the year identification mechanism.
[0065] The larger the proportion of the medicinal material field of view of the medicinal material sample image or the smaller the variance of the image pixel value, the greater the application feature of the medicinal material sample image, and the better the image quality of the corresponding medicinal material sample image. Selecting the medicinal material sample image with the largest application feature for marking and then introducing it into the year identification mechanism can improve the accuracy of analyzing medicinal material samples.
[0066] In step S3, the year identification mechanism is entered, and the marked medicinal material sample image is processed by the microstructure boundary recognition algorithm and the color drift path difference function to generate the cell collapse index and the sequential color drift index;
[0067] The year identification mechanism refers to the image year feature extraction process performed on labeled medicinal material samples. This mechanism is based on the pixel distribution and structural evolution of the medicinal material samples. It uses a microstructure boundary recognition algorithm to extract cell structure degradation features and combines the color drift path difference function to quantify the color evolution trend to characterize the temporal attributes of the medicinal material samples.
[0068] Furthermore, the microstructure boundary recognition algorithm refers to an image processing method used to extract microstructure contour information from medicinal material images. Based on the pixel grayscale gradient change and texture boundary density distribution law, a multi-scale boundary response function is constructed to explicitly express structural aging signs such as medicinal material cell shrinkage and collapse, thereby quantifying the structural complexity and edge blur in the image to calculate the cell collapse index.
[0069] The color drift path difference function is a function model that measures the degree of deviation between the main color vector of the medicinal material image and the color evolution trajectory of the target year based on the standard color time series model. By constructing the main color vector path of the time series and calculating the vector distance of the current sample image on this path, the sequential color drift index is generated. It will not be described in detail here.
[0070] The cell collapse index is a quantitative image feature used to characterize the degree of microscopic cell structure degradation in medicinal material samples. Its value reflects the degree of cell shrinkage, structural collapse, and boundary blurring caused by aging. Its acquisition logic grayscales the medicinal material sample image, counts the number of boundary points through threshold processing, and simultaneously detects the average brightness of low-grayscale areas in the image to obtain the average grayscale value of the dark area. This is then ratioed with the number of boundary points to obtain the cell collapse index.
[0071] The input medicinal material sample image is converted into a standard grayscale image, and the edge detection operator is used to extract the edge area in the image to obtain the boundary response map. The specific formula is as follows:
[0072] ;
[0073] Where, is the grayscale image function, is the grayscale change rate of the image in the horizontal direction, that is, the horizontal gradient, is the grayscale change rate of the image in the longitudinal direction, that is, the vertical gradient, is the gradient intensity at the current point, indicating the severity of the local change of the image;
[0074] Compare the gradient strength at the current point with the preset response threshold, i.e. threshold processing. If the gradient strength at the current point is greater than or equal to the preset response threshold, the point is marked as a boundary response point; if the gradient strength at the current point is less than the preset response threshold, the point is marked as a non-boundary area point;
[0075] Count all the boundary response point pixels to get the number of boundary points;
[0076] It should be noted that the preset response threshold was obtained by our experimenters based on the edge distribution characteristics of the image grayscale histogram and the structural texture density survey data, and will not be elaborated here;
[0077] Furthermore, the average brightness of the low grayscale areas in the image is detected at the same time. Since the reflectivity decreases after the cell collapses, the area and depth of the dark area increase. The formula for calculating the average value of the area in the grayscale image whose grayscale value is lower than the darkness threshold is as follows:
[0078] ;
[0079] Where, is the average gray value of the dark area, is the dark area pixel set, is the number of dark area pixels, is the grayscale image intensity value;
[0080] The dark area pixel set is a set of all pixels whose grayscale values are lower than the preset darkness threshold, representing a relatively dark area in the image;
[0081] It should be noted that the preset darkness threshold was obtained by our experimenters based on the distribution characteristics of the brightness histogram of medicinal material images and the grayscale distribution pattern of low-reflection areas in sample images of different years, and will not be elaborated here.
[0082] The cell collapse index is constructed by combining the number of boundary points and the average gray value of the dark area. The specific calculation formula is as follows:
[0083] ;
[0084] Where, is the cell collapse index, is the number of boundary points, To prevent a tiny constant with a zero denominator;
[0085] The sequential color drift index is an indicator used to quantify the gradual shift characteristics of the main color in medicinal material images as they age. By comparing the main color vector of the current sample image with the preset standard color trajectory of the year, it reflects the visual change pattern of the medicinal material over time. Its acquisition logic is to perform color space conversion on the marked medicinal material sample image, mapping the RGB color space to the perceptually uniform Lab color space, extracting the main color vector of the current image, and then constructing a standard main color vector sequence containing multiple year points based on historical data to form the color evolution trajectory corresponding to the year. The deviation between the current main color vector and the corresponding point of the year standard trajectory is calculated according to the Euclidean distance formula. The corresponding point of the year with the smallest deviation is selected to obtain the sequential color drift index.
[0086] The Lab color space has a uniformity that is more consistent with human perception and is conducive to accurately capturing subtle color changes. The standard dominant color vector sequence is a set of dominant color vectors extracted from medicinal material sample images from different years. The Euclidean distance formula is common knowledge to those skilled in the art and is not detailed here.
[0087] Normalizing the cell collapse index and the sequential color drift index so that they are kept in the same dimension;
[0088] It should be noted that the standardization methods include but are not limited to standard linear transformation based on interval scaling, Z-Score standardization method based on statistics, or normalization method based on nonlinear mapping function. The application methods of standardization are not described in detail here.
[0089] Substituting the normalized cell collapse index and sequential color drift index into the product amplification difference regulation model, the year identification feature of the labeled medicinal material sample image is obtained. The specific formula is as follows:
[0090] ;
[0091] Where, To mark the year identification characteristics of the medicinal material sample pictures, is the normalized cell collapse index, is the normalized sequential color drift index, is the nonlinear response adjustment parameter;
[0092] It should be noted that when constructing the year identification features of the labeled medicinal material sample images, the cell collapse index and the sequential color drift index respectively reflect different year response trends, specifically:
[0093] When the cell collapse index is larger, the degree of degradation of the medicinal material cell structure is more serious, which means that the age of the marked medicinal material is older, and the corresponding year identification feature of the marked medicinal material sample is larger. Conversely, when the sequential color drift index is larger, the deviation from the standard color trajectory is greater, which means that the year judgment is more uncertain, and the corresponding year identification feature of the marked medicinal material sample is smaller.
[0094] Furthermore, the product-amplified difference regulation model is a fusion function built based on the positive and negative correlation of key indicators. By multiplying the complementary value of the cell collapse index and the sequential color drift index and introducing a response adjustment parameter to control the overall amplitude, it can achieve the quantitative expression of the age attribute of the medicinal material image. This will not be described in detail here.
[0095] In step S4, the structure intra-spot ratio of the marked medicinal material sample image is extracted by an image enhancement method;
[0096] The structural intra-spot ratio of the labeled medicinal material sample image is the proportion of irregular spots appearing within the medicinal material tissue structure region (such as cell walls or fiber boundaries) in the image. This indicator can reflect the trend that the longer the storage years, the more heterochromatic deposits or corrosive accumulations in the tissue. Its acquisition logic is to extract the tissue boundary region through image enhancement, calculate the total area of the spot region, and calculate the ratio of the total area to the structural region to obtain the structural intra-spot ratio of the labeled medicinal material sample image.
[0097] The structural region area refers to the total pixel area covered by the complete tissue structure enclosed area extracted by image enhancement and structure recognition algorithms in the medicinal material image, including the cell outline enclosed area, the complete fiber bundle block, and other structural boundary areas, but does not include the boundary line itself and the non-structural background area, which will not be elaborated here;
[0098] By marking the structure inner spot ratio of the medicinal material sample image, the medicinal material year interval corresponding to the structure inner spot ratio is called;
[0099] It is understood that the structural spot ratios of the marked medicinal material samples in different numerical ranges correspond to preset medicinal material age ranges. The preset rules for the specific medicinal material age ranges were determined by our researchers based on the statistical analysis results of a large number of measured medicinal material samples and the correlation research between medicinal material storage time and structural degradation characteristics. The specific correlation research literature is not detailed here.
[0100] Specifically, examples of medicinal material year ranges corresponding to the ratio of spots within the structure are as follows:
[0101] When the ratio of the spots within the structure ranges from 0% to 10%, the medicinal material years corresponding to the marked medicinal material sample images range from 1 to 3 years;
[0102] When the ratio of spots within the structure ranges from 11% to 25%, the medicinal material age range corresponding to the marked medicinal material sample map is 4 to 6 years;
[0103] When the ratio of the spots within the structure ranges from 26% to 45%, the medicinal material age range corresponding to the marked medicinal material sample map is 7 to 10 years;
[0104] When the ratio of the spots within the structure is greater than 45%, the medicinal material age range corresponding to the marked medicinal material sample image is greater than 10 years.
[0105] Select the values of each year in the medicinal material year interval corresponding to the ratio of spots in the structure, add them up, and calculate the ratio with the total number of years in the interval to obtain the year benchmark value;
[0106] It should be noted that when calculating the year benchmark value, it is not necessary to calculate the mean to determine the year benchmark value. The weighted average or median selection method can also be used, which will not be elaborated here;
[0107] Specifically, the formula for calculating the annual benchmark value is as follows:
[0108] ;
[0109] Where, is the year base value of the current interval, is the total number of years included in the current interval, is the specific year value in the current interval, ;
[0110] Among them, the interval expression is a closed interval, and the year value set is ;
[0111] Correspondingly, the expressions of each parameter in the year value set are: The year that the current interval begins. The year after the start of the current interval, The end year of the current interval;
[0112] The product calculation is performed based on the year identification characteristics and the year benchmark value. The specific formula is as follows:
[0113] ;
[0114] Where, For the medicinal material year, The modulation parameters added by the experimenters are used to convert the year identification features of the marked medicinal material sample images into the scaling ratio for judging the year;
[0115] It should be noted that the modulation parameters are set by the experimenters according to the specific implementation scenario and will not be described in detail here.
[0116] Example 2, a method and system for identifying the age of medicinal materials based on machine vision, such as Figure 2 As shown, it includes a medicinal material photo taking module, a sample image screening module, a feature analysis module and a year prediction module, and each module is connected with electrical signals;
[0117] The medicinal material photography module is used to set multiple groups of sampling angles and light intensities to photograph medicinal material samples to obtain medicinal material sample images, and detect the medicinal material display area and image pixel value of each group of medicinal material sample images and pass them to the sample image screening module;
[0118] The sample image screening module is used to receive the medicinal material display area and image pixel value of each medicinal material sample image, calculate the image pixel value variance based on the medicinal material display area and the medicinal material field of view, screen each group of medicinal material sample images and mark them, and send the marked medicinal material sample images to the feature analysis module;
[0119] The feature analysis module processes the labeled medicinal material sample image through a microstructure boundary recognition algorithm and a color drift path difference function, generates a cell collapse index and a sequential color drift index, and calculates the year identification feature of the labeled medicinal material sample image, and uploads the year identification feature of the labeled medicinal material sample image to the year prediction module;
[0120] The year prediction module extracts the structural inner spot ratio of the marked medicinal material sample image and calls the medicinal material year interval corresponding to the structural inner spot ratio. After calculating the year benchmark value based on the medicinal material year interval, it combines the year identification characteristics to predict the medicinal material year of the medicinal material sample and outputs the prediction result.
[0121] The above embodiments may be implemented in whole or in part through software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product.
[0122] Those skilled in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application of the technical solution and the invention constraints. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0123] In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0124] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0125] Finally: The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for identifying the age of medicinal materials based on machine vision, characterized in that: The following steps are included: Step S1: setting multiple sets of sampling angles and light intensities to pre-sample medicinal material samples to obtain multiple sets of medicinal material sample images, detecting the medicinal material display area and noise level of each set of medicinal material sample images, and calculating the medicinal material field of view ratio of each set of medicinal material sample images based on the medicinal material display area; Step S2: Calculate the application characteristics of each group of medicinal material sample images based on the noise level and the proportion of the medicinal material field of view, screen and mark the medicinal material sample images according to the application characteristics, and pass the marked medicinal material sample images into the year identification mechanism; Step S3: In the year identification mechanism, the labeled medicinal material sample image is processed using a microstructure boundary recognition algorithm and a color drift path difference function; a cell collapse index and a sequential color drift index are generated, and the year identification feature of the labeled medicinal material sample image is calculated; The color drift path difference function is a function model that measures the degree of deviation between the main color vector of the medicinal material image and the color evolution trajectory of the target year based on the standard color time series model through the following steps: Perform color space conversion on the labeled medicinal material sample images, mapping the RGB color space to the perceptually uniform Lab color space; Extract the main color vector of the current image, construct a standard main color vector sequence containing multiple year points based on historical data, and form the color evolution trajectory corresponding to the year; The deviation between the current main color vector and the corresponding point of the year standard trajectory is calculated according to the Euclidean distance formula, and the corresponding point of the year with the smallest deviation is selected to generate the sequential color drift index; The cell collapse index is calculated by graying the medicinal material sample image, counting the number of boundary points through threshold processing, detecting the average brightness of the low-grayscale area in the image, that is, the average grayscale value of the dark area, and establishing a ratio relationship between the average grayscale value of the dark area and the number of boundary points. The index is calculated as the average grayscale value of the dark area divided by the sum of the number of boundary points and a small constant. The sequential color drift index is calculated by using the color drift path difference function to calculate the Euclidean distance deviation between the current main color vector and the corresponding point of the year standard trajectory, and then selecting the index corresponding to the year with the smallest deviation; Step S4: extracting the structural spot ratio of the marked medicinal material sample image by an image enhancement method, calling the medicinal material year interval corresponding to the structural spot ratio and calculating the year reference value, and outputting the medicinal material year according to the year identification feature and the year reference value; The intra-structural spot ratio refers to the ratio of the area of irregular spots inside the tissue structure region of the medicinal material to the area of the structural region.
2. The method for identifying the age of medicinal materials based on machine vision according to claim 1, characterized in that: In step S1, the medicinal material display area is the display area of the medicinal material sample in the medicinal material sample image, and the noise level is the image pixel value variance in the medicinal material sample image; When calculating the variance of the image pixel values in each group of medicinal material sample images, the display position of the medicinal material sample in the corresponding group of medicinal material sample images is first extracted using edge computing technology, and the pixel values of all pixels in the display position are detected and the variance is calculated as the image pixel value variance in the corresponding group of medicinal material sample images; Edge computing technology is a distributed computing architecture used to extract the display locations of medicinal material samples in the corresponding group of medicinal material sample images.
3. The method for identifying the age of medicinal materials based on machine vision according to claim 2, characterized in that: In step S1, when calculating the medicinal material field of view ratio, the total area of the medicinal material sample pictures is obtained, and the ratio of the medicinal material display area of each group of medicinal material sample pictures to the total area of the corresponding group of medicinal material sample pictures is used as the medicinal material field of view ratio of the corresponding group of medicinal material sample pictures.
4. The method for identifying the age of medicinal materials based on machine vision according to claim 3, characterized in that: In step S2, the image pixel value variance and the proportion of the medicinal material field of view in the comprehensive medicinal material sample images are used as input variables to construct a logistic regression model to calculate the application characteristics of each group of medicinal material sample images, and the application characteristics of each group of medicinal material sample images are compared. The medicinal material sample images with the largest application characteristics are screened out, marked, and passed into the year identification mechanism.
5. The method for identifying the age of medicinal materials based on machine vision according to claim 1, characterized in that: In step S2, a logistic regression model is constructed to calculate the application characteristics of each group of medicinal material sample images. The specific steps are as follows: Initialize input variables: Initialize the input variables by taking the variance of image pixel values and the logarithm of the proportion of the medicinal material field of view; Calculate the logistic regression parameters: Divide the result after the initialization of the medicinal material field of view ratio and the result after the initialization of the image pixel value variance to obtain the logistic regression parameters and mark them as z; Build a logistic regression model: , where e is the natural base, z is the logistic regression parameter, and L is the output result of the logistic regression model; Determine the application features: Construct a logistic regression model for the image pixel value variance and the proportion of the medicinal material field of view in each group of medicinal material sample images, and calculate the output results of the logistic regression model. The output results of the logistic regression model are used as the application features of the corresponding group of medicinal material sample images.
6. The method for identifying the age of medicinal materials based on machine vision according to claim 5, characterized in that: In step S3, the year identification mechanism is entered, and the marked medicinal material sample image is processed using a microstructure boundary recognition algorithm and a color drift path difference function; The medicinal material sample images were grayscaled, and the number of boundary points was counted through threshold processing. The average brightness of the low-grayscale area in the image was detected, and the average grayscale value of the dark area was obtained. The ratio relationship between the average grayscale value and the number of boundary points was established to obtain the cell collapse index. The color space conversion of the marked medicinal material sample image is performed, and the RGB color space is mapped to the perceptually uniform Lab color space. The main color vector of the current image is extracted. Then, based on historical data, a standard main color vector sequence containing multiple year points is constructed to form the color evolution trajectory corresponding to the year. The deviation between the current main color vector and the corresponding point of the year standard trajectory is calculated according to the Euclidean distance formula. The corresponding point of the year with the smallest deviation is selected to obtain the sequential color drift index.
7. The method for identifying the age of medicinal materials based on machine vision according to claim 6, characterized in that: In step S3, the cell collapse index and the sequential color drift index are normalized and substituted into the product amplification difference adjustment model to obtain the year identification feature of the marked medicinal material sample image. The specific formula is expressed as follows: ; Where, To mark the year identification characteristics of the medicinal material sample pictures, is the normalized cell collapse index, is the normalized sequential color drift index, is the nonlinear response tuning parameter.
8. The method for identifying the age of medicinal materials based on machine vision according to claim 7, characterized in that: In step S4, the structure intra-spot ratio of the marked medicinal material sample image is extracted by an image enhancement method; The tissue boundary area is extracted by image enhancement, the total area of the spot area is counted, and the ratio of the spot area to the structural area is calculated to obtain the structural spot ratio of the marked medicinal material sample image; By marking the structural inner spot ratio of the medicinal material sample image, calling the medicinal material year interval corresponding to the structural inner spot ratio, selecting the values of each year in the medicinal material year interval corresponding to the structural inner spot ratio for cumulative calculation, and calculating the ratio with the total number of years in the interval to obtain the year benchmark value.
9. The method for identifying the age of medicinal materials based on machine vision according to claim 8, characterized in that: The product calculation is performed based on the year identification characteristics and the year benchmark value. The specific formula is as follows: ; Where, For the medicinal material year, is the modulation parameter, The base value for the year.
10. A medicinal material year identification system based on machine vision, based on the medicinal material year identification method based on machine vision according to any one of claims 1 to 9, characterized in that: It includes a medicinal material photography module, a sample image screening module, a feature analysis module, and a year prediction module, and each module is connected with electrical signals; The medicinal material photography module is used to set multiple groups of sampling angles and light intensities to photograph medicinal material samples to obtain medicinal material sample images, and detect the medicinal material display area and image pixel value of each group of medicinal material sample images and pass them to the sample image screening module; The sample image screening module is used to receive the medicinal material display area and image pixel value of each medicinal material sample image, calculate the image pixel value variance based on the medicinal material display area and the medicinal material field of view, screen each group of medicinal material sample images and mark them, and send the marked medicinal material sample images to the feature analysis module; The feature analysis module processes the labeled medicinal material sample image through a microstructure boundary recognition algorithm and a color drift path difference function, generates a cell collapse index and a sequential color drift index, and calculates the year identification feature of the labeled medicinal material sample image, and uploads the year identification feature of the labeled medicinal material sample image to the year prediction module; The year prediction module extracts the structural inner spot ratio of the marked medicinal material sample image and calls the medicinal material year interval corresponding to the structural inner spot ratio. After calculating the year benchmark value based on the medicinal material year interval, it combines the year identification characteristics to predict the medicinal material year of the medicinal material sample and outputs the prediction result.
Citation Information
Patent Citations
Cell layered image processing method and system
CN110363719A
Ginseng year identification method
CN119785344A