Image recognition-based quality evaluation method and system for non-antibiotic traditional veterinary drugs

By using image recognition technology, threshold segmentation, and local analysis window techniques, texture features of traditional Chinese veterinary medicine granules are extracted and time-series analysis is performed. This solves the problem that traditional methods have difficulty identifying subtle "oily" defects and achieves efficient quality evaluation.

CN122116346APending Publication Date: 2026-05-29YUNFU ROYAL PHARM CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
YUNFU ROYAL PHARM CO LTD
Filing Date
2026-01-14
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Traditional image recognition methods struggle to identify defects in traditional Chinese veterinary drug granules caused by abnormal processing, such as a slight "oily sheen" or increased reflectivity. Furthermore, the characteristics of a few defective granules are averaged out in the overall statistics, leading to inaccurate quality evaluation.

Method used

An image recognition-based approach is employed, using threshold segmentation, morphological processing, and local analysis window techniques to extract the texture features of particles. Anomalies are evaluated based on the time series of texture features, and continuous analysis is performed using multi-frame image sequences to mark and distinguish abnormal regions.

Benefits of technology

This improves the accuracy and reliability of quality evaluation for traditional Chinese veterinary medicine granules, prevents potential quality issues from escalating, and ensures product functionality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122116346A_ABST
    Figure CN122116346A_ABST
Patent Text Reader

Abstract

The application relates to the field of image recognition, in particular to a quality evaluation method and system of non-antibiotic traditional Chinese veterinary medicine based on image recognition. The method comprises the following steps: acquiring image data; performing segmentation processing on the image data to obtain independent regions of each granule; for each independent region, performing local scanning in the independent region by using a preset local analysis window to obtain texture features of each local surface region; based on the texture features, marking abnormal feature points in the independent region which meet a preset abnormality criterion, judging whether an abnormal region exists in the independent region; and outputting a quality evaluation result of the traditional Chinese veterinary medicine granules according to the judgment result of the abnormal region. The method solves the problems that in the prior art, it is difficult to effectively identify the defects of weak "oily luster" or increased reflectivity of the granule surface caused by process problems, and the visual features of a small amount of defective granules are easily averaged and submerged in the overall statistics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image recognition technology, and more specifically, to a method and system for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition. Background Technology

[0002] In the production of antibiotic-free traditional Chinese veterinary medicine preparations, automated image recognition is often used for appearance quality evaluation to ensure product quality and production efficiency. However, for granular materials like traditional Chinese veterinary medicine granules, if the defect is only manifested as a few particles forming an extremely thin, transparent "enamel layer" due to process abnormalities, resulting in a smoother surface, increased reflectivity, and a slight "oily" appearance, traditional diffuse light imaging and macroscopic statistical analysis are difficult to identify. Diffuse light, designed to eliminate shadows and reflections, can cause these weak highlights to mix with the light and dark variations caused by the irregular shape of the particles, making them difficult to distinguish. At the same time, the proportion of defective particles is very small (possibly only a few percent). When performing color statistics on the overall spread surface, the scattered highlight pixels are averaged out, having minimal impact on indicators such as average color and uniformity, and are submerged in normal fluctuations. As a result, the system cannot separate the differences caused by physical characteristics such as smoothness and reflectivity from color differences, which may lead to misjudging the batch as qualified and causing potential quality problems to leak out.

[0003] To address the aforementioned issues, existing technologies urgently need improvement. Summary of the Invention

[0004] This application discloses a method and system for quality evaluation of antibiotic-free traditional Chinese veterinary medicine based on image recognition. It aims to solve the problems in the prior art, such as the difficulty in effectively identifying defects such as a slight "oily" appearance or increased reflectivity on the surface of particles caused by process problems, and the fact that the visual characteristics of a small number of defective particles are easily averaged out and submerged in the overall statistics.

[0005] The technical solution of this application is as follows: In a first aspect, this application discloses a method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition, including: Acquire image data containing the veterinary drug granules to be evaluated; The image data is segmented to identify and separate individual particles in the image data, obtaining the independent regions of each particle; wherein the segmentation process includes at least threshold segmentation and morphological processing, and the adhered regions are separated when particles are adhered. For each independent region, a preset local analysis window is used to perform a local scan within the independent region to identify multiple local surface regions and obtain the texture features of each local surface region. Based on texture features, abnormal feature points that meet preset anomaly criteria are marked in independent regions. It is determined whether the abnormal feature points form an anomalous feature point cluster with preset spatial distribution characteristics on the particle surface. When it is determined that an anomalous feature point cluster has formed, it is determined that there is an abnormal region in the independent region. The preset spatial distribution characteristics include at least one or more of the following: the connectivity clustering relationship of abnormal feature points and the clustering scale threshold. Based on the judgment results of abnormal areas, the quality evaluation results of veterinary drug granules are output.

[0006] Furthermore, the image data includes acquiring a multi-frame image sequence containing the veterinary drug granules to be evaluated, performing image data segmentation to identify and separate individual particles in the image data, and obtaining the independent regions of each particle, including: The image data is segmented, including segmenting each frame of a multi-frame image sequence to identify and separate each particle in each frame and obtain the independent region of each particle. For each independent region, a preset local analysis window is used to perform a local scan within the independent region to identify multiple local surface regions and acquire the texture features of each local surface region, including: For each independent region, a preset local analysis window is used to perform local scanning within the independent region to identify multiple local surface regions, obtain the texture features of each local surface region, and obtain the time series of texture features of the corresponding local surface regions in a multi-frame image sequence. Based on texture features, abnormal feature points that meet preset anomaly criteria are marked within independent regions, including: The persistence of texture features over time is evaluated based on texture feature time series analysis to mark anomalous feature points that meet preset anomaly criteria.

[0007] Furthermore, the persistence of texture features in the time dimension is evaluated based on the time series of texture features to mark anomalous feature points that meet the preset anomaly criteria, including: Within a preset time window, calculate the first mean and first standard deviation of the texture feature time series; A dynamic threshold is set based on the first average value and the first standard deviation; Check whether the texture feature time series has at least a preset proportion of frames that meet the abnormal criteria defined by the dynamic threshold within a preset time window; The local trend of the texture feature time series is analyzed. The local trend is used to characterize the direction of change and fluctuation stability of the texture feature time series within a preset time window. When the direction of change continuously points to a preset abnormal direction within the preset time window and meets the preset fluctuation stability judgment condition, it is determined to be a stable abnormal trend. The preset fluctuation stability judgment condition includes at least: the first standard deviation of the texture feature time series within the preset time window is less than the preset fluctuation threshold. When the texture feature time series meets the preset frame rate requirement and / or the local trend is characterized as a stable abnormal trend, the corresponding local surface region is determined to meet the preset abnormality criterion, and the corresponding abnormal feature points are marked.

[0008] Furthermore, the texture features of each local surface region are obtained, and the time series of texture features of the corresponding local surface regions are obtained from a multi-frame image sequence, including: Based on the degree of variation of the texture features of each local surface region within an independent region in the spatial dimension, the window size of the local analysis window is adjusted to form at least two different scales of local analysis windows; Multiple sets of texture features are extracted from local surface regions based on at least two different scale local analysis windows. Multiple sets of texture features are fused to obtain the fused texture features. The fused texture features are normalized to obtain normalized texture features, and then the normalized texture features are organized in the multi-frame image sequence according to the frame order to form a texture feature time series.

[0009] Furthermore, the image data is segmented to identify and separate individual particles within the image data, including: The image data is preprocessed to suppress random noise and preserve particle edge information, resulting in preprocessed image data. The Otsu method and / or the local adaptive thresholding method are used to perform threshold segmentation on the preprocessed image data to distinguish the threshold segmentation results between the granular region and the background region. Morphological opening is performed on the threshold segmentation results to remove noise and smooth particle edges; When particles are adhered, the seed points for segmentation of the adhered region are determined based on distance transformation, and the watershed algorithm is used to separate the adhered region to achieve separation of adhered particles.

[0010] Furthermore, the fused texture features are normalized to obtain normalized texture features, which are then organized in frame order across a multi-frame image sequence to form a texture feature time series, including: For each independent region, obtain the current distribution parameters of the fused texture features. The current distribution parameters include at least the second mean and the second standard deviation. Based on the current distribution parameters and the preset defect sensitivity factor, the normalization processing parameters are adjusted to adapt to the distribution differences of the fused texture features under different particles or different batches. Based on the adjusted normalization parameters, the fused texture features are adaptively normalized to obtain normalized texture features. Cross-frame tracking is performed on the normalized texture features to associate the corresponding local surface regions of the same particle in different frames; The normalized texture features obtained from cross-frame tracking are then correlated in chronological order to form a texture feature time series.

[0011] Furthermore, for each independent region, the current distribution parameters of the fused texture features are obtained, including: Multi-scale structural analysis was performed on the fused texture features to identify whether there were non-defect structures such as microbubbles or depressions on the surface of particles corresponding to independent regions, and the results of multi-scale structural analysis were obtained. Based on the results of multi-scale structural analysis, the fused texture features are divided into regions to distinguish between potential defect regions and non-defect structural regions. For both potentially defective and non-defective structural regions, calculate the regional statistics of the fused texture features for the corresponding regions. Based on the difference between the regional statistics of potentially defective regions and the regional statistics of non-defective structural regions, the representation weights of the current distribution parameters are adjusted. Based on the adjusted representation weights, the second mean and second standard deviation of the fused texture features are calculated as the current distribution parameters.

[0012] Furthermore, based on the current distribution parameters and the preset defect sensitivity factor, the normalization processing parameters are adjusted, including: Obtain the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch, compare the current distribution parameters with the historical distribution range, and obtain the degree of deviation of the current distribution parameters relative to the historical distribution range. The historical distribution range includes at least the historical mean range and / or historical fluctuation range of the corresponding fused texture features. The defect sensitivity factor is dynamically adjusted based on the degree of offset. The normalization parameters are then adjusted based on the adjusted defect sensitivity factor and the current distribution parameters.

[0013] Furthermore, the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch is obtained, including: The morphological parameters and brightness distribution parameters of each particle's independent region are calculated, and particles that meet the preset normal screening conditions are determined as reference samples based on whether the morphological parameters and brightness distribution parameters fall within the corresponding preset normal range. For the reference sample, its image data is collected and the fused texture features are extracted. The reference statistics of the fused texture features of the reference sample are calculated. The reference statistics include at least the reference mean and the reference standard deviation. The comparison results are obtained by comparing the reference statistics with the distribution range of similar historical normal texture features of batches with similar process parameters in the past. When the difference between the comparison result characterizing the reference statistic and the distribution range of similar historical normal texture features exceeds the preset difference threshold and / or the amount of historical data is insufficient, the sampling frequency of the fused texture features of normal particles in the current production batch is increased, the reference statistic is continuously updated, and a preliminary distribution range of normal texture features is constructed based on the updated reference mean and reference standard deviation. Based on the number of normal particles sampled in the reference sample and the distribution stability of the fused texture features, a confidence evaluation factor is generated and adjusted. When the confidence evaluation factor is less than the preset confidence threshold, the preset initial distribution range is used as the initial value of the initial historical normal distribution range, and it gradually converges to the initial normal texture feature distribution range as the confidence evaluation factor increases. By combining the similarity between the key process parameters of the current production batch and the key process parameters of similar historical batches, the initial historical normal distribution range after convergence is weighted and corrected to obtain the corrected historical distribution range. The corrected historical distribution range is then used as the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch.

[0014] Secondly, this application also discloses an image recognition-based quality evaluation system for antibiotic-free traditional Chinese veterinary medicine, comprising: The image data acquisition module is used to acquire image data containing the veterinary drug granules to be evaluated. The particle recognition and separation module is used to segment image data to identify and separate individual particles in the image data, obtaining the independent regions of each particle; wherein, the segmentation process includes at least threshold segmentation and morphological processing, and separates the adhered regions when particles are adhered. The texture feature acquisition module is used to perform local scanning within each independent region using a preset local analysis window to determine multiple local surface regions and acquire the texture features of each local surface region. An abnormal region judgment module is used to mark abnormal feature points that meet preset abnormality criteria in an independent region based on texture features, and to determine whether the abnormal feature points form an anomalous feature point cluster with preset spatial distribution characteristics on the particle surface. When it is determined that an anomalous feature point cluster has been formed, it is determined that there is an abnormal region in the independent region. The preset spatial distribution characteristics include at least one or more of the following: the connectivity clustering relationship of the abnormal feature points and the clustering scale threshold. The quality evaluation result output module is used to output the quality evaluation results of veterinary drug granules based on the judgment results of abnormal areas.

[0015] Beneficial effects: The method of this application can effectively identify defects such as a slight "oily" appearance or increased reflectivity on the surface of traditional Chinese veterinary medicine granules caused by process problems. It overcomes the problems of diffuse light environment masking defects and the averaged characteristics of a small number of defective particles in the prior art. It significantly improves the accuracy and reliability of quality evaluation of antibiotic-free traditional Chinese veterinary medicine granules, thereby avoiding the leakage of quality hazards and ensuring the functionality of the product. Attached Figure Description

[0016] Figure 1 This is a flowchart illustrating a method for evaluating the quality of antibiotic-free traditional Chinese veterinary drugs based on image recognition, as provided in this application.

[0017] Figure 2 A flowchart of a quality evaluation system for antibiotic-free traditional Chinese veterinary drugs based on image recognition, provided for this application.

[0018] In the diagram: 1. Image data acquisition module; 2. Particle recognition and separation module; 3. Texture feature acquisition module; 4. Abnormal region judgment module; 5. Quality evaluation result output module. Detailed Implementation

[0019] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. The components of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

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

[0021] In the traditional production process of antibiotic-free traditional Chinese veterinary medicine preparations, automated image recognition systems have limitations in evaluating appearance quality. When product defects manifest as a slight "oily" appearance or increased reflectivity on the surface of a few particles due to process issues, traditional image recognition methods based on diffuse light imaging and macroscopic statistical analysis are difficult to effectively identify. This is because diffuse light environments can mask these differences based on surface reflectivity, and the visual characteristics of a few defective particles are easily averaged out and obscured in the overall statistical analysis, leading to the system's inability to accurately judge product quality and thus affecting the product's functionality.

[0022] Reference Figure 1 In another embodiment of this application, a method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition is further proposed, including: S1000: Acquire image data containing the veterinary drug granules to be evaluated; S2000: Perform segmentation processing on image data to identify and separate individual particles in the image data, obtaining independent regions for each particle; wherein, the segmentation processing includes at least threshold segmentation and morphological processing, and separates the adhered regions when particles are adhered. S3000: For each independent region, a preset local analysis window is used to perform a local scan within the independent region to determine multiple local surface regions and obtain the texture features of each local surface region. S4000: Based on texture features, mark abnormal feature points that meet preset abnormality criteria in an independent region, determine whether the abnormal feature points form an anomalous feature point cluster with preset spatial distribution characteristics on the particle surface, and when it is determined that an anomalous region exists in the independent region, the preset spatial distribution characteristics include at least one or more of the following: the connectivity clustering relationship of abnormal feature points and the clustering scale threshold. S5000: Based on the judgment results of abnormal areas, output the quality evaluation results of veterinary drug granules.

[0023] Here, "image data" refers to digital image information containing the veterinary drug granules to be evaluated, acquired through optical imaging equipment (such as an industrial camera). This can be a single frame image or a sequence of multiple frames. "Segmentation processing" refers to separating the foreground target (i.e., the veterinary drug granules) from the background in the image data, and distinguishing adhered particles when they are present, to obtain the image region of each independent particle. "Independent region" refers to the set of pixels occupied by each individual particle in the image after segmentation processing. "Local analysis window" refers to an analysis unit of specific size and shape used for local scanning within an independent region, used to focus on a small area on the particle surface. "Local surface region" refers to a small local area on the particle surface determined by the local analysis window scanning within an independent region. "Texture features" refers to quantitative indicators describing the grayscale or color distribution pattern of the local surface region image, such as gray-level co-occurrence matrix features, local binary pattern (LBP) features, wavelet texture features, etc., used to reflect visual characteristics such as roughness, smoothness, and uniformity of the particle surface. "Anomaly criteria" refer to the standards used to determine whether the texture features of a local surface area deviate from the normal range, usually established based on statistical methods or machine learning models. "Anomaly feature points" refer to the center point or representative point of a local surface area whose texture features satisfy the preset anomaly criteria. "Preset spatial distribution characteristics" refer to the geometric or topological properties that anomaly feature points should satisfy when they aggregate on the particle surface, such as the connectivity between anomaly feature points, the size and shape of the aggregated area, etc. "Anomaly regions" refer to areas on the particle surface formed by the aggregation of anomaly feature points, exhibiting specific spatial distribution characteristics, indicating the presence of potential quality defects in that area. "Quality evaluation results" refer to the conclusion given regarding the quality status of the traditional Chinese veterinary medicine granules based on the judgment of the anomaly regions, such as "qualified," "unqualified," or a specific type of defect.

[0024] This application first acquires image data containing the veterinary drug granules to be evaluated. For example, an industrial camera is used to photograph the veterinary drug granules: the granules are evenly spread on a conveyor belt, and the camera captures an image as the granules pass under it. The image data can be a single frame or a continuous sequence of multiple frames, depending on the detection requirements and the movement of the granules.

[0025] Secondly, the image data is segmented to identify and separate individual particles, obtaining independent regions for each particle. Segmentation separates particles from the background and handles particle adhesion. For example, threshold-based segmentation methods, such as Otsu's method or local adaptive thresholding, can be used to distinguish particle regions from background regions in the image; subsequently, morphological processing, such as opening operations, is performed to remove noise points and smooth particle edges. When particle adhesion exists, a method based on distance transform and watershed algorithms can be used for separation: first, the distance transform of the adhered region is calculated; then, the segmentation seed point is determined based on the local maximum of the distance transform; finally, the watershed algorithm is applied to separate the adhered particles into independent regions.

[0026] Next, for each independent region, a preset local analysis window is used to perform a local scan within the independent region to identify multiple local surface regions and acquire the texture features of each local surface region. For example, a rectangular or circular window of a fixed size is defined as the local analysis window, and the scan is performed with a certain step size to cover the particle surface; texture features are extracted for each local surface region. Texture features may include: calculating statistics such as energy, contrast, correlation, and entropy of the gray-level co-occurrence matrix (GLCM), or extracting local binary pattern (LBP) features to quantify information such as roughness, directionality, and uniformity of the local texture.

[0027] Then, based on texture features, abnormal feature points that meet preset anomaly criteria are marked within independent regions, and it is determined whether these abnormal feature points form an anomalous feature point cluster with preset spatial distribution characteristics on the particle surface. When an anomalous feature point cluster is determined to have formed, an abnormal region is identified within the independent region. The anomaly criteria can be established by statistically analyzing the texture features of a large number of normal and defective particles to establish a threshold: when a certain texture feature value of a local surface region exceeds the normal range, it is marked as an abnormal feature point; or a classifier (such as a support vector machine, neural network, etc.) can be trained to determine whether a local surface region is abnormal based on texture features. Subsequently, clustering judgment is performed: preset spatial distribution characteristics can be set as the connectivity and clustering relationship of abnormal feature points and the clustering size threshold; when multiple abnormal feature points are spatially connected and the clustering size exceeds the preset threshold, an abnormal region is identified, thereby suppressing misjudgments caused by random noise.

[0028] Finally, based on the judgment results of abnormal areas, the quality evaluation results of the veterinary drug granules are output. For example, if one or more abnormal areas exist within an independent region of the granules, the granules can be determined to be unqualified; if the proportion of unqualified granules in a batch exceeds a preset threshold, the batch can be determined to be unqualified. The quality evaluation results can be output as text, image markers, or data reports for easy subsequent processing.

[0029] Traditional methods often involve macroscopic statistical analysis under diffuse lighting conditions. The subtle "oily sheen" produced by the extremely thin, transparent "enamel layer" formed on the particle surface due to excessive heating is difficult to distinguish, and the characteristics of a few defective particles are easily averaged out in the overall statistics. This application first obtains the independent regions of each particle through fine segmentation, and then performs local scanning and extracts texture features through a local analysis window. This allows the system to focus on microscopic details and capture texture changes that are easily overlooked in macroscopic statistics. For example, when an "enamel layer" exists on the particle surface, the changes in smoothness and reflectivity of its local area can be quantified and characterized through texture features (such as contrast and energy). Furthermore, by marking abnormal feature points with anomaly criteria and constraining the aggregation of abnormal feature points with preset spatial distribution features (connectivity clustering relationships, clustering scale thresholds, etc.), random noise and real defect areas can be effectively distinguished, improving detection robustness. Thus, visual differences caused by physical characteristics such as smoothness and reflectivity can be separated from color differences, accurately identifying "oily sheen" defects that are difficult to detect with traditional methods, and outputting reliable quality evaluation results, reducing the risk of potential quality hazards escalating.

[0030] In another embodiment of this application, it is further proposed that the image data includes acquiring a multi-frame image sequence containing the veterinary drug granules to be evaluated, and S2000 includes: S2100: Perform segmentation processing on image data, including segmenting each frame of a multi-frame image sequence to identify and separate each particle in each frame and obtain the independent region of each particle. S2200: For each independent region, a preset local analysis window is used to perform a local scan within the independent region to determine multiple local surface regions and acquire the texture features of each local surface region, including: S2300: For each independent region, a preset local analysis window is used to perform local scanning within the independent region to determine multiple local surface regions, obtain the texture features of each local surface region, and obtain the time series of texture features of the corresponding local surface region in a multi-frame image sequence. S2400: Based on texture features, mark abnormal feature points that meet preset anomaly criteria within independent regions, including: S2500: Evaluate the persistence of texture features in the time dimension based on texture feature time series, so as to mark abnormal feature points that meet the preset abnormality criteria.

[0031] Among them, a multi-frame image sequence refers to a series of images containing the veterinary drug granules to be evaluated, captured continuously or intermittently over a period of time. Its purpose is to introduce temporal dimension information to capture the dynamic changes in the surface features of the granules, thereby distinguishing between transient noise and persistent defects. For example, the granules can be continuously photographed at a fixed frame rate using a high-speed camera, or multiple triggers can control the camera to take pictures at different time points as the granules pass through the detection area.

[0032] Furthermore, segmenting each frame in a multi-frame image sequence means independently performing particle recognition and separation on each static image in the sequence to ensure that each particle can be accurately identified and its independent region extracted in different frames, laying the foundation for subsequent texture feature extraction and texture feature time series construction.

[0033] Furthermore, a texture feature time series refers to a set of texture features arranged chronologically across multiple frames of images for the same local surface region. It is used to extend static texture features to the temporal dimension to analyze their patterns of change and persistence. For example, for a specific local region on a particle surface, a texture feature value is extracted in the first frame, another texture feature value in the second frame, and so on, forming a time series.

[0034] In practical applications, evaluating the persistence of texture features over time based on texture feature time series analysis involves analyzing the changing trends and stability of texture features across multiple consecutive frames. This eliminates transient anomalies caused by random factors (such as lighting fluctuations or temporary dust particle adhesion), marking only anomalous feature points that are persistent over time, thereby improving the accuracy of anomaly detection. For example, if the texture features of a local surface area exhibit abnormalities across multiple consecutive frames, it is more likely to be identified as a genuine anomalous feature point.

[0035] The proposed solution introduces a multi-frame image sequence, enabling quality assessment to move beyond static image information at a single moment. Instead, it allows for the construction of a time series of texture features for the same local surface region and continuous evaluation, thereby filtering out transient noise interference or occasional pseudo-defects, such as brief changes in illumination or tiny impurities floating in the air. These factors may be misjudged as anomalies in a single-frame image, but they are not marked as anomalies in a multi-frame sequence due to their lack of continuity. Therefore, it can more accurately identify anomalous feature points that are stable in time and reflect particle quality problems, improving the reliability and anti-interference capability of anomaly determination.

[0036] In another embodiment of this application, the specific steps of S2500 are further described as follows: S2510: Within a preset time window, calculate the first average and first standard deviation of the texture feature time series; S2520: Set a dynamic threshold based on the first average value and the first standard deviation; S2530: Check whether the texture feature time series has at least a preset proportion of frames that meet the abnormality criteria defined by the dynamic threshold within a preset time window; S2540: And analyze the local trend of the texture feature time series. The local trend is used to characterize the direction of change and fluctuation stability of the texture feature time series within a preset time window. When the direction of change continues to point to a preset abnormal direction within the preset time window and meets the preset fluctuation stability judgment condition, it is determined to be a stable abnormal trend. The preset fluctuation stability judgment condition includes at least: the first standard deviation of the texture feature time series within the preset time window is less than the preset fluctuation threshold. S2550: When the texture feature time series meets the frame number requirement of the preset ratio and / or the local trend is characterized as a stable abnormal trend, determine that the corresponding local surface region meets the preset abnormality criterion and mark the corresponding abnormal feature points.

[0037] Specifically, the preset time window refers to the length of a continuous time frame used to analyze the texture feature time series. Its setting can be determined based on the particle movement speed, image acquisition frequency, and the duration of the defects to be detected, ensuring that the variation patterns of texture features are captured within a sufficient time span. Within the preset time window, the first mean and first standard deviation of the texture feature time series are calculated to quantify the central tendency and dispersion, and to provide a statistical basis for setting the dynamic threshold.

[0038] Furthermore, the dynamic threshold is adaptively set based on the first average value and the first standard deviation, which can be adjusted according to the statistical characteristics of the texture features of the current local surface area, thereby more accurately defining the range of anomalies and avoiding the mismatch caused by a fixed threshold.

[0039] In addition, the system checks whether at least a preset percentage of frames within a preset time window meet the anomaly criteria defined by a dynamic threshold. This ensures that the anomaly is not instantaneous but persistent. The preset percentage can be configured as needed. For example, setting it to 70% means that at least 70% of the frames within the preset time window have texture feature values ​​that exceed the dynamic threshold before they are considered potential anomalies.

[0040] Meanwhile, local trend analysis is used to characterize the direction of change and fluctuation stability of the texture feature time series within a preset time window: when the direction of change continuously points to a preset abnormal direction within the preset time window (e.g., the texture feature value continuously increases or decreases, reflecting that the surface roughness or smoothness continuously deviates from the normal range), and the preset fluctuation stability judgment condition is met, it is determined to be a stable abnormal trend; the preset fluctuation stability judgment condition may, for example, require that the first standard deviation of the texture feature time series within the preset time window is less than a preset fluctuation threshold, so as to exclude the case of violent fluctuations but no clear abnormal direction and ensure that the abnormal stability is effective.

[0041] Therefore, when the texture feature time series meets the preset frame number requirement and / or the local trend is characterized as a stable abnormal trend, the corresponding local surface region is finally determined to meet the preset abnormality criterion and marked as an abnormal feature point, thereby forming a dual or composite judgment mechanism to improve accuracy and robustness.

[0042] In some preferred embodiments, the following specific example illustrates the situation: Suppose that when evaluating the quality of a batch of veterinary drug granules, the image acquisition system acquires the image sequence of the granules at a rate of 30 frames per second; for a certain local surface area, its texture feature time series is extracted, and the preset time window is set to 1 second (i.e. 30 frames).

[0043] First, within the preset 1-second time window, the first average value and first standard deviation of the time series of texture features of the local surface region are calculated. For example, if the texture features represent surface roughness, the first average value is 0.5 and the first standard deviation is 0.05. Based on this, the dynamic threshold is set to the first average value plus or minus a multiple related to the first standard deviation (e.g., 0.5 ± 3 * 0.05) to obtain the dynamic normal range.

[0044] Next, the system checks whether at least a preset proportion (e.g., 80%) of the frames in these 30 frames have texture feature values ​​that exceed the dynamic threshold; if only a few frames (e.g., 2-3 frames) exceed the threshold, it can be considered as caused by transient noise or lighting changes and is not marked as abnormal.

[0045] At the same time, the system analyzes the local trend of the texture feature time series: for example, if the texture feature value continues to rise throughout the entire 1-second window, and its volatility (e.g., the first standard deviation calculated from the detrended residual) is less than the preset volatility threshold (e.g., 0.02), then even if not every frame strictly exceeds the dynamic threshold, it can be determined as a stable abnormal trend.

[0046] Ultimately, an area of ​​local surface texture features is identified as meeting a preset anomaly criterion and marked as an anomalous feature point only when its time series meets a preset percentage of frame count requirements (e.g., more than 80% of frames exceed the dynamic threshold) and / or its local trend is characterized as a stable abnormal trend. For example, a persistent scratch or dent will have texture feature values ​​that consistently deviate from the normal range for multiple frames, and its local trend will consistently point in the abnormal direction, thus allowing for accurate identification. Conversely, a brief dust particle or light flicker typically lacks both persistence and a stable trend, and will not simultaneously meet the criteria, thus avoiding false alarms.

[0047] In another embodiment of this application, it is further proposed to obtain the texture features of each local surface region and obtain the time series of texture features of the corresponding local surface region in a multi-frame image sequence, specifically including: S2310: Based on the degree of variation of the texture features of each local surface region within an independent region in the spatial dimension, adjust the window size of the local analysis window to form at least two different scales of local analysis windows; S2320: Extract multiple sets of texture features from local surface regions based on at least two different scale local analysis windows; S2330: Perform feature fusion processing on multiple sets of texture features to obtain fused texture features; S2340: Normalize the fused texture features to obtain normalized texture features, and organize the normalized texture features in a multi-frame image sequence according to frame order to form a texture feature time series.

[0048] Specifically, based on the degree of variation in the texture features of each local surface region within an independent area in the spatial dimension, the window size of the local analysis window is adjusted to form at least two different scales of local analysis windows. The degree of variation in texture features in the spatial dimension can be understood as the fineness or roughness of the particle surface texture. For example, for regions with drastic texture changes (such as edges or fine cracks), a smaller local analysis window is used to capture fine structures; for regions with gentle texture changes (such as large smooth surfaces), a larger local analysis window is used to obtain macroscopic features and suppress local noise. This adaptive adjustment mechanism ensures that surface features at different scales can be effectively captured.

[0049] Furthermore, multiple sets of texture features are extracted from the local surface region based on at least two different scales of local analysis windows. That is, feature extraction is performed multiple times on the same local surface region using analysis windows of different sizes. For example, a 5x5 pixel window can be used to extract one set of texture features, and a 15x15 pixel window can be used to extract another set of texture features, describing the particle surface texture information from multiple scales and obtaining a richer feature representation.

[0050] Based on this, feature fusion processing is performed on multiple sets of texture features to obtain fused texture features. Feature fusion is used to integrate texture features extracted from windows of different scales into a more discriminative comprehensive feature vector. Fusion methods may include, but are not limited to, simple concatenation of feature vectors, weighted averaging, principal component analysis (PCA) dimensionality reduction fusion, etc., to comprehensively utilize multi-scale information and improve robustness and sensitivity to defects.

[0051] Subsequently, the fused texture features are normalized to obtain normalized texture features, which are used to eliminate the differences in dimensionality and numerical range between different feature dimensions, so that the features are comparable in the subsequent anomaly criterion evaluation and to avoid features with large numerical ranges dominating the discrimination process. Commonly used normalization methods include min-max normalization, Z-score normalization, etc.

[0052] Finally, the normalized texture features are organized in the multi-frame image sequence according to the frame order to form a texture feature time series. That is, for the same local surface region of the same particle, the texture features extracted from the continuous multi-frame images and after fusion and normalization are arranged in time order to form a time series, which is used to characterize the changing trend of texture features over time and to provide a data basis for subsequent anomaly criterion evaluation based on the persistence of time dimension.

[0053] In some preferred embodiments, this application is implemented as follows: Suppose that during image acquisition of traditional Chinese veterinary medicine granules, a multi-frame image sequence containing the granules to be evaluated was obtained. When extracting texture features from a specific region, a preliminary analysis is first performed on that region, such as evaluating the fineness of its texture by calculating the local gray-level gradient or local variance. If high-frequency changes (such as fine cracks or depressions) are detected in the region, the local analysis window is adjusted to include a smaller scale (e.g., 3x3 pixels) and a medium scale (e.g., 7x7 pixels). If the texture of the region is relatively smooth, a window with a medium scale (7x7 pixels) and a larger scale (15x15 pixels) is used.

[0054] Specifically, for each local surface region, local analysis windows of three different scales, namely 3x3, 7x7 and 15x15, are used for scanning, and various texture features are extracted, such as the energy, contrast, homogeneity and entropy of the gray-level co-occurrence matrix (GLCM), as well as the local binary mode (LBP) features, so as to obtain three sets of texture feature vectors of different scales.

[0055] Subsequently, feature fusion processing is performed on these three sets of texture features. For example, the three sets of feature vectors can be simply concatenated to form a longer comprehensive feature vector; or a weighted average method can be used to assign different weights to the contribution of features at different scales to defect identification, so that the fused texture feature vector simultaneously contains multi-scale particle surface information.

[0056] Next, the fused texture features are normalized. For example, the Z-score normalization method is used to convert each feature dimension into a distribution with a mean of 0 and a standard deviation of 1, in order to eliminate differences in units and numerical ranges.

[0057] Finally, the normalized fused texture features are organized according to their temporal order in the multi-frame image sequence to form a texture feature time series for the local surface region. For example, if a local surface region is tracked in 100 consecutive frames, a time series containing 100 normalized fused texture feature vectors is formed for subsequent anomaly criterion evaluation, thereby more comprehensively and stably characterizing the dynamic texture changes of the particle surface and improving the accuracy of anomaly detection.

[0058] In another embodiment of this application, a segmentation process is further proposed for image data to identify and separate individual particles in the image data, including: S2600: Preprocesses the image data to suppress random noise and retain particle edge information to obtain preprocessed image data; S2700: Threshold segmentation is performed on the preprocessed image data using the Otsu method and / or the local adaptive thresholding method to distinguish the threshold segmentation results between the granular region and the background region; S2800: Perform morphological opening on the threshold segmentation results to remove noise and smooth particle edges; S2900: When particles are adhered, seed points for segmentation of the adhered region are determined based on distance transformation, and the watershed algorithm is used to separate the adhered region to achieve separation of adhered particles.

[0059] Specifically, image data preprocessing aims to optimize image quality and provide clearer, more accurate input for subsequent segmentation operations. This preprocessing can employ Gaussian filtering, median filtering, etc., to suppress random noise, and edge enhancement algorithms (such as the Canny operator, Sobel operator, etc.) to preserve and highlight particle edge information, enabling particle contours to be clearly identified in subsequent processing, thus obtaining preprocessed image data.

[0060] Thresholding segmentation is a crucial step in distinguishing granular regions from background regions. Otsu's method is a globally adaptive thresholding method that determines the threshold by maximizing the inter-class variance, suitable for images with high foreground-background contrast. Locally adaptive thresholding methods (such as the Niblack or Sauvola methods) determine the threshold based on local pixel distribution, making them more suitable for images with uneven lighting or complex backgrounds. By employing Otsu's method and / or locally adaptive thresholding methods, a thresholding strategy can be selected based on image characteristics, resulting in accurate thresholding segmentation results.

[0061] In practical applications, morphological opening operations are performed on the threshold segmentation results to further optimize the segmentation effect. Morphological opening is a combination of erosion and dilation: first, erosion is performed to remove small noise points and break small spurious connections, and then dilation is performed to restore the particle size and smooth the edges, thereby obtaining a more regular particle region.

[0062] Furthermore, when particles are adhered together, threshold segmentation and morphological processing may not be effective in separating them. This application introduces a technique for separating adhered particles based on distance transform and watershed algorithm: the distance transform calculates the distance from the foreground pixel to the nearest background pixel, forming a distance peak within the adhered region, and the peak point can be used as the center or "seed point" of the adhered particles; the watershed algorithm treats the image as a topographic map, and by simulating the "catchment basin" segmentation process, it separates the adhered region into multiple independent regions along the "watershed" line based on the seed point, thus achieving effective separation even in the case of tight adhesion.

[0063] The solution proposed in this application addresses noise interference, edge blurring, and particle adhesion through a multi-stage, refined image segmentation process.

[0064] In some preferred embodiments, this application is implemented as follows: Suppose we have acquired a batch of image data of traditional Chinese veterinary medicine granules. First, we preprocess the raw image data, for example, by using a Gaussian filter to smooth the image and suppress random noise. At the same time, to avoid blurring the granule edges, we can use the Canny edge detection algorithm to enhance the edges and highlight the granule contours, resulting in clear preprocessed image data with less noise.

[0065] Subsequently, thresholding is performed on the preprocessed image data. Considering uneven illumination, a local adaptive thresholding method (such as the NiBlack algorithm) can be used to calculate independent thresholds for each local region to effectively distinguish between particle regions and background regions, thus obtaining preliminary binarized segmentation results.

[0066] Next, morphological opening operations are performed on the threshold segmentation results. For example, a 3x3 erosion is performed first to eliminate small noise points and fine connections, and then a 3x3 dilation is performed to restore the particle size and smooth the edges, thereby making the particle edges more regular.

[0067] Finally, for particle adhesion, distance transform and watershed algorithm are used for separation: a distance transform is performed on the binary image after morphological opening to obtain a distance map, in which local maxima are formed at the center of the adhered particles; the local maxima are used as seed points for the watershed algorithm, and the watershed algorithm is applied to the distance map to segment the image into multiple "water basins", each water basin corresponding to an independent particle; in this way, even tightly adhered particles can be separated into independent regions, providing accurate independent particle regions for subsequent texture feature extraction and quality assessment.

[0068] In another embodiment of this application, S2340 further includes: S2341: For each independent region, obtain the current distribution parameters of the fused texture features. The current distribution parameters include at least the second mean and the second standard deviation. S2342: Based on the current distribution parameters and the preset defect sensitivity factor, adjust the normalization processing parameters to adapt to the distribution differences of the fused texture features under different particles or different batches; S2343: Based on the adjusted normalization processing parameters, the fused texture features are adaptively normalized to obtain normalized texture features; S2344: Perform cross-frame tracking on the normalized texture features to associate the corresponding local surface regions of the same particle in different frames; S2345: Then associate the normalized texture features obtained from cross-frame tracking in chronological order to form a texture feature time series.

[0069] Specifically, for each independent region, obtaining the current distribution parameters of the fused texture features means that the system performs real-time statistics on the fused texture features of the current particle to be evaluated, and obtains statistical characteristics such as its second mean and second standard deviation, so as to characterize the overall level and fluctuation range of the texture features of the current particle or the current production batch, and provide basic data for subsequent adaptive processing.

[0070] Furthermore, adjusting the normalization processing parameters based on the current distribution parameters and the preset defect sensitivity factor means that the system dynamically corrects the parameters used for normalization processing based on the real-time acquired current distribution parameters and the adjustable defect sensitivity factor. The defect sensitivity factor can be set as needed; for example, a higher sensitivity can be set in scenarios with low defect tolerance, so that the normalization processing parameters can adapt to the differences in texture feature distribution among different individual particles, different production batches, or different environmental conditions, thereby more stably distinguishing between normal areas and potentially abnormal areas.

[0071] Based on this, adaptive normalization is performed on the fused texture features using the adjusted normalization parameters to obtain normalized texture features. Adaptive normalization can employ Z-score normalization or Min-Max normalization. The mean, standard deviation, minimum, or maximum values ​​in the normalization formula are dynamically determined by the aforementioned adjusted normalization parameters. This ensures that the normalized texture features maintain relative diversity while eliminating absolute differences between batches or individuals, thus more effectively highlighting defect features.

[0072] Furthermore, the normalized texture features are tracked across frames to associate the corresponding local surface regions of the same particle in different frames. Since particles may move or change pose in a multi-frame image sequence, tracking algorithms based on feature matching, optical flow, or deep learning can be used to identify and track the position of the same particle in consecutive frames, ensuring that the texture features extracted from different frames can be correctly attributed to the same local surface region of the same particle.

[0073] Finally, the normalized texture features obtained from cross-frame tracking are correlated in chronological order to form a texture feature time series, thereby constructing a continuous texture feature time series for each local surface region, providing a reliable data foundation for subsequent evaluation of anomalous feature points based on the time dimension.

[0074] The proposed solution acquires the current distribution parameters of the fused texture features in real time and dynamically adjusts the normalization parameters based on a defect sensitivity factor. This enables the normalization process to adaptively address differences in texture feature distribution between different particles or batches, effectively highlighting defect features and reasonably suppressing normal fluctuations. Simultaneously, by performing cross-frame tracking on the normalized texture features, it ensures that the texture features of the same particle in multiple frames can be accurately correlated, providing stable input for subsequent anomaly detection based on temporal continuity and reducing misjudgments or missed judgments caused by particle movement or posture changes.

[0075] In another embodiment of this application, it is further proposed that, for each independent region, the current distribution parameters of the fused texture features be obtained, including: S2341-1: Perform multi-scale structural analysis on the fused texture features to identify whether there are non-defect structures such as microbubbles or depressions on the surface of particles corresponding to independent regions, and obtain the multi-scale structural analysis results. S2341-2: Based on the results of multi-scale structural analysis, the fused texture features are divided into regions to distinguish between potential defect regions and non-defect structural regions. S2341-3: Calculate the regional statistics of the fused texture features for both potential defective regions and non-defective structural regions respectively; S2341-4: Adjust the representation weight of the current distribution parameter based on the difference between the regional statistics of the potentially defective region and the regional statistics of the non-defective structural region; S2341-5: Based on the adjusted representation weights, calculate the second mean and second standard deviation of the fused texture features as the current distribution parameters.

[0076] Specifically, multi-scale structural analysis of the fused texture features involves decomposing and reconstructing the fused texture features of the particle surface using analysis kernels or transformation methods at different scales, such as wavelet transform, Gabor filter banks, or Difference of Gaussians (DoG), thereby capturing the structural information of the particle surface at different spatial frequencies. The aim is to identify and distinguish small, regularly shaped structures on the particle surface that are not defects, such as microbubbles or slight depressions formed during production. These structures may resemble the fused texture features of real defects at a single scale, but exhibit different response patterns under multi-scale structural analysis. The resulting multi-scale structural analysis results are used to characterize the structural properties of different regions on the particle surface.

[0077] Among these, region division based on multi-scale structural analysis results refers to dividing independent regions into at least two categories—potentially defective regions and non-defective structural regions—based on the structural characteristics reflected in the multi-scale structural analysis results. For example, a structural feature threshold can be set: if the structural feature value of a region exceeds this threshold, it is determined to be a potentially defective region; otherwise, it is determined to be a non-defective structural region. The purpose of this region division is to provide regional differentiation for subsequent parameter calculations, allowing regions with different properties to be treated differently in statistical and weighting processes.

[0078] In practical applications, calculating the regional statistics of the fused texture features for potential defective regions and non-defective structural regions respectively means calculating statistical measures such as mean, standard deviation, variance, skewness, kurtosis or entropy for the fused texture feature values ​​of pixels or local surface regions in each type of region, in order to more precisely describe the distribution characteristics of the fused texture features of different regions.

[0079] Furthermore, based on the difference between the regional statistics of potentially defective regions and the regional statistics of non-defective structural regions, the representation weights of the current distribution parameters are adjusted. This means using the difference between the two types of regional statistics as the basis for weight adjustment: when the difference is large, the representation weight of potentially defective regions is increased and the representation weight of non-defective structural regions is decreased; when the difference is small, the weight adjustment magnitude is correspondingly reduced. The purpose is to make the final current distribution parameters more focused on the fused texture feature changes related to real defects, and to reduce the interference of non-defective structures such as microbubbles or depressions on parameter estimation.

[0080] Therefore, based on the adjusted representation weights, the second mean and second standard deviation of the fused texture features are calculated as the current distribution parameters. This means that representation weights are introduced into the calculation of the second mean and second standard deviation, so that the fused texture features of the potential defect region contribute more to the second mean and second standard deviation. This makes the current distribution parameters more representative of the defect degree of the particles, rather than just a simple statistical result of the entire independent region.

[0081] In another embodiment of this application, it is further proposed that the normalization processing parameters be adjusted according to the current distribution parameters and the preset defect sensitivity factor, including: S2342-1: Obtain the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch, compare the current distribution parameters with the historical distribution range, and obtain the degree of deviation of the current distribution parameters relative to the historical distribution range. The historical distribution range includes at least the historical mean range and / or historical fluctuation range of the corresponding fused texture features. S2342-2: Dynamically adjust the defect sensitivity factor based on the degree of offset; S2342-3: Adjust the normalization parameters based on the adjusted defect sensitivity factor and the current distribution parameters.

[0082] Specifically, obtaining the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch refers to the system continuously collecting and storing the fused texture feature data of particles identified as normal in different production batches, and constructing a statistical model based on this historical data to characterize the typical distribution range of the fused texture features of normal particles. This historical distribution range can serve as a baseline or reference standard for the fused texture features of normal particles, providing an objective basis for comparison for the current production batch. The historical distribution range includes at least the historical mean range and / or historical fluctuation range of the corresponding fused texture features, such as the range defined by recording the average value and standard deviation of historical normal particle texture features, or its distribution range defined by non-parametric methods (such as quantiles).

[0083] Comparing the current distribution parameters with historical distribution ranges yields the degree of deviation of the current distribution parameters relative to the historical distribution range. This involves comparing the second average and second standard deviation of the fused texture features of the particles in the current production batch with the historical distribution range. For example, the distance of the current average value relative to the historical average range can be calculated, or the overlap or difference between the current standard deviation and the historical fluctuation range can be calculated. The degree of deviation is used to quantify the degree of difference between the current production batch and historical normal production conditions to identify whether the current production batch deviates from normal production conditions.

[0084] Dynamically adjusting the defect sensitivity factor based on the degree of deviation refers to real-time correction of the preset defect sensitivity factor according to the degree of deviation of the texture feature distribution after fusion of the current production batch from the historical normal distribution. For example, when the second average value of the texture features after fusion of the current production batch deviates significantly from the historical average range, it can be considered that the overall production status has changed skewed. At this time, by adjusting the defect sensitivity factor, the defect judgment sensitivity is matched with the actual situation of the current production batch, avoiding misjudgment or missed judgment caused by a fixed sensitivity.

[0085] Based on the adjusted defect sensitivity factor and the current distribution parameters, the normalization parameters are adjusted. This means that after the dynamic adjustment of the defect sensitivity factor is completed, the parameters used for subsequent normalization processing are recalculated and set in combination with the second average value and the second standard deviation of the current production batch. These parameters include scaling factors and translation amounts in the normalization function, to ensure that the normalized texture features can accurately reflect the true surface characteristics of the particles and provide a consistent and reliable data basis for subsequent abnormal feature point marking.

[0086] In some preferred embodiments, it is assumed that the system continuously collects and stores the fused texture feature data of the past one hundred normal production batches, and constructs a historical distribution range accordingly, where the historical mean range is [0.4, 0.6] and the historical fluctuation range (standard deviation) is [0.05, 0.1]. When a new production batch begins to be evaluated, the system calculates the second average value and the second standard deviation of the fused texture features of the particles in the current production batch, for example, the second average value is 0.65 and the second standard deviation is 0.12, and compares the current distribution parameters with the historical distribution range. Specifically, the current average value of 0.65 is higher than the upper limit of the historical mean range [0.4, 0.6], and the current standard deviation of 0.12 is higher than the upper limit of the historical fluctuation range [0.05, 0.1], indicating that the current production batch may be slightly brighter or have slightly greater fluctuations overall. The system determines the degree of offset based on this and dynamically adjusts the preset defect sensitivity factor. For example, the preset defect sensitivity factor is fine-tuned from 0.8 to 0.75 to avoid oversensitivity to slight overall offsets and false alarms. Subsequently, the system recalculates and sets the normalization processing parameters based on the adjusted defect sensitivity factor of 0.75 and the current distribution parameters (0.65, 0.12). For example, the scaling factor and offset in the normalization function are adjusted so that the normalized texture features can still accurately reflect local relative anomalies and provide a reliable data basis for subsequent anomaly feature point marking.

[0087] In another embodiment of this application, it is further proposed to obtain the historical distribution range of the fused texture features of normal particles that meet preset normal screening conditions in the current production batch, including: S2342-11: Calculate the morphological parameters and brightness distribution parameters of the independent regions of each particle, and determine the particles that meet the preset normal screening conditions as reference samples based on whether the morphological parameters and brightness distribution parameters fall within the corresponding preset normal range. S2342-12: For a reference sample, collect its image data and extract the fused texture features, calculate the reference statistics of the fused texture features of the reference sample, and the reference statistics include at least the reference mean and the reference standard deviation. S2342-13: Compare the reference statistic with the distribution range of similar historical normal texture features of batches with similar process parameters in the past to obtain the comparison results; S2342-14: When the difference between the comparison result characterizing the reference statistic and the distribution range of similar historical normal texture features exceeds the preset difference threshold and / or the amount of historical data is insufficient, increase the sampling frequency of the fused texture features of normal particles in the current production batch, continuously update the reference statistic, and construct a preliminary distribution range of normal texture features based on the updated reference mean and reference standard deviation. S2342-15: Based on the number of normal particles sampled in the reference sample and the distribution stability of the fused texture features, generate and adjust the confidence evaluation factor. When the confidence evaluation factor is less than the preset confidence threshold, the preset initial distribution range is used as the initial value of the initial historical normal distribution range, and it gradually converges to the initial normal texture feature distribution range as the confidence evaluation factor increases. S2342-16: Based on the similarity between the key process parameters of the current production batch and the key process parameters of similar historical batches, the initial historical normal distribution range after convergence is weighted and corrected to obtain the corrected historical distribution range. The corrected historical distribution range is then used as the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch.

[0088] Specifically, morphological parameters and brightness distribution parameters are calculated for independent regions of each particle. Based on whether these parameters fall within their respective preset normal ranges, particles meeting the preset normal screening criteria are selected as reference samples. Morphological parameters are quantitative indicators describing particle shape and size, such as aspect ratio, roundness, area, and perimeter. Brightness distribution parameters characterize the uniformity and variation of particle surface brightness, such as average brightness, brightness standard deviation, and brightness histogram. By setting preset normal ranges, particles meeting the normal appearance standards can be initially screened as the benchmark for subsequent analysis. The purpose is to exclude obviously abnormal or incomplete particles, ensuring the representativeness of the reference samples.

[0089] Furthermore, for the reference sample, its image data is collected and the fused texture features are extracted. Reference statistics for the fused texture features of the reference sample are calculated, including at least the reference mean and reference standard deviation. These reference statistics are used to quantify the central tendency and dispersion of the normal particle texture features of the current production batch, providing a basis for subsequent comparisons with historical data.

[0090] The reference statistic is used to compare the distribution range of similar historical normal texture features with that of batches with similar process parameters in the past, yielding a comparison result. The distribution range of similar historical normal texture features refers to the statistical distribution characteristics of the texture features of normal particles in historical batches under similar production conditions, such as their mean range and fluctuation range. This comparison allows for the assessment of the consistency between the texture features of normal particles in the current production batch and historical experience data, in order to identify any potential overall biases.

[0091] In practical applications, when the difference between the comparison result representing the reference statistic and the distribution range of similar historical normal texture features exceeds a preset difference threshold and / or the amount of historical data is insufficient, the sampling frequency of the fused texture features of normal particles in the current production batch is increased, and the reference statistic is continuously updated. A preliminary distribution range of normal texture features is constructed based on the updated reference mean and reference standard deviation. The preset difference threshold is used to determine whether the difference is significant, for example, by setting it according to statistical significance or deviation factor. When significant differences occur or the amount of data is insufficient, the sampling frequency is increased and the reference statistic is updated continuously to make the preliminary distribution range of normal texture features closer to the true distribution of the current production batch, thereby improving representativeness and statistical reliability.

[0092] Furthermore, a confidence assessment factor is generated and adjusted based on the number of normal particles sampled in the reference sample and the distribution stability of the fused texture features. When the confidence assessment factor is less than a preset confidence threshold, a preset initial distribution range is used as the initial value of the initial historical normal distribution range, and it gradually converges to the initial normal texture feature distribution range as the confidence assessment factor increases. The confidence assessment factor can comprehensively consider factors such as the number of samples, data volatility, and time series stability to quantify statistical reliability. When there are insufficient samples or unstable distributions, a wider initial distribution range is used to reduce the risk of misjudgment. As data accumulates and stability improves, it gradually converges to a more precise initial normal texture feature distribution range to balance initial robustness and later accuracy.

[0093] Finally, by combining the similarity of key process parameters of the current production batch with those of similar historical batches, the initial historical normal distribution range after convergence is weighted and corrected to obtain the corrected historical distribution range. This corrected historical distribution range is then used as the historical distribution range of the fused texture features of normal particles in the current production batch that meet the preset normal screening conditions. Key process parameters include, for example, drying temperature, mixing time, and tableting pressure, which affect particle texture features. By weighting and correcting based on similarity, the final historical distribution range can better fit the current production conditions, improving accuracy and applicability.

[0094] One specific implementation method is as follows: Suppose a new batch of veterinary medicine granules needs to be evaluated for quality on a production line. First, a batch of granule images is randomly selected from the batch. For each granule's independent region, morphological parameters such as aspect ratio and roundness, as well as brightness distribution parameters such as average brightness and brightness standard deviation, are calculated. Preset normal ranges are established, for example, the aspect ratio should be between 0.8 and 1.2, and the average brightness should be between 150 and 200. Granules whose morphological and brightness distribution parameters fall within these normal ranges are selected as reference samples. For these reference samples, their fused texture features are extracted, and the reference mean and reference standard deviation of these features are calculated. These reference statistics are compared with the historical mean and historical fluctuation ranges of normal granule texture features from batches with similar production processes (e.g., the same drying temperature and mixing time) over the past three months. If a significant deviation is found between the current batch's reference average and the historical average range (e.g., exceeding the historical average range by 2 standard deviations), or if the number of reference samples in the current batch is insufficient (e.g., less than 500), the system will automatically increase the sampling frequency of the fused texture features of normal particles in the current batch, for example, from sampling 1 per 100 particles to sampling 1 per 50 particles. Simultaneously, the reference average and reference standard deviation will be continuously updated, and a preliminary distribution range of normal texture features will be constructed based on these updated statistics.

[0095] As the number of reference samples increases and the texture feature distribution stabilizes, the system generates a confidence assessment factor. For example, when the number of samples reaches 500 and the standard deviation of the texture features fluctuates by less than 5% within 100 consecutive samples, the confidence assessment factor gradually increases. If the initial confidence assessment factor is low (e.g., less than 0.6), the system first uses a relatively broad preset initial distribution range (e.g., ±10% of the historical maximum and minimum values) as the initial value for the initial historical normal distribution range. As the confidence assessment factor increases, this initial range gradually converges and approaches the previously constructed preliminary normal texture feature distribution range. Finally, the system combines the key process parameters of the current batch (e.g., drying time of 2 hours, mixing speed of 100 rpm) with the similarity weights of batches with similar process parameters in historical batches. For example, if the drying time of the current batch is exactly the same as that of a historical batch, the data from that historical batch will be given a higher weight during the correction process. Through this weighted correction, a corrected historical distribution range that accurately reflects the characteristics of the current production batch is finally obtained, which is used for subsequent normalization parameter adjustments.

[0096] Reference Figure 2 The specific embodiments of this application also disclose an image recognition-based quality evaluation system for antibiotic-free traditional Chinese veterinary drugs, including: Image data acquisition module 1 is used to acquire image data containing the veterinary drug granules to be evaluated; The particle recognition and separation module 2 is used to segment the image data to identify and separate each particle in the image data, and obtain the independent region of each particle; wherein, the segmentation process includes at least threshold segmentation and morphological processing, and separates the adhered regions when particles are adhered. The texture feature acquisition module 3 is used to perform local scanning within each independent region using a preset local analysis window to determine multiple local surface regions and acquire the texture features of each local surface region. The abnormal region judgment module 4 is used to mark abnormal feature points that meet the preset abnormality criteria in an independent region based on texture features, and to determine whether the abnormal feature points form an abnormal feature point cluster with preset spatial distribution characteristics on the particle surface. When it is determined that an abnormal feature point cluster has been formed, it is determined that there is an abnormal region in the independent region. The preset spatial distribution characteristics include at least one or more of the following: the connectivity clustering relationship of abnormal feature points and the clustering scale threshold. The quality evaluation result output module 5 is used to output the quality evaluation results of veterinary drug granules based on the judgment results of abnormal areas.

[0097] The image recognition-based quality evaluation system for antibiotic-free traditional Chinese veterinary medicine proposed in this application aims to effectively identify the slight "oily" defects on the surface of traditional Chinese veterinary medicine granules through the synergistic effect of its various functional modules, thereby improving the accuracy of quality evaluation.

[0098] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition, characterized in that, include: Acquire image data containing the veterinary drug granules to be evaluated; The image data is segmented to identify and separate individual particles in the image data, obtaining independent regions for each particle; wherein the segmentation process includes at least threshold segmentation and morphological processing, and separates the adhered regions when particles are adhered. For each of the independent regions, a preset local analysis window is used to perform a local scan within the independent region to determine multiple local surface regions and obtain the texture features of each local surface region. Based on the texture features, abnormal feature points that meet the preset abnormality criteria are marked in the independent area. It is determined whether the abnormal feature points form an agglomeration of abnormal feature points with preset spatial distribution characteristics on the particle surface. When it is determined that an agglomeration of abnormal feature points has been formed, it is determined that there is an abnormal area in the independent area. The preset spatial distribution characteristics include at least one or more of the following: the connectivity and aggregation relationship of abnormal feature points and the aggregation scale threshold. Based on the judgment results of the abnormal areas, the quality evaluation results of the traditional Chinese veterinary medicine granules are output.

2. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 1, characterized in that, The image data includes acquiring a multi-frame image sequence containing the veterinary drug granules to be evaluated. The segmentation process of the image data to identify and separate each particle in the image data, obtaining the independent region of each particle, includes: The image data is segmented, including segmenting each frame of the multi-frame image sequence to identify and separate each particle in each frame and obtain the independent region of each particle. For each of the independent regions, a preset local analysis window is used to perform a local scan within the independent region to determine multiple local surface regions and obtain the texture features of each local surface region, including: For each independent region, a preset local analysis window is used to perform a local scan within the independent region to determine multiple local surface regions, obtain the texture features of each local surface region, and obtain the time series of the texture features of the corresponding local surface regions in the multi-frame image sequence. The step of marking abnormal feature points that satisfy preset anomaly criteria within the independent region based on the texture features includes: The persistence of the texture features in the time dimension is evaluated based on the time series of the texture features to mark the abnormal feature points that meet the preset anomaly criteria.

3. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 2, characterized in that, The persistence of the texture features in the time dimension is evaluated based on the texture feature time series to mark abnormal feature points that meet the preset anomaly criteria, including: Within a preset time window, calculate the first average value and the first standard deviation of the texture feature time series; A dynamic threshold is set based on the first average value and the first standard deviation; Check whether the texture feature time series has at least a preset proportion of frames that meet the abnormality criteria defined by the dynamic threshold within the preset time window; The local trend of the texture feature time series is analyzed. The local trend is used to characterize the direction of change and fluctuation stability of the texture feature time series within the preset time window. When the direction of change continuously points to a preset abnormal direction within the preset time window and meets the preset fluctuation stability judgment condition, it is determined to be a stable abnormal trend. The preset fluctuation stability judgment condition includes at least: the first standard deviation of the texture feature time series within the preset time window is less than a preset fluctuation threshold. When the texture feature time series meets the preset frame rate requirement and / or the local trend is characterized as a stable abnormal trend, the corresponding local surface region is determined to meet the preset abnormality criterion, and the corresponding abnormal feature point is marked.

4. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 2, characterized in that, Obtaining the texture features of each of the local surface regions, and obtaining the time series of the texture features of the corresponding local surface regions in the multi-frame image sequence, including: Based on the degree of variation of the texture features of each local surface region within the independent region in the spatial dimension, the window size of the local analysis window is adjusted to form at least two different scales of local analysis windows; Multiple sets of texture features are extracted from the local surface region based on at least two different scales of the local analysis window; Multiple sets of texture features are fused to obtain the fused texture features. The fused texture features are normalized to obtain normalized texture features, and the normalized texture features are organized in the multi-frame image sequence according to the frame order to form the texture feature time series.

5. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 1, characterized in that, The image data is segmented to identify and separate individual particles within the image data, including: The image data is preprocessed to suppress random noise and retain particle edge information, resulting in preprocessed image data. The preprocessed image data is segmented using the Otsu method and / or a local adaptive thresholding method to distinguish the threshold segmentation results between granular regions and background regions. A morphological opening operation is performed on the threshold segmentation result to remove noise and smooth particle edges; When particles are adhered, the seed points for segmentation of the adhered region are determined based on distance transformation, and the watershed algorithm is used to separate the adhered region to achieve separation of adhered particles.

6. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 4, characterized in that, The fused texture features are normalized to obtain normalized texture features, and these normalized texture features are organized in the multi-frame image sequence according to frame order to form the texture feature time series, including: For each independent region, the current distribution parameters of the fused texture features are obtained, wherein the current distribution parameters include at least the second mean and the second standard deviation; Based on the current distribution parameters and the preset defect sensitivity factor, the normalization processing parameters are adjusted to adapt to the distribution differences of the fused texture features under different particles or different batches. Based on the adjusted normalization parameters, the fused texture features are adaptively normalized to obtain normalized texture features. Cross-frame tracking is performed on the normalized texture features to associate the corresponding local surface regions of the same particle in different frames; The normalized texture features obtained from cross-frame tracking are then correlated in chronological order to form the texture feature time series.

7. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 6, characterized in that, For each of the independent regions, obtain the current distribution parameters of the fused texture features, including: Multi-scale structural analysis is performed on the fused texture features to identify whether there are non-defect structures such as microbubbles or depressions on the surface of the corresponding particles in the independent regions, and the multi-scale structural analysis results are obtained. Based on the results of the multi-scale structural analysis, the fused texture features are divided into regions to distinguish between potential defect regions and non-defect structural regions. For the potential defect region and the non-defect structural region respectively, calculate the region statistics of the fused texture features of the corresponding regions; The representation weights of the current distribution parameters are adjusted based on the difference between the regional statistics of the potential defective region and the regional statistics of the non-defective structural region. Based on the adjusted representation weights, the second mean and second standard deviation of the fused texture features are calculated as the current distribution parameters.

8. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 6, characterized in that, Based on the current distribution parameters and the preset defect sensitivity factor, adjust the normalization processing parameters, including: Obtain the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch, compare the current distribution parameter with the historical distribution range, and obtain the degree of deviation of the current distribution parameter relative to the historical distribution range. The historical distribution range includes at least the historical mean range and / or historical fluctuation range of the corresponding fused texture features. The defect sensitivity factor is dynamically adjusted based on the degree of offset. The normalization parameters are then adjusted based on the adjusted defect sensitivity factor and the current distribution parameters.

9. The method for quality evaluation of antibiotic-free traditional Chinese veterinary drugs based on image recognition according to claim 8, characterized in that, Obtain the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch, including: The morphological parameters and brightness distribution parameters of each particle's independent region are calculated, and particles that meet the preset normal screening conditions are determined as reference samples based on whether the morphological parameters and brightness distribution parameters fall within the corresponding preset normal range. For the reference sample, its image data is collected and the fused texture features are extracted. The reference statistics of the fused texture features of the reference sample are calculated. The reference statistics include at least the reference mean and the reference standard deviation. The reference statistics are compared with the distribution range of similar historical normal texture features of batches with similar process parameters in the past to obtain the comparison results; When the comparison result indicates that the difference between the reference statistic and the distribution range of similar historical normal texture features exceeds a preset difference threshold and / or the amount of historical data is insufficient, the sampling frequency of the fused texture features of normal particles in the current production batch is increased, the reference statistic is continuously updated, and a preliminary distribution range of normal texture features is constructed based on the updated reference mean and reference standard deviation. Based on the number of normal particles sampled in the reference sample and the distribution stability of the fused texture features, a confidence evaluation factor is generated and adjusted. When the confidence evaluation factor is less than the preset confidence threshold, the preset initial distribution range is used as the initial value of the initial historical normal distribution range, and as the confidence evaluation factor increases, it gradually converges to the initial normal texture feature distribution range. By combining the similarity between the key process parameters of the current production batch and the key process parameters of similar historical batches, the initial historical normal distribution range after convergence is weighted and corrected to obtain the corrected historical distribution range. The corrected historical distribution range is then used as the historical distribution range of the fused texture features of normal particles that meet the preset normal screening conditions in the current production batch.

10. A quality evaluation system for antibiotic-free traditional Chinese veterinary drugs based on image recognition, characterized in that, include: The image data acquisition module is used to acquire image data containing the veterinary drug granules to be evaluated. The particle recognition and separation module is used to segment the image data to identify and separate each particle in the image data, obtaining an independent region for each particle; wherein, the segmentation process includes at least threshold segmentation and morphological processing, and separates the adhered regions when particles are adhered. The texture feature acquisition module is used to perform local scanning within each independent region using a preset local analysis window to determine multiple local surface regions and acquire the texture features of each local surface region. An abnormal region determination module is used to mark abnormal feature points that meet preset abnormality criteria in the independent region based on the texture features, determine whether the abnormal feature points form an anomalous feature point cluster with preset spatial distribution characteristics on the particle surface, and determine that there is an abnormal region in the independent region when it is determined that an anomalous feature point cluster has formed. The preset spatial distribution characteristics include at least one or more of the following: the connectivity clustering relationship of abnormal feature points and the clustering scale threshold. The quality evaluation result output module is used to output the quality evaluation result of the traditional Chinese veterinary medicine granules based on the judgment result of the abnormal area.