An image recognition-based traditional Chinese medicine decoction piece identification data processing method and system

CN122780945APending Publication Date: 2026-09-18GUANGZHOU RUNCE ELECTRONIC TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611231043.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-14
Publication Date
2026-09-18

AI Technical Summary

Technical Problem

[0005]针对背景技术中记载的技术问题,本发明提供了一种基于图像识别的中药饮片识别数据处理方法及系统,解决了中药饮片多样本同屏识别中,候选品类接近、局部特征密集以及破碎重叠状态导致的识别结果不稳定和复核顺序不明确的问题

Benefits of technology

在整个基于图像识别的中药饮片识别数据处理方法中,首先,通过获取当前识别周期内的中药饮片样本、样本来源约束数据、特征库数据和处理能力数据,并获取每个中药饮片样本的颜色特征数据、形态特征数据、纹理特征数据和样本图像状态数据,使识别过程不仅基于样本图像特征进行候选品类比对,还能够结合处方清单、当前药斗标识和当前药斗历史确认品类记录对特征库数据进行分层处理。通过将候选品类划分为处方内候选品类、同药斗历史候选品类和开放候选品类,可以在保留开放识别能力的同时,减少与当前调配任务关联较弱的候选品类对比对结果的影响。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122780945A_ABST
    Figure CN122780945A_ABST
Patent Text Reader

Abstract

The application discloses a traditional Chinese medicine decoction piece recognition data processing method and system based on image recognition, relates to the technical field of data processing, and comprises the following steps: acquiring traditional Chinese medicine decoction piece samples, sample source constraint data, feature library data and processing capacity data in a current recognition period, and extracting color, shape, texture and sample image state data; performing hierarchical comparison according to a prescription, a same medicine history and an open candidate category, determining a candidate recognition category, a candidate similarity gap and a candidate unstable marker; combining a feature sorting sequence to generate local feature dense markers and decoction piece confusion clusters, determining confusion risk values, review action types and review recognition batches, and outputting recognition results or review markers. The application solves the problems of unstable recognition and unclear review sequence caused by multiple samples on the same screen, candidate proximity, fragmentation and overlap, and improves the stability of recognition of easily confused decoction pieces.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, specifically to a method and system for processing data related to the identification of traditional Chinese medicine decoction pieces based on image recognition. Background Technology

[0002] Traditional Chinese medicine (TCM) decoction pieces typically appear in slices, segments, blocks, or broken pieces during pharmacy dispensing, dispensing from medicine hoppers, prescription verification, and automated dispensing processes. Multiple TCM decoction piece samples may exist simultaneously in the same image, and different samples may exhibit similar colors, shapes, or textures due to differences in cutting specifications, processing degree, drying state, shooting angle, and partial occlusion.

[0003] Existing image recognition-based methods for identifying medicinal slices mainly rely on comparing the color, morphological, and texture features of a single sample with a feature library, and then outputting the recognition results based on the similarity of candidate categories. This approach can achieve basic recognition in scenarios where the sample is complete, the edges are clear, and the candidate categories are significantly different. However, when the first and second candidate categories are similar, it is easy to lack further verification.

[0004] In practical dispensing scenarios, prescription lists, medicine drawer labels, and historical confirmed category records for the current medicine drawer can provide source constraints for candidate category comparison. If comparison is entirely based on open feature libraries, irrelevant candidate categories may enter the candidate identification category set, increasing confusion between similar categories; if only prescription lists or medicine drawer records are relied upon, abnormal categories may be missed due to medicine drawer replenishment errors, manual placement errors, or prescription adjustments. Furthermore, broken medicinal slices, overlapping medicinal slices, low-resolution samples, and samples with discontinuous edges can affect features such as contour, cross-sectional color, and texture direction, preventing the highest candidate comprehensive similarity from fully reflecting the stability of the identification results. Summary of the Invention

[0005] In response to the technical problems described in the background art, the present invention provides a data processing method and system for the identification of Chinese herbal medicine pieces based on image recognition, which solves the problems of unstable identification results and unclear verification order caused by the similarity of candidate categories, dense local features, and fragmented and overlapping states in the identification of multiple samples of Chinese herbal medicine pieces on the same screen.

[0006] A method for processing data for identifying traditional Chinese medicine (TCM) decoction pieces based on image recognition includes: acquiring color, morphology, and texture feature data of multiple TCM decoction piece samples within the current recognition period; comparing these data with feature database data to obtain a first candidate identification category, a second candidate identification category, and a candidate similarity difference; generating a candidate unstable marker when the candidate similarity difference does not reach a candidate difference threshold; within the sample range where two TCM decoction piece samples have the same first candidate identification category, or where the first and second candidate identification categories of the two samples overlap, establishing a feature sorting sequence based on the color, morphology, and texture feature similarity of each TCM decoction piece sample under the corresponding candidate category; determining three types of local proximity states based on the feature interval of adjacent samples; and generating a local feature dense marker when there is local proximity in at least two types of states; screening TCM decoction piece samples that simultaneously possess candidate unstable markers and local feature dense markers as decoction piece confusion candidate samples; and when any two decoction piece confusion candidate samples have the same category in their first or second candidate identification categories, merging them into the same decoction piece confusion cluster, and transferring the TCM decoction piece samples within the decoction piece confusion cluster to a verification recognition process.

[0007] Optionally, multiple Chinese herbal medicine (TCM) decoction piece samples are obtained within the current recognition period, including: obtaining the original image within the current recognition period; performing brightness equalization processing on the original image to ensure that the central and edge regions meet the same image segmentation brightness conditions; determining whether the original image meets the contour extraction conditions based on the edge sharpness check results; performing foreground segmentation on the original image that meets the contour extraction conditions to obtain the foreground region of the decoction pieces; filtering the foreground region of the decoction pieces based on the area of ​​the connected region, the edge continuity ratio, and the contour concavity ratio; using the retained connected region as the TCM decoction piece sample region; and obtaining TCM decoction piece samples based on the TCM decoction piece sample region.

[0008] Optionally, acquire color, morphology, and texture feature data of multiple Chinese herbal medicine slice samples within the current recognition period, including: color feature data including the uniformity of cross-sectional color of the Chinese herbal medicine slice sample area; morphology feature data including the edge continuity ratio and contour concavity ratio of the Chinese herbal medicine slice sample area; and texture feature data including the consistency of texture direction and local crack density of the Chinese herbal medicine slice sample area. Based on the edge continuity ratio, contour concavity ratio, edge clarity check results, and overlapping area judgment results, acquire sample image state data including suspected broken slice state, suspected overlapping slice state, low-resolution state, and edge discontinuity state.

[0009] Optionally, the comparison with the feature library data is used to obtain the first candidate identification category, the second candidate identification category, and the candidate similarity difference, including: obtaining the prescription list corresponding to the current dispensing task, the current medicine cabinet identifier, and the historical confirmed category record of the current medicine cabinet; taking the Chinese herbal medicine categories in the prescription list as the candidate categories within the prescription, taking the Chinese herbal medicine categories in the historical confirmed category record of the current medicine cabinet as the historical candidate categories of the same medicine cabinet, and taking the Chinese herbal medicine categories in the feature library data that are not classified into the aforementioned two categories as open candidate categories; and comparing the candidate categories in the order of candidate categories within the prescription, historical candidate categories of the same medicine cabinet, and open candidate categories.

[0010] Optionally, candidate category comparison is performed in the order of candidate categories within the prescription, historical candidate categories within the same medicine container, and open candidate categories. This includes: comparing the color feature data, morphological feature data, and texture feature data of each Chinese herbal medicine sample with the standard color feature, standard morphological feature, and standard texture feature of the candidate category item by item, obtaining the color feature similarity, morphological feature similarity, and texture feature similarity respectively, and averaging the three to obtain the candidate comprehensive similarity; the candidate categories ranked first and second in terms of candidate comprehensive similarity are respectively used as the first candidate identification category and the second candidate identification category, and the difference between the two candidate comprehensive similarities is used to obtain the candidate similarity gap; when the candidate similarity gap does not reach the candidate gap threshold, a candidate unstable marker is generated.

[0011] Optionally, a feature ranking sequence is established based on the similarity of color, morphology, and texture features of each Chinese herbal medicine sample under the corresponding candidate category. This includes: when the first candidate identification category is the same, establishing each feature ranking sequence based on the first candidate identification category as the comparison benchmark; when a candidate category cross relationship is formed, establishing each feature ranking sequence based on the commonly involved candidate category as the comparison benchmark; comparing the color feature interval, morphology feature interval, and texture feature interval with the color confusion interval threshold, morphology confusion interval threshold, and texture confusion interval threshold, respectively, to determine the corresponding local proximity state; when the same Chinese herbal medicine sample is determined to be locally close in at least two local proximity states, a local feature dense marker is generated.

[0012] Optionally, screening Chinese herbal medicine (TCM) decoction piece samples that simultaneously possess candidate unstable markers and local feature dense markers as TCM decoction piece confusion candidate samples includes: for any two TCM decoction piece confusion candidate samples, when the first candidate identification category or the second candidate identification category of one TCM decoction piece confusion candidate sample is the same as the first candidate identification category or the second candidate identification category of another TCM decoction piece confusion candidate sample, the two TCM decoction piece confusion candidate samples are merged into the same TCM decoction piece confusion cluster; for TCM decoction piece samples that have suspected broken decoction piece state, suspected overlapping decoction piece state, low-resolution state, or discontinuous edge state, and do not form a candidate category cross relationship with other TCM decoction piece confusion candidate samples, they are regarded as single sample TCM decoction piece confusion clusters.

[0013] Optionally, the Chinese herbal medicine samples within the herbal medicine sample confusion cluster are transferred to a verification and identification process, including: obtaining a herbal medicine sample candidate category confusion risk value based on the candidate similarity difference level, the number of similar local features, the number of candidate category crossovers, the waiting period level, and the number of abnormal image states of the Chinese herbal medicine sample within the herbal medicine sample confusion cluster; the candidate similarity difference level is the floor value of 3 minus the ratio of the candidate similarity difference to the candidate difference threshold, and the difference is taken as the maximum value by 0; the number of candidate category crossovers, the waiting period level, and the number of abnormal image states are subject to upper limit processing, the number of similar local features is averaged with the results of the three upper limit processing to obtain an auxiliary risk level, and the candidate similarity difference level is added to the auxiliary risk level to obtain the herbal medicine sample candidate category confusion risk value.

[0014] Optionally, the Chinese herbal medicine samples within the mixed cluster are transferred to the verification and identification process, including: determining the verification action type (color similarity, morphological similarity, texture similarity, and sample image state data) based on the color feature similarity difference, morphological similarity difference, texture similarity difference, multidimensional similarity, or image state abnormality of the Chinese herbal medicine samples under the first and second candidate identification categories; color similarity corresponds to cross-sectional color uniformity recalculation, morphological similarity corresponds to edge contour recalculation and broken edge removal, texture similarity corresponds to texture direction consistency recalculation and local crack density recalculation, multidimensional similarity corresponds to local image re-sampling, and image state abnormality corresponds to sample area re-segmentation, local image re-sampling, broken edge removal, or edge contour recalculation.

[0015] Optionally, the Chinese herbal medicine samples within the herbal medicine confusion cluster are transferred to the verification and identification process, including: generating first, second, and third verification and identification batches based on the herbal medicine confusion cluster, the confusion risk value of the candidate herbal medicine category, the verification action type, and the upper limit of the number of verification and identification samples; the first verification and identification batch includes samples within the cluster with high confusion risk values ​​and samples whose image status data indicates abnormality; the second verification and identification batch includes samples with candidate unstable markers but not included in the first verification and identification batch; the third verification and identification batch includes samples with candidate stable markers and whose image status data does not indicate abnormality; when the number of samples in the first verification and identification batch exceeds the upper limit, it is split into multiple first verification sub-batches according to the confusion risk value from high to low, and the identification process is performed according to the first, second, and third verification and identification batches.

[0016] Optionally, the identification process is performed in three batches: the first batch performs the verification action corresponding to the verification action type; the second batch first performs verification comparison in the candidate categories within the prescription and the historical candidate categories in the same drug compartment; if the candidate comprehensive similarity corresponding to the first candidate identification category after verification does not reach the confirmation threshold or the candidate similarity difference does not reach the candidate difference threshold, it enters the open candidate category comparison; the third batch performs basic candidate comparison; based on the first candidate identification category after verification, the candidate similarity difference, the candidate comprehensive similarity, the confirmation threshold, and the verification threshold, the confirmed identification result, the mark to be manually verified, the mark to be re-segmented, or the unconfirmed mark is output.

[0017] A data processing system for identifying traditional Chinese medicine (TCM) decoction pieces based on image recognition is also provided. The system is used to implement a method for identifying TCM decoction pieces based on image recognition. The system includes: a data acquisition module, used to acquire color, morphology, and texture feature data of multiple TCM decoction piece samples within the current recognition period; a candidate category processing module, used to compare the feature data with feature library data, obtain the first candidate identification category, the second candidate identification category, and the candidate similarity difference, and generate candidate unstable markers; a confusion cluster processing module, used to establish a feature sorting sequence, obtain local feature dense markers, screen decoction piece confusion candidate samples, and group decoction piece confusion candidate samples with the same first or second candidate identification category into decoction piece confusion clusters; and a verification recognition module, used to transfer samples within the decoction piece confusion clusters to verification recognition processing.

[0018] The beneficial effects of this invention are reflected in: In the entire image recognition-based method for identifying traditional Chinese medicine (TCM) decoction pieces, the first step involves acquiring TCM decoction piece samples, sample source constraint data, feature library data, and processing capability data within the current identification period. Furthermore, it involves acquiring color feature data, morphological feature data, texture feature data, and sample image state data for each TCM decoction piece sample. This allows the identification process to not only compare candidate categories based on sample image features but also to perform hierarchical processing of the feature library data by combining the prescription list, the current medicine drawer identifier, and historical confirmed category records of the current medicine drawer. By dividing candidate categories into intra-prescription candidate categories, historical candidate categories within the same medicine drawer, and open candidate categories, the method can retain open identification capabilities while reducing the impact of comparing candidate categories with weak relevance to the current dispensing task on the results.

[0019] This invention further generates candidate unstable markers based on the candidate similarity difference between the first and second candidate identification categories, and generates locally dense markers based on color feature sorting sequences, morphological feature sorting sequences, and texture feature sorting sequences. By using candidate unstable markers, locally dense markers, candidate category cross-relationships, and sample image state data together to generate medicinal herb confusion clusters, the invention identifies candidate category proximity and locally feature proximity relationships among multiple Chinese herbal medicine samples within the same identification period, and transfers the corresponding samples to a verification identification process.

[0020] In the review and verification stage, this invention obtains the confusion risk value of candidate categories for medicinal slices based on the candidate similarity difference level, the number of similar local features, the number of candidate category crossovers, the waiting period for recognition level, and the number of abnormal image states. It also determines the type of review action based on the color feature similarity difference, morphological feature similarity difference, texture feature similarity difference, and sample image state data. Therefore, the review and verification process can correspond to specific actions such as local image re-acquisition, sample region re-segmentation, edge contour recalculation, broken edge removal, cross-sectional color uniformity recalculation, texture direction consistency recalculation, local crack density recalculation, or candidate category expansion comparison, ensuring that the review and verification batches have corresponding data basis and execution content. Attached Figure Description

[0021] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.

[0022] Figure 1 This is a schematic diagram illustrating the steps of the image recognition-based traditional Chinese medicine decoction piece identification data processing method of the present invention; Figure 2 This is a schematic diagram of a portion of step S1 in the image recognition-based traditional Chinese medicine decoction piece identification data processing method of the present invention; Figure 3 This is a schematic diagram of a portion of step S2 in the image recognition-based traditional Chinese medicine decoction piece identification data processing method of the present invention; Figure 4 This is a schematic diagram of a portion of step S3 in the image recognition-based traditional Chinese medicine decoction piece identification data processing method of the present invention; Figure 5 This is a schematic diagram of a portion of step S4 in the image recognition-based traditional Chinese medicine decoction piece identification data processing method of the present invention; Figure 6 This is a schematic diagram of the module structure of the image recognition-based traditional Chinese medicine decoction piece identification data processing system of the present invention; Figure 7This is a timing diagram illustrating the generation and output of verification batches in the image recognition-based traditional Chinese medicine decoction piece identification data processing method of the present invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0024] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0025] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0026] This invention provides a data processing method for identifying traditional Chinese medicine decoction pieces based on image recognition, such as... Figure 1 As shown, in one specific embodiment, the method includes: S1. Obtain the Chinese herbal medicine sample, sample source constraint data, feature library data and processing capability data within the current recognition period, and obtain the color feature data, morphological feature data, texture feature data and sample image status data for each Chinese herbal medicine sample; S2. Based on the sample source constraint data, the feature library data is divided into candidate categories within the prescription, historical candidate categories within the same medicine box, and open candidate categories. The color feature data, morphological feature data, and texture feature data are compared according to the division results to obtain the first candidate identification category, the second candidate identification category, the candidate similarity difference, and the candidate unstable marker. S3. Obtain feature sorting sequences and local feature dense markers based on color feature data, morphological feature data and texture feature data, and generate medicinal slice confusion clusters based on candidate unstable markers, local feature dense markers, first candidate identification category, second candidate identification category and sample image state data, and obtain the confusion risk value of medicinal slice candidate categories and the verification action type; S4. Generate a review and identification batch based on the confusion risk value of candidate medicinal slices, the type of review action, and the processing capacity data, and output the confirmation and identification results, the mark to be manually reviewed, the mark to be re-segmented, or the unconfirmed mark according to the review and identification batch.

[0027] In this embodiment, the current identification cycle refers to the processing cycle corresponding to the identification system completing one round of traditional Chinese medicine (TCM) decoction piece sample acquisition, feature data acquisition, candidate category comparison, decoction piece confusion cluster generation, review identification batch generation, and identification result output. A TCM decoction piece sample refers to the decoction piece image object segmented from the original image within the current identification cycle that requires category identification. Sample source constraint data includes at least one of the following: the prescription list corresponding to the current dispensing task, the current medicine cabinet identifier, and the historical confirmed category record of the current medicine cabinet. Feature library data includes standard color features, standard morphological features, standard texture features, and corresponding category names corresponding to multiple TCM decoction piece categories. Processing capacity data includes the upper limit of the basic identification sample quantity and the upper limit of the review processing sample quantity. The upper limit of the number of basic identification samples is used to represent the boundary of the number of samples that can complete the basic candidate comparison within the current identification period; the upper limit of the number of verification processing samples is used to represent the boundary of the number of samples that can be used to perform local image re-sampling, sample region re-segmentation, edge contour recalculation, broken edge removal, cross-sectional color uniformity recalculation, texture direction consistency recalculation, local crack density recalculation, or candidate category expansion comparison within the current identification period.

[0028] The feature library data is generated from historical calibration samples. For each category of Chinese herbal medicine slices, historical calibration sample images with manually confirmed category names are first acquired. These historical calibration sample images undergo the same brightness equalization, foreground segmentation, connected component filtering, and feature extraction processes as in the current recognition cycle, yielding color, morphological, and texture feature data for the corresponding category. Then, standard color, morphological, and texture features are generated based on the statistical results of each indicator within the same category and written into the feature library data. Within the current recognition cycle, the recognition system performs deterministic comparison processing according to the written feature library data.

[0029] In this embodiment, it should be noted that in S1, the recognition system first acquires the Chinese herbal medicine (TCM) decoction piece samples that need to be processed within the current recognition period, and simultaneously acquires sample source constraint data, feature library data, and processing capability data. The TCM decoction piece samples are obtained from the original images after brightness equalization, edge sharpness checking, foreground segmentation, and connected region filtering. Color feature data, morphological feature data, and texture feature data correspond to the color appearance, outline shape, and surface texture of the decoction piece samples, respectively. Sample image state data is used to record the states of suspected broken decoction pieces, suspected overlapping decoction pieces, low-resolution states, and edge discontinuities. For example, if five samples of Chinese herbal medicine (TCM) slices are acquired within a current recognition period, and the first and second samples both originate from white, flaky slice regions, the fourth sample has edge defects, and the fifth sample exhibits local overlap, then S1 outputs not only the color, morphological, and texture feature data of the five samples, but also the suspected broken slice status of the fourth sample and the suspected overlapping slice status of the fifth sample. This processing allows subsequent steps to use image anomalies as a basis for verification, rather than directly deleting or confirming abnormal samples during the basic recognition stage.

[0030] In S2, the recognition system stratifies the feature library data into candidate categories based on sample source constraints. Candidate categories within the prescription come from the prescription list corresponding to the current dispensing task; historical candidate categories within the same medicine cabinet come from confirmed category records in the current medicine cabinet; and open candidate categories come from other Chinese herbal medicine categories in the feature library that are not classified into the first two categories. The recognition system first compares color, morphological, and texture feature data within the candidate categories within the prescription, then performs supplementary comparisons within the historical candidate categories within the same medicine cabinet, and, if necessary, enters the open candidate category comparison. This comparison order reduces interference from candidate categories unrelated to the current dispensing task while preserving the path for abnormal categories to enter the open candidate category comparison. For each Chinese herbal medicine sample, the recognition system obtains the first candidate recognition category ranked first and the second candidate recognition category ranked second in terms of comprehensive candidate similarity, and then obtains the candidate similarity difference between the two. When the candidate similarity difference does not reach the candidate difference threshold, a candidate instability marker is generated. For example, the candidate comprehensive similarity of the first Chinese herbal medicine sample with white peony root slices is 0.84, and the candidate comprehensive similarity with atractylodes macrocephala slices is 0.81. The candidate similarity difference is 0.03. If the candidate difference threshold is 0.05, then the first Chinese herbal medicine sample is marked as an unstable candidate sample. The confirmation result cannot be directly output simply because white peony root slices are ranked first.

[0031] In S3, the recognition system establishes color feature sorting sequences, morphological feature sorting sequences, and texture feature sorting sequences for Chinese herbal medicine (TCM) decoction piece samples within the current recognition period. These sequences are all established within the sample range corresponding to the same candidate category or a cross-category relationship. If two TCM decoction piece samples share the same first candidate identification category, corresponding feature sorting sequences are established based on their color feature similarity, morphological feature similarity, and texture feature similarity within that first candidate identification category. If the first candidate identification categories of two TCM decoction piece samples intersect with their second candidate identification categories, corresponding feature similarities are obtained using the common candidate categories as a comparison benchmark, and corresponding feature sorting sequences are established based on this benchmark. If two TCM decoction piece samples neither share the same first candidate identification category nor have a cross-category relationship, the feature interval between them is not used as a basis for judging local feature proximity. If the feature interval between the same TCM decoction piece sample and its adjacent samples in at least two feature sorting sequences satisfies the local proximity condition, a locally dense feature marker is generated.

[0032] Subsequently, the identification system uses both candidate unstable markers and locally dense feature markers as the basis for generating the herbal medicine confusion cluster, and further determines whether the first and second candidate identification categories overlap with other samples. For example, if the first candidate identification category of the first herbal medicine sample is white peony root slices and the second candidate identification category is atractylodes macrocephala slices, and the first candidate identification category of the second herbal medicine sample is atractylodes macrocephala slices and the second candidate identification category is white peony root slices, and both are locally similar in both color feature ranking sequence and morphological feature ranking sequence, then the first and second herbal medicine samples are merged into the same herbal medicine confusion cluster. For samples within the herbal medicine confusion cluster, the identification system continues to obtain the confusion risk value of the candidate herbal medicine category and the type of review action, thereby determining the subsequent review order and review action.

[0033] In S4, the identification system generates verification batches based on the confusion risk value of candidate herbal pieces, the type of verification action, and processing capacity data. If the number of herbal pieces to be identified in the current identification period does not exceed the upper limit of the basic identification sample number, there are no herbal piece confusion clusters, and the sample image status data does not indicate any abnormalities, then the system enters the basic identification path. Based on the candidate comprehensive similarity, candidate similarity difference, confirmation threshold, and verification threshold, it outputs the confirmed identification result, a mark indicating pending manual verification, or an unconfirmed mark. If the number of herbal pieces to be identified in the current identification period exceeds the upper limit of the basic identification sample number, or there are herbal piece confusion clusters, or the sample image status data indicates a suspected broken herbal piece state, a suspected overlapping herbal piece state, a low-resolution state, or a discontinuous edge state, then the system enters the verification identification path. Based on the confusion risk value of candidate herbal piece categories and the type of verification action, it generates the first verification batch, the second verification batch, and the third verification batch. The first review and identification batch prioritizes samples with high risk values ​​within the herbal medicine confusion cluster and samples whose image status data indicates anomalies. The second review and identification batch processes samples with candidate unstable markers but not included in the first review and identification batch. The third review and identification batch processes samples with stable candidates and whose image status data does not indicate anomalies. For example, if there are 5 Chinese herbal medicine samples in the current identification period, the maximum number of basic identification samples is 3, the maximum number of review processing samples is 1, and there is a herbal medicine confusion cluster, the identification system will not directly confirm all samples in the same identification period. Instead, it will first process samples with high risk values ​​for confusion among candidate herbal medicine categories and perform actions such as local image re-sampling, edge contour recalculation, or texture direction consistency recalculation according to the review action type.

[0034] In summary, this invention stratifies the feature library data into candidate categories by constraining sample source data, reducing the interference of open candidate categories with weak relevance to the current dispensing task on the recognition results; it generates candidate instability markers by using the first candidate identification category, the second candidate identification category, and the candidate similarity difference to identify samples where the difference between the highest and second candidate identification categories is insufficient; it generates local feature-dense markers by using color feature sorting sequences, morphological feature sorting sequences, and texture feature sorting sequences to identify the proximity relationship between multiple samples in the local feature space within the same recognition period; it generates medicinal herb confusion clusters by using candidate instability markers, local feature-dense markers, and candidate category cross-relationships to merge medicinal herb samples with confusion risk; and it generates review recognition batches by using the medicinal herb candidate category confusion risk value and review action type to allocate processing power to medicinal herb samples with similar candidate categories, dense local features, and abnormal image states. In the context of medicinal herb dispensing, this processing chain connects sample acquisition, candidate category comparison, confusion cluster generation, and review recognition batch output into a continuous data processing process.

[0035] like Figure 2As shown, in one specific embodiment, S1 includes: S11. Obtain the original image within the current recognition period, and perform brightness equalization processing on the original image so that the central and edge regions in the original image meet the same image segmentation brightness conditions.

[0036] S12. Based on the edge sharpness check results, determine whether the original image meets the contour extraction conditions. Perform foreground segmentation on the original image that meets the contour extraction conditions to obtain the foreground region of the medicinal slices.

[0037] S13. The foreground region of the medicinal slices is screened according to the area of ​​the connected region, the proportion of continuous edges and the proportion of concave contours. The retained connected regions are used as the sample regions of Chinese medicinal slices, and Chinese medicinal slice samples are obtained according to the sample regions of Chinese medicinal slices.

[0038] In this embodiment, it should be noted that in S11, the original image can be an image of a medicinal herb tray, a medicine dispenser, a mixing table, or other images containing samples of Chinese medicinal herbs acquired within the current recognition cycle. Brightness equalization processing is used to reduce color feature deviations in the original image caused by local lighting differences. Specifically, the original image can be divided into multiple regions, and the brightness statistics of the central and edge regions can be obtained separately. Brightness correction is then applied to areas that are too dark or too bright based on the brightness statistics, ensuring that the central and edge regions in the same original image can enter the same foreground segmentation processing conditions. During brightness equalization processing, the recognition system uses the brightness statistics of the central region as a reference, correcting the brightness values ​​of the edge regions or locally dark regions according to the difference between them and the brightness statistics of the central region. If the corrected pixel value exceeds the image's allowed value range, it is truncated according to the upper or lower limit of the image's allowed value range. After brightness correction is completed, foreground segmentation is then performed. For example, the original image acquired during the current recognition period has a resolution of 1920×1080, with an average brightness of 142 in the central region and 116 in the edge region. The difference between these two values ​​affects the edge segmentation of white, sheet-like medicinal slices. After brightness equalization processing, the average brightness of the edge region is adjusted to 140, and both the central and edge regions can meet the same image segmentation brightness condition. This brightness equalization is not intended to change the color of the medicinal slices themselves, but rather to ensure that subsequent color feature data acquisition is not affected by the shooting position, thus providing input for candidate category comparison in S2.

[0039] In S12, the edge sharpness check result can be obtained based on the degree of gray-level change near the sample boundary, the continuity of the boundary gradient, and the boundary noise in the original image. If the edge sharpness check result shows that the sample boundary can be distinguished from the background area, the original image is judged to meet the contour extraction condition; if the edge sharpness check result shows that the sample boundary cannot be stably distinguished, the corresponding sample area can be marked as low-sharpness and retained for subsequent review and recognition batches. Foreground segmentation is used to separate the foreground area of ​​the medicinal slices from the background area. The foreground area of ​​the medicinal slices is the pixel area in the original image that may belong to the sample of traditional Chinese medicine medicinal slices. During foreground segmentation, the recognition system generates a foreground candidate area based on the difference in brightness, color, or edge between the medicinal slice area and the background area in the brightness-equalized image, and performs hole filling and small-area noise removal on the foreground candidate area to obtain the foreground area of ​​the medicinal slices. For example, among five samples of Chinese herbal medicine slices, the first and second samples have clear boundaries and meet the contour extraction criteria. The fifth sample, due to local overlap, shows local edge breakage in its edge clarity check, but still has a separable foreground region. Therefore, this sample is not deleted; instead, its low-resolution state and suspected overlapping state are retained until S3 and S4. This prevents real samples from being prematurely discarded due to abnormal local image states.

[0040] In S13, the area of ​​the connected region is used to exclude excessively small noise regions and incomplete debris regions; the edge continuity ratio is used to determine whether the boundary of the connected region forms a stable profile of the medicinal slice; and the contour concavity ratio is used to determine whether the connected region has an abnormal contour caused by overlap, occlusion, or breakage. When screening the connected regions of the foreground region of the medicinal slice, if the area of ​​a certain connected region does not reach the lower limit of the sample area corresponding to the historical calibration sample, the connected region is removed as a noise region; if a certain connected region meets the sample area condition, but the edge continuity ratio does not reach the lower limit of the edge continuity ratio, the connected region is retained and an edge discontinuity state is generated; if a certain connected region meets the sample area condition, but the contour concavity ratio reaches the abnormal contour concavity ratio condition, the connected region is retained and a suspected broken medicinal slice state or a suspected overlapping medicinal slice state is generated. For example, the area of ​​the fourth medicinal slice sample region is 6200 pixels. 2 The sample area condition was met, but the edge continuity ratio was only 0.68, lower than the lower limit of 0.75 obtained from historical calibration samples. Therefore, the fourth herbal medicine sample was retained, while generating edge discontinuity and suspected broken slice states. Through this processing, the recognition system can transform abnormal image states into criteria for subsequent verification.

[0041] In one specific implementation, acquiring the color feature data, morphological feature data, texture feature data, and sample image state data for each Chinese herbal medicine sample further includes the following processing: Color feature data is acquired based on the average values ​​of the red, green, and blue channels, as well as the average hue, saturation, and brightness of the sample area and the uniformity of the cross-section color. Morphological feature data is acquired based on the area, perimeter, length and width of the bounding rectangle, aspect ratio, roundness, rectangularity, edge continuity ratio, and contour concavity ratio of the sample area. Texture feature data is acquired based on the texture contrast, texture energy, texture homogeneity, texture direction consistency, and local crack density of the sample area. Sample image state data, including suspected broken slices, suspected overlapping slices, low-resolution slices, and discontinuous edges, is acquired based on the edge continuity ratio, contour concavity ratio, edge sharpness check results, and overlapping area judgment results. In this process, different types of indicators in color feature data, morphological feature data, and texture feature data are first converted into feature values ​​within a unified range based on the value range of the corresponding indicators in historical calibration samples. Then, they are compared with standard color features, standard morphological features, and standard texture features in the feature library data. In this way, different types of data such as area, length, color mean, and texture statistics are not directly added together, but are compared separately within their respective indicator systems.

[0042] The uniformity of the cut surface color is obtained as follows: After excluding edge transition pixels within the sample area of ​​the Chinese herbal medicine slices, the remaining area is divided into multiple local sub-regions. The average color value of each local sub-region is calculated, and the difference between the average color values ​​of each local sub-region is compared. The smaller the difference, the more uniform the cut surface color, and the higher the uniformity of the cut surface color. The consistency of texture direction is obtained as follows: The texture edge direction is extracted within the sample area of ​​the Chinese herbal medicine slices, and the main texture direction and the number of textures deviating from the main texture direction are counted. The fewer textures deviating from the main texture direction, the higher the consistency of texture direction. The density of local cracks is obtained as follows: Slender crack areas formed by grayscale or color abrupt changes are identified within the sample area of ​​the Chinese herbal medicine slices, and the occupancy of crack areas within a unit sample area is counted. The more crack areas within a unit sample area, the higher the local crack density. The result of overlapping area judgment is obtained as follows: When there are two or more local contour directions within the same connected area, there is a clear contour overlap boundary, or there are mutually occluding color and texture boundaries within the same area, a suspected overlapping slice state is generated; otherwise, a suspected overlapping slice state is not generated.

[0043] like Figure 3 As shown, in one specific embodiment, S2 includes: S21. Obtain the prescription list, current medicine cabinet identifier, and current medicine cabinet historical confirmed category record corresponding to the current dispensing task from the sample source constraint data.

[0044] S22. The categories of Chinese herbal medicine pieces included in the prescription list are used as candidate categories within the prescription. The categories of Chinese herbal medicine pieces included in the current medicine cabinet's historical confirmed category records are used as candidate categories within the same medicine cabinet. The categories of Chinese herbal medicine pieces in the feature database that have not been classified as candidate categories within the prescription or candidate categories within the same medicine cabinet are used as open candidate categories.

[0045] S23. Compare candidate categories in the order of candidate categories within the prescription, historical candidate categories in the same drug comparison, and open candidate categories to obtain the first candidate identification category, the second candidate identification category, the candidate similarity difference, and the candidate instability marker.

[0046] In this embodiment, it should be noted that in S21, the prescription list is used to indicate the categories of Chinese herbal medicine slices that should appear in the current dispensing task; the current medicine trough identifier is used to indicate the medicine trough from which the Chinese herbal medicine slice samples may originate; and the current medicine trough historical confirmed category record is used to indicate the categories of Chinese herbal medicine slices that have been confirmed to appear in the same medicine trough during the historical identification period. The sample source constraint data does not directly determine the identification result, but is only used to limit the candidate category comparison order and the candidate category verification scope. For example, if the prescription list corresponding to the current dispensing task includes white peony root slices, atractylodes macrocephala slices, astragalus membranaceus slices, and licorice root slices, and the historical confirmed category record corresponding to the current medicine trough identifier includes white peony root slices and atractylodes macrocephala slices, then the identification system will prioritize the above-mentioned prescription and medicine trough related categories during the initial candidate comparison. If the prescription list corresponding to the current dispensing task cannot be obtained, then the candidate category constraint within the prescription is not used; if the current medicine trough identifier cannot be obtained, then the historical candidate category constraint of the same medicine trough is not used; if neither the prescription list nor the current medicine trough identifier can be obtained, then all candidate categories participate in the comparison as open candidate categories. This treatment method is guaranteed to be applicable under different pharmacy equipment conditions.

[0047] In S22, overlapping categories are allowed among in-prescription candidate categories, historical candidate categories within the same medicine collection, and open candidate categories. If a certain type of Chinese herbal medicine decoction piece belongs to both in-prescription candidate categories and historical candidate categories within the same medicine collection, it will be prioritized as an in-prescription candidate category in the candidate category comparison order, while retaining its historical candidate attribute within the same medicine collection. If a certain type of Chinese herbal medicine decoction piece belongs to neither in-prescription candidate categories nor historical candidate categories within the same medicine collection, it will participate in subsequent comparisons as an open candidate category. For example, if the feature database contains 120 types of Chinese herbal medicine decoction pieces, the current prescription list contains 4 types of Chinese herbal medicine decoction pieces, and the current medicine collection historical confirmed category record contains 2 types of Chinese herbal medicine decoction pieces, and white peony decoction pieces belong to both in-prescription candidate categories and historical candidate categories within the same medicine collection, then white peony decoction pieces will be prioritized as an in-prescription candidate category during candidate comparison; other categories in the feature database that are not classified as either in-prescription candidate categories or historical candidate categories within the same medicine collection will be included in the open candidate categories. This classification method does not exclude open identification, but rather establishes a comparison order from closest to furthest. When ranking candidates by comprehensive similarity, only one candidate comprehensive similarity record is retained for the same category of Chinese herbal medicine pieces. If the same category of Chinese herbal medicine pieces belongs to both the candidate category within the prescription and the historical candidate category within the same herb collection, the comparison record corresponding to the candidate category within the prescription is used for ranking, while its historical candidate attribute within the same herb collection is retained as the source attribute for verification.

[0048] In step S23, the identification system first compares the color, morphological, and texture features of each Chinese herbal medicine sample with the standard color, morphological, and texture features of the candidate categories within the prescription, item by item, and obtains the candidate comprehensive similarity based on the comparison results. If the comparison results of the candidate categories within the prescription do not meet the confirmation criteria, the system continues to compare them with historical candidate categories within the same prescription. If the comparison results of historical candidate categories within the same prescription still do not meet the confirmation criteria, the system proceeds to the open candidate category comparison. The candidate comprehensive similarity is used to represent the degree of overall similarity between a Chinese herbal medicine sample and a candidate category in terms of color, morphology, and texture.

[0049] Before acquiring the first and second candidate identification categories, the identification system first checks the number of candidate categories already involved in the comparison. If the number of candidate categories already involved in the comparison is less than two, it continues to supplement candidate categories from historical candidate categories in the same medicine database or open candidate categories and performs candidate category comparison until at least two candidate categories participate in the candidate comprehensive similarity ranking. If the total number of candidate categories that can participate in the comparison in the feature library data is still less than two, the first candidate identification category is retained, and the corresponding Chinese herbal medicine sample is output as a mark to be manually reviewed, without calculating the candidate similarity difference.

[0050] When obtaining the candidate comprehensive similarity, the original index values ​​corresponding to each indicator in the Chinese herbal medicine decoction piece sample are first converted into feature values ​​within a unified range. For the f-th indicator of the j-th Chinese herbal medicine decoction piece sample, if the minimum value of the f-th indicator in the historical calibration samples is a... min,f The maximum value is a max,f , and a max,f >a min,f Then the eigenvalue x within the uniform range of values j,f Obtain it in the following way:

[0051] Where, x j,f This represents the transformed feature value of the f-th indicator of the j-th Chinese herbal medicine sample, where j represents the sample number of the Chinese herbal medicine, f represents the indicator number, and a j,f Let a represent the f-th original index value of the j-th Chinese herbal medicine sample. min,f a represents the minimum value of the f-th indicator in the historical calibration sample. max,f Let f represent the maximum value of the f-th indicator in the historical calibration sample, min(·) represents the minimum value function, and max(·) represents the maximum value function. If a max,f =a min,f If the index is not found in the overall similarity calculation for this candidate, then this index will not be included in the overall similarity calculation.

[0052] For candidate category c, the f-th standard feature value corresponding to candidate category c in the feature library data is denoted as... and according to color feature set morphological feature set and texture feature set Obtain color feature similarity respectively Morphological similarity Similarity to texture features Then obtain the candidate comprehensive similarity S. j,c :

[0053] in, This represents the feature similarity between the j-th Chinese herbal medicine sample and candidate category c under feature type d, where d represents the feature type. The color feature type is represented by 'shp', the morphological feature type by 'tex', and the candidate category by 'c'. This represents the set of indicators corresponding to feature type d. This indicates the number of indicators corresponding to feature type d. This indicates that the f-th indicator belongs to the set of indicators corresponding to feature type d. This represents the f-th standard feature value corresponding to candidate category c in the feature library data. This represents the color feature similarity between the j-th Chinese herbal medicine sample and candidate category c. S represents the morphological similarity between the j-th Chinese herbal medicine sample and candidate category c. tex,j,c S represents the textural feature similarity between the j-th Chinese herbal medicine sample and candidate category c. j,c This represents the candidate comprehensive similarity between the j-th Chinese herbal medicine sample and candidate category c. The number 3 indicates the number of similarities among the three types of features—color feature similarity, morphological feature similarity, and texture feature similarity—in the candidate comprehensive similarity calculation.

[0054] The candidate category with the highest overall similarity ranking is designated as the first candidate category, and the candidate category with the second highest overall similarity ranking is designated as the second candidate category. The difference between the overall similarity scores of the first and second candidate categories is calculated to obtain the candidate similarity gap. The candidate similarity gap G is then used. j Obtain it in the following way:

[0055] Among them, G j C represents the candidate similarity difference of the j-th Chinese herbal medicine sample, where j represents the sample number of the Chinese herbal medicine. j,1 C represents the first candidate category for the j-th Chinese herbal medicine sample. j,2 This represents the second candidate category for the j-th Chinese herbal medicine sample. This indicates that the j-th Chinese herbal medicine sample is related to the first candidate identification category C. j,1 Candidate comprehensive similarity, This indicates that the j-th Chinese herbal medicine sample is related to the second candidate identification category C. j,2 The candidate comprehensive similarity. Due to C j,1 C is the candidate category ranked first in terms of overall similarity. j,2 G is the second candidate category in terms of overall similarity, therefore... j It is a non-negative value. When G... j <G th When the candidate similarity difference does not reach the candidate difference threshold, an unstable candidate marker is generated; when G j ≥G th When the candidate similarity difference reaches the candidate difference threshold, it is determined that the similarity difference between the candidates reaches the threshold. th This represents the candidate gap threshold.

[0056] For example, the candidate comprehensive similarity of the first Chinese herbal medicine sample with the white peony root sample is 0.84, and the candidate comprehensive similarity with the atractylodes macrocephala sample is 0.81. The candidate similarity difference is 0.03, and the candidate difference threshold is 0.05. Therefore, an unstable candidate marker is generated.

[0057] like Figure 4 As shown, in one specific embodiment, S3 includes: S31. Establish a color feature sorting sequence based on the color feature similarity of each Chinese herbal medicine sample under the corresponding candidate category, establish a morphological feature sorting sequence based on the morphological feature similarity of each Chinese herbal medicine sample under the corresponding candidate category, establish a texture feature sorting sequence based on the texture feature similarity of each Chinese herbal medicine sample under the corresponding candidate category, and obtain local feature dense markers based on each feature sorting sequence.

[0058] S32. Generate a medicinal slice confusion cluster based on candidate unstable markers, local feature dense markers, first candidate identification category, second candidate identification category and sample image state data.

[0059] S33. Obtain the confusion risk value and review action type of candidate categories of medicinal slices based on the confusion clusters of medicinal slices.

[0060] In this embodiment, it should be noted that in S31, the color feature sorting sequence, morphological feature sorting sequence, and texture feature sorting sequence are all generated within the current recognition period. The color feature sorting sequence, morphological feature sorting sequence, and texture feature sorting sequence are all established within the sample range corresponding to the same candidate category or the cross-relationship of candidate categories. If the first candidate identification category of two Chinese herbal medicine samples is the same, then corresponding feature sorting sequences are established according to the color feature similarity, morphological feature similarity, and texture feature similarity of the two samples under that first candidate identification category. If the first candidate identification category and the second candidate identification category of two Chinese herbal medicine samples form a cross-relationship, then the corresponding feature similarity is obtained based on the candidate category they both involve as a comparison benchmark, and a corresponding feature sorting sequence is established under that benchmark. If two Chinese herbal medicine samples neither have the same first candidate identification category nor a cross-relationship of candidate categories, then the feature interval between them is not used as a basis for judging local feature proximity.

[0061] For each sample of traditional Chinese medicine (TCM) decoction pieces, the recognition system calculates the color feature interval, morphological feature interval, and texture feature interval between it and adjacent TCM decoction piece samples, and compares these intervals with the color confusion interval threshold, morphological confusion interval threshold, and texture confusion interval threshold, respectively. If the color feature interval of a TCM decoction piece sample meets the local proximity condition for color features, then the color feature local proximity state is determined; if the morphological feature interval meets the local proximity condition for morphological features, then the morphological feature local proximity state is determined; if the texture feature interval meets the local proximity condition for texture features, then the texture feature local proximity state is determined. When the same TCM decoction piece sample is determined to be locally close in at least two of the three states (color feature local proximity state, morphological feature local proximity state, and texture feature local proximity state), a local feature dense marker is generated. For example, the color feature interval between the first and second Chinese herbal medicine samples is 0.02 in the color feature sorting sequence, 0.03 in the morphological feature sorting sequence, and 0.09 in the texture feature sorting sequence. If the color confusion interval threshold is 0.04, the morphological confusion interval threshold is 0.05, and the texture confusion interval threshold is 0.06, then the first and second Chinese herbal medicine samples are judged to be locally similar in both color and morphological states, and local feature dense markers are generated.

[0062] In step S32, the identification system first filters out Chinese herbal medicine (TCM) slice samples that simultaneously possess candidate unstable markers and locally dense feature markers as candidate samples for TCM slice confusion. For any two candidate samples for TCM slice confusion, if the first or second candidate identification category of one candidate sample is the same as the first or second candidate identification category of the other candidate sample, the two candidate samples for TCM slice confusion are merged into the same TCM slice confusion cluster. This merging rule requires that the two samples not only have local proximity in feature ranking but also overlap at the candidate category level. For TCM slice samples that have suspected broken slice state, suspected overlapping slice state, low-resolution state, or discontinuous edge state, and do not form a candidate category overlap relationship with other candidate samples for TCM slice confusion, the TCM slice sample is regarded as a single sample TCM slice confusion cluster. If a sample of Chinese herbal medicine (TCM) decoction pieces only has candidate unstable markers but no densely packed local feature markers, it will not be directly classified into the decoction piece confusion cluster, but will instead enter the ordinary pending review judgment. If a sample of Chinese herbal medicine decoction pieces only has densely packed local feature markers but the candidate similarity difference reaches the candidate difference threshold, it will not be included in the decoction piece confusion cluster. For example, the first candidate identification category of the first TCM decoction piece sample is white peony root decoction piece and the second candidate identification category is white atractylodes macrocephala decoction piece. The first candidate identification category of the second TCM decoction piece sample is white atractylodes macrocephala decoction piece and the second candidate identification category is white peony root decoction piece. Both of them have candidate unstable markers and densely packed local feature markers, so they are merged into the same decoction piece confusion cluster. The fifth TCM decoction piece sample has a suspected overlapping decoction piece state. Even if it does not form a candidate category cross relationship with other decoction piece confusion candidate samples, it is treated as a single sample decoction piece confusion cluster.

[0063] In S33, the confusion risk value of candidate herbal medicine categories is obtained based on the candidate similarity gap level, the number of local feature similarities, the number of candidate category crossovers, the waiting period level, and the number of image state anomalies among the herbal medicine sample samples within the confusion cluster. Specifically, the candidate similarity gap level is derived from the relationship between the candidate similarity gap and the candidate gap threshold, representing the degree of proximity between the first and second candidate identification categories; the number of local feature similarities represents the number of times the same herbal medicine sample is judged as locally similar in the color feature sorting sequence, morphological feature sorting sequence, and texture feature sorting sequence; the number of candidate category crossovers represents the number of times the same herbal medicine sample crosses candidate categories with other herbal medicine samples within the current identification period; the waiting period level represents the duration of time a herbal medicine sample has not been identified since entering the identification range; and the number of image state anomalies represents the statistical results of suspected broken herbal medicine states, suspected overlapping herbal medicine states, low-resolution states, and edge discontinuities. The number of image state anomalies is Q. jThe number of abnormal states can be directly obtained from the sample image state data. Specifically, for the j-th Chinese herbal medicine sample, it is determined whether it has the states of suspected broken pieces, suspected overlapping pieces, low resolution, and discontinuous edges. Each state is counted as 1, thus obtaining the number of image state anomalies Q. j For example, if the fifth herbal medicine sample simultaneously exhibits suspected overlapping, low-resolution, and discontinuous edge characteristics, but does not exhibit suspected broken characteristics, then Q5=3.

[0064] Risk value of confusion for candidate categories of medicinal slices (R) j Represented as: Among them, R j G represents the confusion risk value of the candidate category of the j-th Chinese herbal medicine sample, where j represents the sample number of the Chinese herbal medicine. j G represents the candidate similarity difference of the j-th Chinese herbal medicine sample. th G represents the candidate gap threshold and th >0, The function represents the floor function, max(·) represents the maximum value function, and min(·) represents the minimum value function. N near,j N represents the number of similar local features corresponding to the j-th sample of Chinese herbal medicine. cross,j W represents the number of candidate category crossovers corresponding to the j-th Chinese herbal medicine sample. j Q represents the waiting period level corresponding to the j-th Chinese herbal medicine sample. j This indicates the number of image state anomalies corresponding to the j-th Chinese herbal medicine sample. The number 3 indicates the upper limit of the level used when the candidate similarity difference level item, the number of candidate category crossovers, the waiting period level, and the number of image state anomalies are included in the risk calculation. The number 4 indicates the number of factors involved in the averaging of the auxiliary risk level, including the number of local feature similarities, the number of candidate category crossovers after upper limit processing, the waiting period level after upper limit processing, and the number of image state anomalies after upper limit processing.

[0065] In the above expression, G j and G th Both values ​​are derived from the difference in candidate comprehensive similarity, and since they share the same data basis, they can be compared; N near,j N cross,j W j and Q jAll data are count or rank data. After upper limit processing, they fall within the same rank range, allowing for averaging to obtain the auxiliary risk level. The candidate similarity gap rank item reflects the closeness between the first and second candidate categories. The auxiliary risk level reflects the combined impact of local feature similarity, candidate category overlap, waiting period for recognition, and abnormal image state on the confusion risk. This expression corresponds to five technical reasons: unstable candidate recognition, local closeness of samples on the same screen, candidate category overlap, persistent unconfirmed cases, and abnormal image state.

[0066] In S33, the verification action type is determined based on the color feature similarity difference, morphological feature similarity difference, texture feature similarity difference, and sample image status data of the Chinese herbal medicine samples in the herbal medicine confusion cluster under the first candidate identification category and the second candidate identification category. If the color feature similarity difference does not reach the color confusion threshold, but the morphological feature similarity difference or texture feature similarity difference can provide a basis for differentiation, then the color proximity verification action type is determined; if the morphological feature similarity difference does not reach the morphological confusion threshold, but the color feature similarity difference or texture feature similarity difference can provide a basis for differentiation, then the morphological proximity verification action type is determined; if the texture feature similarity difference does not reach the texture confusion threshold, but the color feature similarity difference or morphological feature similarity difference can provide a basis for differentiation, then the texture proximity verification action type is determined; if the color feature similarity difference, morphological feature similarity difference, and texture feature similarity difference all do not reach the corresponding confusion threshold, then the multidimensional proximity verification action type is determined; if the sample image state data includes suspected broken slices, suspected overlapping slices, low-resolution, or discontinuous edges, then the image state anomaly verification action type is determined. Different verification action types correspond to different verification actions: color proximity type corresponds to local brightness correction, cross-sectional color uniformity recalculation, and color feature similarity recalculation; morphology proximity type corresponds to edge contour recalculation, broken edge removal, aspect ratio recalculation, and roundness recalculation; texture proximity type corresponds to texture direction consistency recalculation, local crack density recalculation, and texture contrast recalculation; multidimensional proximity type corresponds to local image resampling; image state anomaly type corresponds to sample region resegmentation, local image resampling, broken edge removal, or edge contour recalculation.

[0067] When the same Chinese herbal medicine sample simultaneously meets the requirements of both image state anomaly verification action type and at least one of the verification action types of color similarity, morphological similarity, texture similarity, or multidimensional similarity, the sample is preferentially identified as image state anomaly type, and sample region re-segmentation, local image re-acquisition, broken edge removal, or edge contour recalculation are performed first. After reacquiring the sample region, the recalculated color feature similarity difference, morphological feature similarity difference, and texture feature similarity difference determine whether to continue performing the verification actions corresponding to color similarity, morphological similarity, texture similarity, or multidimensional similarity. Therefore, the execution order of verification action types is to first handle image state anomalies, and then handle the color, morphological, or texture similarity issues between candidate categories.

[0068] To illustrate the calculation logic of the confusion risk value of candidate categories for processed medicinal herbs in S33, the following explanation is based on specific data. Assume the first candidate category for the first sample of processed medicinal herbs is white peony root slices, with a candidate comprehensive similarity of 0.84, and the second candidate category is atractylodes macrocephala slices, with a candidate comprehensive similarity of 0.81. Then the candidate similarity difference is 0.03; the candidate difference threshold is 0.05. Rounding down the result 0.6 (0.03 / 0.05) yields 0, and the candidate similarity difference level is 3. The first sample of Chinese herbal medicine was identified as locally similar in the color feature sorting sequence and the morphological feature sorting sequence, but not in the texture feature sorting sequence; therefore, the number of locally similar features is 2. The first sample of Chinese herbal medicine overlaps with the second sample of Chinese herbal medicine in terms of candidate category, so the number of candidate category overlaps is 1. The first sample of Chinese herbal medicine has been waiting for one identification cycle without being confirmed, so the waiting period level is 1. The first sample of Chinese herbal medicine has no suspected broken pieces, suspected overlapping pieces, low-resolution, or discontinuous edges, so the number of abnormal image states is 0. At this point, the auxiliary risk level is (2+1+1+0) / 4=1, and the candidate category confusion risk value is 3+1=4. The calculation results indicate that although the first sample of Chinese herbal medicine has a normal image state, the candidate similarity difference is insufficient, the number of locally similar features meets the conditions, and there is candidate category overlap; therefore, it needs to enter the review and identification batch.

[0069] Taking the fifth Chinese herbal medicine sample as an example, assuming the candidate comprehensive similarity for the first candidate identification category of the fifth Chinese herbal medicine sample is 0.78, the candidate comprehensive similarity for the second candidate identification category is 0.70, the candidate similarity difference is 0.08, and the candidate difference threshold is 0.05, rounding down the result 1.6 of 0.08 / 0.05 yields 1, the candidate similarity difference level is 2. The fifth Chinese herbal medicine sample is only judged as locally close in the morphological feature sorting sequence, so the number of locally close features is 1; there is no candidate category overlap with other Chinese herbal medicine samples, so the number of candidate category overlaps is 0; the waiting period level is 1; it also has a suspected overlapping state, a low-resolution state, and a discontinuous edge state, so the number of image state anomalies is 3. At this time, the auxiliary risk level is (1+0+1+3) / 4=1.25, and the candidate category confusion risk value is 2+1.25=3.25. The results indicate that although the fifth herbal medicine sample had a greater candidate similarity difference than the first, its image state anomalies numbered three, necessitating a review and verification process involving sample region re-segmentation or local image re-acquisition. This calculation allows the recognition system to simultaneously consider unstable candidate categories, similar local features, overlapping candidate categories, waiting periods for recognition, and image state anomalies, rather than solely relying on the highest overall candidate similarity for confirmation.

[0070] like Figure 5 As shown, in one specific embodiment, S4 includes: S41. Based on the processing capacity data, determine whether the current recognition cycle should enter the basic recognition path or the verification recognition path.

[0071] S42. Generate the first review and identification batch, the second review and identification batch, and the third review and identification batch based on the confusion cluster of medicinal slices, the confusion risk value of candidate categories of medicinal slices, the review action type, and the upper limit of the number of review processing samples.

[0072] S43. Perform identification processing according to the batch of verification and identification, and output the confirmed identification results, the mark to be manually verified, the mark to be re-segmented, or the unconfirmed mark.

[0073] In this embodiment, it should be noted that in S41, if the number of Chinese herbal medicine samples to be identified within the current identification period does not exceed the upper limit of the basic identification sample number, there are no herbal medicine confusion clusters, and the sample image status data does not indicate any abnormality, the system enters the basic identification path. In the basic identification path, the identification system outputs a confirmed identification result, a manual review mark, or an unconfirmed mark based on the candidate comprehensive similarity, candidate similarity gap, confirmation threshold, and verification threshold corresponding to the first candidate identification category. The confirmation threshold and verification threshold are both boundary conditions for judging the candidate comprehensive similarity, and the verification threshold is not higher than the confirmation threshold. When the candidate comprehensive similarity corresponding to the first candidate identification category reaches the confirmation threshold, and the candidate similarity gap reaches the candidate gap threshold, a confirmed identification result is output; when the candidate comprehensive similarity corresponding to the first candidate identification category reaches the verification threshold but not the confirmation threshold, or the candidate similarity gap does not reach the candidate gap threshold, a manual review mark is output; when the candidate comprehensive similarity corresponding to the first candidate identification category does not reach the verification threshold, an unconfirmed mark is output; when the sample area still cannot form a stable Chinese herbal medicine sample area after re-segmentation, a re-segmentation mark is output.

[0074] If the number of Chinese herbal medicine samples to be identified in the current identification period exceeds the upper limit of the basic identification sample number, or if there are clusters of confused herbs, or if the sample image status data indicates that there are suspected broken herbs, suspected overlapping herbs, low-resolution herbs, or discontinuous edges, the system will enter the verification identification path. The verification identification path is used to perform identification processing according to verification batches when the basic identification capability is limited or there is a risk of sample confusion. For example, if the number of Chinese herbal medicine samples to be identified in the current identification period is 5, the upper limit of the basic identification sample number is 3, and there are clusters of confused herbs, then the system will enter the verification identification path.

[0075] In S42, the first verification batch includes Chinese herbal medicine (TCM) samples with high confusion risk values ​​for candidate TCM categories within the TCM confusion cluster, as well as TCM samples whose image state data indicates abnormalities. The TCM samples in the first verification batch undergo local image re-sampling, sample region re-segmentation, edge contour recalculation, broken edge removal, cross-sectional color uniformity recalculation, texture direction consistency recalculation, local crack density recalculation, or candidate category expansion comparison, corresponding to the verification action type. If the number of samples in the first verification batch exceeds the upper limit for the number of verification samples, it is split into multiple first verification sub-batches according to the confusion risk value of the candidate TCM category from high to low. When multiple TCM samples have the same confusion risk value for candidate TCM categories, they are first sorted from high to low according to the number of abnormal image states; if the number of abnormal image states is still the same, they are sorted from high to low according to the waiting period level; if the waiting period level is still the same, they are sorted from small to large according to the TCM sample number. Through this process, the sample order in the first review identification batch and the first review sub-batch can be determined by the data within the current identification cycle.

[0076] The second review and identification batch includes Chinese herbal medicine (TCM) decoction piece samples with candidate unstable markers but not included in the first review and identification batch. TCM decoction piece samples in the second review and identification batch undergo candidate category review and comparison within the prescription's candidate categories and historical candidate categories of the same herb. If the candidate comprehensive similarity corresponding to the first candidate identification category after review does not reach the confirmation threshold, or the candidate similarity difference does not reach the candidate difference threshold, then it enters the open candidate category comparison. The third review and identification batch includes TCM decoction piece samples with stable candidates and whose sample image state data does not indicate abnormalities. TCM decoction piece samples in the third review and identification batch undergo basic candidate comparison. For example, if the maximum number of review samples is 1, the confusion risk value of the candidate category for the first TCM decoction piece sample is 4, and the confusion risk value of the candidate category for the fifth TCM decoction piece sample is 3.25, then the first TCM decoction piece sample first enters the first review sub-batch, and the fifth TCM decoction piece sample enters a subsequent first review sub-batch.

[0077] In step S43, for the Chinese herbal medicine slices samples in the first batch of verification, if the verification action type is color similarity, then local brightness correction, cross-sectional color uniformity recalculation, and color feature similarity recalculation are performed; if the verification action type is morphological similarity, then edge contour recalculation, broken edge removal, aspect ratio recalculation, and roundness recalculation are performed; if the verification action type is texture similarity, then texture direction consistency recalculation, local crack density recalculation, and texture contrast recalculation are performed; if the verification action type is multidimensional similarity, then local image re-acquisition is performed, and color feature data, morphological feature data, and texture feature data are re-acquired based on the re-acquisitioned image; if the verification action type is image state anomaly, then sample region re-segmentation, local image re-acquisition, broken edge removal, or edge contour recalculation are performed based on the sample image state data. Local image re-acquisition refers to re-acquiring local image data for the Chinese herbal medicine slice sample area that needs to be verified. The local image data can come from a cropped region within the same image, or from adjacent frame images cached in the current recognition cycle, or from newly acquired local images. When sufficient local image data for verification can be obtained from the cached images, no additional image acquisition hardware is required. After verification, the first candidate category, the second candidate category, the candidate similarity difference, and the candidate comprehensive similarity are reacquired.

[0078] For the Chinese herbal medicine samples in the second batch of verification, the identification system prioritizes candidate category verification and comparison within the prescription and historical candidate categories of the same herb. If the overall similarity of the first candidate identification category after verification does not reach the confirmation threshold, or the candidate similarity difference does not reach the candidate difference threshold, then it proceeds to open candidate category comparison. For the Chinese herbal medicine samples in the third batch of verification, the identification system performs basic candidate comparison. Based on the first candidate identification category, the second candidate identification category, the candidate similarity difference, the overall candidate similarity, the confirmation threshold, and the verification threshold after verification, the system outputs the confirmed identification result, a mark pending manual verification, a mark pending re-segmentation, or an unconfirmed mark. If the first candidate category remains stable after review, and the candidate similarity difference reaches the candidate difference threshold, and the candidate comprehensive similarity reaches the confirmation threshold, then the confirmed identification result is output; if the candidate comprehensive similarity corresponding to the first candidate category reaches the review threshold, but the candidate similarity difference still does not reach the candidate difference threshold, then a mark indicating manual review is output; if the sample region still cannot be stably segmented after review, then a mark indicating re-segmentation is output; if the candidate comprehensive similarity does not reach the review threshold, then an unconfirmed mark is output.

[0079] This invention also provides a data processing system for identifying traditional Chinese medicine decoction pieces based on image recognition, such as... Figure 6 As shown, it includes a data acquisition module, a candidate category processing module, a confusion cluster processing module, and a verification and identification module.

[0080] The data acquisition module is used to acquire Chinese herbal medicine (TCM) slice samples, sample source constraint data, feature library data, and processing capability data within the current recognition period. It also acquires color feature data, morphological feature data, texture feature data, and sample image status data for each TCM slice sample. Furthermore, based on edge continuity ratio, contour concavity ratio, edge clarity check results, and overlapping area judgment results, the data acquisition module generates states such as suspected broken slices, suspected overlapping slices, low-resolution, or discontinuous edges.

[0081] The candidate category processing module divides the feature library data into in-prescription candidate categories, historical candidate categories from the same medicine drawer, and open candidate categories based on sample source constraints. It then compares color feature data, morphological feature data, and texture feature data according to the division results to obtain a first candidate identification category, a second candidate identification category, a candidate similarity difference, and a candidate instability marker. The module also performs candidate category comparison in the order of in-prescription candidate categories, historical candidate categories from the same medicine drawer, and open candidate categories, and generates a candidate instability marker based on the candidate similarity difference between the first and second candidate identification categories.

[0082] The confusion cluster processing module is used to obtain feature sorting sequences and locally dense feature markers based on color feature data, morphological feature data, and texture feature data. It then generates confusion clusters for medicinal slices based on candidate unstable markers, locally dense feature markers, the first candidate identification category, the second candidate identification category, and sample image state data. The module also obtains the confusion risk value and verification action type for each candidate category. Furthermore, the module merges confusion clusters based on the cross-relationships of candidate categories and determines the verification action type based on color feature similarity differences, morphological feature similarity differences, texture feature similarity differences, and sample image state data.

[0083] The verification and identification module generates verification and identification batches based on the confusion risk value of candidate herbal medicine slices, verification action type, and processing capacity data. It then outputs confirmed identification results, marks pending manual verification, marks pending re-segmentation, or unconfirmed marks according to the verification and identification batch. The module also performs tasks based on the verification action type, including local image re-acquisition, sample region re-segmentation, edge contour recalculation, broken edge removal, cross-sectional color uniformity recalculation, texture direction consistency recalculation, local crack density recalculation, or candidate category expansion comparison.

[0084] In one specific implementation, the data acquisition module, candidate category processing module, confusion cluster processing module, and verification and identification module can be implemented by a processor executing a computer program, or they can be implemented collaboratively by multiple processing units. The output of the data acquisition module serves as the input of the candidate category processing module, the output of the candidate category processing module serves as the input of the confusion cluster processing module, and the output of the confusion cluster processing module serves as the input of the verification and identification module. The data transmitted between the modules includes Chinese herbal medicine samples, color feature data, morphological feature data, texture feature data, sample image state data, first candidate identification category, second candidate identification category, candidate similarity difference, candidate unstable marker, local feature dense marker, herbal medicine confusion cluster, herbal medicine candidate category confusion risk value, verification action type, and verification and identification batch. All of the above data are determined by the image data of the current identification cycle, sample source constraint data, feature library data, processing capacity data, and historical calibration sample data, and there is a corresponding relationship between each input data, processing rule, and output data.

[0085] like Figure 7 As shown, the data acquisition module first outputs the Chinese herbal medicine slices sample, color feature data, morphological feature data, texture feature data, and sample image state data; the candidate category processing module outputs the first candidate identification category, the second candidate identification category, the candidate similarity difference, and the candidate unstable marker based on the sample source constraint data and feature library data; the confusion cluster processing module outputs the slice confusion cluster, the slice candidate category confusion risk value, and the review action type based on the candidate unstable marker, the local feature dense marker, and the sample image state data; the review and identification module generates review and identification batches based on the processing capacity data, and outputs the confirmed identification result, the marker to be manually reviewed, the marker to be re-segmented, or the unconfirmed marker according to the review and identification batch.

[0086] The following section uses a scenario with specific parameters and data to illustrate the data processing method and system for identifying traditional Chinese medicine decoction pieces based on image recognition.

[0087] In a specific application scenario, the prescription list corresponding to the current dispensing task includes white peony root slices, atractylodes macrocephala slices, astragalus membranaceus slices, and licorice root slices. The current medicine cabinet's historical confirmed category records include white peony root slices and atractylodes macrocephala slices. The original image is acquired within the current recognition period, with a resolution of 1920×1080. After foreground segmentation and connected component filtering, five samples of traditional Chinese medicine slices are obtained. In the processing capability data, the maximum number of basic recognition samples is 3, and the maximum number of verification processing samples is 1. The average brightness of the central region of the original image is 142, and the average brightness of the edge region is adjusted from 116 to 140 to ensure that the central and edge regions meet the same image segmentation brightness condition. The area of ​​the fourth traditional Chinese medicine slice sample is 6200 pixels. 2The edge continuity ratio is 0.68, which is lower than the lower limit of 0.75, thus generating a suspected broken herbal piece state and an edge discontinuity state; the 5th herbal piece sample has local overlap, generating a suspected overlapping herbal piece state, a low-resolution state, and an edge discontinuity state.

[0088] During the candidate category comparison process, the first herbal medicine sample showed a candidate comprehensive similarity of 0.84 with white peony root slices, 0.81 with atractylodes macrocephala slices, 0.63 with astragalus membranaceus slices, and 0.58 with licorice root slices. Therefore, the first candidate category was white peony root slices, and the second candidate category was atractylodes macrocephala slices, with a candidate similarity difference of 0.03. The candidate difference threshold was 0.05. Since 0.03 < 0.05, the first herbal medicine sample was marked as an unstable candidate. The second herbal medicine sample showed a candidate comprehensive similarity of 0.83 with atractylodes macrocephala slices and 0.79 with white peony root slices, with a candidate similarity difference of 0.04, and was also marked as unstable. The third Chinese herbal medicine sample had a candidate comprehensive similarity of 0.88 with Astragalus membranaceus and 0.72 with Glycyrrhiza uralensis. The candidate similarity difference was 0.16, and no candidate unstable marker was generated.

[0089] During the feature ranking process, the color feature interval between the first and second Chinese herbal medicine (TCM) decoction piece samples is 0.02 in the color feature ranking sequence, 0.03 in the morphological feature ranking sequence, and 0.09 in the texture feature ranking sequence. The color confusion interval thresholds are 0.04, morphological confusion interval thresholds are 0.05, and texture confusion interval thresholds are 0.06. Therefore, the first and second TCM decoction piece samples are considered locally similar in both color and morphological features, and local feature density markers are generated. Since the first candidate identification category for the first TCM decoction piece sample is white peony root slices and the second candidate identification category is atractylodes macrocephala slices, and the first candidate identification category for the second TCM decoction piece sample is atractylodes macrocephala slices and the second candidate identification category is white peony root slices, there is a candidate category overlap. Therefore, the first and second TCM decoction piece samples are grouped into the same decoction piece confusion cluster. The fourth Chinese herbal medicine sample was classified as a single-sample mixed cluster due to its suspected broken pieces and discontinuous edges. The fifth Chinese herbal medicine sample was classified as a single-sample mixed cluster due to its suspected overlapping pieces, low resolution, and discontinuous edges.

[0090] For the first sample of Chinese herbal medicine, substituting the specific value into the expression in S33, the calculation process is: 0.03 / 0.05=0.6. Rounding down 0.6 yields 0, therefore R1=max(0,3-0)+(2+1+1+0) / 4=3+1=4. Thus, the confusion risk value of the candidate category for the first sample of Chinese herbal medicine is 4. This result is consistent with the sample status: although the first sample of Chinese herbal medicine does not have any image anomalies such as brokenness, overlap, low clarity, or discontinuous edges, its candidate similarity difference is only 0.03, and it overlaps with the candidate category of the second sample of Chinese herbal medicine. Furthermore, it shows local similarity in color and morphological features, therefore it needs to be prioritized for verification and recognition.

[0091] For the fifth Chinese herbal medicine sample, assuming its first candidate identification category has a candidate comprehensive similarity of 0.78, its second candidate identification category has a candidate comprehensive similarity of 0.70, and its candidate similarity difference is 0.08; it is only judged as locally close in the morphological feature ranking sequence, with a local feature closeness count of 1; it does not have candidate category overlap with other Chinese herbal medicine samples, with a candidate category overlap count of 0; its waiting identification cycle level is 1; and it simultaneously exhibits suspected overlapping slice status, low-resolution status, and edge discontinuity status, with an image status anomaly count of 3. Substituting the specific values ​​into the expression in S33, the calculation process is: 0.08 / 0.05=1.6, rounding down 1.6 yields 1, therefore R5=max(0,3-1)+(1+0+1+3) / 4=2+1.25=3.25. Therefore, the slice candidate category confusion risk value for the fifth Chinese herbal medicine sample is 3.25. The candidate similarity difference of the 5th Chinese herbal medicine sample is greater than that of the 1st Chinese herbal medicine sample, but the number of abnormal image states is 3. Therefore, it still enters the verification and recognition path and performs local image re-sampling and sample region re-segmentation.

[0092] For the fourth herbal medicine sample, assuming its candidate similarity difference is 0.08 and the candidate difference threshold is 0.05, rounding down the result 1.6 of 0.08 / 0.05 yields 1, so the candidate similarity difference level is 2. The fourth herbal medicine sample is judged to be locally similar in the morphological feature ranking sequence, with a local feature similarity count of 1. It does not have any candidate category overlap with other herbal medicine samples, resulting in a candidate category overlap count of 0. Its waiting period level is 1. It also exhibits both suspected broken herbal pieces and discontinuous edge states, with an image state abnormality count of 2. Therefore, the auxiliary risk level for the fourth herbal medicine sample is (1+0+1+2) / 4=1, and the herbal medicine candidate category confusion risk value is 2+1=3.

[0093] During the batch generation process for verification and identification, there are 5 Chinese herbal medicine (TCM) decoction piece samples in the current identification cycle, exceeding the upper limit of the basic identification sample quantity, and there are also decoction piece confusion clusters. Therefore, they enter the verification and identification path. The upper limit of the number of verification samples is 1. The confusion risk value of the candidate decoction piece category for the first TCM decoction piece sample is 4, the confusion risk value of the candidate decoction piece category for the fifth TCM decoction piece sample is 3.25, and the confusion risk value of the candidate decoction piece category for the fourth TCM decoction piece sample is 3. Therefore, the first TCM decoction piece sample enters the first verification sub-batch, the fifth TCM decoction piece sample enters the subsequent first verification sub-batch, and the fourth TCM decoction piece sample enters the next subsequent first verification sub-batch. The second TCM decoction piece sample has a candidate unstable marker but did not enter the first verification sub-batch, so it enters the second verification and identification batch. The third TCM decoction piece sample has a candidate stable marker and the sample image status data does not indicate any abnormalities, so it enters the third verification and identification batch.

[0094] During the review, the first herbal medicine sample underwent recalculation of cross-sectional color uniformity, edge contour, and texture direction consistency. After review, the candidate comprehensive similarity between the first herbal medicine sample and white peony root slices was adjusted to 0.87, and the candidate comprehensive similarity with atractylodes macrocephala slices was adjusted to 0.78. The candidate similarity difference became 0.09, reaching the candidate difference threshold, and the first candidate identification category remained white peony root slices. Therefore, white peony root slices were output as the confirmed identification result. The fifth herbal medicine sample underwent local image re-acquisition and sample region re-segmentation. If a stable herbal medicine sample region could not be formed after re-segmentation, a re-segmentation marker was output. If a stable region could be formed after re-segmentation, color feature data, morphological feature data, and texture feature data were reacquired, and the sample was re-entered for candidate category comparison.

[0095] The preferred embodiments of the present disclosure have been described in detail above with reference to the accompanying drawings. However, the present disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of the present disclosure, various simple modifications can be made to the technical solutions of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0096] It should also be noted that the various specific technical features described in the above embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.

[0097] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.

[0098] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be covered within the scope of the claims and specification of the present invention.

Claims

1. An image recognition-based traditional Chinese medicine decoction piece identification data processing method, characterized in that, The methods include: The color, shape and texture feature data of multiple Chinese herbal medicine slices samples within the current recognition period are obtained, compared with the feature library data, and the first candidate recognition category, the second candidate recognition category and the candidate similarity difference are obtained. When the candidate similarity difference does not reach the candidate difference threshold, a candidate unstable label is generated. Within the sample range where the first candidate identification category of two Chinese herbal medicine slices is the same, or where the first and second candidate identification categories of the two samples have an overlapping relationship, a feature sorting sequence is established according to the similarity of color, shape and texture features of each Chinese herbal medicine slice sample under the corresponding candidate category. Based on the feature interval of adjacent samples, three types of feature local proximity states are determined, and local feature dense markers are generated when there is local proximity in at least two types of states. Chinese herbal medicine samples that simultaneously possess both candidate unstable markers and locally dense feature markers are selected as candidate samples for confusion. When any two candidate samples for confusion contain the same category in their first or second candidate identification category, they are merged into the same confusion cluster, and the Chinese herbal medicine samples within the confusion cluster are transferred to the verification and identification process.

2. The method for processing data of traditional Chinese medicine decoction pieces based on image recognition according to claim 1, characterized in that, Obtain multiple samples of traditional Chinese medicine decoction pieces within the current identification period, including: Acquire the original image within the current recognition period, and perform brightness equalization processing on the original image to ensure that the central and edge regions meet the same image segmentation brightness conditions. Based on the edge sharpness check results, determine whether the original image meets the contour extraction conditions. Perform foreground segmentation on the original image that meets the contour extraction conditions to obtain the foreground region of the medicinal slices. The foreground region of medicinal herbs is selected based on the area of ​​the connected region, the proportion of continuous edges, and the proportion of contour concavity. The retained connected regions are used as the sample regions of medicinal herbs, and medicinal herb samples are obtained based on the sample regions of medicinal herbs.

3. The image recognition-based traditional Chinese medicine decoction piece identification data processing method according to claim 1, characterized in that, Obtain color, morphological, and texture feature data of multiple Chinese herbal medicine slices samples within the current recognition period, including: Color feature data includes the uniformity of cross-sectional color of the Chinese herbal medicine sample area; morphological feature data includes the edge continuity ratio and contour concavity ratio of the Chinese herbal medicine sample area; and texture feature data includes the texture direction consistency and local crack density of the Chinese herbal medicine sample area. Based on the edge continuity ratio, contour concavity ratio, edge clarity inspection results, and overlapping area judgment results, sample image status data are obtained, including suspected broken slices, suspected overlapping slices, low-resolution, and discontinuous edge states.

4. The image recognition-based traditional Chinese medicine decoction piece identification data processing method according to claim 1, characterized in that, By comparing with the feature library data, the first candidate identification category, the second candidate identification category, and the candidate similarity difference are obtained, including: Retrieve the prescription list, current medicine drawer identifier, and historical confirmed product category records for the current dispensing task; The categories of Chinese herbal medicines in the prescription list are used as candidate categories within the prescription. The categories of Chinese herbal medicines in the current medicine cabinet's historical confirmed category records are used as candidate categories in the same medicine cabinet's history. The categories of Chinese herbal medicines in the feature database that are not classified into the aforementioned two categories are used as open candidate categories. Candidate categories are compared in the following order: in-prescription candidate categories, historical candidate categories from the same drug comparison, and open candidate categories.

5. The method for processing data of traditional Chinese medicine decoction pieces based on image recognition according to claim 4, characterized in that, Candidate categories are compared in the following order: in-prescription candidate categories, historical candidate categories from the same drug list, and open candidate categories, including: The color feature data, morphological feature data, and texture feature data of each Chinese herbal medicine decoction piece sample are compared with the standard color feature, standard morphological feature, and standard texture feature of the candidate category one by one to obtain the color feature similarity, morphological feature similarity, and texture feature similarity, and the average of the three is used to obtain the candidate comprehensive similarity. The candidate categories ranked first and second in terms of comprehensive similarity are taken as the first and second candidate categories for identification, respectively. The difference between their comprehensive similarity scores is used to obtain the candidate similarity gap. When the candidate similarity difference does not reach the candidate difference threshold, an unstable candidate label is generated.

6. The method for processing data of traditional Chinese medicine decoction pieces based on image recognition according to claim 1, characterized in that, A feature ranking sequence was established based on the similarity of color, morphology, and texture features of each Chinese herbal medicine sample under the corresponding candidate category, including: When the first candidate identification category is the same, the first candidate identification category is used as the comparison benchmark to establish the ranking sequence of each feature; when the candidate category crosses, the candidate category involved in the same way is used as the comparison benchmark to establish the ranking sequence of each feature. The color feature interval, morphological feature interval, and texture feature interval are compared with the color confusion interval threshold, morphological confusion threshold, and texture confusion threshold, respectively, to determine the corresponding local proximity state; When the same Chinese herbal medicine sample is determined to be locally close in at least two local proximity states, a local feature dense marker is generated.

7. The method for processing data of traditional Chinese medicine decoction pieces based on image recognition according to claim 1, characterized in that, Traditional Chinese medicine (TCM) decoction piece samples that simultaneously possess candidate unstable markers and locally dense markers are selected as candidate samples for decoction piece confusion, including: For any two candidate samples of mixed medicinal slices, if the first candidate identification category or the second candidate identification category of one candidate sample of mixed medicinal slices is the same as the first candidate identification category or the second candidate identification category of the other candidate sample of mixed medicinal slices, the two candidate samples of mixed medicinal slices will be merged into the same mixed medicinal slices cluster. For Chinese herbal medicine samples that are suspected of being broken, overlapping, low-resolution, or have discontinuous edges, and that do not form a cross-category relationship with other candidate samples that are confused with other herbal medicine samples, they are treated as single-sample confused herbal medicine clusters.

8. The method for processing data of traditional Chinese medicine decoction pieces based on image recognition according to claim 1, characterized in that, The samples of Chinese herbal medicines within the confusion cluster are transferred to a verification and identification process, including: Based on the candidate similarity difference level, the number of similar local features, the number of candidate category crossovers, the waiting period level, and the number of abnormal image states of Chinese herbal medicine samples within the herbal medicine confusion cluster, the risk value of confusion of candidate categories of herbal medicine is obtained. The candidate similarity gap level is calculated by subtracting the floor value of the ratio of the candidate similarity gap to the candidate gap threshold from 3, and then taking the maximum value between the resulting difference and 0. Upper limits are applied to the number of candidate category crossovers, the waiting period level, and the number of abnormal image states. The number of similar local features is averaged with the results of the three upper limit processing to obtain the auxiliary risk level. The candidate similarity difference level is added to the auxiliary risk level to obtain the confusion risk value of the candidate categories of medicinal slices.

9. The method for processing data of traditional Chinese medicine decoction pieces based on image recognition according to claim 1, characterized in that, The samples of Chinese herbal medicines within the confusion cluster are transferred to a verification and identification process, including: Based on the color feature similarity difference, morphological feature similarity difference, texture feature similarity difference, and sample image status data of Chinese herbal medicine samples under the first and second candidate identification categories, determine the verification action type of color similarity, morphological similarity, texture similarity, multidimensional similarity, or image status abnormality. Color proximity corresponds to cross-sectional color uniformity recalculation; shape proximity corresponds to edge contour recalculation and broken edge removal; texture proximity corresponds to texture direction consistency recalculation and local crack density recalculation; multidimensional proximity corresponds to local image resampling; and image state anomaly corresponds to sample region resegmentation, local image resampling, broken edge removal, or edge contour recalculation.

10. A data processing system for identifying traditional Chinese medicine decoction pieces based on image recognition, characterized in that, The system is used to implement the image recognition-based traditional Chinese medicine decoction piece identification data processing method as described in any one of claims 1 to 9, and the system includes: The data acquisition module is used to acquire the color, morphology, and texture feature data of multiple Chinese herbal medicine slices samples within the current identification period; The candidate category processing module is used to compare feature data with feature library data, obtain the first candidate identification category, the second candidate identification category and the candidate similarity difference, and generate candidate unstable markers; The confusion cluster processing module is used to establish a feature sorting sequence, obtain local feature dense markers, screen candidate samples for confusion of medicinal slices, and merge candidate samples for confusion of medicinal slices with the same first candidate identification category or second candidate identification category into a confusion cluster of medicinal slices; The verification and identification module is used to transfer samples within the confusion cluster of medicinal slices to the verification and identification process.