A traditional Chinese medicine decoction piece detection device and detection method

CN122948768APending Publication Date: 2026-10-20SHUNTONG INFORMATION TECH (DALIAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611021288.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-09
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

[0003]为了解决传统方法仅考虑单一维度的图像特征,无法区分药材自身的生理性荧光与真正的异物荧光,导致良品被误判为异物的技术问题,本发明的目的在于提供一种中药饮片检测装置和检测方法,所采用的技术方案具体如下:

Benefits of technology

本发明首先通过对纹理图像进行区域划分,以纹理图像作为区域划分参考基准,饮片子区域表征了单中药饮片的物理位置,增加了异物检测结果的精准度。然后,通过特征解耦与降维,从纹理图像中提取代表生理结构的纹理骨架线,从对齐荧光图像中提取代表发光位置的荧光骨架线,将复杂的图像比对转化为几何特征点的匹配问题,使得计算量减小,可解释性强。进一步地,通过每个纹理骨架点与每个荧光骨架点之间的距离分布、对应的纹理切线向量和荧光切线向量之间的夹角,计算纹理骨架点与荧光骨架点之间的匹配权重,在对两种不同特征图像上的骨架点进行特征匹配时,充分考虑了距离特征和骨架方向特征这两个不同维度,使得特征匹配结果更加准确,进而筛选出的未匹配游离荧光点,能够更加准确的表征在荧光特征维度下真实的异物表现出的游离点,为后续能够有效区分异物与药材提供数据基础,提高了异物检测结果的准确性。最后,通过计算游离荧光能量比,从形态学角度区分了生理性荧光(依附于纹理)和病理性荧光(游离于纹理)。该指标能够敏锐捕捉游离于纹理之外的微小异物(如塑料纤维、虫卵),而不受良品本身高亮纹理的干扰,显著提升了净选纯度,有效地区分了饮片生理纹理荧光与异物荧光。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure SMS_3
    Figure SMS_3
  • Figure SMS_8
    Figure SMS_8
Patent Text Reader

Abstract

This invention relates to the field of image data processing technology, specifically to a device and method for detecting traditional Chinese medicine (TCM) decoction pieces. The invention acquires texture and fluorescence images for the current processing cycle, and divides the texture image into regions to obtain decoction piece sub-regions. Within each sub-region, the texture centerline and fluorescence skeleton line are discretely extracted to obtain corresponding skeleton points and tangent vectors. A matching weight is calculated by combining the distance distribution between texture skeleton points and fluorescence skeleton points with the angle between the corresponding tangent vectors. Unmatched free fluorescence points are then screened out using weighted matching. An energy percentage index is calculated based on the cumulative grayscale values ​​of the unmatched free fluorescence points, and this index is used for anomaly detection. This invention, through dual-modal feature fusion and graph matching algorithms, accurately removes the fluorescence from the vascular bundles of the medicinal material itself, significantly improving the accuracy and robustness of foreign object detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image data processing technology, and specifically to a device and method for detecting traditional Chinese medicine decoction pieces. Background Technology

[0002] During the processing of traditional Chinese medicine (TCM) decoction pieces (such as astragalus, licorice, and other rhizome-based herbs), foreign objects with colors extremely similar to the medicinal materials are often mixed in, such as pale yellow woven bag filaments, plastic fibers, insect eggs, and mycelia from early mold growth. These foreign objects and medicinal materials have similar colors under visible light and similar fluorescence intensities under ultraviolet light, making them ineffective for traditional detection methods based on a single feature (color or brightness). High-frequency random vibrations in industrial settings cause nonlinear displacement of the same medicinal material between different spectral images. Rigid registration cannot compensate for this local deformation, leading to false difference signals in edge regions. To avoid false alarms due to registration errors, the system must reduce detection sensitivity, but this directly leads to missed detection of minute foreign objects, creating a detection blind spot. Existing methods cannot distinguish between the physiological fluorescence (vascular bundle structure) of the medicinal material itself and the fluorescence of genuine foreign objects, causing good products to be misjudged as foreign objects. Therefore, there is an urgent need for a detection method that can adapt to high-speed transport vibrations and effectively distinguish between the physiological texture fluorescence of decoction pieces and the fluorescence of foreign objects. Summary of the Invention

[0003] To address the technical problem that traditional methods, which only consider single-dimensional image features, cannot distinguish between the physiological fluorescence of medicinal materials and the fluorescence of true foreign substances, leading to the misclassification of good products as foreign substances, the present invention aims to provide a detection device and method for traditional Chinese medicine decoction pieces. The specific technical solution adopted is as follows: Collect texture and fluorescence images of Chinese herbal medicine slices in the current processing cycle; divide the texture images into regions to obtain sub-regions of the herbal medicine slices; In the herbal slice sub-region, the texture center line extracted from the texture image is discretized to obtain texture skeleton points and texture tangent vectors; the fluorescence skeleton line extracted from the fluorescence image is discretized to obtain fluorescence skeleton points and fluorescence tangent vectors. Based on the distance distribution between each texture skeleton point and each fluorescent skeleton point, and the angle between the corresponding texture tangent vector and the fluorescent tangent vector, the matching weight between the texture skeleton point and the fluorescent skeleton point is calculated; based on the matching weight, the texture skeleton point and the fluorescent skeleton point are matched to obtain the unmatched free fluorescent points in each slice sub-region; Based on the cumulative grayscale value of the unmatched free fluorescent dots in the sub-region of the medicinal slice, the energy ratio index is obtained; using the energy ratio index, anomalies are judged in the sub-region of the medicinal slice, and the detection results of foreign object medicinal slices are obtained.

[0004] Furthermore, the method for calculating the matching weights between texture skeleton points and fluorescent skeleton points includes: For any texture skeleton point and any fluorescent skeleton point, the geometric distance between the texture skeleton point and the fluorescent skeleton point is obtained based on their coordinates; the angle between the tangent vectors between the texture skeleton point and the fluorescent skeleton point is obtained based on the texture tangent vector corresponding to the texture skeleton point and the fluorescent tangent vector corresponding to the fluorescent skeleton point. If the geometric distance between the texture skeleton point and the fluorescent skeleton point is greater than the preset jitter radius, or the angle between the tangent vectors between the texture skeleton point and the fluorescent skeleton point is greater than the preset direction threshold, then the matching weight between the texture skeleton point and the fluorescent skeleton point is set to the preset value. If the geometric distance between the texture skeleton point and the fluorescent skeleton point is less than or equal to the preset jitter radius, and the angle between the tangent vectors of the texture skeleton point and the fluorescent skeleton point is less than or equal to the preset direction threshold, then the difference between the preset jitter radius and the geometric distance between the texture skeleton point and the fluorescent skeleton point is used as the matching weight between the texture skeleton point and the fluorescent skeleton point. The preset value is less than the value of all current matching weights.

[0005] Furthermore, the method for obtaining unmatched free fluorescent spots in each sub-region of the medicinal slice includes: Any texture skeleton point is paired with any fluorescent skeleton point to form a matching pair. The sum of the matching weights of all matching pairs is calculated. The matching relationship corresponding to all matching pairs with the maximum sum of matching weights is extracted and determined as the final matching result. In the final matching result, fluorescent skeleton points that do not have a matching relationship with texture skeleton points are regarded as unmatched free fluorescent points.

[0006] Furthermore, the method for obtaining the energy percentage index includes: The total free fluorescence energy is obtained by summing the gray values ​​of all unmatched free fluorescent spots; the total fluorescence energy is obtained by summing the gray values ​​of all fluorescent backbone spots; and the ratio of the total free fluorescence energy to the total fluorescence energy is used as the energy percentage index.

[0007] Furthermore, the method for obtaining the detection results of foreign object medicinal slices includes: If the energy percentage index of a certain area of ​​the medicinal herb is greater than a preset standard threshold, then the medicinal herb corresponding to that area is a foreign object; if the energy percentage index is less than or equal to the preset standard threshold, then the medicinal herb corresponding to that area is a good product.

[0008] Furthermore, the method for obtaining texture skeleton points and texture tangent vectors includes: The skeleton of the medicinal slice is extracted to obtain the texture center line; the pixels on the texture center line are called texture skeleton points. On the texture center line, the texture tangent vector of each texture skeleton point is determined based on the coordinate difference between each texture skeleton point and its adjacent texture skeleton points.

[0009] Furthermore, the method for obtaining the herbal slice sub-region includes: The optimal grayscale segmentation threshold is calculated using the Otsu thresholding algorithm. Pixels in the texture image whose grayscale value is greater than the optimal grayscale segmentation threshold are taken as target pixels. The connected regions formed by the target pixels are taken as the slice sub-regions.

[0010] Furthermore, the method for obtaining the fluorescent backbone points and fluorescent tangent vectors includes: Obtain background pixels in the texture image other than the target pixels; determine the extraction threshold based on the average gray value of the background pixels at the same location in the fluorescence image; The region formed by pixels with gray values ​​greater than or equal to the extraction threshold in the fluorescence image is determined as the effective fluorescence region; the effective fluorescence region is subjected to morphological refinement processing to obtain the fluorescence skeleton line; the pixels on the fluorescence skeleton line are called fluorescence skeleton points. On the fluorescent skeleton line, the fluorescence tangent vector of each fluorescent skeleton point is determined based on the coordinate difference between each fluorescent skeleton point and its adjacent fluorescent skeleton points.

[0011] Furthermore, the method for acquiring texture and fluorescence images of Chinese herbal medicine slices in the current processing cycle includes: The medicinal slices are exposed to a preset first light source for the first time to obtain a texture image; the medicinal slices are exposed to a preset second light source for the second time at a preset time interval to obtain a preliminary fluorescence image; the first light source and the second light source are different types of light source signals; The running speed of the Chinese herbal medicine slices within a preset time is obtained. Based on the product of the camera resolution parameters, the preset time length, and the running speed, the distance to be corrected in the preliminary fluorescence image is determined. The preliminary fluorescence image is then shifted inversely by the distance to be corrected to obtain the fluorescence image.

[0012] The present invention also proposes a device for detecting traditional Chinese medicine decoction pieces, the device comprising: The image data acquisition module is used to acquire texture images and fluorescence images of Chinese herbal medicine slices in the current processing cycle; the texture images are divided into regions to obtain sub-regions of the herbal medicine slices; The region feature extraction module is used to discretize the texture center line extracted from the texture image in the sub-region of the medicinal slices to obtain texture skeleton points and texture tangent vectors; and to discretize the fluorescence skeleton line extracted from the fluorescence image to obtain fluorescence skeleton points and fluorescence tangent vectors. The feature matching module is used to calculate the matching weight between texture skeleton points and fluorescent skeleton points based on the distance distribution between each texture skeleton point and each fluorescent skeleton point, and the angle between the corresponding texture tangent vector and the fluorescence tangent vector; and to match texture skeleton points and fluorescent skeleton points based on the matching weight to obtain unmatched free fluorescent points in each herbal slice sub-region. The herbal slice detection module is used to obtain an energy ratio index based on the cumulative gray value of the unmatched free fluorescent dots in the herbal slice sub-region; and to use the energy ratio index to make anomaly judgments in the herbal slice sub-region to obtain the foreign object herbal slice detection results.

[0013] The present invention has the following beneficial effects: This invention first divides the texture image into regions, using the texture image as a reference for region division. The sub-regions of medicinal slices represent the physical location of individual Chinese herbal medicine slices, increasing the accuracy of foreign object detection results. Then, through feature decoupling and dimensionality reduction, texture skeleton lines representing physiological structures are extracted from the texture image, and fluorescent skeleton lines representing luminescence positions are extracted from the aligned fluorescence image. This transforms the complex image comparison into a geometric feature point matching problem, reducing computational load and enhancing interpretability. Furthermore, by calculating the distance distribution between each texture skeleton point and each fluorescent skeleton point, and the angle between the corresponding texture tangent vector and fluorescence tangent vector, the matching weight between texture skeleton points and fluorescent skeleton points is calculated. When performing feature matching on skeleton points in two different feature images, both distance features and skeleton orientation features are fully considered, making the feature matching results more accurate. The unmatched free fluorescent points selected can more accurately represent the free points exhibited by real foreign objects under the fluorescence feature dimension, providing a data foundation for effectively distinguishing foreign objects from medicinal materials and improving the accuracy of foreign object detection results. Finally, by calculating the free fluorescence energy ratio, physiological fluorescence (attached to the texture) and pathological fluorescence (free from the texture) were distinguished from a morphological perspective. This indicator can keenly capture tiny foreign objects (such as plastic fibers and insect eggs) that are free from the texture, without being disturbed by the bright texture of the good product itself, significantly improving the purity of the cleaned product and effectively distinguishing between physiological texture fluorescence and foreign object fluorescence in the processed medicinal slices. Attached Figure Description

[0014] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0015] Figure 1This is a flowchart of a method for detecting traditional Chinese medicine decoction pieces provided in one embodiment of the present invention. Detailed Implementation

[0016] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of a traditional Chinese medicine decoction piece detection device and method proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0017] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0018] The following description, in conjunction with the accompanying drawings, details the specific scheme of the detection device and detection method for traditional Chinese medicine decoction pieces provided by the present invention.

[0019] Please see Figure 1 The diagram illustrates a flowchart of a method for detecting traditional Chinese medicine decoction pieces according to an embodiment of the present invention. The method includes: Step S1: Collect texture and fluorescence images of Chinese herbal medicine slices in the current processing cycle; divide the texture image into regions to obtain slice sub-regions.

[0020] To acquire original images reflecting different spectral characteristics of Chinese herbal medicine slices, separate the target from the environmental background from the original images, and eliminate spatial displacement caused by the high-speed movement of the conveyor belt, thus providing a unified pixel coordinate benchmark for subsequent foreign object detection, this invention requires acquiring two original images of Chinese herbal medicine slices with different spectral characteristics in the current processing cycle. One of these images (the texture image) is then divided into regions to obtain sub-regions of the medicinal slices. These two original images with different spectral characteristics lay the foundation for the subsequent detection process, and the sub-regions of the medicinal slices define the scope of the subsequent detection process.

[0021] Therefore, to eliminate spatial displacement and separate detection areas, improving detection accuracy, texture and fluorescence images of the Chinese herbal medicine (TCM) slices in the current processing cycle are acquired. The texture images are then divided into regions to obtain slice sub-regions. During TCM slice detection, the texture image provides a physiological baseline, describing the slice's structure. Since the slices are not affected by foreign objects in the texture image, topological matching analysis is needed in conjunction with the fluorescence image to determine the presence of foreign objects. The fluorescence image primarily reflects the unique fluorescence emission of the TCM slices; slices containing foreign objects will produce strong and atypical fluorescence responses, providing a basis for obtaining the fluorescence skeleton line. Region division of the texture image identifies which regions contain TCM slices, establishing the scope of subsequent execution steps and shielding against background noise interference. If multiple randomly scattered TCM slices exist within a single texture image, without segmenting into slice sub-regions, the system will confuse the feature data of all TCM slices, making it impossible to accurately attribute the fluorescence of specific foreign objects to individual TCM slices. Dividing the data into independent sub-regions allows for the creation of a dedicated file for each piece of Chinese herbal medicine, facilitating the acquisition of subsequent test results.

[0022] Step S2: In the sub-region of the medicinal slices, the texture center line extracted from the texture image is discretized to obtain texture skeleton points and texture tangent vectors; the fluorescence skeleton line extracted from the fluorescence image is discretized to obtain fluorescence skeleton points and fluorescence tangent vectors.

[0023] In order to extract key geometric features for subsequent correlation analysis from the aligned dual-spectral images, namely the texture center line representing the physiological structure of Chinese herbal medicine slices and the fluorescence skeleton line representing the fluorescence emission position, this invention extracts the texture center line from the texture image and the fluorescence skeleton line from the fluorescence image for subsequent feature analysis.

[0024] Therefore, to extract key features, in the sub-region of the medicinal herb, the texture centerline extracted from the texture image is discretized to obtain texture skeleton points and texture tangent vectors; the fluorescence skeleton line extracted from the fluorescence image is also discretized to obtain fluorescence skeleton points and fluorescence tangent vectors. Performing this operation within the sub-region of the medicinal herb reduces computational load and eliminates the need to scan blank areas of the entire texture image. The texture centerline represents the geometric skeleton of the vascular bundles (physiological structure) inside the medicinal herb; it serves as a baseline for judgment. Any fluorescence signal that does not match this texture centerline in position and direction can be identified as foreign, non-structural fluorescence. The texture skeleton points lie on the texture centerline, providing data support for subsequent calculations of the geometric distance between texture skeleton points and fluorescence skeleton points; the texture tangent vectors provide data support for subsequent calculations of the angle between the tangent vectors of texture skeleton points and fluorescence skeleton points. The fluorescence skeleton line represents the luminescence energy axis of the excitation fluorescence signal in the fluorescence image. It is a skeleton line to be tested, matched with the baseline. If the match fails, it can be identified as an external, unstructured foreign object. Fluorescence is used for subsequent statistical analysis of grayscale value accumulation. Fluorescent skeleton points lie on the fluorescence skeleton line, providing data support for subsequent calculation of the geometric distance between texture skeleton points and fluorescent skeleton points. The fluorescence tangent vector provides data support for subsequent calculation of the angle between the tangent vectors of texture skeleton points and fluorescent skeleton points.

[0025] Step S3: Based on the distance distribution between each texture skeleton point and each fluorescent skeleton point, and the angle between the corresponding texture tangent vector and the fluorescent tangent vector, calculate the matching weight between the texture skeleton point and the fluorescent skeleton point; based on the matching weight, match the texture skeleton point and the fluorescent skeleton point to obtain the unmatched free fluorescent point in each slice sub-region.

[0026] In order to accurately classify fluorescent dots into structure-dependent and free types, and thus quantify the severity of foreign matter, this invention classifies different types of fluorescent dots by analyzing the geometric topological relationship between fluorescent skeleton dots and texture skeleton dots.

[0027] Therefore, to accurately quantify the severity of foreign matter, a matching weight is calculated between each texture skeleton point and each fluorescent skeleton point based on the geometric distance and the angle between their tangent vectors. Weighted matching of texture and fluorescent skeleton points yields unmatched free fluorescent points in each sub-region of the medicinal slice. The geometric distance between texture and fluorescent skeleton points measures the distance deviation between different skeleton points, while the angle between their tangent vectors measures the directional deviation. The matching weight is comprehensively evaluated based on the differences in these two different feature dimensions. The calculation of the matching weight provides a data foundation for subsequent feature matching. By using the comprehensively evaluated matching weight, texture and fluorescent skeleton points are matched to find the optimal matching scheme. This allows for the identification of matching relationships between skeleton points of different feature types. Furthermore, the unmatched free fluorescent points, in addition to those that are successfully matched, reflect the unsuccessfully matched fluorescent skeleton points and characterize the free features on the fluorescent skeleton lines.

[0028] Step S4: Based on the cumulative gray value of the unmatched free fluorescent dots in the sub-region of the medicinal slice, obtain the energy ratio index; use the energy ratio index to make anomaly judgments in the sub-region of the medicinal slice and obtain the foreign object medicinal slice detection results.

[0029] To quantify the proportion of non-physiological abnormal fluorescence within a sub-region of medicinal slices, effectively distinguish physiological fluorescence such as that from the vascular bundles of the slices themselves from pathological fluorescence caused by foreign bodies or mold, and to eliminate, to some extent, the interference of physiological structural fluorescence on the detection results and avoid missed detection of minute foreign body fluorescence, an energy proportion index is calculated based on the cumulative gray value of unmatched free fluorescent points in the sub-region of the medicinal slices. This energy proportion index is used to identify anomalies in the sub-region of the medicinal slices, outputting objective and accurate detection results of foreign body medicinal slices, and realizing the quantitative assessment and accurate determination of the foreign body contamination status of traditional Chinese medicine medicinal slices.

[0030] Therefore, this embodiment obtains the energy percentage index based on the cumulative grayscale value of the unmatched free fluorescent points in the herbal slice sub-region; using the energy percentage index, anomaly judgment is performed on the herbal slice sub-region to obtain the foreign object herbal slice detection result. One herbal slice exists in each herbal slice sub-region; operating within this sub-region improves the accuracy of herbal slice detection. Unmatched free fluorescent points indicate that texture skeleton points cannot be found within the allowable range, and are marked as fluorescent signals with suspected foreign object characteristics, entering subsequent percentage evaluation. The cumulative grayscale value represents the sum of the grayscale values ​​of the unmatched free fluorescent points and is an important component of the energy percentage index. The energy percentage index can capture tiny foreign objects (such as plastic fibers and insect eggs) outside the texture, without being interfered with by the bright texture of the good product itself, significantly improving the purity of the net selection. This index intuitively reflects what proportion of the fluorescent signals in the current herbal slice are abnormal signals, providing support for obtaining the foreign object herbal slice detection result. The foreign object detection result shows whether the detected herbal slice is a foreign object.

[0031] In summary, this invention acquires texture and fluorescence images of Chinese herbal medicine slices during the current processing cycle, preparing for the subsequent acquisition of texture center lines and fluorescence skeleton lines. Secondly, it divides the texture image into sub-regions to provide a detection range, improving detection accuracy. Then, it discretizes the texture center lines and fluorescence skeleton lines sequentially, obtaining texture skeleton points and texture tangent vectors, and fluorescence skeleton points and fluorescence tangent vectors, providing support for subsequent calculation of matching weights. Based on the distance distribution and tangent vector angle between each texture skeleton point and each fluorescence skeleton point, it calculates the matching weight between texture skeleton points and fluorescence skeleton points, performs feature matching, and obtains unmatched free fluorescence points. Finally, it obtains an energy percentage index based on the cumulative grayscale values ​​of unmatched free fluorescence points in the slice sub-regions, and uses this energy percentage index to obtain the detection result of foreign matter slices. This result effectively distinguishes between physiological texture fluorescence and foreign matter fluorescence in slices, adapting to high-speed transport vibration.

[0032] Preferably, in some implementations of the present invention, the method for acquiring texture images and fluorescence images of traditional Chinese medicine decoction pieces in the current processing cycle includes: The medicinal slices are first exposed using a preset first light source to obtain a texture image. After a preset time interval, the slices are then exposed a second time using a preset second light source to obtain a preliminary fluorescence image. The first and second light sources are different types of light source signals. Within the current processing cycle, a trigger signal is sent to the preset first light source to activate its stroboscopic illumination, and then the area array camera is controlled to perform the first exposure, obtaining the texture image. The texture image mainly presents the cross-sectional texture, color depth, and opacity characteristics of the medicinal slices, serving as baseline data for subsequent extraction of physiological structures. After a preset time interval, the light source is switched, and a trigger signal is sent to the preset second light source to activate its stroboscopic illumination, and then the area array camera is controlled to perform the second exposure, obtaining a preliminary fluorescence image. The preliminary fluorescence image mainly presents the autofluorescence within the medicinal slices and the excitation fluorescence of potential foreign substances (such as aflatoxin and whitening agents). The first and second light sources are different types of light source signals used to extract different skeletons from the medicinal slices. The preset time interval is set based on the camera's minimum exposure recovery time and the afterglow dissipation time of the light source, ensuring no spectral overlap between the two exposures. In this embodiment of the invention, the preset first light source is a white LED light source, the preset second light source is an ultraviolet LED light source, and the preset interval is 200. .

[0033] It should be noted that a single conveyor belt imaging trigger is considered as a complete processing cycle. The current processing cycle is denoted as the t-th cycle, and this cycle is defined by a time interval of 200 corresponding to the acquisition of the texture image. The time range between the acquisition of the subsequent fluorescence images corresponds to a complete time cycle. Within this cycle, texture images reflecting the surface morphology of the medicinal material and fluorescence images reflecting the response of its internal components are acquired. Since the photosensitive chip of an area array camera typically cannot respond to two different spectral bands simultaneously, and to avoid spectral crosstalk between different light sources, the system employs a time-division exposure acquisition strategy. Each processing cycle contains two independent and identical complete images acquired through time-division exposure within a fixed physical field of view of the area array camera: one texture image and one fluorescence image. Subsequent modules process these two images as a whole within this processing cycle. The two images are two-dimensional matrix structures, with pixels being independent units within the matrix.

[0034] The process involves acquiring the running speed of the Chinese herbal medicine slices within a preset time period. Based on the product of the camera resolution parameters, the preset time duration, and the running speed, a distance to be corrected for the preliminary fluorescence image is determined. This distance is then shifted backwards from the preliminary fluorescence image to obtain the final fluorescence image. Because the conveyor belt operates at a continuous high speed, the position of the Chinese herbal medicine slices in the obtained preliminary fluorescence image is offset relative to their position in the texture image. To establish a unified pixel coordinate reference, the lag-acquired fluorescence image needs to be backtracked to the moment of the texture image for distance correction, resulting in an aligned fluorescence image. Considering the potential for slight speed fluctuations in the conveyor belt during operation (such as speed fluctuations caused by changes in motor load), a fixed rated speed is not used. Instead, the pulse signal from the rotary encoder mounted on the conveyor belt drive shaft is read to acquire the running speed of the Chinese herbal medicine slices in real time within the preset time period. It should be noted that, ignoring the relative displacement between the medicinal materials and the conveyor belt, the running speed of the conveyor belt is represented as the conveying speed of the Chinese herbal medicine slices. That is, the running speed of the Chinese herbal medicine slices within the preset time period is calculated by reading data from the rotary encoder mounted on the conveyor belt drive shaft. For example, the formula for obtaining the current running speed of Chinese herbal medicine slices is expressed as: in This indicates the speed at which the Chinese herbal medicine slices are processed within a preset time. This indicates the rotary encoder within a preset time window. The cumulative pulse change within the range, This represents the pre-calibrated single-pulse displacement equivalent (i.e., the reciprocal of the number of pulses corresponding to a 1mm movement of the conveyor belt, configured as a preset constant in the controller). It should be noted that the preset time window is divided before the preset time and includes multiple preset times. Within the same preset time window, the running speed of the Chinese herbal medicine slices is the same. In this embodiment of the invention, the preset time window is 0.02s.

[0035] The distance to be corrected in the preliminary fluorescence image is obtained by multiplying the camera resolution parameters, the running speed of the Chinese herbal medicine slices, and the preset time. For example, the formula for obtaining the distance to be corrected in the preliminary fluorescence image is expressed as: in Indicates the distance to be corrected. The rounding function is used to ensure that subsequent translation operations are performed on integer coordinates. This indicates the speed at which the Chinese herbal medicine slices are processed within a preset time. Indicates the preset time. Used to The units of measurement are converted to s to ensure unit alignment. This represents the resolution parameters of the area scan camera, which are the camera's specifications and are configured as preset constants in the register. The formula indicates... Speed ​​of processing Chinese herbal medicine slices The distance to be corrected is directly proportional to the speed of the Chinese herbal medicine slices. As the speed of the slices increases, the distance to be corrected increases; conversely, as the speed of the slices decreases, the distance to be corrected decreases. By introducing real-time speed feedback, the system can adaptively compensate for fluctuations in the speed of the Chinese herbal medicine slices, ensuring the accuracy of the distance to be corrected.

[0036] The fluorescence image is obtained by shifting all pixels in the fluorescence image by a distance of pixels in the opposite direction of the movement of the Chinese herbal medicine slices. The resulting image edge regions are then filled with black (grayscale value of 0). At this point, the obtained fluorescence image has achieved spatial alignment in the pixel coordinate system, eliminating the main linear displacement. However, due to the presence of micrometer-level high-frequency random vibrations, there may still be slight nonlinear misalignments at the edges of the Chinese herbal medicine slices in the two images, requiring further processing in subsequent steps.

[0037] Preferably, in some implementations of the present invention, the method for obtaining the herbal slice sub-region includes: The optimal grayscale segmentation threshold is calculated using the Otsu thresholding algorithm. Pixels in the texture image whose grayscale value is greater than the optimal grayscale segmentation threshold are designated as target pixels. The connected regions formed by these target pixels are designated as sub-regions of the medicinal herbs. To avoid interference from dust, scratches, or stray light on the conveyor belt surface, it is necessary to clearly distinguish the medicinal material portion in the image. The system selects a texture image with high contrast as the segmentation benchmark. Since medicinal herbs typically exhibit brighter grayscale values ​​under white LED light, while the conveyor belt background exhibits darker grayscale values, the optimal grayscale segmentation threshold corresponding to the texture image is obtained using the Otsu thresholding algorithm. In the texture image, if the grayscale value of a pixel is greater than the optimal grayscale segmentation threshold, all matching pixels are designated as target pixels. In other embodiments of the invention, morphological closing operations are performed on some medicinal herbs (such as root and stem slices wrapped in dark bark) that may have internal holes or edge breaks, resulting in complete and continuous target pixels. The target pixels establish the search range for subsequent texture and fluorescence skeletons, and feature extraction is performed only on the target pixels, thereby shielding against background noise interference. It should be noted that the texture and fluorescence images acquired by the area scan camera are both single-channel images. The grayscale value of each pixel is generated by the analog-to-digital conversion module of the camera hardware, with a quantization depth set to 8 bits and a value range of 0 to 255, where 0 represents no illumination response and 255 represents illumination response saturation. The Otsu thresholding algorithm and morphological closing operation are techniques well-known to those skilled in the art and will not be elaborated upon or limited here.

[0038] Since the texture and fluorescence images acquired in a single trigger represent a complete conveyor belt area within the fixed physical field of view of the area array camera, and the images contain background and multiple randomly scattered medicinal herb instances, the obtained target pixels also contain multiple medicinal herbs. Therefore, further segmentation of the target pixels is necessary. Connectivity analysis is performed on the target pixels to divide them into multiple independent sub-regions of medicinal herbs, each corresponding to a single medicinal herb slice. This achieves precise control of individual medicinal herb slices. Subsequent steps are executed cyclically within their respective independent sub-regions, further improving the accuracy of medicinal herb slice control.

[0039] Furthermore, before feature extraction, a preprocessing step for an idle state is performed. This step determines whether there are valid Chinese herbal medicine pieces in the texture image to avoid wasting computational resources and causing misjudgments due to background noise if no herbal medicine pieces are present. The total number of target pixels in the texture image is counted against the total number of pixels in the texture image. The ratio between the total number of target pixels and the total number of pixels in the texture image is calculated to obtain the target pixel percentage. If the target pixel percentage is less than a preset threshold, it indicates that there are no Chinese herbal medicine pieces or only tiny fragments within the fixed physical field of view of the area scan camera, and the process is considered an idle state, terminating subsequent steps. If the target pixel percentage is greater than or equal to the threshold, it indicates that valid Chinese herbal medicine pieces exist within the fixed physical field of view of the area scan camera, and the process is considered a valid detection state, continuing with subsequent steps. In this embodiment, the preset threshold is 1%. It should be noted that this preprocessing step processes the target pixels to prevent the percentage from being too small, which could lead to misjudgments.

[0040] Preferably, in some implementations of the present invention, the method for obtaining texture skeleton points and texture tangent vectors includes: The skeleton of the medicinal slice sub-region is extracted to obtain the texture center line; the pixels on the texture center line are called texture skeleton points; on the texture center line, the texture tangent vector of each texture skeleton point is determined based on the coordinate difference between each texture skeleton point and its adjacent texture skeleton points.

[0041] Specifically, before extracting the skeleton from the texture centerline, image enhancement processing can be performed on the texture image. Then, a skeleton thinning algorithm is applied to the enhanced texture image to obtain a single-pixel-width line, i.e., the texture centerline. The image enhancement processing can employ a Frangi filter, which enhances tubular structures (such as vascular bundles) in the texture image by analyzing the Hessian matrix eigenvalues ​​of each pixel, while suppressing flat areas and speckle noise, outputting an enhanced texture image. Higher pixel values ​​indicate a greater likelihood of the presence of tubular textures at that location. The texture centerline provides a physiological structural benchmark for traditional Chinese medicine decoction pieces, facilitating subsequent comparison with fluorescent skeleton lines. The Frangi filter, Hessian matrix, and skeleton thinning algorithm are all well-known techniques in the field and will not be elaborated upon here.

[0042] The coordinate difference between any texture skeleton point on the texture centerline and the coordinate of its adjacent preceding texture skeleton point is used as the texture tangent vector. Obtaining texture skeleton points and texture tangent vectors provides data support for subsequent comprehensive evaluation of matching weights based on the differences in features across two different dimensions: distance and direction. It should be noted that the preceding texture skeleton point is obtained sequentially from one endpoint of the texture skeleton line to the other endpoint. The order of obtaining adjacent texture skeleton points on subsequent fluorescent skeleton lines is the same as that on the texture skeleton lines themselves. If the first skeleton point on a texture skeleton line or fluorescent skeleton line cannot obtain corresponding feature parameters, no feature analysis is performed.

[0043] Preferably, in some implementations of the present invention, the method for obtaining the fluorescent backbone points and fluorescent tangent vectors includes: Background pixels, excluding target pixels, are acquired from the texture image. An extraction threshold is determined based on the average grayscale value at the same location of these background pixels in the fluorescence image. Regions in the fluorescence image where the grayscale value is greater than or equal to the extraction threshold are defined as effective fluorescence regions. Morphological refinement is performed on these effective fluorescence regions to obtain fluorescence skeleton lines. Pixels on these fluorescence skeleton lines are called fluorescence skeleton points. Based on the coordinate difference between each fluorescence skeleton point and its adjacent points, a fluorescence tangent vector is determined for each fluorescence skeleton point. Background pixels are those of the conveyor belt. Since the texture and fluorescence images are spatially aligned, the background pixels and fluorescence images are spatially aligned. The grayscale values ​​at the same location of these background pixels in the fluorescence image are extracted. The average grayscale value of all pixels is used as the luminance value. The luminance value reflects the fluorescence reflection level of the current conveyor belt surface. If fluorescent dust accumulates on the conveyor belt surface, the luminance value increases; if the conveyor belt is newer or cleaner, the luminance value decreases. The luminance value is used to dynamically adjust the extraction threshold of the current fluorescence image, thereby achieving adaptive calibration of the detection sensitivity. The extraction threshold is determined based on the brightness value. The theoretical extraction threshold is determined according to the brightness value.

[0044] For example, the formula for determining the theoretical extraction threshold is expressed as: in This represents the theoretical extraction threshold. This represents the preset signal-to-noise ratio coefficient. Indicates the brightness value. This represents a preset safety margin. When the background becomes dirty (brightness value increases), the theoretical extraction threshold automatically increases, thereby suppressing background noise; when the background becomes clean, the theoretical extraction threshold automatically decreases, thereby improving sensitivity to weak fluorescence. It should be noted that the preset signal-to-noise ratio coefficient indicates that the extraction threshold should be slightly higher than the background noise level, and the preset safety margin is used to prevent false extractions caused by background fluctuations. In this embodiment of the invention, the preset signal-to-noise ratio coefficient is 1.2, and the preset safety margin is 5.

[0045] Furthermore, to prevent excessive noise due to an extremely clean conveyor belt background (brightness value close to 0) leading to a low theoretical extraction threshold, or to avoid missed detections due to an excessively high theoretical extraction threshold caused by abnormal background reflection, amplitude clamping protection logic is introduced, setting a minimum allowable sensitivity lower limit (e.g., 20) and a maximum allowable sensitivity upper limit (e.g., 200). The theoretical extraction threshold is corrected using a median function to obtain the final extraction threshold written to the register. For example, the formula for obtaining the extraction threshold is expressed as: in Indicates the extraction threshold. This indicates the lower limit of minimum sensitivity. This represents the theoretical extraction threshold. This indicates the upper limit of maximum sensitivity. This is a median function. This formula ensures that regardless of drastic fluctuations in background brightness, the final extraction threshold is always kept within a safe range. The extraction threshold is written to a register for segmentation of the fluorescence image acquired in the next processing cycle.

[0046] When processing the current fluorescence image, this value is directly read as the threshold for fluorescence segmentation, thus completing the adaptive closed-loop update of the parameters and eliminating the background brightness drift caused by dust accumulation on the conveyor belt surface during production. It should be noted that the median function is a well-known technique and will not be elaborated upon here.

[0047] The region formed by pixels with gray values ​​greater than or equal to the extraction threshold in the fluorescence image is determined as the effective fluorescence region. Morphological thinning is performed on the effective fluorescence region to obtain the fluorescence skeleton line. Pixels on the fluorescence skeleton line are called fluorescence skeleton points. Based on the coordinate difference between each fluorescence skeleton point and its adjacent fluorescence skeleton points, the fluorescence tangent vector of each fluorescence skeleton point is determined. Morphological thinning avoids the matching error caused by simplifying large fluorescence spots to a single centroid (the centroid of a large spot may be located on the texture center line, but its edge may have exceeded the texture center line). Specifically, connected component analysis is performed on pixels with gray values ​​greater than or equal to the extraction threshold in the fluorescence image to obtain... The connected regions are the effective fluorescent regions. It should be noted that morphological refinement and connected region analysis are techniques well-known to those skilled in the art, and will not be elaborated upon here.

[0048] The difference between the coordinates of any fluorescent skeleton point on the fluorescent backbone and the coordinates of its adjacent preceding fluorescent skeleton point is used as the fluorescent tangent vector. Obtaining the fluorescent skeleton points and the fluorescent tangent vector provides data support for subsequent comprehensive evaluation of the matching weights based on the differences in features from two different dimensions: distance and direction.

[0049] Preferably, in some implementations of the present invention, the method for calculating the matching weights between texture skeleton points and fluorescent skeleton points includes: For any texture skeleton point and any fluorescent skeleton point, the geometric distance between them is obtained based on their coordinates. The angle between their tangent vectors is obtained based on their respective texture and fluorescent skeleton point tangent vectors. The geometric distance between them represents the distance deviation between different skeleton points, and the angle between their tangent vectors represents the directional deviation between them; both determine the matching weight. The Euclidean distance between pixels is calculated using the coordinates of any texture skeleton point and any fluorescent skeleton point, thus obtaining the geometric distance between them. For example, the formula for obtaining the geometric distance between texture and fluorescent skeleton points is expressed as: in This represents the geometric distance between fluorescent skeleton point j and texture skeleton point i. , ) represents the coordinates of the fluorescent backbone point, ( , The coordinates of the texture skeleton point are represented by . The calculation result of this formula serves as the basis for determining whether the positions of the fluorescent skeleton point and the texture skeleton point coincide.

[0050] By applying inverse trigonometric functions to the texture tangent vector corresponding to any texture skeleton point and the fluorescence tangent vector corresponding to any fluorescence skeleton point, the angle between the tangent vectors of any texture skeleton point and any fluorescence skeleton point can be obtained. For example, the formula for obtaining the angle between the tangent vectors of a texture skeleton point and a fluorescence skeleton point is expressed as: in This represents the angle between the tangent vectors of fluorescent skeleton point j and texture skeleton point i. Let be the fluorescence tangent vector at point j on the fluorescence backbone. Let i be the texture tangent vector at point i on the texture skeleton.

[0051] If the geometric distance between the texture skeleton point and the fluorescent skeleton point is greater than a preset jitter radius, or the angle between the tangent vectors of the texture skeleton point and the fluorescent skeleton point is greater than a preset direction threshold, then the matching weight between the texture skeleton point and the fluorescent skeleton point is set to a preset value. This result indicates that the fluorescent skeleton point exceeds the allowable error range or has an inconsistent direction, and is therefore determined to be impossible to assign. This processing significantly reduces the computational load of subsequent weight matching. It should be noted that in this embodiment of the invention, the preset value is 0, indicating the weakest matching relationship, and the corresponding matching weight is the smallest.

[0052] If the geometric distance between a texture skeleton point and a fluorescent skeleton point is less than or equal to a preset jitter radius, and the angle between the tangent vectors of the texture skeleton point and the fluorescent skeleton point is less than or equal to a preset direction threshold, then the difference between the preset jitter radius and the geometric distance between the texture skeleton point and the fluorescent skeleton point is used as the matching weight between the texture skeleton point and the fluorescent skeleton point. The preset value is less than the values ​​of all current matching weights. This result indicates that the fluorescent skeleton point not only falls within the allowable error range of the texture skeleton point, but also has the same orientation as the texture skeleton point, thus indicating a potential dependency relationship. For example, the formula for obtaining the matching weight between the texture skeleton point and the fluorescent skeleton point is expressed as: ;in This represents the matching weight between fluorescent skeleton point j and texture skeleton point i. Indicates the preset jitter radius. This represents the geometric distance between fluorescent skeleton point j and texture skeleton point i. This formula indicates that the smaller the geometric distance between the texture skeleton point and the fluorescent skeleton point, the better. The greater the difference, the greater the matching weight between the texture skeleton point and the fluorescent skeleton point, indicating a higher level of matching confidence; when the distance is exactly equal to When the weight is 1, it ensures that the edge can be recognized as a valid match by the algorithm.

[0053] In this embodiment of the invention, the preset jitter radius is 5 pixels and the preset direction threshold is 30°.

[0054] Preferably, in some implementations of the present invention, the method for obtaining the unmatched free fluorescent points corresponding to each texture skeleton point includes: The fluorescent skeleton point set is used as one vertex set of a bipartite graph, i.e., the set to be matched, and the texture skeleton point set is used as the other vertex set of the bipartite graph, i.e., the reference set. The fluorescent skeleton point set is composed of fluorescent skeleton points, and the texture skeleton point set is composed of texture skeleton points. The feature matching problem is transformed into a maximum weight matching problem in bipartite graph theory. The geometric and topological relationships between the fluorescent and texture skeleton points are analyzed to accurately classify the structure type of the fluorescence signal, thereby quantifying the severity of foreign matter and improving the accuracy of the detection results for traditional Chinese medicine decoction pieces.

[0055] Any texture skeleton point is paired with any fluorescent skeleton point to form a matching pair. The sum of the matching weights of all matching pairs is calculated. The matching relationship corresponding to all matching pairs with the maximum sum of matching weights is extracted and determined as the final matching result. The matching relationship corresponding to the maximum sum of matching weights indicates that the overall positional deviation between all fluorescent skeleton points and all texture skeleton points is minimized at this point. This resolves the many-to-many conflict between texture skeleton points and fluorescent skeleton points (i.e., a fluorescent skeleton point may be close to multiple texture skeleton points at the same time, or multiple fluorescent skeleton points may compete for the same texture skeleton point), and the optimal matching scheme is found.

[0056] In the final matching results, fluorescent skeleton points that do not match the texture skeleton points are considered free fluorescent points. Based on the final matching results, the fluorescent skeleton points in the set are divided into two categories: those that match the texture skeleton points are considered matched fluorescent points. Although these fluorescent skeleton points may have slight misalignments, they have successfully found corresponding texture skeleton points within the allowable range and are identified as physiological fluorescence of traditional Chinese medicine decoction pieces; those that do not match the texture skeleton points are considered free fluorescent points. These fluorescent skeleton points cannot find any texture skeleton points that meet the directional constraints within the allowable range and are identified as defective fluorescence of foreign objects (such as plastic fibers, insect eggs, or mold overflowing the texture).

[0057] Preferably, in some implementations of the embodiments of the present invention, the method for obtaining the energy percentage index includes: The total free fluorescence energy is calculated by summing the gray values ​​of all unmatched free fluorescent spots; the total fluorescence energy is calculated by summing the gray values ​​of all fluorescent backbone spots; and the ratio of the total free fluorescence energy to the total fluorescence energy is used as the energy percentage index. The energy percentage index quantifies the severity of the foreign object and avoids misjudgment caused by weak background noise. For example, the formula for obtaining the energy percentage index is expressed as: in Indicates the energy percentage index. Indicates the total energy of free fluorescence. This represents the total fluorescence energy. The calculation result of this formula intuitively reflects what proportion of fluorescence signals in current Chinese herbal medicine slices are abnormal signals that cannot be explained by physiological structure. The larger the value, the more serious the foreign matter contamination, and it will serve as a basis for anomaly judgment decisions.

[0058] In this embodiment of the invention, a preset effective fluorescence response threshold is introduced, and the total fluorescence energy is compared with the preset effective fluorescence response threshold. If the total fluorescence energy is less than or equal to the preset effective fluorescence response threshold, it indicates that the overall fluorescence of the current Chinese medicine decoction piece is extremely weak, possibly only dark current noise or background stray light. In this case, it is directly determined that there are no foreign objects in the current Chinese medicine decoction piece, and the energy ratio index is set to 0 to reduce the amount of calculation. If the total fluorescence energy is greater than the preset effective fluorescence response threshold, it indicates that there is an effective fluorescence signal, and the energy ratio index is calculated. It should be noted that the preset effective fluorescence response threshold is 0.5% of the sensor's full scale.

[0059] Preferably, in some implementations of the present invention, the method for obtaining the detection results of foreign object medicinal slices includes: The energy percentage index is compared with the preset standard threshold; anomaly judgment is performed in the sub-region of the medicinal slice. If the energy percentage index is greater than the preset standard threshold, it indicates that most of the fluorescence signal on the surface of the medicinal slice cannot coincide with the physiological texture structure, which belongs to non-structural foreign body fluorescence (such as aflatoxin spots or plastic fibers), and the medicinal slice is judged to be a foreign body; if the energy percentage index is less than or equal to the preset standard threshold, it indicates that the fluorescence signal on the surface of the medicinal slice mainly depends on the physiological texture structure, which belongs to the autofluorescence of good products, and the medicinal slice is judged to be a good product; the detection results of foreign body medicinal slices are obtained.

[0060] Furthermore, if the Chinese herbal medicine slice is determined to be a foreign object, a foreign object removal operation is performed, and the timing for removal is calculated. Based on the running speed of the Chinese herbal medicine slice and the physical distance from the fluorescent image acquisition position to the air valve nozzle, the delay time required for the foreign object to reach the removal position is calculated and written into a timer. When the timer overflows, an opening pulse is sent to the corresponding high-speed solenoid air valve, and compressed air is used to blow the foreign object into the waste tank. If the Chinese herbal medicine slice is determined to be a good product, the removal operation is not performed, and the good product falls naturally into the finished product tank.

[0061] Based on the same inventive concept, the present invention also proposes a device for detecting traditional Chinese medicine decoction pieces, the device comprising: The image data acquisition module is used to acquire texture images and fluorescence images of Chinese herbal medicine slices in the current processing cycle; the texture images are divided into regions to obtain sub-regions of the herbal medicine slices; The region feature extraction module is used to discretize the texture center line extracted from the texture image in the sub-region of the medicinal slices to obtain texture skeleton points and texture tangent vectors; and to discretize the fluorescence skeleton line extracted from the fluorescence image to obtain fluorescence skeleton points and fluorescence tangent vectors. The feature matching module is used to calculate the matching weight between texture skeleton points and fluorescent skeleton points based on the distance distribution between each texture skeleton point and each fluorescent skeleton point, and the angle between the corresponding texture tangent vector and the fluorescence tangent vector; and to match texture skeleton points and fluorescent skeleton points based on the matching weight to obtain unmatched free fluorescent points in each herbal slice sub-region. The herbal slice detection module is used to obtain an energy ratio index based on the cumulative gray value of the unmatched free fluorescent dots in the herbal slice sub-region; and to use the energy ratio index to make anomaly judgments in the herbal slice sub-region to obtain the foreign object herbal slice detection results.

[0062] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. The processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0063] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

Claims

1. A method for detecting traditional Chinese medicine decoction pieces, characterized in that, The method includes: Collect texture and fluorescence images of Chinese herbal medicine slices in the current processing cycle; divide the texture images into regions to obtain sub-regions of the herbal medicine slices; In the herbal slice sub-region, the texture center line extracted from the texture image is discretized to obtain texture skeleton points and texture tangent vectors; the fluorescence skeleton line extracted from the fluorescence image is discretized to obtain fluorescence skeleton points and fluorescence tangent vectors. Based on the distance distribution between each texture skeleton point and each fluorescent skeleton point, and the angle between the corresponding texture tangent vector and the fluorescent tangent vector, the matching weight between the texture skeleton point and the fluorescent skeleton point is calculated; based on the matching weight, the texture skeleton point and the fluorescent skeleton point are matched to obtain the unmatched free fluorescent points in each slice sub-region; Based on the cumulative grayscale value of the unmatched free fluorescent dots in the sub-region of the medicinal slice, the energy ratio index is obtained; using the energy ratio index, anomalies are judged in the sub-region of the medicinal slice, and the detection results of foreign object medicinal slices are obtained.

2. The method for detecting traditional Chinese medicine decoction pieces according to claim 1, characterized in that, The method for calculating the matching weights between texture skeleton points and fluorescent skeleton points includes: For any texture skeleton point and any fluorescent skeleton point, the geometric distance between the texture skeleton point and the fluorescent skeleton point is obtained based on their coordinates; the angle between the tangent vectors between the texture skeleton point and the fluorescent skeleton point is obtained based on the texture tangent vector corresponding to the texture skeleton point and the fluorescent tangent vector corresponding to the fluorescent skeleton point. If the geometric distance between the texture skeleton point and the fluorescent skeleton point is greater than the preset jitter radius, or the angle between the tangent vectors between the texture skeleton point and the fluorescent skeleton point is greater than the preset direction threshold, then the matching weight between the texture skeleton point and the fluorescent skeleton point is set to the preset value. If the geometric distance between the texture skeleton point and the fluorescent skeleton point is less than or equal to the preset jitter radius, and the angle between the tangent vectors of the texture skeleton point and the fluorescent skeleton point is less than or equal to the preset direction threshold, then the difference between the preset jitter radius and the geometric distance between the texture skeleton point and the fluorescent skeleton point is used as the matching weight between the texture skeleton point and the fluorescent skeleton point. The preset value is less than the value of all current matching weights.

3. The method for detecting traditional Chinese medicine decoction pieces according to claim 1, characterized in that, The method for obtaining unmatched free fluorescent spots in each sub-region of the medicinal slice includes: Any texture skeleton point is paired with any fluorescent skeleton point to form a matching pair. The sum of the matching weights of all matching pairs is calculated. The matching relationship corresponding to all matching pairs with the maximum sum of matching weights is extracted and determined as the final matching result. In the final matching result, fluorescent skeleton points that do not have a matching relationship with texture skeleton points are regarded as unmatched free fluorescent points.

4. The method for detecting traditional Chinese medicine decoction pieces according to claim 1, characterized in that, The method for obtaining the energy percentage index includes: The total free fluorescence energy is obtained by summing the gray values ​​of all unmatched free fluorescent spots; the total fluorescence energy is obtained by summing the gray values ​​of all fluorescent backbone spots; and the ratio of the total free fluorescence energy to the total fluorescence energy is used as the energy percentage index.

5. The method for detecting traditional Chinese medicine decoction pieces according to claim 1, characterized in that, The method for obtaining the detection results of foreign body medicinal slices includes: If the energy percentage index of a certain area of ​​the medicinal herb is greater than a preset standard threshold, then the medicinal herb corresponding to that area is a foreign object; if the energy percentage index is less than or equal to the preset standard threshold, then the medicinal herb corresponding to that area is a good product.

6. The method for detecting traditional Chinese medicine decoction pieces according to claim 1, characterized in that, The method for obtaining texture skeleton points and texture tangent vectors includes: The skeleton of the medicinal slice is extracted to obtain the texture center line; the pixels on the texture center line are called texture skeleton points. On the texture center line, the texture tangent vector of each texture skeleton point is determined based on the coordinate difference between each texture skeleton point and its adjacent texture skeleton points.

7. The method for detecting traditional Chinese medicine decoction pieces according to claim 1, characterized in that, The method for obtaining the sub-region of medicinal slices includes: The optimal grayscale segmentation threshold is calculated using the Otsu thresholding algorithm. Pixels in the texture image whose grayscale value is greater than the optimal grayscale segmentation threshold are taken as target pixels. The connected regions formed by the target pixels are taken as the slice sub-regions.

8. The method for detecting traditional Chinese medicine decoction pieces according to claim 7, characterized in that, The method for obtaining fluorescence backbone points and fluorescence tangent vectors includes: Obtain background pixels in the texture image other than the target pixels; determine the extraction threshold based on the average gray value of the background pixels at the same location in the fluorescence image; The region formed by pixels with gray values ​​greater than or equal to the extraction threshold in the fluorescence image is determined as the effective fluorescence region; the effective fluorescence region is subjected to morphological refinement processing to obtain the fluorescence skeleton line; the pixels on the fluorescence skeleton line are called fluorescence skeleton points. On the fluorescent skeleton line, the fluorescence tangent vector of each fluorescent skeleton point is determined based on the coordinate difference between each fluorescent skeleton point and its adjacent fluorescent skeleton points.

9. The method for detecting traditional Chinese medicine decoction pieces according to claim 1, characterized in that, The method for acquiring texture and fluorescence images of Chinese herbal medicine slices in the current processing cycle includes: The medicinal slices are exposed to a preset first light source for the first time to obtain a texture image; the medicinal slices are exposed to a preset second light source for the second time at a preset time interval to obtain a preliminary fluorescence image; the first light source and the second light source are different types of light source signals; The running speed of the Chinese herbal medicine slices within a preset time is obtained. Based on the product of the camera resolution parameters, the preset time length, and the running speed, the distance to be corrected in the preliminary fluorescence image is determined. The preliminary fluorescence image is then shifted inversely by the distance to be corrected to obtain the fluorescence image.

10. A device for detecting traditional Chinese medicine decoction pieces, characterized in that, The device includes: The image data acquisition module is used to acquire texture images and fluorescence images of Chinese herbal medicine slices in the current processing cycle; the texture images are divided into regions to obtain sub-regions of the herbal medicine slices; The region feature extraction module is used to discretize the texture center line extracted from the texture image in the sub-region of the medicinal slices to obtain texture skeleton points and texture tangent vectors; and to discretize the fluorescence skeleton line extracted from the fluorescence image to obtain fluorescence skeleton points and fluorescence tangent vectors. The feature matching module is used to calculate the matching weight between texture skeleton points and fluorescent skeleton points based on the distance distribution between each texture skeleton point and each fluorescent skeleton point, and the angle between the corresponding texture tangent vector and the fluorescence tangent vector; and to match texture skeleton points and fluorescent skeleton points based on the matching weight to obtain unmatched free fluorescent points in each herbal slice sub-region. The herbal slice detection module is used to obtain an energy ratio index based on the cumulative gray value of the unmatched free fluorescent dots in the herbal slice sub-region; and to use the energy ratio index to make anomaly judgments in the herbal slice sub-region to obtain the foreign object herbal slice detection results.