Traditional Chinese medicine detection system and method based on visual analysis
By dividing the surface of traditional Chinese medicine into regions and comparing defect characteristic values, the target defect areas and their associated areas are screened out, and a defect diffusion status set is constructed. This solves the problem of dynamic analysis of surface defects of traditional Chinese medicine and achieves accurate quantitative monitoring and timely intervention of defect diffusion trends.
Patent Information
- Application Number
- CN202510950066.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-10
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2045-07-10
AI Technical Summary
Existing visual inspection methods are unable to effectively capture the evolution process of surface defects of traditional Chinese medicine from local spots to large-scale diffusion, and it is difficult to quantify the expansion rate of insect-infested holes over time, resulting in the inability to take effective intervention measures in the early stages of defects, causing waste of traditional Chinese medicine resources and economic losses.
A traditional Chinese medicine detection method based on visual analysis divides the surface of the traditional Chinese medicine sample into regions, compares historical and current defect feature values, screens out target defect areas and their associated areas, constructs a defect diffusion status set, and calculates the defect diffusion rate.
It has achieved quantitative monitoring of the dynamic changes of surface defects in traditional Chinese medicine, ensuring that key defect areas are not missed, providing data support for timely adjustment of management and control strategies, and reducing the risk of quality loss caused by defect spread.
Smart Images

Figure CN120468153B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of surface inspection of traditional Chinese medicine, and more particularly to a traditional Chinese medicine detection system and method based on visual analysis. Background Art
[0002] Quality control of traditional Chinese medicines is a core link in ensuring clinical efficacy and medication safety. Throughout the entire industry chain, including planting, harvesting, processing, and storage, traditional Chinese medicines are susceptible to factors such as environmental temperature and humidity, microbial erosion, and insect pests, leading to surface defects such as mildew, insect infestation, and cracks. With the development of machine vision technology, image recognition technology has begun to be used to detect defects on the surface of traditional Chinese medicines. However, existing visual inspection methods mostly focus on the identification of static defects and can only determine whether there are defects on the surface of traditional Chinese medicines and the type of defects at the current moment, lacking dynamic analysis of defect development trends. For example, traditional methods cannot effectively capture the evolution of moldy areas from local spots to large-scale spread, nor can they quantify the rate of expansion of insect-infested holes over time. This makes it impossible to take effective intervention measures at the early stages of defects, resulting in waste of traditional Chinese medicine resources and economic losses. Summary of the Invention
[0003] In view of the shortcomings of the existing technology, the purpose of the present invention is to provide a traditional Chinese medicine detection system and method based on visual analysis.
[0004] To achieve the above object, the present invention provides the following technical solutions:
[0005] A method for detecting traditional Chinese medicine based on visual analysis, the method comprising the following steps:
[0006] Perform surface area division on the Chinese medicine samples to be tested to obtain a surface area division set;
[0007] Comparing and analyzing the historical defect characteristic values of each area in the surface area division set and the current defect characteristic values of the corresponding area to obtain a comparison result set;
[0008] Screening out a target defect area from the surface area partition set according to a first comparison result of the comparison result set;
[0009] According to the target defect area, a set of associated areas adjacent to the target defect area is screened out from the surface area partition set;
[0010] The comparison result set, target defect area and surface area partition set are processed and analyzed to obtain the defect diffusion status set;
[0011] Obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the target defect area and the associated area set based on the defect diffusion status.
[0012] Preferably, the comparison result set, the target defect area, and the surface area partition set are processed and analyzed to obtain a defect diffusion status set, specifically comprising the following steps:
[0013] Processing and analyzing the first comparison result and the second comparison result in the comparison result set to obtain first correlation difference data;
[0014] extracting a first target associated region from the associated region set according to the first associated difference data;
[0015] Collecting statistics on defect diffusion status information of the first target associated area and the target defect area within a preset first historical period to obtain a first defect diffusion status;
[0016] Extracting a second target associated region from the associated region set; wherein the second target associated region refers to the remaining adjacent associated regions excluding the first target associated region;
[0017] Collecting statistics on the defect propagation status information of the second target associated area within a preset second historical period to obtain a second defect propagation status; wherein the second historical period is all historical periods before the first historical period;
[0018] The first defect propagation condition and the second defect propagation condition constitute a defect propagation condition set.
[0019] Preferably, performing surface area division on the Chinese medicine sample to be detected to obtain a surface area division set specifically includes the following steps:
[0020] Statistical results of defect distribution are obtained by statistically analyzing the surface defect distribution of the Chinese medicine samples to be tested;
[0021] According to the defect distribution statistical results, the surface of the Chinese medicine sample to be tested is divided into several regions to obtain a surface region division set.
[0022] Preferably, screening out the target defect area according to the first comparison result of the comparison result set specifically includes the following steps:
[0023] Filtering a first comparison result from the comparison result set; wherein the first comparison result is that the current defect characteristic value is greater than the historical defect characteristic value, and the current defect characteristic value is less than a preset defect characteristic threshold;
[0024] A target defect area that meets the first comparison result is extracted from the surface area segmentation set.
[0025] Preferably, processing and analyzing the first comparison result and the second comparison result in the comparison result set to obtain first correlation difference data specifically includes the following steps:
[0026] Performing difference calculation on the first comparison result to obtain a first defect difference;
[0027] Performing a difference calculation on the second comparison result to obtain a second defect difference; wherein the second comparison result is that the current defect characteristic value is greater than the historical defect characteristic value, and the current defect characteristic value is greater than a preset defect characteristic threshold;
[0028] Perform difference statistics on the first defect difference and the second defect difference to obtain a difference data set;
[0029] The first associated difference data that is within a preset defect difference associated interval threshold is screened out from the difference data set.
[0030] Preferably, obtaining a first defect diffusion status by collecting statistics on the first target associated area and the defect diffusion status information of the first target associated area within a preset first historical period specifically includes the following steps:
[0031] After respectively collecting defect impact feature information of the target defect area and the first target associated area in the first historical period, a first defect impact feature information set is obtained;
[0032] The first defect impact feature information set and the first associated difference data are combined into a first defect diffusion status.
[0033] Preferably, obtaining a second defect diffusion status by collecting statistics on the defect diffusion status information of the second target associated area within a preset second historical period specifically includes the following steps:
[0034] After collecting defect impact feature information of the target defect area and the second target associated area within the second historical period, outputting a second defect impact feature information set;
[0035] The second defect impact feature information set and the second associated difference data set are combined into a second defect diffusion status set.
[0036] Preferably, obtaining a current defect impact feature information set of the target defect area and the associated area set within the current time period, matching a defect diffusion status from a defect diffusion status set according to the current defect impact feature information set, and calculating a surface defect diffusion rate of the traditional Chinese medicine in the target defect area and the associated area set according to the defect diffusion status, specifically includes the following steps:
[0037] After obtaining the defect impact feature information of the target defect area and the associated area set within the current period, output the current defect impact feature information set;
[0038] combining the first defect impact feature information set and the second defect impact feature information set into a defect impact feature reference information set;
[0039] A pre-processed defect impact feature information set that matches the current defect impact feature information set is screened out from the defect impact feature reference information set.
[0040] Filter out corresponding defect diffusion conditions from the defect diffusion condition set according to the pre-processed defect impact feature information set;
[0041] Predict the defect development characteristic values of the target defect area and the associated area set within the current period based on the current defect impact characteristic information set, and then output the current defect development characteristic value data set;
[0042] After collecting the actual defect feature values of the target defect area and the associated area set in the current period, the actual defect feature value data set is obtained.
[0043] After inputting the current defect development eigenvalue dataset, the actual defect eigenvalue dataset and the defect diffusion status into the traditional Chinese medicine surface defect diffusion rate model, the defect diffusion rates of the target defect area and the associated area set are obtained.
[0044] Traditional Chinese medicine detection system based on visual analysis, including:
[0045] Partitioning module: divides the surface area of the Chinese medicine sample to be tested to obtain a surface area partition set;
[0046] Comparison module: compares and analyzes the historical defect characteristic values of each area in the surface area division set with the current defect characteristic values of the corresponding area to obtain a comparison result set;
[0047] A first screening module: screening out a target defect area from the surface area partition set according to a first comparison result of the comparison result set;
[0048] The second screening module: screening out a set of associated regions adjacent to the target defect region from the surface region partition set according to the target defect region;
[0049] Processing module: Processing and analyzing the comparison result set, target defect area and surface area partition set to obtain the defect diffusion status set;
[0050] Calculation module: obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the target defect area and the associated area set based on the defect diffusion status.
[0051] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, a traditional Chinese medicine detection method based on visual analysis is implemented.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] The present invention divides the surface of traditional Chinese medicine samples into regions and constructs a surface region division set. Combined with comparative analysis of historical and current defect feature values, it can locate the target defect area. Compared with the traditional overall detection mode, it avoids the problem of missed detection caused by local defects being masked by overall data, and ensures that key defect areas are not missed.
[0054] By calculating the first correlation difference data through hierarchical processing of the comparison results, the intrinsic connection between defect areas of different severity is explored, the first target correlation area and the second target correlation area are screened, and the defect diffusion conditions in different historical periods are statistically analyzed to form a defect diffusion condition set. This process comprehensively restores the defect diffusion trajectory from the dual dimensions of time and space, covering not only the dynamic changes of the recent strongly correlated areas, but also the historical evolution of the long-term weakly correlated areas, making the analysis of the defect diffusion process more systematic and complete. By calculating the defect diffusion rate, staff can adjust the management and control strategies in a timely manner to reduce the risk of quality loss caused by defect diffusion. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 A schematic diagram of the steps of the traditional Chinese medicine detection method based on visual analysis proposed by the present invention;
[0056] Figure 2 The present invention proposes a module schematic diagram of a traditional Chinese medicine detection system based on visual analysis;
[0057] Figure 3 It is a structural diagram of an electronic device provided by an embodiment of the present invention.
[0058] 610 , processor; 620 , communication interface; 630 , memory; 640 , communication bus. DETAILED DESCRIPTION
[0059] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0060] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0061] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it constitute a separate or selective embodiment that is mutually exclusive with other embodiments.
[0062] Reference Figure 1-Figure 3 shown.
[0063] Example 1 further illustrates the traditional Chinese medicine detection method based on visual analysis proposed by the present invention.
[0064] A method for detecting traditional Chinese medicine based on visual analysis, the method comprising the following steps:
[0065] Perform surface area division on the Chinese medicine samples to be tested to obtain a surface area division set;
[0066] Comparing and analyzing the historical defect characteristic values of each area in the surface area division set and the current defect characteristic values of the corresponding area to obtain a comparison result set;
[0067] Screening out a target defect area from the surface area partition set according to a first comparison result of the comparison result set;
[0068] According to the target defect area, a set of associated areas adjacent to the target defect area is screened out from the surface area partition set;
[0069] The comparison result set, target defect area and surface area partition set are processed and analyzed to obtain the defect diffusion status set;
[0070] Obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the target defect area and the associated area set based on the defect diffusion status.
[0071] This application can control the surface defect status and diffusion trend of traditional Chinese medicine. First, the surface area is divided, and it is split into several independent areas according to the texture and color natural characteristics of the surface of the traditional Chinese medicine sample, and then a surface area division set is constructed.
[0072] Each area in the surface area division set has historical defect characteristic values accumulated from past inspections (such as quantitative indicators such as defect area and grayscale difference). Combined with the current defect characteristic values obtained from the current inspection, the historical defect characteristic values of each area in the surface area division set and the current defect characteristic values of the corresponding area are compared and analyzed to obtain a comparison result set. From the historical dimension, it is judged whether the defects in each area have deteriorated or remained stable, laying the foundation for finding key defect areas.
[0073] The first comparison result that meets the preset exception rule is selected from the result set, and the corresponding area is the target defect area.
[0074] Because surface defects in traditional Chinese medicines can spread physically, such as mold and insect damage, which can spread to adjacent areas, we filter out adjacent related area sets from the surface area partition set based on spatial adjacency based on the target defect area, and predict which surrounding areas may be affected by the defect, thus preparing for diffusion analysis.
[0075] The comparison result set, target defect area and surface area partition set are integrated to determine the potential connection of defect changes, obtain the possible diffusion path and range of defects, and then construct the defect diffusion status set.
[0076] Obtain the defect impact feature information set of the target defect area and the associated area set in the current period, match the corresponding diffusion pattern in the defect diffusion status set, and calculate the defect diffusion rate to achieve quantitative monitoring of the dynamic changes of surface defects of traditional Chinese medicine, so that staff can grasp the rhythm of defect development and provide data support for traditional Chinese medicine quality control and subsequent processing decisions.
[0077] The comparison result set, target defect area, and surface area partition set are processed and analyzed to obtain a defect diffusion status set, specifically including the following steps:
[0078] Processing and analyzing the first comparison result and the second comparison result in the comparison result set to obtain first correlation difference data;
[0079] extracting a first target associated region from the associated region set according to the first associated difference data;
[0080] Collecting statistics on defect diffusion status information of the first target associated area and the target defect area within a preset first historical period to obtain a first defect diffusion status;
[0081] Extracting a second target associated region from the associated region set; wherein the second target associated region refers to the remaining adjacent associated regions excluding the first target associated region;
[0082] The second defect diffusion status is obtained by collecting statistics on the defect diffusion status information of the second target associated area within a preset second historical period; wherein the second historical period is all historical periods before the first historical period;
[0083] The first defect diffusion condition and the second defect diffusion condition constitute a defect diffusion condition set.
[0084] This application focuses on two key data types within the comparison result set (the first comparison result and the second comparison result). The first corresponds to areas with early defect development, where "the current defect characteristic value exceeds the historical value but does not reach the preset threshold," and the second corresponds to areas with severe defect development, where "the current defect characteristic value exceeds the historical value and exceeds the preset threshold." The application first calculates the defect development range (the difference between the current defect characteristic value and the historical characteristic value) for each area. Then, a statistical difference is calculated between the two types of differences, selecting the first correlation difference data that falls within the preset defect difference correlation interval threshold. This method quantifies the inherent correlation between defect areas at different development levels.
[0085] Based on the first correlation difference data, a first target correlation region is extracted from the correlation region set. This region has a close defect diffusion correlation with the target defect region within a preset first historical period (which can be set based on the actual cycle of TCM defect development, such as the short-term storage inspection period). A comprehensive statistical analysis of the defect diffusion status of this region and the target defect region within the preset first historical period is performed, including the expansion trajectory of the defect area, the dynamic trend of morphological changes (such as the expansion direction of the damage boundary and the progress of hole fusion), and the rate of change of characteristic values (such as the growth of the defect area and abnormal color changes). This information is integrated to form the first defect diffusion status, focusing on the dynamic diffusion details of the recent strongly correlated areas.
[0086] The first target associated area that has been identified is eliminated from the surface area partition set, and the remaining adjacent associated areas are the second target associated areas. Since the diffusion association with the target defect area often exists in an earlier historical stage, it is necessary to retrospectively analyze the defect diffusion information of this area within the preset second historical period (which is earlier than the full cycle of the first historical period and covers the historical period of traditional Chinese medicine storage, processing, etc.). This process focuses on analyzing the long-term defect accumulation pattern (such as the annual defect growth curve and the impact of seasonal fluctuations on defect development), the traceability association between early defects and current diffusion (for example, whether the historical damage point is the initial inducement of the current defect diffusion), the diffusion hysteresis effect of weakly associated areas, etc., and generates a second defect diffusion situation through historical data mining and long-term trend fitting to supplement the diffusion background information of the long-term weakly associated areas.
[0087] The defect diffusion status dataset consists of a primary defect diffusion status focusing on recent, strongly correlated dynamics, and a secondary defect diffusion status covering a more distant, weakly correlated background. This dataset systematically integrates the diffusion characteristics of TCM surface defects at different historical stages (recent and distant) and in different correlated regions (strongly correlated primary target regions and weakly correlated secondary target regions). This includes multi-regional spatiotemporal diffusion paths, defect development rates and patterns over multiple time periods, and the diffusion impact between correlated regions, facilitating the analysis of defect diffusion patterns and the calculation of diffusion rates.
[0088] Performing surface area division on the Chinese medicine sample to be tested to obtain a surface area division set specifically includes the following steps:
[0089] Statistical results of defect distribution are obtained by statistically analyzing the surface defect distribution of the Chinese medicine samples to be tested;
[0090] According to the defect distribution statistics, the surface of the Chinese medicine sample to be tested is divided into several regions to obtain a surface region partition set.
[0091] This application uses visual inspection technology (e.g., using a machine vision system to capture images of the surface of a TCM sample, combined with image segmentation and defect recognition algorithms) to comprehensively scan and extract information about surface defects (including mold, insect damage, cracks, and other blemishes). The application then calculates the specific location, morphological characteristics, and number density of defects on the sample surface to generate defect distribution statistics. This step clearly demonstrates the spatial distribution of surface defects in TCM samples through quantitative means, providing a data foundation for subsequent regional division.
[0092] Based on characteristics such as the spatial clustering and distribution density differences of defects, reasonable regional division rules (for example, using the boundaries of defect clusters as a reference and partitioning according to the defect density gradient) are used to divide the surface of the traditional Chinese medicine sample into several sub-regions with relatively independent defect distribution characteristics. These sub-regions together constitute the surface region division set. This operation breaks down the continuous detection object of the traditional Chinese medicine sample surface into discrete regional units that are easier to analyze and manage. Subsequently, operations such as defect feature comparison and diffusion analysis can be independently carried out on each region, laying a solid foundation for in-depth research on traditional Chinese medicine surface defects (such as tracking defect development trends and analyzing defect correlations in different regions), and achieving a technical connection from the overall to the local, and from macroscopic distribution to fine regional analysis.
[0093] Screening out a target defect area according to the first comparison result of the comparison result set specifically includes the following steps:
[0094] Filtering a first comparison result from the comparison result set; wherein the first comparison result is that the historical defect characteristic value is greater than the current defect characteristic value and greater than a preset defect characteristic threshold;
[0095] A target defect area that meets the first comparison result is extracted from the surface area segmentation set.
[0096] This application constructs a screening mechanism based on feature value comparison around the screening target defect area. First, relying on the comparative analysis of historical defect feature values and current defect feature values of various areas on the surface of traditional Chinese medicine samples, a comparison result set covering multi-region feature comparison results is formed. The first comparison result is extracted from the comparison result set, that is, the comparison data that satisfies the historical defect feature value greater than the current defect feature value, and the historical defect feature value greater than the preset defect feature threshold. The purpose is to lock in the regional feature comparison records where the degree of defects in the historical stage was more serious (exceeding the preset threshold) and the current defect characteristics have changed (historical values are greater than current values, or reflect defect improvement, or reflect detection differences, etc.).
[0097] Using the surface region partition set as the underlying data, the method performs a matching search on each partitioned surface region based on the first comparison result. The region that matches the comparison result is extracted and defined as the target defect region. This process selects regions from the numerous regions on the surface of the traditional Chinese medicine sample that exhibit both "historical defect severity exceeding the standard" and "historical and current defect characteristics differ," facilitating the determination of the evolution of defects in these regions.
[0098] Processing and analyzing the first comparison result and the second comparison result in the comparison result set to obtain first correlation difference data specifically includes the following steps:
[0099] Performing difference calculation on the first comparison result to obtain a first defect difference;
[0100] A second defect difference is obtained by performing a difference calculation on the second comparison result; wherein, the second comparison result is that the historical defect characteristic value is greater than the current defect characteristic value and less than the preset defect characteristic threshold; the preset defect characteristic threshold is set according to the acceptable range of defect characteristics specified in the quality standards of traditional Chinese medicine.
[0101] Perform difference statistics on the first defect difference and the second defect difference to obtain a difference data set;
[0102] The first associated difference data that is within a preset defect difference associated interval threshold is screened out from the difference data set.
[0103] In order to explore the correlation between the differences in surface defect characteristic values of traditional Chinese medicine samples, this technical solution quantitatively analyzes the correlation degree of different comparison results based on the first correlation difference data. The first comparison result is that the historical defect characteristic value is greater than the current defect characteristic value and greater than the preset defect characteristic threshold, reflecting that the area has had serious defects and is currently changing; the second comparison result is that the historical defect characteristic value is greater than the current defect characteristic value but less than the preset threshold, reflecting that regional defects have existed in history but the degree is relatively controllable and is currently changing.
[0104] The first defect difference is calculated based on the difference between the historical and current defect characteristic values for the first comparison result to quantify the characteristic change amplitude of the severe defect area. The same operation is performed on the second comparison result to calculate the second defect difference to measure the characteristic change amplitude of the relatively minor defect area.
[0105] The difference between the first and second defect differences is statistically analyzed to generate a difference dataset. This dataset contains information comparing the difference in defect characteristic changes between the two regions. Finally, the first correlation difference data within the preset defect difference correlation interval threshold is filtered from the difference dataset. This data screening process essentially extracts correlation information about the difference in defect characteristic changes between the two comparison results using threshold constraints. This provides a quantitative basis for correlation differences in subsequent analysis of the linkage relationship and diffusion impact of defect regions of varying severity.
[0106] The first defect diffusion status is obtained by collecting statistics on the first target associated area and the defect diffusion status information of the first target associated area within a preset first historical period, specifically including the following steps:
[0107] After respectively collecting defect impact feature information of the target defect area and the first target associated area in the first historical period, a first defect impact feature information set is obtained.
[0108] The first defect impact feature information set and the first associated difference data are combined into a first defect diffusion status.
[0109] This application aims to clarify the defect diffusion trends of the first target associated area and the target defect area in a specific historical stage. Focusing on the first defect diffusion situation, the application first focuses on a preset first historical period (a time interval that can be determined based on the development cycle of traditional Chinese medicine defects, data statistical requirements, etc.). Visual inspection feature extraction technology is used to collect defect impact characteristic information of the target defect area and the first target associated area during this period. This information covers multi-dimensional data such as defect area expansion, morphological evolution, and characteristic value change rate. After integration, it forms the first defect impact characteristic information set, which comprehensively records the dynamic characteristics of defects in the two areas during this period.
[0110] The first correlation difference data (quantitative data reflecting the degree of correlation between the defect characteristic differences between the two types of regions) is fused with the first defect impact characteristic information set. This data combination integrates the dynamic changes in defect characteristics (represented by the information set) and the correlation between defect differences between regions (reflected by the correlation difference data) to construct the first defect diffusion status. This process provides a dynamic analysis of the defect diffusion dynamics and correlation between the target defect region and the first target correlation region over the first historical period, providing structured data support for subsequent analysis of defect diffusion patterns and assessment of diffusion risks.
[0111] The second defect diffusion status is obtained by collecting statistics on the defect diffusion status information of the second target associated area within a preset second historical period, specifically comprising the following steps:
[0112] After collecting defect impact feature information of the target defect area and the second target associated area within the second historical period, outputting a second defect impact feature information set;
[0113] The second defect impact feature information set and the second associated difference data set are combined into a second defect diffusion status set.
[0114] This application first predefines a second historical period (this period precedes the first historical period and is used to explore the long-term defect diffusion background). Then, using visual inspection feature parameter extraction technology, the application collects defect impact characteristic information from both the target defect area and the second target associated area during this period. This information covers multiple dimensions, including defect morphological changes, area expansion, and characteristic value fluctuations. After integration, the second defect impact characteristic information set is output.
[0115] The second correlation difference dataset is fused with the second defect impact feature information set. This data combination integrates the dynamic changes in defect characteristics during the second historical period (represented by the information set) and the correlation between defect differences between regions (represented by the correlation difference dataset) to construct a second defect diffusion status. This process allows the dynamic evolution and correlation logic of defect diffusion in earlier historical stages to be reflected between the target defect area and the second target correlation area, providing key data support for supplementing the long-term laws of surface defect diffusion in traditional Chinese medicine and improving the defect diffusion status set.
[0116] Obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the traditional Chinese medicine in the target defect area and the associated area set based on the defect diffusion status, specifically including the following steps:
[0117] After obtaining the defect impact feature information of the target defect area and the associated area set within the current period, output the current defect impact feature information set;
[0118] Combining the first defect impact feature information set and the second defect impact feature information set into a defect impact feature reference information set;
[0119] A pre-processed defect impact feature information set that matches the current defect impact feature information set is screened out from the defect impact feature reference information set.
[0120] This application uses visual detection feature extraction technology to collect defect impact feature information (such as defect area, morphological change rate, etc.) of the target defect area and the associated area set in the current period, and integrates it to form the current defect impact feature information set, thereby reflecting the dynamic characteristics of the defects in the current period.
[0121] Next, the first defect impact feature information set (defect dynamic data from the first historical period) and the second defect impact feature information set (defect dynamic data from the second historical period) that were previously constructed are called upon and integrated to construct a defect impact feature reference information set. This information set covers defect feature data from different historical periods and related regions, forming a multi-dimensional, full-cycle defect feature database.
[0122] Based on data matching, a pre-processed defect impact feature information set is selected from the defect impact feature reference information set to match the current defect impact feature information set in terms of feature dimensions (such as defect development trends and feature value change patterns). This matching allows the current defect status to be associated with similar historical scenarios, laying the foundation for data association for subsequent defect diffusion status matching and diffusion rate calculation.
[0123] Filter out corresponding defect diffusion conditions from the defect diffusion condition set according to the pre-processed defect impact feature information set;
[0124] Predict the defect development characteristic values of the target defect area and the associated area set within the current period based on the current defect impact characteristic information set, and then output the current defect development characteristic value data set;
[0125] After collecting the actual defect feature values of the target defect area and the associated area set in the current period, the actual defect feature value data set is obtained.
[0126] After inputting the current defect development eigenvalue dataset, the actual defect eigenvalue dataset and the defect diffusion status into the traditional Chinese medicine surface defect diffusion rate model, the defect diffusion rates of the target defect area and the associated area set are obtained.
[0127] This application uses a pre-processed defect impact feature information set to select suitable defect diffusion conditions from the defect diffusion condition set, establishing a correlation between the current defect characteristics and historical diffusion patterns. Then, based on the current defect impact feature information set, the defect development feature values (such as defect area growth and morphological evolution parameters) of the target defect area and the associated area set in the current time period are predicted to generate a current defect development feature value dataset.
[0128] Predicting the defect development characteristic values of the target defect area and the associated area set in the current period based on the current defect impact feature information set and outputting the corresponding data set requires a collaborative process of data association, pattern mining, and model prediction. First, an in-depth analysis of the current defect impact feature information set is performed. This data set covers the current multi-dimensional defect characteristics of the target defect area and the associated area set, such as the size of the defect, its morphological outline (such as whether it exhibits irregular expansion), the degree of color change (the deviation value from the normal surface color of traditional Chinese medicine), and the texture damage state (the length and density of the cracks). These features constitute the basic input for prediction and comprehensively characterize the actual state of the current defect.
[0129] Next, the defect diffusion status set constructed from historical correlations is used to discover defect evolution patterns in similar scenarios. Specifically, historical cases that closely match the current defect impact feature information set in terms of characteristic dimensions (such as the initial defect form and development stage) are selected from the defect diffusion status set. The developmental characteristics of the defects in these historical cases during the corresponding time periods (which are similar to the current period in the defect development process) are then determined. For example, whether the defect area expands at a uniform rate or exponentially, and whether the form continues to fragment or gradually merges, is analyzed to summarize the correlation patterns of "feature input - development output."
[0130] Subsequently, an adapted prediction model is selected for computation. If defect characteristics exhibit continuous changes over time, a time series model (such as ARIMA or LSTM) can be used. This model can learn the temporal fluctuation patterns of historical defect characteristic values, using the current defect impact characteristic information set as initial input to infer the defect development characteristic values for subsequent time periods (i.e., within the current time period). If the defect exhibits a clear spatial diffusion trend (penetrating from the target area to associated areas), a spatial interpolation model (such as Kriging or Gaussian process regression) is then combined to predict the development of defect characteristics within the associated area set based on the current spatial distribution of the defect and the adjacency of the associated areas. Through model computation, a region-by-region, multi-dimensional prediction of the defect development characteristic values (such as the expected growth value of the defect area over the next period of time, parameters after morphological changes, and the deepening of color changes) is performed for the target defect area and the associated area set in the current time period.
[0131] Finally, the predicted defect development characteristic values of each region and dimension are integrated and output in a unified data format (e.g., with region as the dimension, each region corresponds to an array containing feature prediction values such as area, shape, and color) to form the current defect development characteristic value dataset.
[0132] Through real-time detection and collection of the actual defect characteristic values in the corresponding area, a defect actual characteristic value dataset is formed. The current defect development characteristic value dataset (predicted data), the actual defect characteristic value dataset (measured data), and the screened defect diffusion status are input into a pre-built traditional Chinese medicine surface defect diffusion rate model (this model can be constructed based on physical diffusion equations, machine learning algorithms, etc., and integrates defect characteristic changes and diffusion patterns). Through model calculations, the diffusion rate of defects in the target area and related areas is quantified, achieving accurate quantitative analysis of the dynamic diffusion process of traditional Chinese medicine surface defects, providing data support for quality control.
[0133] The construction of the diffusion rate model of surface defects of traditional Chinese medicine is as follows:
[0134] The first step is data collection and preprocessing. The basis for model construction is to obtain comprehensive and accurate data, which covers the static properties of traditional Chinese medicine samples and the dynamic characteristics of defects. In terms of static properties, it is necessary to collect information such as the variety, origin, and processing technology of traditional Chinese medicine. Different varieties of traditional Chinese medicine have different susceptibility to defects. The origin and processing technology will also affect the initial quality and defect resistance of the medicinal materials. At the same time, it is also necessary to obtain the surface area division results and preset defect feature thresholds to locate the defect position and judge the severity of the defect. Dynamic feature data is mainly collected continuously through visual inspection technology, including features such as defect area, morphology, grayscale difference, as well as defect diffusion patterns in different historical periods and different related areas, and defect feature values obtained from actual detection as real label data. After the collection is completed, the data needs to be normalized to eliminate dimensional differences; missing values are filled to ensure data integrity; and categorical data is encoded to meet the model input requirements.
[0135] During the core logic construction phase, the model integrates physical mechanisms and data intelligence, introducing corresponding physical or biological equations to describe the basic diffusion laws for different types of defects. For mold defects, an equation was constructed based on Fick's diffusion law, taking into account the relationship between the expansion of the mold area and factors such as ambient temperature and humidity, and the moisture content of traditional Chinese medicine. For insect-infested defects, a hole growth equation was constructed based on a biological population propagation model, incorporating parameters such as pest reproduction and environmental carrying capacity. Through feature engineering, derived features such as defect area difference and regional feature similarity were constructed, and a hybrid architecture of "physical model output + machine learning residual compensation" was adopted to improve the model's accuracy and adaptability.
[0136] Model training and validation are key steps to ensure model performance. Preprocessed data is divided into training, validation, and test sets. Mean squared error is used as the loss function, and optimizers such as Adam are used to iteratively update model parameters. Regularization is also introduced to prevent overfitting. During training, cross-validation is used to assess model stability, and error attribution analysis is performed to distinguish between physical mechanism errors and data-related errors for model optimization. Furthermore, considering the dynamic changes in the storage environment and the state of traditional Chinese medicine, the model is regularly retrained and parameters are updated to adapt to new situations.
[0137] After model training is complete, real-time data on defect impact characteristics and environmental parameters is collected and preprocessed before being fed into the model. The model first calculates the basic diffusion rate using physical equations, then uses machine learning to correct for residual errors. Ultimately, it outputs the final diffusion rate for each region and generates a dataset of current defect development characteristic values. This provides a quantitative basis for TCM quality control, allowing staff to prioritize intervention measures in areas with high diffusion rates and achieve refined control of TCM quality.
[0138] Example 2 further illustrates the traditional Chinese medicine detection system based on visual analysis proposed by the present invention.
[0139] Traditional Chinese medicine detection system based on visual analysis, including:
[0140] Partitioning module: divides the surface area of the Chinese medicine sample to be tested to obtain a surface area partition set;
[0141] Comparison module: compares and analyzes the historical defect characteristic values of each area in the surface area division set with the current defect characteristic values of the corresponding area to obtain a comparison result set;
[0142] A first screening module: screening out a target defect area from the surface area partition set according to a first comparison result of the comparison result set;
[0143] The second screening module: screening out a set of associated regions adjacent to the target defect region from the surface region partition set according to the target defect region;
[0144] Processing module: Processing and analyzing the comparison result set, target defect area and surface area partition set to obtain the defect diffusion status set;
[0145] Calculation module: obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the target defect area and the associated area set based on the defect diffusion status.
[0146] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, a traditional Chinese medicine detection method based on visual analysis is implemented.
[0147] like Figure 3 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communication interface 620, and the memory 630 communicate with each other via the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute the traditional Chinese medicine detection method based on visual analysis.
[0148] Furthermore, the logic instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0149] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform a traditional Chinese medicine detection method based on visual analysis.
[0150] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform a traditional Chinese medicine detection method based on visual analysis.
[0151] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0152] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.
[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A traditional Chinese medicine detection method based on visual analysis, characterized in that: The method comprises the following steps: Perform surface area division on the Chinese medicine samples to be tested to obtain a surface area division set; Comparing and analyzing the historical defect characteristic values of each area in the surface area division set and the current defect characteristic values of the corresponding area to obtain a comparison result set; Screening out a target defect area from the surface area segmentation set according to a first comparison result of the comparison result set, wherein the first comparison result is that a current defect characteristic value is greater than a historical defect characteristic value, and the current defect characteristic value is less than a preset defect characteristic threshold; According to the target defect area, a set of associated areas adjacent to the target defect area is screened out from the surface area partition set; The comparison result set, target defect area, and surface area partition set are processed and analyzed to obtain a defect diffusion status set, specifically including the following steps: Processing and analyzing a first comparison result and a second comparison result in the comparison result set to obtain first correlation difference data, wherein the second comparison result is that the current defect characteristic value is greater than the historical defect characteristic value, and the current defect characteristic value is greater than a preset defect characteristic threshold; extracting a first target associated region from the associated region set according to the first associated difference data; Collecting statistics on defect diffusion status information of the first target associated area and the target defect area within a preset first historical period to obtain a first defect diffusion status; Extracting a second target associated region from the associated region set; wherein the second target associated region refers to the remaining adjacent associated regions excluding the first target associated region; Collecting statistics on the defect propagation status information of the second target associated area within a preset second historical period to obtain a second defect propagation status; wherein the second historical period is all historical periods before the first historical period; Wherein, the first defect propagation condition and the second defect propagation condition constitute a defect propagation condition set; Obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the target defect area and the associated area set based on the defect diffusion status.
2. The method for detecting traditional Chinese medicine based on visual analysis according to claim 1, wherein Performing surface area division on the Chinese medicine sample to be tested to obtain a surface area division set specifically includes the following steps: Statistical results of defect distribution are obtained by statistically analyzing the surface defect distribution of the Chinese medicine samples to be tested; According to the defect distribution statistical results, the surface of the Chinese medicine sample to be tested is divided into several regions to obtain a surface region division set.
3. The method for detecting Chinese medicine based on visual analysis according to claim 2, wherein: Screening out a target defect area according to the first comparison result of the comparison result set specifically includes the following steps: Filtering the first comparison result from the comparison result set; A target defect area that meets the first comparison result is extracted from the surface area segmentation set.
4. The method for detecting traditional Chinese medicine based on visual analysis according to claim 3, wherein: Processing and analyzing the first comparison result and the second comparison result in the comparison result set to obtain first correlation difference data specifically includes the following steps: Performing difference calculation on the first comparison result to obtain a first defect difference; Performing difference calculation on the second comparison result to obtain a second defect difference; Perform difference statistics on the first defect difference and the second defect difference to obtain a difference data set; The first associated difference data that is within a preset defect difference associated interval threshold is screened out from the difference data set.
5. The method for detecting traditional Chinese medicine based on visual analysis according to claim 4, characterized in that: The first defect diffusion status is obtained by collecting statistics on the first target associated area and the defect diffusion status information of the first target associated area within a preset first historical period, specifically comprising the following steps: After respectively collecting defect impact feature information of the target defect area and the first target associated area in the first historical period, a first defect impact feature information set is obtained; The first defect impact feature information set and the first associated difference data are combined into a first defect diffusion status.
6. The method for detecting traditional Chinese medicine based on visual analysis according to claim 5, characterized in that: The second defect diffusion status is obtained by collecting statistics on the defect diffusion status information of the second target associated area within a preset second historical period, specifically comprising the following steps: After collecting defect impact feature information of the target defect area and the second target associated area within the second historical period, outputting a second defect impact feature information set; The second defect impact feature information set and the second associated difference data set are combined into a second defect diffusion status set.
7. The method for detecting traditional Chinese medicine based on visual analysis according to claim 6, characterized in that: Obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the traditional Chinese medicine in the target defect area and the associated area set based on the defect diffusion status, specifically including the following steps: After obtaining the defect impact feature information of the target defect area and the associated area set within the current period, output the current defect impact feature information set; combining the first defect impact feature information set and the second defect impact feature information set into a defect impact feature reference information set; Filtering out a pre-processed defect impact feature information set that matches the current defect impact feature information set from the defect impact feature reference information set; Filter out corresponding defect diffusion conditions from the defect diffusion condition set according to the pre-processed defect impact feature information set; Predict the defect development characteristic values of the target defect area and the associated area set within the current period based on the current defect impact characteristic information set, and then output the current defect development characteristic value data set; After collecting the actual defect feature values of the target defect area and the associated area set in the current period, the actual defect feature value data set is obtained; After inputting the current defect development eigenvalue dataset, the actual defect eigenvalue dataset and the defect diffusion status into the traditional Chinese medicine surface defect diffusion rate model, the defect diffusion rates of the target defect area and the associated area set are obtained.
8. A traditional Chinese medicine detection system based on visual analysis, applied to the traditional Chinese medicine detection method based on visual analysis according to any one of claims 1 to 7, characterized in that: include: Partitioning module: divides the surface area of the Chinese medicine sample to be tested to obtain a surface area partition set; Comparison module: compares and analyzes the historical defect characteristic values of each area in the surface area division set with the current defect characteristic values of the corresponding area to obtain a comparison result set; A first screening module: screening out a target defect area from the surface area partition set according to a first comparison result of the comparison result set; The second screening module: screening out a set of associated regions adjacent to the target defect region from the surface region partition set according to the target defect region; Processing module: Processing and analyzing the comparison result set, target defect area and surface area partition set to obtain the defect diffusion status set; Calculation module: obtain the current defect impact feature information set of the target defect area and the associated area set in the current period, match the defect diffusion status from the defect diffusion status set based on the current defect impact feature information set, and calculate the surface defect diffusion rate of the target defect area and the associated area set based on the defect diffusion status.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the traditional Chinese medicine detection method based on visual analysis as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Chinese herbal medicine disease identification system based on vue and Springboot
CN117523353A
Medicinal material production quality detection method based on image recognition
CN119091259A