Intelligent detection system and method for pharmaceutical particles based on image processing

Through multi-scale residual information enhancement and structure-guided filtering technology, combined with the graph neural network, the efficient and accurate identification of microcracks and foreign matter adhesion in drug particle detection is solved, high-precision intelligent detection is achieved, and the quality control level of the pharmaceutical industry is improved.

CN120235871BActive Publication Date: 2025-08-08SHANDONG ZHONGTAI PHARMA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510715401.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-08-08
Estimated Expiration
2045-05-30

AI Technical Summary

Technical Problem

The prior art is difficult to efficiently and accurately detect defects such as microcracks and foreign matter adhesion of pharmaceutical particles in complex backgrounds, and traditional methods are difficult to meet the high-precision and high-efficiency quality inspection needs of the pharmaceutical industry.

Method used

Multi-scale residual information enhancement, structure-guided filtering, hierarchical contour evolution and graph neural network (GNN) technology is used to enhance image microstructure through multi-scale residual information, combined with local contrast normalization and space-pixel joint filter, suppress noise and retain edges, and segmentation using direction-aware structural gradients and regional shape priors, and model the spatial semantic relationship between regions with boundary relative potential graphs and graph neural networks to achieve defect recognition and classification.

Benefits of technology

It improves the accuracy and adaptability of drug particle detection, realizes sensitive identification and high-precision classification of small and weak and significant defects, and improves the intelligence and automation level of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120235871B_ABST
    Figure CN120235871B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image defect detection technology, specifically to an intelligent pharmaceutical particle detection system and method based on image processing. The method uses a high-resolution industrial camera and a polarized light source to dynamically capture pharmaceutical particles on an assembly line to obtain high-quality original images from multiple angles. Multi-scale residual information enhancement and structure-preserving adaptive filtering are used to achieve noise suppression and microstructure enhancement, and local contrast normalization is used to improve detail resolution. Directionally aware multi-scale structural gradients and regional shape priors are integrated, and hierarchical contour evolution and dynamic thresholding strategies are used to accurately segment the main particle contour and microcracks. A multi-scale texture perception algorithm guided by boundary relative potential maps is used to identify minor defects, and multi-category defect classification is achieved through graph neural network modeling of spatial and semantic dependencies between regions. Finally, a traceable quality inspection report is generated. The present invention improves the intelligence, accuracy, and automation of pharmaceutical particle detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image defect detection, and in particular to an intelligent drug particle detection system and method based on image processing. Background Art

[0002] Pharmaceutical particle quality testing is a core link in the pharmaceutical production process and is directly related to the safety and efficacy stability of drugs. With the expansion of pharmaceutical production scale and the improvement of quality control standards, traditional methods relying on manual visual inspection or semi-automatic equipment are gradually unable to meet the needs of high-precision and high-efficiency quality inspection. In recent years, the deep integration of image processing technology, machine learning algorithms and industrial inspection equipment has provided new directions for automated inspection. However, the detection of defects such as microcracks and foreign matter attachment on the surface of pharmaceutical particles in complex backgrounds (such as non-uniform illumination, high noise, and low contrast) still faces challenges.

[0003] The Chinese invention patent application with announcement number CN118527377B discloses a fragment detection and rejection device and method, which includes obtaining an image sequence of a predetermined area from a high-definition camera illuminated by a mesh projection; preprocessing and preliminary segmenting the image sequence to obtain a two-dimensional image mask of the segmented tablets, and constructing a two-dimensional and three-dimensional data set of the tablets in combination with the two-dimensional image mask; based on the two-dimensional and three-dimensional data sets, performing image registration and fusion, and performing fine segmentation, texture analysis, shape analysis and spectral feature extraction to obtain a comprehensive data set of tablets; reading the comprehensive data set, calling the pre-configured comprehensive defect feature vector, using an integrated learning module to finely classify the fine modules, and evaluating the severity of the defects based on the fine classification results to give an overall quality score for the tablets; if the overall quality score is less than a threshold, issuing a rejection instruction to the rejection mechanism; by purely visually rejecting fragments, the problem that the photoelectric counter is easily blocked by dust, resulting in counting and detection errors, is solved.

[0004] With the increasing demand for intelligence and automation in the pharmaceutical industry, the development of efficient and accurate intelligent detection systems has become an urgent need in the industry. This invention aims to optimize the accuracy and adaptability of drug particle defect detection by combining technologies such as multi-scale residual enhancement, structure-guided filtering, hierarchical contour evolution, and graph neural networks (GNNs), providing technical support for the standardization and intelligence of pharmaceutical production line quality control. Summary of the Invention

[0005] The purpose of the present invention is to address the problems existing in the background technology and to propose an intelligent detection system and method for pharmaceutical particles based on image processing.

[0006] The technical solution of the present invention is an intelligent detection method for pharmaceutical particles based on image processing, which includes the following specific implementation steps:

[0007] S1, collect original images of drug particles on the production line;

[0008] S2: Extract detail residuals by constructing a multi-scale Gaussian blurred image, enhance image microstructure by weighted fusion of multi-scale residual information, improve discrimination by combining local contrast normalization, and use a spatial-pixel joint guided filter to suppress noise and preserve edges. Finally, generate an enhanced image through an adaptive fusion strategy;

[0009] The enhancement process of image microstructure enhancement by weighted fusion of multi-scale residual information is as follows:

[0010] S21. Based on the original image I(x,y), construct Gaussian blurred images of several scales : ;

[0011] in, Represents a two-dimensional Gaussian kernel function, whose standard deviation Control the degree of blur, i=1, 2, ..., n; Represents a two-dimensional convolution operation; n represents different blur scales; Indicated on scale The blurred image below;

[0012] S22. Perform a difference operation between the original image and the blurred images at each scale to extract the detail residual information at the corresponding scale: ;

[0013] The multi-scale residuals are then weighted fused to form an enhanced image:

[0014] ;

[0015] in, Representation scale Detailed residual plot below; Indicates the corresponding scale The residual information weight under ; Represents the image enhancement result after fusing multi-scale detail information;

[0016] S3, generates the main structure response map through direction-aware multi-scale structural gradient, builds the edge confidence fusion map based on regional shape prior, adopts the hierarchical contour evolution model and dynamic threshold strategy, adaptively adjusts the segmentation threshold based on regional mean and local texture variance, and outputs the segmentation mask;

[0017] S4. Construct the boundary relative potential field based on the segmentation mask, combine it with the calculation of multi-directional texture perturbation intensity, capture the damage of defects to directional consistency, generate a texture enhancement feature map by weighted fusion of the perturbation map and the potential map, extract the regional average perturbation intensity, standard deviation, skewness and kurtosis to construct the regional level defect perception texture feature vector;

[0018] S5. By constructing texture anomaly density mapping and morphological heterogeneity parameters, integrating texture-morphology joint scoring, and statistically discriminating defect areas based on dynamic thresholds, a multi-category defect classification method based on graph structure is combined with graph neural network (GNN) to model the spatial semantic relationship between regions and identify defect categories.

[0019] S6. Perform result annotation and visualization processing on the particles that have been identified as defects, and output a traceable defect detection report.

[0020] Preferably, the enhancement process of generating an enhanced image by the adaptive fusion strategy is as follows:

[0021] B1. Use local contrast normalization method to normalize the image: ;

[0022] in, represents the normalized image after contrast adjustment; Represents the average value of the neighborhood with radius r as the center; Represents the standard deviation of the neighborhood with radius r centered at point (x, y); Represents a very small positive number;

[0023] B2. Use structure-guided filters to remove random noise but retain structural edges:

[0024] ;

[0025] ;

[0026] in, Represents a local window centered at pixel p=(x,y); Represents the space-pixel value joint guidance weight; represents the standard deviation of the spatial domain; represents the standard deviation of pixel intensity differences; represents the normalization factor; represents the natural exponential function; represents the denoised image; p represents the current pixel coordinate, p=(x,y); q represents the neighborhood pixel coordinate, q=(i,j);

[0027] B3. Fuse the original image with the structure-preserving image to generate the final enhanced image:

[0028] ;

[0029] in, Represents the final output image; represents the fusion weight coefficient, .

[0030] Preferably, the generation process of the edge confidence fusion map is as follows:

[0031] S31, Multi-scale structure gradient extraction operator using direction awareness , construct a structural response plot:

[0032] ;

[0033] in, Indicates the main direction of the formulation; s indicates the scale parameter, ; represents the direction-scale structure gradient operator; Represents the gradient response map under direction θ and scale s;

[0034] Then the multi-scale responses are fused to obtain the main structure response map : ;

[0035] S32. Construct a local area prior map: ;

[0036] in, Represents a neighborhood with a radius of r and a point (x, y) as the center; and Represent the neighborhood grayscale mean and standard deviation respectively; represents the regional shape prior response map;

[0037] S33, combined with the main structure response diagram Response plot with regional shape priors , and the fusion gets the edge confidence fusion map: ;

[0038] in, Represents the normalization function, mapping the value range to [0,1]; represents the fusion weight of edge and regional responses, ; Represents the final edge confidence map.

[0039] Preferably, the segmentation process of the segmentation mask is as follows:

[0040] The edge confidence map Input into the hierarchical contour evolution model and use dynamic threshold strategy for region segmentation:

[0041] ;

[0042] ;

[0043] Among them, k represents the current segmentation level; Represents the segmentation mask of the kth layer, and a value of 1 indicates that the target belongs to this layer; Represents the dynamic threshold at the kth layer, based on the regional mean , local texture variance Adaptive settings: Represents the segmentation sensitivity control parameter of the k-th layer.

[0044] Preferably, the construction process of the region-level defect-aware texture feature vector is as follows:

[0045] S41, based on segmentation mask , construct the relative potential field from each candidate region to its contour boundary, capturing the texture attenuation trend from the interior of the region toward the boundary: ;

[0046] in, Represents the relative potential of the boundary of pixel point (x, y) in region k; Represents the Euclidean distance from a point (x, y) to the boundary of the corresponding region; Represents the Gaussian scale parameter that controls the distance decay rate;

[0047] S42. In each area, along Calculate the local texture perturbation intensity in multiple directions:

[0048] ;

[0049] Among them, I(x,y) represents the grayscale value of the original image; Indicates the pixel offset corresponding to direction θ; represents the texture perturbation intensity in the direction θ;

[0050] The comprehensive perturbation map is then calculated : ;

[0051] S43, the disturbance graph Relative potential diagram Weighted fusion introduces regional potential into texture perturbation modeling to form a texture enhancement feature map: ;

[0052] in, Represents the texture potential fusion map of region k; represents the potential weight adjustment factor, ;

[0053] S44. For each region S k Texture fusion feature map Perform statistical coding: ; ;

[0054] in, represents the regional average disturbance intensity; represents the standard deviation; represents skewness; It represents the kurtosis, which characterizes the central tendency of texture; Represents the region-level defect-aware texture feature vector.

[0055] Preferably, the defect area identification process is as follows:

[0056] S51. Construct texture abnormality density mapping function: ;

[0057] in, Represents the normalized texture anomaly density index;

[0058] S52. Calculate the geometric parameters of the region: ;

[0059] in, Indicates the perimeter of the area contour; Indicates the area of the region; represents the degree of morphological heterogeneity;

[0060] S53. Construct a joint discriminant scoring function:

[0061] ;

[0062] in, represents the regional comprehensive defect score; represents the collaborative weight of texture and morphology, ;

[0063] S54. Construct a dynamic discrimination strategy based on score distribution statistics:

[0064] ; ;

[0065] in, and Represents all regional scores separately The mean and standard deviation of represents the dynamic threshold; Represents the final regional defect discrimination label;

[0066] When the final identified regional defect discrimination label is "abnormal", the multi-category defect classification method based on graph structure is executed to identify the final defect category; otherwise, the normal result of the current drug particle is directly output.

[0067] Preferably, the implementation process of the multi-category defect classification method based on graph structure is as follows:

[0068] A1. Construct a regional graph structure G = (V, E):

[0069] Graph node V={ }: Each node Corresponding to the extracted defect area, the node features are :

[0070] ;

[0071] in, Represents the normalized texture anomaly density index; represents the regional comprehensive defect score; represents the degree of morphological heterogeneity; Indicates the compactness of the outline; represents the coordinates of the center of gravity of the region;

[0072] Graph edge E construction: The strategy for constructing graph edges is a combination of semantic space constraints and texture similarity:

[0073] ;

[0074] in, represents the Euclidean distance between the centroids of regions i and j; represents cosine similarity; and represent the spatial threshold and similarity threshold respectively; represents the edge between nodes i and j;

[0075] A2. Graph Attention Neural Network Classification Inference

[0076] Use a multi-layer graph attention network for node feature propagation and defect classification prediction:

[0077] ;

[0078] in, Represents the representation of node k in the l+1 layer, initially ; Represents the linear mapping matrix of the lth layer; represents the set of neighbor nodes of node k; represents the attention weight; Represents the LeakyReLU activation function;

[0079] The final layer output is the softmax classification probability vector :

[0080] ;

[0081] in, Represents the output of the last layer node of GNN; represents the probability that the node belongs to the cth class;

[0082] A3. According to the classification probability vector The maximum value of the output determines the final defect class:

[0083] ; ;

[0084] in, Indicates the final defect category of the region; Represents the defect confidence score.

[0085] Preferably, the main direction θ is defined as follows: .

[0086] The technical solution of the present invention is an intelligent drug particle detection system based on image processing, which is used to perform an intelligent drug particle detection method based on image processing, including:

[0087] Image acquisition module, used to collect original images of drug particles on the assembly line;

[0088] The preprocessing module uses multi-scale residual information enhancement and structure-preserving adaptive filtering to dynamically fuse residual signals of different scales and improve microstructure differentiation using local contrast normalization. It also combines a spatial-pixel joint guided filter to suppress noise and preserve edges, ultimately outputting an enhanced denoised image.

[0089] The contour extraction module is used to integrate the direction-aware multi-scale structural gradient, regional shape prior, and edge confidence response. Through the hierarchical contour evolution model combined with the dynamic threshold strategy, it adaptively segments the main contour of the drug particle and the microcracks to generate the segmentation mask;

[0090] The defect analysis module uses a multi-scale directional texture perception method guided by the boundary relative potential map to quantify gradient perturbations, structural discontinuities, and local contrast changes in defect areas. It constructs a joint discriminant score by statistically nesting and fusing texture, morphology, and spatial distribution features. It also introduces a graph neural network to model spatial semantic relationships between regions, enabling robust recognition and multi-category classification of small and weakly significant defects.

[0091] The result output module is used to annotate and visualize the test results, generate a traceable report containing defect scores, category labels, and spatial locations, and support the quality traceability of pharmaceutical particles and automated sorting decisions.

[0092] Compared with the prior art, the above technical solution of the present invention has the following beneficial technical effects:

[0093] The present invention designs an intelligent detection system and method for pharmaceutical particles based on image processing. Through multi-scale residual information enhancement and structure-preserving adaptive filtering, the recognizability of microstructures in images is effectively improved and non-uniform noise interference is suppressed. A hierarchical contour evolution model that fuses direction-aware structural gradients with regional shape priors is adopted to accurately extract the main contours and microcracks of pharmaceutical particles. A multi-scale texture perception method guided by boundary relative potential maps is introduced to improve the sensitive recognition ability of tiny and weakly significant defect areas. Spatial semantic dependency relationships between regions are constructed through graph neural networks to achieve high-precision classification of multiple categories of defects. The system as a whole has the advantages of high detection accuracy, strong adaptability, good robustness and high degree of automation, which significantly improves the intelligence level and industrial application value of pharmaceutical particle quality detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0094] Figure 1 This is a system architecture diagram of an intelligent drug particle detection system based on image processing proposed by the present invention;

[0095] Figure 2 This is a flow chart of the method for intelligent detection of drug particles based on image processing proposed by the present invention. DETAILED DESCRIPTION

[0096] Example 1, as Figure 1 As shown, the present invention proposes an intelligent drug particle detection system based on image processing, which includes: an image acquisition module, a preprocessing module, a contour extraction module, a defect analysis module and a result output module.

[0097] The image acquisition module uses a high-resolution industrial camera combined with a polarized light source to dynamically capture pharmaceutical particles on the assembly line. It precisely controls exposure, focus, and lighting parameters to obtain high-quality original images from multiple angles and light sources, providing a clear and stable image data foundation for subsequent processing.

[0098] The preprocessing module uses multi-scale residual information enhancement and structure-preserving adaptive filtering methods to dynamically fuse residual signals of different scales and use local contrast normalization to improve microstructure differentiation. It combines a spatial-pixel joint guided filter to suppress noise and preserve edges, and finally outputs an enhanced denoised image.

[0099] The contour extraction module integrates direction-aware multi-scale structural gradients, regional shape priors, and edge confidence responses. Through a hierarchical contour evolution model combined with a dynamic threshold strategy, it adaptively segments the main contours of drug particles and microcracks, generating accurate segmentation masks.

[0100] The defect analysis module uses a multi-scale directional texture perception method guided by boundary relative potential maps to quantify gradient perturbations, structural discontinuities, and local contrast changes in defect areas. It constructs a joint discriminant score by statistically nesting and fusing texture, morphology, and spatial distribution features. It also introduces a graph neural network (GNN) to model spatial semantic relationships between regions, enabling robust recognition and multi-category classification of small and weakly significant defects.

[0101] The result output module annotates and visualizes the test results, generating a traceable report containing defect scores, category labels, and spatial locations, supporting drug particle quality traceability and automated sorting decisions.

[0102] Example 2, as Figure 2 As shown, the present invention proposes an intelligent drug particle detection method based on image processing, which is applied to the intelligent drug particle detection system based on image processing proposed in Example 1. The specific implementation steps are as follows:

[0103] S1. The image acquisition module uses a high-resolution industrial camera combined with a polarized light source to dynamically capture the drug particles on the assembly line and obtain the original image I(x,y).

[0104] S2, the preprocessing module proposes a method that integrates multi-scale residual information extraction and structure-preserving adaptive filtering. By introducing multi-scale residual information enhancement, structure-preserving denoising and contrast-driven adjustment methods, the multi-scale residual signal is used as the core intermediate quantity of image enhancement. The structure-guided method and the adaptive fusion strategy are integrated to achieve adaptive enhancement and denoising of drug particle images under complex background and non-uniform noise conditions. The specific implementation process is as follows:

[0105] S21. Based on the original image I(x,y), construct Gaussian blurred images of several scales , used to simulate different levels of structural information: ;

[0106] in, Represents a two-dimensional Gaussian kernel function, whose standard deviation Control the degree of blur, i=1, 2, ..., n; Represents a two-dimensional convolution operation; n represents different blur scales; Indicated on scale The blurred image below;

[0107] S22. Perform a difference operation between the original image and the blurred images at each scale to extract the detail residual information at the corresponding scale: ;

[0108] The multi-scale residuals are then weighted fused to form an enhanced image:

[0109] ;

[0110] in, Representation scale Detailed residual plot below; Indicates the corresponding scale The residual information weight under is dynamically adjusted according to the local texture energy of the image (variance is used in this embodiment) to avoid high-frequency noise from being mistakenly enhanced. ; Represents the image enhancement result after fusing multi-scale detail information;

[0111] S23. To further improve the visual distinction of microstructures in the image, the local contrast normalization method is used to normalize the image: ;

[0112] in, represents the normalized image after contrast adjustment; Represents the average value of the neighborhood with radius r as the center; Represents the standard deviation of the neighborhood with radius r centered at point (x, y); Represents a very small positive number, used to prevent division by zero errors;

[0113] It should be noted that a neighborhood with a radius of r, centered at pixel (x,y), extends r pixels upward, downward, left, and right from the current pixel. Therefore, r rows are extended upward and r rows downward, for a total of r+r+1=2r+1 rows; r columns are extended left and r columns right, for a total of 2r+1 columns. Therefore, the size of the neighborhood (local window) is (2r+1)×(2r+1).

[0114] S24, using structure-guided filter to remove random noise but retain structural edges:

[0115] ;

[0116] ;

[0117] in, Represents a local window centered at pixel p=(x,y) (a square window centered at (x,y) with a side length of 2r+1); Represents the space-pixel value joint guidance weight; Represents the standard deviation of the spatial domain, which is used to control the neighborhood weight decay; Indicates the standard deviation of pixel intensity differences, controlling edge protection capability; represents the normalization factor; represents the natural exponential function; represents the denoised image; p represents the current pixel coordinate, p=(x,y); q represents the neighborhood pixel coordinate, q=(i,j);

[0118] S25. Fuse the original image with the structure-preserving image to generate the final enhanced image:

[0119] ;

[0120] in, Represents the final output image; represents the fusion weight coefficient, .

[0121] S3, the contour extraction module integrates structural gradient, regional shape prior and edge confidence response, and integrates the regional guidance + multi-scale contour response fusion + threshold evolution joint method. The specific implementation process is as follows:

[0122] S31, Multi-scale structure gradient extraction operator using direction awareness , construct a structural response plot:

[0123] ;

[0124] in, Indicates the main direction set. The main directions set in this embodiment are ; s represents the scale parameter, which controls the receptive field of the convolution kernel. ; represents the direction-scale structure gradient operator, which in this embodiment consists of direction difference + Gaussian weight; Represents the gradient response map under direction θ and scale s;

[0125] Then the multi-scale responses are fused to obtain the main structure response map : ;

[0126] S32. Considering the relatively regular distribution of particles in the image and the obvious features of isolated regions, a local region prior map is constructed: ;

[0127] in, Represents a neighborhood with a radius of r and a point (x, y) as the center; and Represent the neighborhood grayscale mean and standard deviation respectively; represents the regional shape prior response map;

[0128] S33, combined with the main structure response diagram Response plot with regional shape priors , and the fusion gets the edge confidence fusion map: ;

[0129] in, Represents the normalization function, mapping the value range to [0,1]; represents the fusion weight of edge and regional responses, ; Represents the final edge confidence map, which comprehensively considers edge strength and regional consistency;

[0130] S34, the edge confidence map Input into the hierarchical contour evolution model and use dynamic threshold strategy for region segmentation:

[0131] ;

[0132] ;

[0133] Where k represents the current segmentation level (including but not limited to main contour, secondary contour, and microcrack); Represents the segmentation mask of the kth layer, and a value of 1 indicates that the target belongs to this layer; Represents the dynamic threshold at the kth layer, based on the regional mean , local texture variance Adaptive settings: Represents the segmentation sensitivity control parameter of the k-th layer.

[0134] S4, the defect analysis module uses a multi-scale directional texture perception method guided by the boundary relative potential map. It integrates the spatial gradient perturbation, directional structural discontinuity and adaptive local contrast change of the defect area to achieve sensitive texture expression of small and weak defect areas in complex surface images. The specific implementation process is as follows:

[0135] S41, based on segmentation mask , construct the relative potential field from each candidate region to its contour boundary, capturing the texture attenuation trend from the interior of the region toward the boundary: ;

[0136] in, Represents the relative potential of the boundary of pixel point (x, y) in region k; Represents the Euclidean distance from a point (x, y) to the boundary of the corresponding region; Represents the Gaussian scale parameter that controls the distance decay rate;

[0137] S42. In each area, along multiple directions Calculate the local texture perturbation intensity to characterize the damage of potential defects to directional consistency:

[0138] ;

[0139] Among them, I(x,y) represents the grayscale value of the original image; Indicates the pixel offset corresponding to direction θ; represents the texture perturbation intensity in the direction θ;

[0140] The comprehensive perturbation map is then calculated : ;

[0141] S43, the disturbance graph Relative potential diagram Weighted fusion introduces regional potential into texture perturbation modeling to form a texture enhancement feature map: ;

[0142] in, The texture potential fusion map of region k emphasizes the high potential defect locations with abnormal textures and close to the center within the region; represents the potential weight adjustment factor, which controls the degree of suppression of disturbance response near the boundary. ;

[0143] S44. For each region S k Texture fusion feature map Perform statistical coding to extract descriptors for subsequent defect identification: ; ;

[0144] in, represents the regional average disturbance intensity; represents the standard deviation, which measures texture instability; It represents skewness, reflecting the bias of texture distribution; It represents the kurtosis, which characterizes the central tendency of texture; Represents the region-level defect-aware texture feature vector.

[0145] S5. Defect Analysis Module Construction: A texture density mapping and collaborative threshold decision method based on irregular morphology coupling is proposed. By integrating the texture response, spatial distribution deviation, and structural geometry of the defect area through multi-layer statistical nesting, robust recognition of non-significant texture defects is performed. The specific implementation process is as follows:

[0146] S51. Construct texture abnormality density mapping function: ;

[0147] in, It represents the normalized texture anomaly density index. The larger the value, the more severe the texture anomaly.

[0148] S52. Calculate the geometric parameters of the region to assess its structural irregularity: ;

[0149] in, Indicates the perimeter of the area contour; Indicates the area of the region; Indicates the morphological heterogeneity, reflecting the complexity and irregularity of the regional edge;

[0150] S53. Construct a joint discriminant scoring function:

[0151] ;

[0152] in, represents the regional comprehensive defect score; represents the collaborative weight of texture and morphology, ;

[0153] S54. Construct a dynamic discrimination strategy based on score distribution statistics:

[0154] ; ;

[0155] in, and Represents all regional scores separately The mean and standard deviation of represents the dynamic threshold; Represents the final regional defect discrimination label;

[0156] When the final identified regional defect discrimination label is "abnormal", step S55 is executed to identify the final defect category; otherwise, the normal result of the current drug particle is directly output;

[0157] S55. A multi-category defect classification method based on graph structure, based on texture-morphology joint modeling, introduces a graph neural network (GNN) to capture the spatial semantics and texture structure dependencies between regions, achieves high-precision discrimination of multi-category defects in fine particle drug images, and outputs the final defect category.

[0158] S6. The result output module performs result annotation and visualization processing on the particles that have been identified as defects, and outputs a traceable defect detection report, including but not limited to the regional comprehensive defect score and the final regional defect identification label. and defect categories to facilitate statistics and quality traceability.

[0159] In Example 2, the present invention proposes an intelligent drug particle detection method based on image processing, which also includes a multi-category defect classification method based on graph structure. The specific implementation steps are as follows:

[0160] A1. Construct a regional graph structure G = (V, E):

[0161] Graph node V={ }: Each node Corresponding to a suspected defect area extracted, the node feature is :

[0162] ;

[0163] in, Represents the normalized texture anomaly density index; represents the regional comprehensive defect score; represents the degree of morphological heterogeneity; Indicates the compactness of the outline; Represents the coordinates of the region's center of gravity, used for edge construction and spatial constraints;

[0164] Graph edge E construction: The strategy for constructing graph edges is a combination of semantic space constraints and texture similarity:

[0165] ;

[0166] in, represents the Euclidean distance between the centroids of regions i and j; represents cosine similarity; and represent the spatial threshold and similarity threshold respectively; represents the edge between nodes i and j.

[0167] A2. Graph Attention Neural Network Classification Inference

[0168] A multi-layer graph attention network (GAT) is used for node feature propagation and defect classification prediction:

[0169] ;

[0170] in, Represents the representation of node k in the l+1 layer, initially ; Represents the linear mapping matrix of the lth layer; represents the set of neighbor nodes of node k; represents the attention weight; represents a nonlinear activation function. In this embodiment, the LeakyReLU activation function is used;

[0171] The final layer output is the softmax classification probability vector :

[0172] ;

[0173] in, Represents the output of the last layer node of GNN; represents the probability that the node belongs to the cth class.

[0174] A3. According to the classification probability vector The maximum value of the output determines the final defect class:

[0175] ; ;

[0176] in, Indicates the final defect category of the region; Represents the defect confidence score.

[0177] The embodiments of the present invention are described in detail above with reference to the accompanying drawings, but the present invention is not limited thereto. Various changes can be made within the scope of knowledge possessed by those skilled in the art without departing from the spirit of the present invention.

Claims

1. An intelligent drug particle detection method based on image processing, characterized in that: The specific implementation steps include the following: S1, collect original images of drug particles on the production line; S2: Extract detail residuals by constructing a multi-scale Gaussian blurred image, enhance image microstructure by weighted fusion of multi-scale residual information, improve discrimination by combining local contrast normalization, and use a spatial-pixel joint guided filter to suppress noise and preserve edges. Finally, generate an enhanced image through an adaptive fusion strategy; The enhancement process of image microstructure enhancement by weighted fusion of multi-scale residual information is as follows: S21. Based on the original image I(x,y), construct Gaussian blurred images of several scales : ; in, Represents a two-dimensional Gaussian kernel function, whose standard deviation Control the degree of blur, i=1, 2, ..., n; Represents a two-dimensional convolution operation; n represents different blur scales; Indicated on scale The blurred image below; S22. Perform a difference operation between the original image and the blurred images at each scale to extract the detail residual information at the corresponding scale: ; The multi-scale residuals are then weighted fused to form an enhanced image: ; in, Representation scale Detailed residual plot below; Indicates the corresponding scale The residual information weight under ; Represents the image enhancement result after fusing multi-scale detail information; S3, generates the main structure response map through direction-aware multi-scale structural gradient, builds the edge confidence fusion map based on regional shape prior, adopts the hierarchical contour evolution model and dynamic threshold strategy, adaptively adjusts the segmentation threshold based on regional mean and local texture variance, and outputs the segmentation mask; S4. Construct the boundary relative potential field based on the segmentation mask, combine it with the calculation of multi-directional texture perturbation intensity, capture the damage of defects to directional consistency, generate a texture enhancement feature map by weighted fusion of the perturbation map and the potential map, extract the regional average perturbation intensity, standard deviation, skewness and kurtosis to construct the regional level defect perception texture feature vector; S5. By constructing texture anomaly density mapping and morphological heterogeneity parameters, integrating texture-morphology joint scoring, and statistically discriminating defect areas based on dynamic thresholds, a multi-category defect classification method based on graph structure is combined with graph neural network (GNN) to model the spatial semantic relationship between regions and identify defect categories. S6. Perform result annotation and visualization processing on the particles that have been identified as defects, and output a traceable defect detection report.

2. The method for intelligent detection of pharmaceutical particles based on image processing according to claim 1, characterized in that: The enhancement process of generating enhanced images through adaptive fusion strategy is as follows: B1. Use local contrast normalization method to normalize the image: ; in, represents the normalized image after contrast adjustment; Represents the average value of the neighborhood with radius r as the center; Represents the standard deviation of the neighborhood with radius r centered at point (x, y); Represents a very small positive number; B2. Use structure-guided filters to remove random noise but retain structural edges: ; ; in, Represents a local window centered at pixel p=(x,y); Represents the space-pixel value joint guidance weight; represents the standard deviation of the spatial domain; represents the standard deviation of pixel intensity differences; represents the normalization factor; represents the natural exponential function; represents the denoised image; p represents the current pixel coordinate, p=(x,y); q represents the neighborhood pixel coordinate, q=(i,j); B3. Fuse the original image with the structure-preserving image to generate the final enhanced image: ; in, Represents the final output image; represents the fusion weight coefficient, .

3. The method for intelligent detection of pharmaceutical particles based on image processing according to claim 2, characterized in that: The generation process of the edge confidence fusion map is as follows: S31, Multi-scale structure gradient extraction operator using direction awareness , construct a structural response plot: ; in, Indicates the main direction of the formulation; s indicates the scale parameter, ; represents the direction-scale structure gradient operator; Represents the gradient response map under direction θ and scale s; Then the multi-scale responses are fused to obtain the main structure response map : ; S32. Construct a local region prior map: ; in, Represents a neighborhood with a radius of r and a point (x, y) as the center; and Represent the neighborhood grayscale mean and standard deviation respectively; represents the regional shape prior response map; S33, combined with the main structure response diagram Response plot with regional shape priors , and the fusion gets the edge confidence fusion map: ; in, Represents the normalization function, mapping the value range to [0,1]; represents the fusion weight of edge and regional responses, ; Represents the final edge confidence map.

4. The method for intelligent detection of pharmaceutical particles based on image processing according to claim 3, characterized in that: The segmentation process of the segmentation mask is as follows: The edge confidence map Input into the hierarchical contour evolution model and use dynamic threshold strategy for region segmentation: ; ; Among them, k represents the current segmentation level; Represents the segmentation mask of the kth layer, and a value of 1 indicates that the target belongs to this layer; Represents the dynamic threshold at the kth layer, based on the regional mean , local texture variance Adaptive settings: Represents the segmentation sensitivity control parameter of the k-th layer.

5. The method for intelligent detection of pharmaceutical particles based on image processing according to claim 4, characterized in that: The construction process of the region-level defect-aware texture feature vector is as follows: S41, based on segmentation mask , construct the relative potential field from each candidate region to its contour boundary, capturing the texture attenuation trend from the interior of the region toward the boundary: ; in, Represents the relative potential of the boundary of pixel point (x, y) in region k; Represents the Euclidean distance from a point (x, y) to the boundary of the corresponding region; Represents the Gaussian scale parameter that controls the distance attenuation rate; S42. In each area, along Calculate the local texture perturbation intensity in multiple directions: ; Among them, I(x,y) represents the grayscale value of the original image; Indicates the pixel offset corresponding to direction θ; represents the texture perturbation intensity in the direction θ; The comprehensive perturbation map is then calculated : ; S43, the disturbance graph Relative potential diagram Weighted fusion introduces regional potential into texture perturbation modeling to form a texture enhancement feature map: ; in, Represents the texture potential fusion map of region k; represents the potential weight adjustment factor, ; S44. For each region S k Texture fusion feature map Perform statistical coding: ; ; in, represents the regional average disturbance intensity; represents the standard deviation; represents skewness; It represents the kurtosis, which characterizes the central tendency of texture; Represents the region-level defect-aware texture feature vector.

6. The method for intelligent detection of pharmaceutical particles based on image processing according to claim 5, characterized in that: The process of identifying defective areas is as follows: S51. Construct texture abnormal density mapping function: ; in, Represents the normalized texture anomaly density index; S52. Calculate the geometric parameters of the region: ; in, Indicates the perimeter of the area contour; Indicates the area of the region; represents the degree of morphological heterogeneity; S53. Construct a joint discriminant scoring function: ; in, represents the regional comprehensive defect score; represents the collaborative weight of texture and morphology, ; S54. Construct a dynamic discrimination strategy based on score distribution statistics: ; ; in, and Represents all regional scores separately The mean and standard deviation of represents the dynamic threshold; Represents the final regional defect discrimination label; When the final identified regional defect discrimination label is "abnormal", the multi-category defect classification method based on graph structure is executed to identify the final defect category; otherwise, the normal result of the current drug particle is directly output.

7. The method for intelligent detection of pharmaceutical particles based on image processing according to claim 6, characterized in that: The implementation process of the multi-category defect classification method based on graph structure is as follows: A1. Construct a regional graph structure G = (V, E): Graph node V={ }: Each node Corresponding to the extracted defect area, the node features are : ; in, Represents the normalized texture anomaly density index; represents the regional comprehensive defect score; represents the degree of morphological heterogeneity; Indicates the compactness of the outline; represents the coordinates of the center of gravity of the region; Graph edge E construction: The strategy for constructing graph edges is a combination of semantic space constraints and texture similarity: ; in, represents the Euclidean distance between the centroids of regions i and j; represents cosine similarity; and Represent the spatial threshold and similarity threshold respectively; represents the edge between nodes i and j; A2. Graph Attention Neural Network Classification Inference Use a multi-layer graph attention network for node feature propagation and defect classification prediction: ; in, Represents the representation of node k in the l+1 layer, initially ; Represents the linear mapping matrix of the lth layer; represents the set of neighbor nodes of node k; represents the attention weight; Represents the LeakyReLU activation function; The final layer output is the softmax classification probability vector : ; in, Represents the output of the last layer node of GNN; represents the probability that the node belongs to the cth class; A3. According to the classification probability vector The maximum value of the output determines the final defect class: ; ; in, Indicates the final defect category of the region; Represents the defect confidence score.

8. The method for intelligent detection of pharmaceutical particles based on image processing according to claim 3, characterized in that: The main directions θ are defined as follows: .

9. An intelligent drug particle detection system based on image processing, which is used to execute the intelligent drug particle detection method based on image processing according to any one of claims 1 to 8, characterized in that: include: Image acquisition module, used to collect original images of drug particles on the assembly line; The preprocessing module uses multi-scale residual information enhancement and structure-preserving adaptive filtering to dynamically fuse residual signals of different scales and improve microstructure differentiation using local contrast normalization. It also combines a spatial-pixel joint guided filter to suppress noise and preserve edges, ultimately outputting an enhanced denoised image. The contour extraction module is used to integrate the direction-aware multi-scale structural gradient, regional shape prior, and edge confidence response. Through the hierarchical contour evolution model combined with the dynamic threshold strategy, it adaptively segments the main contour of the drug particle and the microcracks to generate the segmentation mask; The defect analysis module uses a multi-scale directional texture perception method guided by the boundary relative potential map to quantify gradient perturbations, structural discontinuities, and local contrast changes in defect areas. It constructs a joint discriminant score by statistically nesting and fusing texture, morphology, and spatial distribution features. It also introduces a graph neural network to model spatial semantic relationships between regions, enabling robust recognition and multi-category classification of small and weakly significant defects. The result output module is used to annotate and visualize the test results, generate a traceable report containing defect scores, category labels, and spatial locations, and support the quality traceability of pharmaceutical particles and automated sorting decisions.

Citation Information

Patent Citations

  • Debris detection and removal device and method

    CN118527377B

  • Packaging box soft edge flaw detection method and device

    CN114066809A

  • Defect detection method and system based on differentiable neural network architecture search

    CN114299000A