An AI vision-based method and system for identifying the authenticity of medicinal materials

By combining AI vision and thermal infrared imaging, a visual feature benchmark and thermal anomaly diffusion gradient map of medicinal materials were established, which solved the problem of identifying highly similar counterfeit products in the identification of genuine and fake medicinal materials, and improved the accuracy and stability of identification.

CN121527452BActive Publication Date: 2026-07-03ZHEJIANG HUISONG PHARMA +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511523009.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-07-03
Estimated Expiration
2045-10-23

AI Technical Summary

Technical Problem

Existing technologies struggle to capture subtle changes in texture or color of highly similar counterfeit medicinal materials, leading to missed detections or misjudgments. Furthermore, image-based intelligent recognition schemes are unstable in complex samples or under interfering backgrounds.

Method used

An AI-based vision-based method for identifying the authenticity of medicinal materials is adopted. By iteratively generating candidate images and comparing them with images of genuine medicinal materials, a visual feature benchmark is established. Combined with thermal infrared image analysis, a thermal anomaly diffusion gradient map is generated. Threshold judgment is performed on the pixel-level fusion anomaly score map to identify the adulteration location of medicinal materials.

Benefits of technology

It improves the accuracy and robustness of identifying genuine and counterfeit medicinal materials, reduces isolated misjudgments and redundant detection areas, and enables quantitative identification of morphological and thermal conductivity anomalies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121527452B_ABST
    Figure CN121527452B_ABST
Patent Text Reader

Abstract

This invention relates to the field of medicinal material identification technology, specifically to a method and system for identifying the authenticity of medicinal materials based on AI vision. The method includes the following steps: iteratively generating candidate images and comparing them with images of genuine medicinal material slices, adjusting the generation logic based on the comparison results. This invention constructs a latent vector mapping relationship consistent with the visual features of images of genuine medicinal material slices, combines image reconstruction errors for anomaly extraction, and enhances the perception of adulteration locations. The pixel-by-pixel reconstruction error method can locate areas with slight deviations in shape or color, and based on this, extracts the thermal decay curve of the isotopic infrared image sequence. Through time constant fitting calculation, it completes a quantitative modeling of the thermal conductivity characteristics in space, and further calculates the spatial gradient of the thermal decay time constant, realizing the quantification of the boundary strength of the material's thermal diffusion behavior, forming a thermal anomaly diffusion gradient map, providing physical property basis for subsequent multi-spectral fusion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medicinal material identification technology, and in particular to a method and system for identifying the authenticity of medicinal materials based on AI vision. Background Technology

[0002] Medicinal herb identification involves the scientific identification and determination of the type, quality, purity, origin, and processing method of Chinese medicinal materials. Current technologies primarily rely on static images for identifying genuine and counterfeit medicinal materials. However, when highly similar counterfeits appear, these technologies struggle to capture subtle changes in texture or color, leading to missed detections or misjudgments. On the other hand, while some image-based intelligent recognition schemes can improve automation to a certain extent, the lack of clear boundaries inherent in single visual or physicochemical indicators results in unstable identification results under complex samples or interference backgrounds. Therefore, improvements are needed. Summary of the Invention

[0003] The purpose of this invention is to address the shortcomings of existing technologies by proposing an AI vision-based method and system for identifying the authenticity of medicinal materials.

[0004] To achieve the above objectives, the present invention adopts the following technical solution: a method for identifying the authenticity of medicinal materials based on AI vision, comprising the following steps:

[0005] Candidate images are generated iteratively and compared with images of pure medicinal materials. The generation logic is adjusted based on the comparison results and the adjustment is continued until the generated images are indistinguishable from the pure set, thus establishing a visual feature benchmark for pure medicinal materials.

[0006] Based on the visual feature benchmark of the pure medicinal herb slices, for the input image of the medicinal herb slices to be detected, find the latent vector that generates the most similar reconstructed image, obtain the reconstructed version of the image of the medicinal herb slices to be detected, and then calculate the pixel-level absolute difference between the image of the medicinal herb slices to be detected and the reconstructed version of the image of the medicinal herb slices to be detected, and obtain the visual anomaly residual map.

[0007] Based on the region identified in the visual anomaly residual map, the corresponding position in the registered thermal pulse infrared image sequence is examined to generate a spatial distribution map of the thermal decay time constant, and the spatial gradient of the spatial distribution map of the thermal decay time constant is calculated to generate a thermal anomaly diffusion gradient map.

[0008] Based on the thermal anomaly diffusion gradient map, a spatial element-wise operation is performed with the visual anomaly residual map to generate a fused anomaly score map. A threshold is applied to the fused anomaly score map, and all consecutive pixel clusters exceeding the threshold are identified as doping locations to establish the delineation of the abnormal doping area of ​​medicinal herb slices.

[0009] Preferably, the step of obtaining the visual feature benchmarks of the pure medicinal material slices is as follows:

[0010] A potential vector interval is set and sampled at a fixed step size to generate a candidate image sequence. The candidate images are then registered pixel by pixel with images of pure medicinal materials. The mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast are extracted to obtain the candidate image comparison results.

[0011] Based on the comparison results of the candidate images, the candidate image with the smallest difference from the pure medicinal herb slice image is selected, the corresponding latent vector elements are extracted, and the latent vector elements are mapped to the mean hue, mean saturation, luminance variance and gray-level co-occurrence matrix contrast to generate the generation parameters for creating pure medicinal herb slices.

[0012] Based on the generation parameters for creating authentic medicinal herb slices, sampling is performed within the potential vector space to generate a new image set. For each image, the mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast are extracted again to form a visual feature benchmark for authentic medicinal herb slices.

[0013] Preferably, the step of obtaining the reconstructed version of the image of the medicinal herb slices to be detected is as follows:

[0014] Based on the visual feature benchmark of the pure medicinal herb slices, the latent vector optimization search is performed on the input image of the medicinal herb slices to be detected, and a reconstructed version is generated successively to obtain the reconstructed version of the image of the medicinal herb slices to be detected.

[0015] Preferably, the step of obtaining the visual anomaly residual map is as follows:

[0016] Based on the reconstructed version of the image of the medicinal herb slices to be detected, the absolute value of the pixel-by-pixel difference between each reconstructed version and the image of the medicinal herb slices to be detected is calculated to obtain the pixel-level absolute difference.

[0017] Calculate the pixel-level absolute difference threshold based on the pixel-level absolute difference;

[0018] Based on the pixel-level absolute difference threshold, pixels in the pixel-level absolute difference map that exceed the pixel-level absolute difference threshold retain their original differences, while pixels in the pixel-level absolute difference map that are not greater than the pixel-level absolute difference threshold are set to zero, thus generating a visual anomaly residual map.

[0019] Preferably, the step of obtaining the spatial distribution map of the thermal decay time constant is as follows:

[0020] Based on the regions identified in the visual anomaly residual map, the temperature time series of the corresponding regions is extracted pixel by pixel in the registered thermal pulse infrared image sequence. The steady-state offset is removed and the time index is aligned. The temperature curve is converted into a temperature decay curve that decreases monotonically with time, and the temperature decay curve is obtained.

[0021] Based on the temperature decay curve, the thermal decay time constant is calculated, and the thermal decay time constant of each pixel is filled into the corresponding coordinate position to form a spatial distribution map of the thermal decay time constant.

[0022] Preferably, the step of obtaining the thermal anomaly diffusion gradient map is as follows:

[0023] Based on the spatial distribution map of the thermal decay time constant, the difference between adjacent pixels is calculated in the row and column directions, and a mirror extension is applied to the boundary. The difference results are then merged into gradient intensities according to pixel coordinates, while maintaining the spatial distribution with respect to the thermal decay time constant. Figure 1 The size is consistent, and a thermal anomaly diffusion gradient map is generated.

[0024] Preferably, the step of obtaining the fused anomaly score map is as follows:

[0025] Based on the thermal anomaly diffusion gradient map, the visual anomaly residual map is bilinearly interpolated and registered according to coordinates, and the intensity is normalized to the same value range. Element-wise multiplication is performed on the same pixel and the product value is retained to generate a fused anomaly score map.

[0026] Preferably, the step of obtaining the abnormal adulteration zone of the medicinal material slices is as follows:

[0027] Based on the fusion anomaly score map, a pixel-by-pixel screening is performed using a fusion threshold, and connected components are marked using 8-neighbor connectivity. Connected components smaller than the area lower limit are removed, and morphological closing operations are performed on the boundaries of the remaining connected components to generate the delineation of abnormal adulteration areas in medicinal decoction pieces.

[0028] This invention also provides a system for identifying the authenticity of medicinal materials, including:

[0029] The visual feature benchmark construction module is used to iteratively generate candidate images and compare them with images of pure medicinal materials. Based on the comparison results, the generation logic is adjusted and continuously adjusted until the generated images are indistinguishable from the pure set, thus establishing a visual feature benchmark for pure medicinal materials.

[0030] The image reconstruction and residual detection module is used to find the potential vector that generates the most similar reconstructed image for the input image of the medicinal herb to be detected based on the visual feature benchmark of the pure medicinal herb slices, to obtain the reconstructed version of the image of the medicinal herb slices to be detected, and then calculate the pixel-level absolute difference between the image of the medicinal herb slices to be detected and the reconstructed version of the image of the medicinal herb slices to be detected, to obtain the visual anomaly residual map.

[0031] The thermal anomaly diffusion analysis module is used to examine the corresponding position in the registered thermal pulse infrared image sequence based on the region identified in the visual anomaly residual map, generate a spatial distribution map of the thermal decay time constant, calculate the spatial gradient of the spatial distribution map of the thermal decay time constant, and generate a thermal anomaly diffusion gradient map.

[0032] The fusion anomaly identification module is used to perform element-wise spatial operations on the thermal anomaly diffusion gradient map and the visual anomaly residual map to generate a fusion anomaly score map, apply a threshold to the fusion anomaly score map, and identify all consecutive pixel clusters exceeding the threshold as doping locations to establish the delineation of abnormal doping areas in medicinal decoction pieces.

[0033] Compared with the prior art, the advantages and positive effects of the present invention are as follows:

[0034] This invention constructs a latent vector mapping relationship consistent with the visual features of pure medicinal herb slices, and combines image reconstruction errors for anomaly extraction to enhance the perception of doping locations. Based on the pixel-by-pixel reconstruction error, it can locate areas with slight deviations in shape or color, and extract the thermal decay curve of the isotopic infrared image sequence based on this. Through time constant fitting calculation, it completes the quantitative modeling of thermal conductivity characteristics in space, and further calculates the spatial gradient of the thermal decay time constant to quantify the boundary strength of the material's thermal diffusion behavior, forming a thermal anomaly diffusion gradient map. This provides a physical property basis for subsequent multi-spectral fusion. By integrating the thermal anomaly diffusion gradient and the anomaly distribution information in the image residual map in a pixel-level element-by-element fusion manner, it can simultaneously focus on two types of indicators: morphological deviation and thermal conductivity anomaly. In the threshold judgment stage, continuous pixel clusters are subjected to connectivity judgment and elimination to reduce isolated misjudgments and redundant detection areas, improve the overall recognition accuracy and robustness, and make the recognition results more accurate. Attached Figure Description

[0035] Figure 1 This is a schematic diagram of the steps of the present invention. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0037] Please see Figure 1 This invention provides a technical solution: a method for identifying the authenticity of medicinal materials based on AI vision, comprising the following steps:

[0038] Candidate images are generated iteratively and compared with images of pure medicinal materials. The generation logic is adjusted based on the comparison results and the adjustment is continued until the generated images are indistinguishable from the pure set, thus establishing a visual feature benchmark for pure medicinal materials.

[0039] Based on the visual feature benchmark of pure medicinal herb slices, for the input image of medicinal herb slices to be detected, find the latent vector that generates the most similar reconstructed image to obtain the reconstructed version of the image of medicinal herb slices to be detected. Then, calculate the pixel-level absolute difference between the image of medicinal herb slices to be detected and the reconstructed version of the image of medicinal herb slices to be detected to obtain the visual anomaly residual map.

[0040] Based on the regions identified in the visual anomaly residual map, the corresponding positions in the registered thermal pulse infrared image sequence are examined to generate a spatial distribution map of the thermal decay time constant. The spatial gradient of the spatial distribution map of the thermal decay time constant is calculated to generate a thermal anomaly diffusion gradient map.

[0041] Based on the thermal anomaly diffusion gradient map, element-wise spatial operations are performed with the visual anomaly residual map to generate a fused anomaly score map. A threshold is applied to the fused anomaly score map, and all consecutive pixel clusters exceeding the threshold are identified as doping sites, thus establishing the delineation of the abnormal doping zone of medicinal herb slices.

[0042] The steps for obtaining the visual characteristic benchmarks of pure medicinal herb slices are as follows:

[0043] A potential vector interval is set and sampled at a fixed step size to generate a candidate image sequence. The candidate images are then registered pixel by pixel with images of pure medicinal materials. The mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast are extracted to obtain the candidate image comparison results.

[0044] Based on the comparison results of candidate images, the candidate image with the smallest difference from the pure medicinal herb slice image is selected, the corresponding latent vector elements are extracted, and the latent vector elements are mapped to the mean hue, mean saturation, luminance variance and gray-level co-occurrence matrix contrast to generate the generation parameters for creating pure medicinal herb slices.

[0045] Based on the generation parameters for creating authentic medicinal herb slices, sampling is performed within the potential vector space to generate a new image set. For each image, the mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast are extracted again to form a visual feature benchmark for authentic medicinal herb slices.

[0046] Specifically, a 128-dimensional latent vector space is defined for generating images, where the value of each dimension is limited to the range of -1.0 to 1.0. Then, sampling is performed in each dimension of this 128-dimensional space with a fixed stride of 0.2. For example, for the first dimension, the sampling points are -1.0, -0.8, -0.6, ..., 0.8, 1.0, a total of 11 points. The sampling points in all dimensions are combined to form a grid set containing a large number of discrete latent vectors. Each 128-dimensional latent vector in this set is input into a pre-trained generative adversarial network (GAN) generator. This generator adopts a deep convolutional structure, consisting of transposed convolutional layers, batch... The system consists of stacked normalization and ReLU activation function layers, starting with a fully connected layer that maps a 128-dimensional latent vector to a high-dimensional feature space. Subsequent transposed convolutional layers gradually enlarge the spatial size of the feature map while reducing the number of channels. Finally, an output layer using the Tanh activation function generates a 256x256 pixel candidate image. By traversing all sampled latent vectors, a complete sequence of candidate images is generated. Then, each generated candidate image is spatially aligned with a pre-prepared set of pure medicinal herb slice images. The alignment process uses the Scale Invariant Feature Transform (SIFT) algorithm. First, the candidate image and each pure medicinal herb slice image are... Keypoints are detected and their descriptors are calculated. Then, keypoint pairs are matched using a nearest neighbor ratio strategy (e.g., a ratio threshold of 0.75) by calculating the Euclidean distance between descriptors. Based on successfully matched keypoint pairs, a robust affine transformation matrix is ​​estimated using the Random Sample Consensus (RANSAC) algorithm. This matrix describes the optimal transformation relationship from the candidate image to the coordinate system of the authentic medicinal herb slice image. This affine transformation matrix is ​​applied to perform geometric correction on the candidate images, completing pixel-by-pixel registration. For each registered candidate image, its color space is converted from RGB to HSV, and the average value of all pixel hue channels (H channels) is calculated to obtain the hue mean. The saturation value is then calculated. The average saturation value is obtained by calculating the average value of the S-channel and the variance of all pixel values ​​in the V-channel. The image is then converted to an 8-bit grayscale image, and a gray-level co-occurrence matrix (GLCM) is constructed. The construction parameters of this matrix are set to a pixel distance of 1 and an orientation of 0 degrees. The contrast is calculated based on this GLCM by iterating through all elements in the matrix, multiplying the square of the difference between the row and column indices of each element by its corresponding probability value, and then summing all the results. Finally, the four feature values ​​of hue mean, saturation mean, luminance variance, and GLCM contrast of each candidate image are recorded to form the candidate image comparison results.

[0047] Based on the candidate image comparison results obtained in the previous step, a reference baseline needs to be established first. This baseline is achieved by extracting the same four features (mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast) from each image in the pure medicinal herb image set. Then, the average value of these four features over the entire pure sample set is calculated to obtain a target feature vector. For example, the calculated target feature vector is {mean hue: 0.15, mean saturation: 0.65, luminance variance: 800, gray-level co-occurrence matrix contrast: 1.2}. Next, a weighted comprehensive difference is calculated between the feature vector of each candidate image and this target feature vector. Before calculation, each feature is normalized to eliminate the influence of different features' dimensions. For example, each feature value is subtracted from its mean across all candidate images and then divided by its standard deviation to obtain the Z-score normalized value. The comprehensive difference is calculated using weighted Euclidean distance, with weight coefficients set empirically to reflect the importance of different features. For example, texture features may better reflect the intrinsic quality of medicinal materials than color features, so the weights are set as follows: hue mean weight is 0.15, saturation mean weight is 0.15, luminance variance weight is 0.30, gray-level co-occurrence matrix contrast weight is 0.40, and the sum of all weights is 1.0. For a normalized image... The comprehensive difference of the transformed candidate feature vectors is calculated as the square root of the sum of the squares of the differences of each feature and the products of their corresponding weights. After calculating the comprehensive difference of all candidate images, these differences are sorted in ascending order, and the top 1% of candidate images with the smallest comprehensive difference are selected as the optimal candidate set. If a total of 20,000 candidate images are generated, the 200 images with the smallest differences are selected. Then, the original 128-dimensional latent vectors corresponding to these 200 optimal candidate images and their respective four visual feature values ​​are extracted from the records to form a training set containing 200 (latest vector, feature vector) data pairs. This training set is used to construct a visual... The feature space to latent vector space mapping model employs a multilayer perceptron (MLP) neural network. Its structure includes an input layer with 4 neurons, corresponding to four visual features; two hidden layers, each containing 256 neurons and using the ReLU activation function; and an output layer with 128 neurons and using a linear activation function, corresponding to a 128-dimensional latent vector. The MLP network is trained using the Adam optimizer and the mean squared error loss function. By minimizing the difference between the predicted latent vector and the true latent vector, the trained MLP model itself constitutes the generation parameters for creating authentic medicinal herb slices.

[0048] Based on the trained mapping model used as the generation parameters for creating authentic medicinal herb slices, the first step is to determine the target feature space range for generating new images. This range is set based on the feature statistics of the original authentic medicinal herb slice image set. Specifically, the mean and standard deviation of four features—mean hue, mean saturation, variance of luminance, and contrast of the gray-level co-occurrence matrix—are calculated in the original authentic sample set. For example, if the mean hue is 0.15 and the standard deviation is 0.02, then the sampling range is set to the mean plus or minus 1.5 times the standard deviation. That is The same operation is performed on the other three features to define a reasonable value range for each feature. Next, within each of these four feature value ranges, the Latin hypercube sampling method is used to generate 10,000 sets of target feature vectors. Each set of vectors contains specific values ​​for a hue mean, a saturation mean, a brightness variance, and a gray-level co-occurrence matrix contrast. These 10,000 sets of target feature vectors are then input one by one into the MLP mapping model trained in the previous step. The model predicts and outputs a corresponding 128-dimensional latent vector for each set of input feature vectors, resulting in a set of 10,000 latent vectors. The distribution of these latent vectors in the latent space is constrained to ensure that they can generate visual characteristics of authentic medicinal materials. The 10,000 potential vectors are then fed into the generator of the initially used generative adversarial network to generate a new image set containing 10,000 high-quality, diverse synthetic images of pure medicinal herbs. Finally, for each image in this newly generated image set, the feature extraction process is repeated, namely, converting the color space, calculating the hue mean and saturation mean, calculating the luminance variance, converting to grayscale and constructing the gray-level co-occurrence matrix, and then calculating the contrast of the gray-level co-occurrence matrix. All the feature vectors extracted from these 10,000 synthetic images are gathered together. This large and accurate set of feature vectors, in the form of statistical distributions (such as mean vectors and covariance matrices), together constitute the final visual feature benchmark of pure medicinal herbs.

[0049] The steps for obtaining the reconstructed version of the image of the medicinal herb slices to be detected are as follows:

[0050] Based on the visual feature benchmark of pure medicinal herb slices, the latent vector optimization search is performed on the input image of the medicinal herb slices to be detected, and a reconstructed version is generated successively to obtain the reconstructed version of the image of the medicinal herb slices to be detected.

[0051] Specifically, based on the visual feature benchmark of authentic medicinal herb slices, a 128-dimensional latent vector randomly sampled from a standard normal distribution is first initialized as the starting point for optimization search. This initial latent vector is input into the generator of a pre-trained generative adversarial network to generate the first reconstructed image. Next, a composite loss function is defined, consisting of two parts. The first part is the pixel-level reconstruction loss, which measures the direct visual difference between the generated reconstructed version and the input image of the medicinal herb slice to be detected by calculating the sum of pixel-by-pixel differences under the L1 norm. The second part is the feature space loss, which first extracts four visual features from the reconstructed version and the image of the medicinal herb slice to be detected: mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast. Then, the Euclidean distance between these two feature vectors is calculated. This loss term ensures that the reconstructed version is macroscopically similar to the image of the medicinal herb slice to be detected. To ensure consistent image quality, the two loss terms are weighted and summed. The weighting coefficients are set empirically, for example, the reconstruction loss weight is set to 0.85 and the feature space loss weight is set to 0.15, to focus more on pixel-level accurate matching. Then, the Adam optimization algorithm is used to minimize the composite loss function. The gradient of the loss function with respect to each dimension of the latent vector is calculated through backpropagation, and the value of the latent vector is updated according to this gradient. This iterative process is repeated, for example, with a maximum number of iterations set to 500, or early termination when the decrease of the loss function in 10 consecutive iterations is less than a preset convergence threshold (e.g., 0.0001). Each iteration generates an updated reconstruction version. When the optimization process terminates, the final latent vector is input into the generator, and the generated image is the reconstruction version most similar to the image of the medicinal herb slice to be detected.

[0052] The steps for obtaining the visual anomaly residual map are as follows:

[0053] Based on the reconstructed version of the image of the medicinal herb slices to be detected, the absolute value of the pixel-by-pixel difference between each reconstructed version and the image of the medicinal herb slices to be detected is calculated to obtain the pixel-level absolute difference.

[0054] The pixel-level absolute difference threshold is calculated based on the pixel-level absolute difference. The calculation formula is as follows:

[0055] ;

[0056] in, The absolute difference threshold at the pixel level. For candidate grayscale indexes, The total number of gray levels representing the absolute difference at the pixel level. For the first Normalized frequency of each gray level For pixel-level absolute differences below a threshold Average gray value, For pixel-level absolute differences exceeding a threshold Average gray value, For pixel-level absolute differences exceeding a threshold variance The total variance of the pixel-level absolute difference map. As a compactness penalty factor;

[0057] Based on the pixel-level absolute difference threshold, pixels in the pixel-level absolute difference map that exceed the pixel-level absolute difference threshold retain their original differences, while pixels in the pixel-level absolute difference map that are not greater than the pixel-level absolute difference threshold are set to zero, thus generating a visual anomaly residual map.

[0058] Specifically, based on the reconstructed version of the image of the medicinal herb slices obtained in the previous step, this reconstructed version and the original input image of the medicinal herb slices are preprocessed. Both images are converted from the RGB color space to an 8-bit single-channel grayscale space using a weighted average method, i.e., the grayscale value is equal to 0.299 times the red channel value plus 0.587 times the green channel value plus 0.114 times the blue channel value. This operation eliminates the influence of color information, allowing subsequent difference calculations to focus on differences in brightness and texture structure, and ensuring that the pixel values ​​of both images are integers from 0 to 255. Next, a new image with the exact same size as the input image (e.g., 256) is created. A two-dimensional floating-point array (x256 pixels) is created and all its elements are initialized to 0. This array will be used to store the calculation results. Then, each pixel position of the image is traversed, starting from row coordinate 0 and column coordinate 0, until the last pixel. At each pixel coordinate, the gray value of the image of the medicinal herb to be detected and the corresponding gray value of its reconstructed version are read. The absolute value of the difference between the two gray values ​​is calculated and the non-negative difference result is stored in the corresponding coordinate position of the newly created two-dimensional array. After traversing all pixels, each element in the two-dimensional array represents the degree of inconsistency between the original image and its reconstructed version at the corresponding position, and finally the pixel-level absolute difference is obtained.

[0059] In the formula for calculating the pixel-level absolute difference threshold, a normalized foreground class variance is introduced. As a penalty, the Otsu inter-class variance maximization method was modified. When searching for the optimal segmentation threshold, it not only maximizes the difference between the foreground (abnormal region) and the background (normal region), but also ensures that the identified foreground region itself has high internal consistency. The denominator... It is the total variance of the entire pixel-level absolute difference map, used to normalize the variance of the foreground class. This makes the penalty term a dimensionless relative metric, while when a certain candidate threshold... This leads to drastic fluctuations in pixel values ​​within the segmented foreground region (i.e. When the threshold is large, the denominator increases, thereby reducing the objective function value corresponding to the threshold. This mechanism suppresses discrete pixels that are incorrectly identified as abnormal due to noise or complex background textures, making the algorithm more inclined to select thresholds that can delineate compact and uniform real abnormal regions.

[0060] The candidate grayscale index represents the grayscale level being evaluated as a potential threshold. In an 8-bit depth pixel-level absolute difference map, the pixel values ​​range from 0 to 255. The value range is an integer from 0 to 254.

[0061] This represents the total number of gray levels in the pixel-level absolute difference. This parameter is determined by the data type of the pixel-level absolute difference image. For a standard 8-bit grayscale image, its gray levels range from 0 to 255, containing a total of 256 different gray levels. The value is 256, which is fixed and used to define the candidate grayscale index. and normalized frequency The calculation range, for example, when processing an 8-bit difference image of 256x256 pixels, The value is fixed at 256.

[0062] For the first The normalized frequency of each gray level is calculated dynamically based on the input pixel-level absolute difference map. First, the normalized frequency of each gray level in the map (from 0 to ...) is counted. The total number of pixels that appear, generate a length of The histogram array is used to calculate the probability of each gray level, i.e., the normalized frequency, by dividing each count value in the histogram array by the total number of pixels in the image. The formula is as follows: For example, for a 512x512 pixel absolute difference image, the total number of pixels is 262,144. If there are 5,243 pixels with a gray level of 30, then... .

[0063] For pixel-level absolute differences less than or equal to a threshold The average grayscale value represents the average brightness of the background class. For each candidate threshold... This value is calculated from gray level 0 to... The average value of all pixels is obtained by the following formula: ,in It is the first The contribution of each gray level to the total gray level. It is the total probability of the background class, for example, in calculating time At that time, it is necessary to accumulate from up to 40 The value, then divided by the value from up to 40 The sum of .

[0064] For pixel-level absolute differences exceeding a threshold The average gray value represents the average brightness of the foreground (abnormal region). For each candidate threshold... This value is calculated from the gray level. arrive The average value of all pixels is obtained by the following formula: The denominator is the total probability of the foreground class, which is related to... Together, they constitute a measure of inter-class separation. The greater the difference between the two, the more obvious the distinction between the foreground and background in terms of brightness.

[0065] For pixel-level absolute differences exceeding a threshold The variance measures the dispersion or compactness of pixel values ​​within the foreground class for each candidate threshold. After calculating the average gray value of the foreground class Then, the variance is obtained by calculating the average of the squares of the differences between each gray level of the foreground class and its mean.

[0066] The total variance of the pixel-level absolute difference image is used as a normalization factor. This parameter is calculated once before thresholding the entire pixel-level absolute difference image. First, the global average gray value of the entire image is calculated, and then the total variance is calculated. For example, after calculation, if the global average gray value of a certain difference image is 20, the total variance... It is 900 (grayscale level)².

[0067] The compactness penalty factor is a dimensionless preset hyperparameter used to balance the importance of inter-class separation (numerator) and foreground class compactness (normalized variance term in the denominator). The setup was determined experimentally on a validation image set containing known doped regions. Fifty images of medicinal materials with manually annotated anomalous regions were collected, and pixel-level absolute difference maps were generated for each image. Then, a series of candidate... Calculate the optimal threshold for each value (e.g., {0.5, 1.0, 2.0, 5.0}). Image segmentation is then performed, and the segmentation results are compared with manually labeled ground truth values. An F1 score is calculated, and the image with the highest average F1 score on the validation set is selected. Values, for example, as found through testing when When the segmentation result matches the true value the best, then... Set to 1.0.

[0068] Calculations based on parameters:

[0069] Taking a pixel-level absolute difference image as an example, its total number of gray levels Compactness penalty factor The total variance of the entire graph Now evaluate the candidate thresholds The objective function value at time [time] was analyzed using the histogram of this graph, yielding the following statistical data:

[0070] The total probability of the background class (grayscale level 0 to 50) ;

[0071] Total probability of foreground class (grayscale level 51 to 255) ;

[0072] Average grayscale value of background class ;

[0073] Average gray value of the foreground class ;

[0074] Variance of the foreground class ;

[0075] Substitute these values ​​into the revised formula:

[0076] Objective function value = :

[0077] = ;

[0078] = ;

[0079] = ;

[0080] ;

[0081] By all Repeat this calculation and find that when At that time, the objective function value reached its maximum value of 451.3. Therefore, the final determined pixel-level absolute difference threshold was... It is 62.

[0082] The results indicate that for the current pixel-level absolute difference map, a grayscale value of 62 is the optimal dividing line between normal background areas and potential abnormal areas. All pixels with a value greater than 62 are considered to be significant difference points, which are likely to correspond to adulterants or counterfeit parts in the medicinal materials. Pixels with a value no greater than 62 are considered to be normal, minor differences caused by limitations in the model's reconstruction capabilities, or background noise. This value of 62 will serve as the basis for generating a visual anomaly residual map in the next step, and will be used to perform binarization or filtering operations on the pixel-level absolute difference map.

[0083] Based on the calculated pixel-level absolute difference threshold of 62, a two-dimensional array of all zeros with the same size as the pixel-level absolute difference map is first created as the initial canvas for the visual anomaly residual map. Then, each pixel in the pixel-level absolute difference map is traversed, its grayscale value is read, and the grayscale value is compared with the pixel-level absolute difference threshold of 62. If the grayscale value of the current pixel is greater than 62, the pixel is determined to belong to the abnormal region, and its original grayscale value (i.e., the value in the pixel-level absolute difference map) is copied to the new array at the corresponding coordinates in the visual anomaly residual map. If the grayscale value of the current pixel is not greater than 62, the pixel is determined to belong to the background or noise, and its initial value is kept at zero at the corresponding coordinate position in the visual anomaly residual map. After completing the traversal and judgment operation for all pixels, the new two-dimensional array obtained is the final visual anomaly residual map.

[0084] The steps to obtain the spatial distribution map of the thermal decay time constant are as follows:

[0085] Based on the regions identified in the visual anomaly residual map, the temperature time series of the corresponding regions is extracted pixel by pixel in the registered post-thermal pulse infrared image sequence. The steady-state offset is removed and the time index is aligned. The temperature curve is then converted into a temperature decay curve that decreases monotonically with time, thus obtaining the temperature decay curve.

[0086] Based on the temperature decay curve, the thermal decay time constant is calculated, and the thermal decay time constant of each pixel is filled into the corresponding coordinate position to form a spatial distribution map of the thermal decay time constant. The calculation formula is as follows:

[0087] ;

[0088] in, The thermal decay time constant is This represents the total number of data points in the temperature decay curve. For the first Each sampling time, The temperature value after logarithmic transformation and calculated as , In the first Temperature values ​​at each sampling time, This represents the limiting temperature at the tail end of the temperature decay curve. For the first The weights of the data points are defined as follows: , It is a signal-to-noise ratio sensitivity index and is used to adjust the weight as the signal strength changes.

[0089] Specifically, based on the regions identified by non-zero pixels in the visual anomaly residual map, connected component analysis is first performed on these regions. Using the 8-neighbor connectivity criterion, spatially adjacent non-zero pixels are aggregated into independent anomaly candidate regions, and the coordinates of all pixels within each candidate region are recorded. Then, in the post-thermal pulse infrared image sequence, which has already undergone affine transformation and precise spatial registration with the visible light image, the corresponding temperature value is extracted frame-by-frame for each pixel coordinate within each identified anomaly candidate region. Since the infrared camera continuously captured images at a frequency of 100Hz for 10 seconds, each image... Each pixel corresponds to an original temperature time series consisting of 1000 temperature data points. Then, to eliminate the baseline effect of ambient temperature, the average temperature before the application of the heat pulse (e.g., the first 20 frames of the sequence, i.e., within 0.2 seconds) is calculated as the steady-state temperature of that pixel. This steady-state temperature value is then subtracted point by point from the entire 1000-point time series to obtain a sequence representing the temperature rise. The next step is to determine the zero point of time by searching for temperature peaks within a short period after the application of the heat pulse (e.g., between frame 21 and frame 100). The time point corresponding to the frame where the peak occurs is defined as... The system retains only all subsequent temperature data points starting from the peak point for analyzing the cooling process. To reduce the interference of sensor noise on subsequent calculations, a moving average filter with a window size of 5 is applied to smooth the truncated cooling stage temperature sequence. This smoothing operation effectively filters out high-frequency noise while preserving the main decay trend, thereby transforming the original temperature curve, which may have slight fluctuations, into a temperature decay curve that decreases monotonically over time on a macroscopic scale.

[0090] formula: The above formula is used to robustly estimate the thermal decay time constant from logarithmically transformed temperature decay data. The physical exponential decay model Linearization is achieved through logarithmic transformation. In the form of, Then, the slope of the linear model is calculated, while introducing a weight term. The weighting term is allocated based on the intensity of the temperature signal (i.e., the amount by which it exceeds the ambient temperature). In the early stage of decay, the temperature difference is large and the signal-to-noise ratio is high, so it is given a larger weight. In the late stage of decay, the signal tends to the noise level, so it is given a smaller weight. This makes the fitting process insensitive to noise and improves the accuracy and robustness of the time constant estimation.

[0091] This represents the total number of data points in the temperature decay curve. This parameter is determined by the infrared thermal imager's acquisition settings and data processing strategy. After the thermal pulse is excited, recording begins from the temperature peak point and continues until the temperature essentially stabilizes. The acquisition duration is typically set to several seconds. For example, if the infrared thermal imager's frame rate is 200Hz and the selected decay analysis duration is 4 seconds, then the total number of data points used for calculation is... .

[0092] For the first Each sampling time represents a data point in the temperature decay curve relative to the temperature peak (i.e., ...). The time coordinates are determined by the index of the sampling time. Sampling time interval of infrared thermal imager (That is, the reciprocal of the frame rate) is determined, and the calculation formula is: ,in The value range is 1 to For example, if the frame rate is 200Hz, then seconds, then the first five sampling times are Second, Second, Second, Second, Second.

[0093] In the first The temperature value at each sampling moment, this parameter is directly obtained from the temperature decay curve for a single pixel generated in the previous step. It represents the temperature reading of the object's surface at a specific moment during the cooling process, in degrees Celsius (°C) or Kelvin (K). These data are the raw physical quantities for thermal characteristic analysis. For example, the temperature of a pixel at a specific sampling moment... The temperature reading at 1 second may be ℃.

[0094] This is the limiting temperature at the tail end of the temperature decay curve, theoretically the thermal equilibrium temperature reached between the object and the environment after complete cooling. In practice, it is estimated by extracting the last portion of data points from the temperature decay curve (e.g., the last 10% of data points) and calculating their average. This method is useful when, for example, the cooling rate of the object has become very slow at the end of the data collection, and its temperature is close to the ambient temperature. For instance, for a decay curve containing 800 data points, averaging the temperature values ​​of the last 80 points yields an average of 25.1℃, which is then set as the threshold temperature. ℃.

[0095] The temperature value after logarithmic transformation is a key step in linearizing the nonlinear exponential decay process. It is obtained by taking the natural logarithm of the overtemperature value at each time step (i.e., the difference between the current temperature and the limiting temperature). The calculation formula is as follows: After this transformation With time The relationship is approximately linear, and the negative reciprocal of its slope is the thermal decay time constant. For example, if ℃ and ℃, then .

[0096] The signal-to-noise ratio sensitivity index is a dimensionless hyperparameter used to adjust the shape of the weighting function. Its value determines how drastically the weights change with signal strength. The selection of values ​​is based on a series of calibration experiments performed on standard samples with known thermal properties. In these experiments, standard samples of different materials (e.g., PTFE, aluminum, copper) were subjected to thermal pulse tests, and then different values ​​were attempted. The thermal decay time constant is calculated using values ​​(e.g., from 0.5 to 3.0 in steps of 0.1). The calculated result is compared to known theoretical values ​​for these materials or values ​​measured by other precise methods, and the value that minimizes the sum of squared calculation errors for all standard samples is selected. The value is used as the globally optimal parameter, and through this process, it is ultimately determined. When measured, the accuracy and stability are optimal.

[0097] For the first The weight of each data point, a parameter dynamically calculated based on the signal-to-noise ratio (proximated by the over-temperature value) of each data point, is defined as follows: This weight directly affects the contribution of each data point to the linear regression fitting. The larger the overheat value, the greater the weight, making the fitted line more likely to pass through the high signal-to-noise ratio region at the beginning of the decay curve. For example, if And in The overtemperature value at time 17.4℃ is then the weight of that point is: .

[0098] Calculations based on parameters:

[0099] Taking the temperature decay curve of a single pixel as an example, the calculation is performed using the first 5 data points, where... , , ℃, sampling time and temperature data are shown in Table 1:

[0100] Table 1 Sampling time and temperature data

[0101]

[0102] First, calculate the weighted sum of each term:

[0103] ;

[0104] ;

[0105] ;

[0106] ;

[0107] ;

[0108] Substitute these sums into the formula to calculate the numerator and denominator:

[0109] molecule = ;

[0110] Denominator = ;

[0111] Final calculation :

[0112] Second;

[0113] The results indicate that the thermal decay time constant of the material region corresponding to this pixel is 0.0144 seconds. This value reflects the rate of heat dissipation at this point. The smaller the time constant, the faster the heat is dissipated, and the higher the thermal conductivity or thermal diffusivity of the corresponding material may be, and vice versa. This calculation was repeated for all identified pixels in the visual anomaly residual map, and the calculated value for each pixel was... By filling the values ​​back to their original two-dimensional coordinate positions, a spatial distribution map of the thermal decay time constant can be constructed, which intuitively reveals the spatial variation of thermal properties within the anomalous region.

[0114] The steps for obtaining the thermal anomaly diffusion gradient map are as follows:

[0115] Based on the spatial distribution map of the thermal decay time constant, the difference between adjacent pixels is calculated in the row and column directions, and the boundary is mirrored. The difference results are then merged into gradient intensities according to pixel coordinates, while maintaining the spatial distribution with respect to the thermal decay time constant. Figure 1 The size is consistent, and a thermal anomaly diffusion gradient map is generated.

[0116] Specifically, based on the spatial distribution map of the thermal decay time constant, two floating-point two-dimensional arrays of the same size as the distribution map are first created to store the difference results in the row direction (horizontal) and column direction (vertical), respectively. For the row direction difference, starting from the first pixel in the upper left corner of the image, the image is scanned row by row, and the difference between each pixel and its right-side adjacent pixel in terms of the thermal decay time constant is calculated. The result is then stored in the corresponding position of the row direction difference group. For the column direction difference, the same method is used to scan column by column, calculating the difference between each pixel and its lower-side adjacent pixel in terms of the thermal decay time constant. The difference in the time constant is subtracted, and the result is stored in the corresponding position of the column-direction difference group. When processing image boundaries, a mirror extension strategy is used. For example, when calculating the row-direction difference of the rightmost column of pixels, its rightmost virtual neighbor is assigned the value of its leftmost real neighbor. Similarly, when calculating the column-direction difference of the bottommost row of pixels, its lower virtual neighbor is assigned the value of its upper real neighbor. This method completes the difference calculation of the entire image without introducing artificial edges. Next, a new spatial distribution with dimensions and thermal decay time constant is created. Figure 1 A two-dimensional array is used to store the final gradient intensity. Iterate through all pixel coordinates, and at each coordinate point, take the corresponding difference value from the difference array in the row and column directions. Square these two difference values ​​respectively, add them together, and then take the square root of the sum. This calculated value is the gradient intensity of that pixel. Fill this gradient intensity value into the corresponding position in the new array. After completing the calculation for all pixels, the array is the thermal anomaly diffusion gradient map.

[0117] The steps to obtain the fused anomaly score map are as follows:

[0118] Based on the thermal anomaly diffusion gradient map, the visual anomaly residual map is bilinearly interpolated and registered according to coordinates, and the intensity is normalized to the same value range. Element-wise multiplication is performed on the same pixel and the product value is retained to generate a fused anomaly score map.

[0119] Specifically, based on the thermal anomaly diffusion gradient map, the spatial resolution of the visual anomaly residual map and the thermal anomaly diffusion gradient map is first checked. If they are inconsistent, the resolution of the thermal anomaly diffusion gradient map is used as the benchmark to perform spatial bilinear interpolation registration on the visual anomaly residual map. Specifically, for each pixel coordinate in the thermal anomaly diffusion gradient map, it is mapped to the coordinate system of the visual anomaly residual map. This mapped coordinate usually falls between four adjacent pixels. By calculating the distance from this mapped coordinate to the center of these four adjacent pixels, and using the reciprocal of the distance as the weight, the intensity values ​​of these four pixels are weighted and averaged. The calculated weighted average is the new intensity value of the registered visual anomaly residual map at that coordinate point. After calculating all coordinate points, a visual anomaly residual map that is spatially perfectly aligned with the thermal anomaly diffusion gradient map is obtained. Subsequently, this registered visual anomaly residual map and the thermal anomaly diffusion gradient map are compared... The anomalous diffusion gradient maps are subjected to intensity normalization, mapping their numerical range to a uniform range of 0 to 1. The normalization process uses a minimum-maximum scaling method. First, the two maps are traversed to find their respective minimum and maximum values. Then, for each pixel in the map, its normalized new value is obtained by subtracting the minimum value of the map from the original value and dividing by the difference between the maximum and minimum values. This step eliminates the difference in numerical dimensions between the two modal data. Next, a new two-dimensional array of all zeros with the same size as the thermal anomaly diffusion gradient map is created as the carrier for the fused anomaly score map. Finally, all pixel coordinates are traversed. At each coordinate point, the corresponding value is taken from the normalized visual anomaly residual map and the normalized thermal anomaly diffusion gradient map, the two values ​​are multiplied, and the product is stored in the corresponding coordinate position of the fused anomaly score map, thus generating the fused anomaly score map.

[0120] The steps for identifying abnormal adulteration zones in prepared medicinal materials are as follows:

[0121] Based on the fusion anomaly score map, a pixel-by-pixel screening is performed using a fusion threshold, and connected components are marked using 8-neighbor connectivity. Connected components smaller than the area lower limit are removed, and morphological closing operations are performed on the boundaries of the remaining connected components to generate the delineation of abnormal adulteration areas in medicinal decoction pieces.

[0122] Specifically, based on the fusion anomaly score map, a preset fusion threshold is first applied to binarize the image. The process of determining this fusion threshold is as follows: Prepare a validation set containing 50 known doped medicinal material samples. Generate a fusion anomaly score map for each sample, and have experts manually delineate the true doped region as the baseline truth. Then, test a series of candidate thresholds, for example, from 0.2 to 0.8, with a step size of 0.05. For each candidate threshold, apply it to all 50 fusion anomaly score maps to generate 50 binary segmentation results. Compare each segmentation result with the corresponding baseline truth and calculate its Dice similarity coefficient. Finally, calculate the average Dice similarity coefficient of each candidate threshold on the entire validation set, and select the value that results in the highest average Dice similarity coefficient as the final fusion threshold. For example, after testing, it was found that the average Dice coefficient is highest when the threshold is 0.55, so the fusion threshold is set to 0.55. All pixels in the fusion anomaly score map with pixel values ​​greater than 0.55 are set to 1 (representing the foreground), and the rest are set to 0 (representing the background), resulting in a binary image. Then... A connected component labeling algorithm based on 8-neighborhood connectivity is applied to the binary image. The image is scanned, and all interconnected foreground pixels are divided into the same region and assigned a unique integer label. Then, the area of ​​all labeled connected components is filtered, and a lower limit is set based on the typical physical size of the adulterants in the medicinal materials and the imaging resolution. For example, experimental measurements show that the smallest meaningful adulterant particle occupies at least 15 pixels in the image, so the lower limit is set to 15. All connected components are traversed, and the total number of pixels contained in each connected component is calculated. If the area of ​​a connected component is less than 15, the value of all its pixels is changed from 1 to 0, thereby eliminating small, potentially noisy regions. Finally, morphological closing operations are performed on the boundaries of the connected components retained after area filtering. This operation uses a 3x3 pixel square structuring element to first dilate the image, fill the small holes inside the region and connect the adjacent broken parts, and then perform erosion to restore the overall outline size of the region. The final binary image obtained after these steps is the delineation of the abnormal adulteration area of ​​the medicinal materials.

[0123] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A method for identifying the authenticity of medicinal materials based on AI vision, characterized in that, Includes the following steps: Candidate images are generated iteratively and compared with images of pure medicinal materials. The generation logic is adjusted based on the comparison results and the adjustment is continued until the generated images are indistinguishable from the pure set, thus establishing a visual feature benchmark for pure medicinal materials. Based on the visual feature benchmark of the pure medicinal herb slices, for the input image of the medicinal herb slices to be detected, find the latent vector that generates the most similar reconstructed image, obtain the reconstructed version of the image of the medicinal herb slices to be detected, and then calculate the pixel-level absolute difference between the image of the medicinal herb slices to be detected and the reconstructed version of the image of the medicinal herb slices to be detected, and obtain the visual anomaly residual map. Based on the region identified in the visual anomaly residual map, the corresponding position in the registered thermal pulse infrared image sequence is examined to generate a spatial distribution map of the thermal decay time constant, and the spatial gradient of the spatial distribution map of the thermal decay time constant is calculated to generate a thermal anomaly diffusion gradient map. Based on the thermal anomaly diffusion gradient map, a spatial element-wise operation is performed with the visual anomaly residual map to generate a fused anomaly score map. A threshold is applied to the fused anomaly score map, and all consecutive pixel clusters exceeding the threshold are identified as doping sites to establish the delineation of the abnormal doping area of ​​medicinal materials. The steps for obtaining the visual feature benchmarks of the pure medicinal herb slices are as follows: A potential vector interval is set and sampled at a fixed step size to generate a candidate image sequence. The candidate images are then registered pixel by pixel with images of pure medicinal materials. The mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast are extracted to obtain the candidate image comparison results. Based on the comparison results of the candidate images, the candidate image with the smallest difference from the pure medicinal herb slice image is selected, the corresponding latent vector elements are extracted, and the latent vector elements are mapped to the mean hue, mean saturation, luminance variance and gray-level co-occurrence matrix contrast to generate the generation parameters for creating pure medicinal herb slices. Based on the generation parameters for creating pure medicinal herb slices, sampling is performed within the potential vector space to generate a new image set. For each image, the mean hue, mean saturation, luminance variance, and gray-level co-occurrence matrix contrast are extracted again to form a visual feature benchmark for pure medicinal herb slices. The steps for obtaining the spatial distribution map of the thermal decay time constant are as follows: Based on the regions identified in the visual anomaly residual map, the temperature time series of the corresponding regions is extracted pixel by pixel in the registered thermal pulse infrared image sequence. The steady-state offset is removed and the time index is aligned. The temperature curve is converted into a temperature decay curve that decreases monotonically with time, and the temperature decay curve is obtained. Based on the temperature decay curve, the thermal decay time constant is calculated, and the thermal decay time constant of each pixel is filled into the corresponding coordinate position to form a spatial distribution map of the thermal decay time constant; The steps for obtaining the thermal anomaly diffusion gradient map are as follows: Based on the spatial distribution map of the thermal decay time constant, the difference between adjacent pixels is calculated in the row and column directions, and the boundary is mirrored. The difference results are merged into gradient intensity according to pixel coordinates and the size is kept consistent with the spatial distribution map of the thermal decay time constant to generate a thermal anomaly diffusion gradient map.

2. The method for identifying the authenticity of medicinal materials based on AI vision according to claim 1, characterized in that, The steps for obtaining the reconstructed version of the image of the medicinal herb slices to be detected are as follows: Based on the visual feature benchmark of the pure medicinal herb slices, the latent vector optimization search is performed on the input image of the medicinal herb slices to be detected, and a reconstructed version is generated successively to obtain the reconstructed version of the image of the medicinal herb slices to be detected.

3. The method for identifying the authenticity of medicinal materials based on AI vision according to claim 1, characterized in that, The steps for obtaining the visual anomaly residual map are as follows: Based on the reconstructed version of the image of the medicinal herb slices to be detected, the absolute value of the pixel-by-pixel difference between each reconstructed version and the image of the medicinal herb slices to be detected is calculated to obtain the pixel-level absolute difference. Calculate the pixel-level absolute difference threshold based on the pixel-level absolute difference; Based on the pixel-level absolute difference threshold, pixels in the pixel-level absolute difference map that exceed the pixel-level absolute difference threshold retain their original differences, while pixels in the pixel-level absolute difference map that are not greater than the pixel-level absolute difference threshold are set to zero, thus generating a visual anomaly residual map.

4. The method for identifying the authenticity of medicinal materials based on AI vision according to claim 1, characterized in that, The steps for obtaining the fusion anomaly score map are as follows: Based on the thermal anomaly diffusion gradient map, the visual anomaly residual map is bilinearly interpolated and registered according to coordinates, and the intensity is normalized to the same value range. Element-wise multiplication is performed on the same pixel and the product value is retained to generate a fused anomaly score map.

5. The method for identifying the authenticity of medicinal materials based on AI vision according to claim 1, characterized in that, The steps for determining the abnormal adulteration zone of the medicinal herb slices are as follows: Based on the fusion anomaly score map, a pixel-by-pixel screening is performed using a fusion threshold, and connected components are marked using 8-neighbor connectivity. Connected components smaller than the area lower limit are removed, and morphological closing operations are performed on the boundaries of the remaining connected components to generate the delineation of abnormal adulteration areas in medicinal decoction pieces.

6. The medicinal material authenticity identification system according to any one of claims 1-5, based on the AI ​​vision method for identifying the authenticity of medicinal materials, is characterized in that, include: The visual feature benchmark construction module is used to iteratively generate candidate images and compare them with images of pure medicinal materials. Based on the comparison results, the generation logic is adjusted and continuously adjusted until the generated images are indistinguishable from the pure set, thus establishing a visual feature benchmark for pure medicinal materials. The image reconstruction and residual detection module is used to find the potential vector that generates the most similar reconstructed image for the input image of the medicinal herb to be detected based on the visual feature benchmark of the pure medicinal herb slices, to obtain the reconstructed version of the image of the medicinal herb slices to be detected, and then calculate the pixel-level absolute difference between the image of the medicinal herb slices to be detected and the reconstructed version of the image of the medicinal herb slices to be detected, to obtain the visual anomaly residual map. The thermal anomaly diffusion analysis module is used to examine the corresponding position in the registered thermal pulse infrared image sequence based on the region identified in the visual anomaly residual map, generate a spatial distribution map of the thermal decay time constant, calculate the spatial gradient of the spatial distribution map of the thermal decay time constant, and generate a thermal anomaly diffusion gradient map. The fusion anomaly identification module is used to perform element-wise spatial operations on the thermal anomaly diffusion gradient map and the visual anomaly residual map to generate a fusion anomaly score map, apply a threshold to the fusion anomaly score map, and identify all consecutive pixel clusters exceeding the threshold as doping locations to establish the delineation of abnormal doping areas in medicinal decoction pieces.

Citation Information

Patent Citations

  • artificial intelligence-based true and false mixed traditional Chinese medicinal material identification method

    CN109919224A

  • Hyperspectral detection method for authenticity of traditional Chinese medicinal materials based on neural network

    CN118865143A