Image Processing-Based Quality Inspection and Control System for Amlodipine Besylate Tablets

By improving the RealNet anomaly detection network model and topology consistency decision filtering rules, the problem of high-precision automatic detection of microcracks in amlodipine besylate tablets was solved, achieving efficient and reliable detection on high-speed pharmaceutical production lines.

CN122134689APending Publication Date: 2026-06-02JIANGSU COAST PHARM CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JIANGSU COAST PHARM CO LTD
Filing Date
2026-03-02
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies make it difficult to achieve high-precision, low-false-detection-rate automated detection of white, low-contrast microcracks in amlodipine besylate tablets on high-speed pharmaceutical production lines, especially under conditions of light disturbance and changes in surface reflection, where traditional methods are prone to misjudgment or missed detection.

Method used

An improved RealNet anomaly detection network model is constructed, which combines a physically consistent diffusion anomaly generation module and an adaptive dynamic interpolation kernel. Through sub-pixel space reconstruction and frequency domain alignment, a high-precision anomaly response map is generated, and the anomaly is judged by combining topology consistency decision filtering rules.

Benefits of technology

It significantly improves the positioning accuracy and judgment reliability of white low-contrast microcracks, taking into account both detection accuracy and real-time requirements, and avoiding the cost and speed reduction problems caused by the improvement of hardware resolution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122134689A_ABST
    Figure CN122134689A_ABST
Patent Text Reader

Abstract

This invention discloses a quality inspection and control system for amlodipine besylate tablets based on image processing, comprising: an image processing module for obtaining a standardized tablet image dataset; an image reconstruction module for obtaining high-resolution reconstructed images of sub-pixels and simultaneously outputting high-frequency detail features of sub-pixels; a training sample module for constructing a synthetic anomaly training sample set; an improved RealNet module for obtaining a trained improved RealNet anomaly detection network model; a probability map generation module for generating a low-resolution anomaly probability map and simultaneously outputting anomaly feature embedding representations; an anomaly response map generation module for generating a high-precision anomaly response map; and a detection and judgment module for outputting the pass / fail judgment result of amlodipine besylate tablets and controlling a rejection device to reject rejected amlodipine besylate tablets. This invention significantly improves the positioning accuracy and judgment reliability of white low-contrast microcracks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quality inspection and testing technology for amlodipine besylate tablets, and more particularly to a quality inspection and testing control system for amlodipine besylate tablets based on image processing. Background Technology

[0002] With the continuous improvement of intelligent manufacturing in the pharmaceutical industry, the appearance quality inspection of tablet drugs is gradually shifting from manual visual inspection to automatic inspection by machine vision. Amlodipine besylate tablets, as a commonly used white tablet in clinical practice, have surface features such as embossed lettering, chamfered edges, and powder particle texture. At the same time, micro-crack defects may occur during production, transportation, and packaging. Since micro-cracks often manifest as extremely shallow grayscale disturbances, their width may be close to or smaller than the size of a single pixel of an image sensor. Therefore, achieving high-precision, low-false-detection-rate automatic inspection on high-speed production lines is technically challenging.

[0003] In the existing technology, the detection methods for tablet surface defects mainly include traditional image processing methods based on threshold segmentation, edge detection or morphological operations, as well as supervised defect classification or segmentation methods based on convolutional neural networks. Traditional image processing methods usually rely on fixed thresholds or local gradient operators to segment images. When the contrast between white tablets and white or light gray microcracks is low, it is easy to have problems such as the threshold being too low, causing the edge of the engraving to be misjudged as a crack, or the threshold being too high, causing the fine cracks to be missed. It is difficult to achieve stable differentiation between the engraving groove structure and the gray-scale perturbation of microcracks.

[0004] For deep learning methods, existing detection models based on classification or segmentation networks typically require a large number of manually labeled defect samples for training. In actual production, the number of microcrack samples is limited, and the crack morphology is random and diverse, making it difficult to cover all defect morphologies. Some unsupervised anomaly detection models identify anomalies by learning the distribution of normal samples, but when the gray-scale perturbation of the tablet engraving structure is highly similar to that of the microcrack, the model is prone to misclassifying the regular engraving structure as an anomaly.

[0005] Furthermore, existing technologies often rely on simple connected region area or length thresholds for defect determination in the post-processing stage, failing to combine the geometric patterns of tablet engravings with dust noise patterns for topological consistency analysis. This can easily lead to false positives or false negatives in complex environments. In high-speed continuous production environments, the lack of comprehensive modeling for illumination disturbances, changes in surface reflection, and structural interference makes it difficult to simultaneously meet the industrial quality control requirements of high-precision detection and low false alarm rates. Summary of the Invention

[0006] One objective of this invention is to propose an image processing-based quality inspection and control system for amlodipine besylate tablets. This invention significantly improves the positioning accuracy and judgment reliability of white low-contrast microcracks, and can balance the requirements of detection accuracy and real-time performance in high-speed pharmaceutical production line environments.

[0007] An image processing-based quality inspection and control system for amlodipine besylate tablets according to an embodiment of the present invention includes: The image processing module acquires raw images of amlodipine besylate tablets from the pharmaceutical production line using an industrial camera, and performs preprocessing to obtain a standardized tablet image dataset. The image reconstruction module performs sub-pixel spatial reconstruction on a standardized pill image dataset based on an adaptive dynamic interpolation kernel, obtains high-resolution reconstructed sub-pixel images, and simultaneously outputs high-frequency detail features of sub-pixels. The training sample module uses the physical consistency diffusion anomaly generation module to perform an intensity-controlled diffusion reverse process on the standardized pill image dataset to construct a synthetic anomaly training sample set. The RealNet module is improved by training an improved RealNet anomaly detection network model based on a synthetic anomaly training sample set, resulting in a fully trained improved RealNet anomaly detection network model. The probability map generation module takes the high-resolution reconstructed sub-pixel image as input to the improved RealNet anomaly detection network model, generates a low-resolution anomaly probability map, and outputs anomaly feature embedding representation. The anomaly response map generation module performs a local Fourier transform on the high-resolution reconstructed image of the sub-pixels, calculates the high-frequency energy distribution map, aligns it with the anomaly feature embedding representation in the frequency domain, generates the sub-pixel spectral residual matrix, and feeds it back to the improved RealNet anomaly detection network model to update the anomaly probability map. It also inputs the high-frequency detail features of the sub-pixels into the cross-scale sub-pixel-semantic fusion interpolation mapping module to generate a high-precision anomaly response map. The detection and judgment module performs connected component analysis, skeleton extraction, and curvature statistics on the high-precision abnormal response graph, constructs topology consistency decision filtering rules, outputs the qualified or unqualified judgment result of amlodipine besylate tablets, and controls the rejection device to reject unqualified amlodipine besylate tablets.

[0008] Optionally, the preprocessing includes geometric correction, motion blur compensation, and illumination equalization.

[0009] Optionally, the image reconstruction module includes: Construct sub-pixel grid coordinates based on sub-pixel magnification; Based on the correspondence between sub-pixel grid coordinates and original pixel coordinates, an adaptive dynamic interpolation kernel is constructed for each standardized pill image; Based on adaptive dynamic interpolation, sub-pixel space reconstruction is performed on standardized tablet images to obtain high-resolution sub-pixel reconstructed images; High-frequency detail features of subpixels are extracted from images reconstructed at high resolution based on subpixels.

[0010] Optionally, the training sample module includes: Normal standardized pill images were selected from the standardized pill image dataset for diffusion anomaly synthesis to construct the synthesis input set; For each standardized pill image in the synthetic input set, a simulated illumination perturbation vector is constructed. Illumination perturbation is applied to the standardized pill image based on the simulated illumination perturbation vector to obtain an illumination perturbation image. Constructing a surface normal estimation field based on illumination perturbation images; Set the number of diffusion steps for the reverse diffusion process with controllable intensity, and define the diffusion time step as an integer sequence from one to the number of diffusion steps; A physically consistent diffusion anomaly generation model is constructed based on diffusion step number, diffusion time step, crack synthesis intensity coefficient, simulated illumination perturbation vector, and surface normal estimation field. By performing multi-value sampling on the crack synthesis intensity coefficient and multiple samplings on the random noise in the physical consistency diffusion anomaly generation model, multi-scale, multi-directional virtual microcrack sample images are generated. Multi-scale, multi-directional virtual microcrack sample images are paired with their corresponding standardized pill images to construct a synthetic anomaly training sample set.

[0011] Optionally, the improved RealNet module includes: Construct an improved RealNet anomaly detection network model driven by physical consistency; Based on the crack synthesis strength coefficient, a strength monotonic consistency loss is constructed; Based on the simulated illumination perturbation vector, an illumination decoupling consistency loss is constructed. Based on the surface normal estimation field, physical weighting coefficients are defined, and directional consistency loss is constructed based on the physical weighting coefficients; Based on the anomaly-aware feature selection mechanism, a channel selection weight vector is constructed, and a channel selection sparse loss is constructed based on the channel selection weight vector. The total training loss function is constructed by weighting the intensity monotonic consistency loss, illumination decoupling consistency loss, orientation consistency loss and channel selection sparsity loss. Based on the total training loss function, iterative optimization and updates are performed on the parameters of the feature extraction network, the parameters of the anomaly perception feature selection mechanism, and the parameters of physical consistency modulation. After training convergence, the improved RealNet anomaly detection network model is output.

[0012] Optionally, the probability map generation module includes: The high-resolution reconstructed image of the nth subpixel is input into the trained improved RealNet anomaly detection network model. During the forward propagation of the network, the corresponding multi-scale feature tensor is output at the lth feature layer. Based on the channel selection weight vector, channel weighting is performed on the multi-scale feature tensor of the l-th feature layer to obtain the anomaly-aware feature tensor. A low-resolution anomaly score map is constructed based on the anomaly perception feature tensor of all feature layers. The anomaly score at each low-resolution spatial coordinate position in the low-resolution anomaly score map is converted into a low-resolution anomaly probability map using the Sigmoid mapping function. The low-resolution anomaly probability map is mapped to the sub-pixel grid coordinate space through an interpolation upsampling operator to obtain the sub-pixel semantic attention weight map; Cross-layer aggregation is performed based on the anomaly-aware feature tensors of all feature layers to obtain anomaly feature embedding representations.

[0013] Optionally, the anomaly response graph generation module includes: Perform a local Fourier transform on the sub-pixel high-resolution reconstructed image to calculate the high-frequency energy distribution map; The high-frequency energy distribution map and the embedded representation of abnormal features are aligned in the frequency domain to generate a sub-pixel spectral residual matrix. The sub-pixel spectral residual matrix is ​​fed back to the trained improved RealNet anomaly detection network model to update the low-resolution anomaly probability map; The updated low-resolution anomaly probability map and high-frequency detail features of sub-pixels are input into the cross-scale sub-pixel-semantic fusion interpolation mapping module. A learnable spatial weight tensor is used to complete the reprojection of anomaly information to the sub-pixel space and pixel-level weighted fusion to generate a high-precision anomaly response map.

[0014] Optionally, the detection and determination module includes: Perform connected component analysis on the high-precision anomaly response map. When the anomaly response value at the sub-pixel grid coordinate position is greater than or equal to the anomaly response threshold, mark the corresponding sub-pixel grid coordinate position as a candidate anomaly pixel. Construct a binary anomaly mask map from all candidate anomaly pixels.

[0015] Performing an eight-neighbor connected component labeling operation on the binary anomaly mask image will divide the spatially interconnected candidate anomaly pixels into several connected regions, resulting in a set of connected regions. For each connected region, perform skeleton extraction and curvature statistics; Construct topology consistency decision filtering rules to remove regions that conform to the lettering geometry pattern and dust noise pattern, and extract the connected regions after topology consistency decision filtering as microcrack defect regions. Crack length, average crack width, and continuity index are calculated based on the microcrack defect region. The crack length, average crack width, and continuity index are compared with the preset quality control thresholds to output the qualified or unqualified results of amlodipine besylate tablets.

[0016] Optionally, the topology consistency decision filtering rule includes: When the area of ​​a connected region is greater than or equal to the area threshold and the average curvature value of the connected region is less than or equal to the curvature threshold, the corresponding connected region is identified as a lettering geometry pattern region and is removed.

[0017] When the area of ​​a connected region is less than or equal to the noise area threshold, the corresponding connected region is identified as a dust noise mode region and is removed.

[0018] Optionally, the criteria for determining whether the amlodipine besylate tablets are qualified or unqualified are as follows: When the crack length of any microcrack defect area is greater than the crack length threshold, or the average crack width is greater than the average crack width threshold, or the continuity index is less than the continuity threshold, amlodipine besylate tablets are determined to be scrap tablets. Amlodipine besylate tablets are considered qualified when the crack length of all microcrack defect areas is less than or equal to the crack length threshold, the average crack width is less than or equal to the average crack width threshold, and the continuity index is greater than or equal to the continuity threshold.

[0019] The beneficial effects of this invention are: (1) This invention constructs an improved RealNet anomaly detection network model driven by physical consistency, introduces crack synthesis intensity coefficient, simulated illumination perturbation vector and surface normal estimation field as physical modulation variables in the training process, establishes a monotonic consistency constraint relationship between the anomaly response amplitude and the crack synthesis intensity coefficient, and constructs illumination decoupling consistency loss and orientation consistency loss, so that the anomaly response output by the network maintains a monotonic calibration relationship when the crack intensity changes, remains stable under illumination perturbation changes, and maintains orientation consistency in different surface orientation regions, thus solving the problems of existing anomaly detection models being sensitive to illumination fluctuations and lacking adaptability to changes in surface reflection; compared with traditional unsupervised methods based only on image-level contrast learning or reconstruction error, by introducing physical consistency constraints, the model learns a crack perturbation mode that conforms to the surface reflection law of amlodipine besylate tablets, which significantly improves the positioning accuracy and judgment reliability of white low-contrast microcracks, and can take into account both detection accuracy and real-time requirements in high-speed pharmaceutical production line environments.

[0020] This invention makes the model more sensitive to sub-pixel-level high-frequency disturbances through frequency domain alignment, effectively enhancing the response capability to microcracks with a width smaller than a single pixel. It achieves a breakthrough in software-level resolution without increasing the physical resolution of industrial cameras, avoiding the problems of increased costs and decreased processing speed caused by simply increasing hardware resolution.

[0021] This invention maps the updated low-resolution anomaly probability map to the sub-pixel grid coordinate space through interpolation and upsampling, generating a sub-pixel semantic attention weight map. It then combines high-frequency detail features of the sub-pixels with a learnable spatial weight tensor for pixel-level weighted fusion, generating a high-precision anomaly response map. Simultaneously, in the post-processing stage, topological consistency decision filtering rules are constructed through connected component analysis, skeleton extraction, and curvature statistics to structurally eliminate engraving geometric patterns and dust noise patterns. A cross-scale semantic-guided reprojection mechanism enables the accurate mapping of low-resolution semantic anomaly information to the sub-pixel space, achieving fine-grained anomaly location. Furthermore, the topological consistency filtering rules further distinguish between cracks and regular engraving edges at the structural level, significantly improving the positioning accuracy and reliability of white low-contrast microcracks. This approach balances detection accuracy and real-time requirements in high-speed pharmaceutical production line environments. Attached Figure Description

[0022] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings: Figure 1 This is a system block diagram of an image processing-based quality inspection and control system for amlodipine besylate tablets proposed in this invention. Detailed Implementation

[0023] Example 1: Reference Figure 1 A quality inspection and control system for amlodipine besylate tablets based on image processing, comprising: The image processing module acquires raw images of amlodipine besylate tablets from the pharmaceutical production line using an industrial camera, and performs preprocessing to obtain a standardized tablet image dataset. The image reconstruction module performs sub-pixel spatial reconstruction on a standardized pill image dataset based on an adaptive dynamic interpolation kernel, obtains high-resolution reconstructed sub-pixel images, and simultaneously outputs high-frequency detail features of sub-pixels. The training sample module uses the physical consistency diffusion anomaly generation module to perform an intensity-controlled diffusion reverse process on the standardized pill image dataset to construct a synthetic anomaly training sample set. The RealNet module is improved by training an improved RealNet anomaly detection network model based on a synthetic anomaly training sample set, resulting in a fully trained improved RealNet anomaly detection network model. The probability map generation module takes the high-resolution reconstructed sub-pixel image as input to the improved RealNet anomaly detection network model, generates a low-resolution anomaly probability map, and outputs anomaly feature embedding representation. The anomaly response map generation module performs a local Fourier transform on the high-resolution reconstructed image of the sub-pixels, calculates the high-frequency energy distribution map, aligns it with the anomaly feature embedding representation in the frequency domain, generates the sub-pixel spectral residual matrix, and feeds it back to the improved RealNet anomaly detection network model to update the anomaly probability map. It also inputs the high-frequency detail features of the sub-pixels into the cross-scale sub-pixel-semantic fusion interpolation mapping module to generate a high-precision anomaly response map. The detection and judgment module performs connected component analysis, skeleton extraction, and curvature statistics on the high-precision abnormal response graph, constructs topology consistency decision filtering rules, outputs the qualified or unqualified judgment result of amlodipine besylate tablets, and controls the rejection device to reject unqualified amlodipine besylate tablets.

[0024] In this embodiment, the preprocessing includes geometric correction, motion blur compensation, and illumination equalization.

[0025] The standardized pill image dataset consists of N standardized pill images. Each standardized pill image has a grayscale intensity value at pixel coordinates (x, y). The pixel coordinates (x, y) are in pixels. The horizontal coordinate x ranges from zero to the number of pixels in the image width minus one, and the vertical coordinate y ranges from zero to the number of pixels in the image height minus one. The image width is W pixels and the image height is H pixels.

[0026] The image reconstruction module in this embodiment includes: Construct sub-pixel grid coordinates based on sub-pixel magnification; In Example 1, the sub-pixel magnification factor is a positive integer and is used to characterize the sampling density of the sub-pixel space. The value range of the horizontal coordinate u of the sub-pixel is from zero to the product of the sub-pixel magnification factor and the number of pixels in the image width minus one. The value range of the vertical coordinate v of the sub-pixel is from zero to the product of the sub-pixel magnification factor and the number of pixels in the image height minus one.

[0027] The correspondence between sub-pixel grid coordinates (u,v) and original pixel coordinates (x,y) is established in the following way: Divide the horizontal coordinate (u) of the sub-pixel by the sub-pixel magnification (r) to obtain the continuous coordinate value of the horizontal coordinate (x); Divide the vertical coordinate (v) of the sub-pixel by the sub-pixel magnification factor (r) to obtain the continuous coordinate value of the vertical coordinate (y).

[0028] Based on the correspondence between sub-pixel grid coordinates and original pixel coordinates, an adaptive dynamic interpolation kernel is constructed for each standardized pill image; In Example 1, a two-dimensional interpolation kernel is preset. The two-dimensional interpolation kernel is a continuously differentiable function used to describe the contribution weight of each pixel in the original pixel neighborhood to the continuous coordinate position. The support region of the two-dimensional interpolation kernel is limited by the interpolation neighborhood radius. The spatial adaptive weight field is calculated based on the local gray-level gradient of the standardized pill image at the original pixel coordinate position. At each sub-pixel continuous coordinate position, the two-dimensional interpolation kernel value of each pixel in the corresponding original pixel neighborhood is multiplied point by point with the weight coefficient of the spatial adaptive weight field at the pixel position to generate the adaptive dynamic interpolation kernel weight set at the continuous coordinate position of the sub-pixel. The adaptive dynamic interpolation kernel weight set is normalized to obtain the adaptive dynamic interpolation kernel at the corresponding sub-pixel continuous coordinate position.

[0029] Based on adaptive dynamic interpolation, sub-pixel space reconstruction is performed on standardized tablet images to obtain high-resolution sub-pixel reconstructed images; In Example 1, for each pair of sub-pixel grid coordinates, the original pixel neighborhood region with an interpolation neighborhood radius L is determined based on its corresponding original pixel coordinates. The sub-pixel high-resolution reconstructed image is obtained by weighted summation of each pixel within the original pixel neighborhood region, with the weights calculated by an adaptive dynamic interpolation kernel.

[0030] ; in, For floor operation, and The original pixel coordinate index used for interpolation. For the interpolation neighborhood radius, Reconstruct the image at high resolution for sub-pixels. To standardize tablet images, It is an adaptive dynamic interpolation kernel.

[0031] High-frequency detail features of subpixels are extracted from images reconstructed at high resolution based on subpixels.

[0032] In Example 1, the high-frequency detail features of the subpixel are obtained by differentiating the high-resolution reconstructed image of the subpixel with the low-frequency smoothing component. The dimension of the high-frequency detail features of the subpixel is grayscale intensity, which is used to characterize the high-frequency grayscale perturbation features corresponding to the microcracks in the amlodipine benzenesulfonate tablets.

[0033] For each sub-pixel high-resolution reconstructed image, a low-pass smoothing neighborhood window is constructed at each sub-pixel grid coordinate position. The radius of the low-pass smoothing neighborhood window is represented as the low-pass smoothing neighborhood radius. A weighted average is performed on the gray intensity values ​​of all sub-pixels within the low-pass smoothing neighborhood window. The low-frequency smoothing component at the corresponding sub-pixel grid coordinate position is obtained by summing the product of the gray intensity values ​​of all sub-pixels within the low-pass smoothing neighborhood window with the corresponding weighting coefficients point by point.

[0034] In this embodiment, the training sample module includes: Normal standardized pill images were selected from the standardized pill image dataset for diffusion anomaly synthesis to construct the synthesis input set; The synthetic input set is represented as a subset of standardized tablet images selected from the standardized tablet image dataset for diffusion anomaly synthesis, wherein the number of standardized tablet images used for diffusion anomaly synthesis is less than or equal to the number of images in the standardized tablet image dataset.

[0035] For each standardized pill image in the synthetic input set, a simulated illumination perturbation vector is constructed. Illumination perturbation is applied to the standardized pill image based on the simulated illumination perturbation vector to obtain an illumination perturbation image. In Example 1, an illumination disturbance intensity range is preset based on the brightness fluctuation range of the actual illumination system in the pharmaceutical production line. Within the illumination disturbance intensity range, illumination gain disturbance components and grayscale intensity bias disturbance components are randomly sampled. The illumination gain disturbance components and grayscale intensity bias disturbance components are combined to form a simulated illumination disturbance vector. The grayscale intensity value at each original pixel coordinate position of the standardized tablet image is multiplied by the gain coefficient obtained by mapping the simulated illumination disturbance vector, and the grayscale intensity bias obtained by mapping the simulated illumination disturbance vector is added. The calculation result is restricted to the upper limit of grayscale intensity between zero and the upper limit value to obtain the illumination disturbance image.

[0036] Constructing a surface normal estimation field based on illumination perturbation images; The surface normal estimation field is a dimensionless vector field that characterizes the local orientation of the amlodipine benzylbenzene tablet surface at each original pixel coordinate position. The surface normal estimation field at each original pixel coordinate position consists of three dimensionless components in three orthogonal directions, and the three orthogonal dimensionless components at each original pixel coordinate position satisfy the normalization constraint that the sum of squares equals one.

[0037] Set the number of diffusion steps for the reverse diffusion process with controllable intensity, and define the diffusion time step as an integer sequence from one to the number of diffusion steps; A physically consistent diffusion anomaly generation model is constructed based on diffusion step number, diffusion time step, crack synthesis intensity coefficient, simulated illumination perturbation vector, and surface normal estimation field. In Example 1, the crack synthesis intensity coefficient is used to control the grayscale perturbation amplitude of the virtual microcrack on the illumination perturbation image.

[0038] The physical consistency diffusion anomaly generation model includes a noise prediction network and a conditional modulation unit. The conditional modulation unit is used to encode the crack synthesis intensity coefficient, the simulated illumination perturbation vector, and the surface normal estimation field into a conditional modulation vector. The conditional modulation vector is injected into the intermediate feature layer of the noise prediction network through feature concatenation or feature weighting. The controlled diffusion inverse process involves the following steps: as the diffusion time step decreases from one, at each diffusion time step, the intermediate variables of the current time step are input into the noise prediction network. Simultaneously, the current diffusion time step identifier, crack synthesis intensity coefficient, simulated illumination perturbation vector, and conditional modulation vector corresponding to the surface normal estimation field are also input into the noise prediction network. The noise prediction network outputs the noise estimate for the current time step. The intermediate variables of the current time step are then denoised and updated based on the noise estimate and the attenuation coefficient corresponding to the diffusion time step. During the denoising and updating process, the grayscale perturbation amplitude is proportionally modulated based on the crack synthesis intensity coefficient. The local grayscale gain is modulated based on the simulated illumination perturbation vector. The direction of local grayscale change is modulated based on the surface normal estimation field. After several inverse updates in the diffusion steps, a virtual microcrack sample image is obtained.

[0039] ; in, For diffusion time step intermediate variables, For diffusion time step The attenuation coefficient, The cumulative decay coefficient from time step 1 to time step 2 is... The noise prediction function for the diffusion anomaly generation network. For diffusion time step The standard deviation of noise injection, For diffusion time step Standard Gaussian noise, For diffusion time step, The crack synthesis strength coefficient is... To simulate the illumination perturbation vector, This is the estimated field for the surface normal.

[0040] By performing multi-value sampling on the crack synthesis intensity coefficient and multiple samplings on the random noise in the physical consistency diffusion anomaly generation model, multi-scale, multi-directional virtual microcrack sample images are generated. Multi-scale, multi-directional virtual microcrack sample images are paired with their corresponding standardized pill images to construct a synthetic anomaly training sample set.

[0041] The training sample set for synthetic anomalies consists of multiple training sample pairs. Each training sample pair includes: a standardized pill image for diffusion anomaly synthesis, a virtual microcrack sample image corresponding to the standardized pill image, a crack synthesis intensity coefficient, a simulated illumination perturbation vector, and a surface normal estimation field.

[0042] This implementation improves the RealNet module, including: Construct an improved RealNet anomaly detection network model driven by physical consistency; In Example 1, the parameter set of the improved RealNet anomaly detection network model is set to include feature extraction network parameters, anomaly perception feature selection mechanism parameters, and physical consistency modulation parameters. The standardized tablet image and virtual microcrack sample image in each training sample pair are respectively input into the improved RealNet anomaly detection network model. The corresponding multi-scale feature tensor is output at each feature layer of the network. The multi-scale feature tensor of each feature layer consists of multiple feature channels. Each feature channel is used to characterize the feature response corresponding to the surface texture, engraving structure, or crack disturbance of amlodipine besylate tablets.

[0043] Based on the crack synthesis strength coefficient, a strength monotonic consistency loss is constructed; In Example 1, for each training sample pair and each feature layer of the network, the pointwise absolute difference between the feature tensor of the virtual microcrack sample image and the feature tensor of the standardized pill image is calculated, and the average summation of all feature channels and spatial locations is performed to obtain the abnormal response amplitude scalar of the training sample pair on that feature layer.

[0044] A strength monotonically consistent loss is constructed to maintain a monotonically consistent relationship between the anomalous response amplitude scalar and the crack synthesis strength coefficient. Specifically, the anomalous response amplitude scalar is increased synchronously when the crack synthesis strength coefficient increases, thus establishing a strength calibration relationship between the crack synthesis strength coefficient and the network anomalous response.

[0045] Based on the simulated illumination perturbation vector, an illumination decoupling consistency loss is constructed. In Example 1, for the same set of training sample pairs, the abnormal response amplitude scalar is calculated under different simulated illumination perturbation vector conditions, and the difference between the abnormal response amplitude scalars under different simulated illumination perturbation vector conditions is calculated.

[0046] A light-decoupled consistency loss is constructed to keep the scalar magnitude of the abnormal response stable under simulated light perturbation vector changes, thus constraining the network to maintain the stability of the abnormal response to microcracks in amlodipine besylate tablets under light fluctuations in the pharmaceutical production line.

[0047] Based on the surface normal estimation field, physical weighting coefficients are defined, and directional consistency loss is constructed based on the physical weighting coefficients; In Example 1, at each original pixel coordinate position, a physical weighting coefficient is calculated based on the vertical component of the surface normal estimation field. The physical weighting coefficient is used to reflect the degree of influence of the tablet surface orientation on the light reflection intensity at that position. When calculating the feature difference between the virtual microcrack sample image and the standardized tablet image, the physical weighting coefficient is used as a spatial weighting factor to weight and sum the feature differences, constructing a direction consistency loss. This ensures that the network's response direction to crack grayscale perturbation remains consistent in different surface orientation regions, constraining the network to learn crack features that conform to the physical laws of surface reflection of amlodipine besylate tablets.

[0048] ; in, For directional consistency loss, Q represents the number of synthetic anomalous training sample pairs, indicating the total number of training sample pairs in the synthetic anomalous training sample set; q is the training sample pair index, an integer ranging from 1 to Q, used to identify the q-th training sample pair; L is the total number of feature layers in the improved RealNet anomaly detection network model; and l is the network layer index, an integer ranging from 1 to L, used to identify the l-th feature layer. These are the physical weighting coefficients. Let be the feature vector of the virtual microcrack sample image in the q-th training sample pair at the l-th feature layer and spatial location (x, y). Let be the feature vector of the standardized pill image in the q-th training sample pair at the l-th feature layer and spatial location (x, y). This is an L1 norm operator used to measure the intensity of feature differences between virtual microcrack sample images and standardized pill images at corresponding spatial locations. To sum the coordinates of all original pixels in the amlodipine besylate tablet image, To sum the features across all feature layers of the improved RealNet anomaly detection network model, This involves summing all training sample pairs in the synthetic anomaly training sample set.

[0049] Based on the anomaly-aware feature selection mechanism, a channel selection weight vector is constructed, and a channel selection sparse loss is constructed based on the channel selection weight vector. In Example 1, for each feature channel of each feature layer, the feature difference response intensity in the crack region and the feature difference response intensity in the structural interference region are statistically analyzed, and the ratio of the response intensity in the crack region to the response intensity in the structural interference region is calculated. Based on the ratio, channel selection weights are assigned to each feature channel, and a channel selection sparsity loss is constructed to gradually reduce the channel selection weight of feature channels with strong responses to structural interference regions, thereby screening out feature channels that are sensitive to gray-scale perturbations of microcracks in amlodipine benzenesulfonate tablets and are not sensitive to the geometric patterns of lettering.

[0050] The total training loss function is constructed by weighting the intensity monotonic consistency loss, illumination decoupling consistency loss, orientation consistency loss and channel selection sparsity loss. Based on the total training loss function, iterative optimization and updates are performed on the parameters of the feature extraction network, the parameters of the anomaly perception feature selection mechanism, and the parameters of physical consistency modulation. After training convergence, the improved RealNet anomaly detection network model is output.

[0051] The trained improved RealNet anomaly detection network model maintains monotonic consistency of the anomaly response under varying crack synthesis intensity coefficients, stability of the anomaly response under varying simulated illumination perturbation vectors, and directional consistency of the anomaly response under varying surface normal estimation fields. Furthermore, through an anomaly-aware feature selection mechanism, it prioritizes the retention of feature channels sensitive to grayscale perturbations in microcracks of amlodipine benzylbenzene tablets.

[0052] In this embodiment, the probability map generation module includes: The high-resolution reconstructed image of the nth subpixel is input into the trained improved RealNet anomaly detection network model. During the forward propagation of the network, the corresponding multi-scale feature tensor is output at the lth feature layer. Based on the channel selection weight vector, channel weighting is performed on the multi-scale feature tensor of the l-th feature layer to obtain the anomaly-aware feature tensor. In Example 1, the feature response of each feature channel is multiplied with its corresponding channel selection weight to obtain the anomaly-aware feature tensor. The anomaly-aware feature tensor is used to preferentially retain the feature channel responses that are sensitive to gray-scale perturbations of microcracks in amlodipine besylate tablets and insensitive to the geometric patterns of lettering.

[0053] A low-resolution anomaly score map is constructed based on the anomaly perception feature tensor of all feature layers. The anomaly score of the low-resolution anomaly score map at the low-resolution spatial coordinate position is calculated by calculating the element-wise absolute difference between the anomaly perception feature vector of all feature layers at the corresponding spatial position and the normal feature mean vector obtained by statistics during the training phase, and summing all feature channels of the feature vector to obtain the single-layer anomaly difference value. The anomaly score at the corresponding spatial position is obtained by weighted summation of the single-layer anomaly difference values ​​of all feature layers.

[0054] The anomaly score at each low-resolution spatial coordinate position in the low-resolution anomaly score map is converted into a low-resolution anomaly probability map using the Sigmoid mapping function. The low-resolution anomaly probability map has an anomaly probability value between zero and one at each low-resolution spatial coordinate position. The low-resolution anomaly probability map is used to represent the probability that there is a microcrack anomaly at the corresponding low-resolution spatial position of amlodipine besylate tablets.

[0055] The low-resolution anomaly probability map is mapped to the sub-pixel grid coordinate space through an interpolation upsampling operator to obtain the sub-pixel semantic attention weight map; Cross-layer aggregation is performed based on the anomaly-aware feature tensors of all feature layers to obtain anomaly feature embedding representations.

[0056] Cross-layer aggregation obtains the global feature vector of the corresponding feature layer by performing global average pooling on the anomaly-aware feature tensor of each feature layer, and then concatenates the global feature vectors of all feature layers in the order of the feature layers to obtain the anomaly feature embedding representation.

[0057] The abnormal response graph generation module in this embodiment includes: Perform a local Fourier transform on the sub-pixel high-resolution reconstructed image to calculate the high-frequency energy distribution map; In Example 1, within the local Fourier window, after applying windowing function weights to all sub-pixel grayscale intensity values, a discrete Fourier transform is performed to obtain the local spectral coefficients at the sub-pixel grid coordinates. The amplitude squared operation is performed on the spectral components belonging to the preset high-frequency index set in the local spectral coefficients, and the amplitude squared results corresponding to all high-frequency indices are accumulated to obtain the high-frequency energy value at the sub-pixel grid coordinates.

[0058] Repeat the above operation for all sub-pixel grid coordinate positions to form a high-frequency energy distribution map. The high-frequency energy distribution map is used to represent the high-frequency gray-level perturbation energy distribution characteristics of the microcracks in the amlodipine benzenesulfonate tablets in the sub-pixel space.

[0059] The high-frequency energy distribution map and the embedded representation of abnormal features are aligned in the frequency domain to generate a sub-pixel spectral residual matrix. In Example 1, the embedded representation of abnormal features is mapped to a frequency domain modulation weight vector through a frequency domain mapping matrix and a frequency domain mapping bias vector. Each element in the frequency domain modulation weight vector corresponds one-to-one with a high-frequency index in a preset high-frequency index set. At each sub-pixel grid coordinate position, the squared result of the local spectral coefficient amplitude of the corresponding high-frequency index is multiplied item by item with the corresponding element in the frequency domain modulation weight vector, and the weighted results corresponding to all high-frequency indices are accumulated to obtain the frequency domain aligned spectrum energy value. The frequency domain aligned spectrum energy value is subtracted from the high-frequency energy value at the sub-pixel grid coordinate position to obtain the spectral residual value at the sub-pixel grid coordinate position.

[0060] The above operation is repeated for all sub-pixel grid coordinate positions to form a sub-pixel spectral residual matrix. The sub-pixel spectral residual matrix is ​​used to represent the residual signal of the high-frequency energy of the microcrack in amlodipine benzylbenzene tablets relative to the baseline high-frequency energy distribution under the guidance of the anomalous feature embedding representation.

[0061] The sub-pixel spectral residual matrix is ​​fed back to the trained improved RealNet anomaly detection network model to update the low-resolution anomaly probability map; The updated low-resolution anomaly probability map and high-frequency detail features of sub-pixels are input into the cross-scale sub-pixel-semantic fusion interpolation mapping module. A learnable spatial weight tensor is used to complete the reprojection of anomaly information to the sub-pixel space and pixel-level weighted fusion to generate a high-precision anomaly response map.

[0062] In Example 1, the updated low-resolution anomaly probability map is mapped to the sub-pixel grid coordinate space through an interpolation upsampling operator to obtain the sub-pixel semantic attention weight map. In the cross-scale sub-pixel-semantic fusion interpolation mapping module, a learnable spatial weight tensor is constructed. At each sub-pixel grid coordinate position, the weight value at the corresponding position of the sub-pixel semantic attention weight map is multiplied by the weight value at the corresponding position of the learnable spatial weight tensor to obtain the semantic modulation term. At the same time, the gray intensity value of the high-frequency detail features of the sub-pixel at the corresponding sub-pixel grid coordinate position is normalized to obtain the high-frequency detail term.

[0063] The semantic modulation term and the high-frequency detail term are fused at the pixel level to obtain the high-precision anomaly response value at the corresponding sub-pixel grid coordinate position. The above operation is repeated for all sub-pixel grid coordinate positions to form a high-precision anomaly response map.

[0064] The detection and determination module in this embodiment includes: Perform connected component analysis on the high-precision anomaly response map. When the anomaly response value at the sub-pixel grid coordinate position is greater than or equal to the anomaly response threshold, mark the corresponding sub-pixel grid coordinate position as a candidate anomaly pixel. Construct a binary anomaly mask map from all candidate anomaly pixels.

[0065] Performing an eight-neighbor connected component labeling operation on the binary anomaly mask image will divide the spatially interconnected candidate anomaly pixels into several connected regions, resulting in a set of connected regions. Each connected region in the set of connected regions represents a potential outlier region.

[0066] For each connected region, perform skeleton extraction and curvature statistics; In Example 1, a morphological thinning operation is performed on each connected region to shrink the connected region into a skeleton map with a width of one pixel. The skeleton map is composed of several skeleton points, and the skeleton points form a skeleton point sequence according to their spatial adjacency.

[0067] For each skeleton point in the skeleton point sequence, the local curvature value is calculated using the positional relationship between the previous and next skeleton points. The average curvature value of the connected region is obtained by averaging all the local curvature values ​​in the connected region. The average curvature value is used to represent the overall curvature of the connected region.

[0068] Construct topology consistency decision filtering rules to remove regions that conform to the lettering geometry pattern and dust noise pattern, and extract the connected regions after topology consistency decision filtering as microcrack defect regions. In Example 1, the area of ​​each connected region is calculated by counting the coordinates of all sub-pixel grids in the connected region.

[0069] For each connected region, the length of the connected region skeleton is calculated. The length of the connected region skeleton is obtained by summing the Euclidean distances between adjacent skeleton points in the skeleton point sequence segment by segment.

[0070] For each connected region, the average curvature value of the connected region is calculated. The average curvature value of the connected region is obtained by averaging all local curvature values ​​in the connected region.

[0071] Crack length, average crack width, and continuity index are calculated based on the microcrack defect region. In Example 1, the difference between the horizontal coordinate and the difference between the vertical coordinate of the i-th skeleton point and the (i+1)-th skeleton point in the skeleton point sequence are squared respectively. The two squared results are added together and the square root is taken to obtain the Euclidean distance between the two points. The Euclidean distance between all adjacent skeleton points in the skeleton point sequence is repeatedly calculated and accumulated to obtain the crack length. The crack length is used to represent the actual extension scale of the microcrack in the sub-pixel grid coordinate space.

[0072] The area of ​​the microcrack defect region is obtained by counting the coordinate positions of all sub-pixel grids in the microcrack defect region. The average crack width is obtained by dividing the area of ​​the microcrack defect region by the crack length. The average crack width is used to represent the average lateral expansion of the microcrack in the sub-pixel grid coordinate space.

[0073] In the skeleton point sequence, endpoint skeleton points are identified. An endpoint skeleton point is defined as a skeleton point that is adjacent to only one skeleton point in an eight-neighbor connectivity structure. The path length between all endpoint skeleton points is calculated. Among the path lengths between all endpoint skeleton points, the longest path length is selected as the longest path length of the skeleton. The longest path length of the skeleton is divided by the crack length to obtain the continuity index. When the continuity index is close to one, it indicates that the microcrack presents a continuous single-branch structure. When the continuity index is significantly less than one, it indicates that the microcrack has a fractured or multi-branch structure.

[0074] Crack length, average crack width, and continuity indices are used to quantitatively represent the geometric characteristics of microcracks in amlodipine benzenesulfonate tablets.

[0075] The crack length, average crack width, and continuity index are compared with the preset quality control thresholds to output the qualified or unqualified results of amlodipine besylate tablets.

[0076] In this embodiment, the topology consistency decision filtering rules include: When the area of ​​a connected region is greater than or equal to the area threshold and the average curvature value of the connected region is less than or equal to the curvature threshold, the corresponding connected region is identified as a lettering geometry pattern region and is removed.

[0077] When the area of ​​a connected region is less than or equal to the noise area threshold, the corresponding connected region is identified as a dust noise mode region and is removed.

[0078] In this embodiment, the judgment rule for determining whether amlodipine besylate tablets are qualified or unusable is as follows: When the crack length of any microcrack defect area is greater than the crack length threshold, or the average crack width is greater than the average crack width threshold, or the continuity index is less than the continuity threshold, amlodipine besylate tablets are determined to be scrap tablets. Amlodipine besylate tablets are considered qualified when the crack length of all microcrack defect areas is less than or equal to the crack length threshold, the average crack width is less than or equal to the average crack width threshold, and the continuity index is greater than or equal to the continuity threshold.

[0079] Example 2: During the continuous production of a batch of amlodipine besylate tablets, the production line maintained a constant cycle time. An industrial camera captured images of each tablet passing through the inspection station. When the system processed the nth standardized tablet image during continuous operation, it was found that there was a slight grayscale fluctuation between the original pixel coordinates (412, 387) and (418, 392). The grayscale intensity difference was only 4 levels, which was lower than the grayscale difference threshold of 8 levels set by the traditional threshold segmentation algorithm. Therefore, it was not identified as a defect in the traditional algorithm.

[0080] In this embodiment, subpixel space reconstruction processing is performed on the standardized tablet image. The subpixel magnification is set to r=4. At this magnification, the original pixel region is mapped to the subpixel grid coordinate range. The original pixel coordinates (412, 387) correspond to the coordinate range (1648, 1548) to (1651, 1551) in the subpixel grid. The system performs weighted summation operations within this region based on an adaptive dynamic interpolation kernel to generate a high-resolution reconstructed subpixel image. The reconstruction result shows that the originally discrete gray-level jumps in this region are continuous into a gray-level gradient band of approximately 13 subpixels in length, and the local gray-level change amplitude is stretched to 9 levels of gray-level difference in the subpixel space. Compared with the traditional image without subpixel reconstruction, the gray-level gradient continuity index in this region is improved from 0.21 to 0.68, indicating that high-frequency details are effectively preserved.

[0081] The system constructs a synthetic input set from images of normal, standardized tablets from the same batch and performs a physically consistent diffusion anomaly generation process. In one simulation, the crack synthesis intensity coefficient is set to 0.6, the gain component in the simulated illumination perturbation vector is 1.05, and the bias component is +3 gray levels. The diffusion step count is set to 1000 steps. During the inverse denoising process from step 1000 to step 1, the noise prediction network outputs a noise estimate with a mean square error of 0.013 at step 850, decreasing to 0.004 at step 200. The generated virtual microcrack sample image has a gray-level perturbation amplitude of 11 levels in the corresponding region. The system pairs the sample with the corresponding standardized tablet image and adds it to the synthetic anomaly training sample set. After accumulating 240,000 sample pairs, the improved RealNet anomaly detection network model is trained.

[0082] During training, the system calculates the anomalous response amplitude scalar for the q-th training sample pair at the l-th feature layer. As the crack synthesis intensity coefficient increases from 0.2 to 0.8, the anomalous response amplitude scalar gradually increases from 0.142 to 0.531, with the change curve showing a monotonically increasing trend. The monotonically consistent constraint loss decreases from the initial 0.087 to 0.009. Meanwhile, when the gain component of the simulated illumination perturbation vector varies between 0.95 and 1.10, the standard deviation of the anomalous response amplitude scalar remains within 0.016, significantly lower than the 0.058 without the illumination decoupling consistency loss.

[0083] After training convergence, the system inputs the reconstructed high-resolution subpixel image into the trained improved RealNet anomaly detection network model. At the l=3 feature layer, the number of feature channels is 128. After weighting by the channel selection weight vector, the number of effective channels is compressed to 37. The system calculates anomaly score of 2.17 at the low-resolution spatial coordinates (103, 96). After Sigmoid mapping, the low-resolution anomaly probability value is 0.897. The anomaly probability value is mapped to the subpixel grid coordinates (1649, 1549) to (1650, 1550) region through the interpolation upsampling operator to form a subpixel semantic attention weight map with a region weight value of 0.91.

[0084] The system performs a local Fourier transform in the sub-pixel region, with the local Fourier window size set to 9×9 sub-pixels. Within the window, a Hanning window function is applied to the grayscale intensity values ​​before performing a discrete Fourier transform. A preset high-frequency index set contains frequency component indices {(3,2),(2,3),(4,1)}. At the corresponding sub-pixel grid coordinates (1649, 1549), the calculated high-frequency energy value is 37.4. After the anomaly feature embedding representation is mapped to the frequency domain modulation weight vector via the frequency domain mapping matrix, the frequency domain aligned spectral energy value at the same location is calculated to be 49.6. Subtracting the two yields a sub-pixel spectral residual value of 12.2. The system feeds this spectral residual matrix back to the improved RealNet anomaly detection network model, increasing the updated low-resolution anomaly probability value from 0.897 to 0.943.

[0085] In the cross-scale sub-pixel-semantic fusion interpolation mapping module, the system multiplies the updated sub-pixel semantic attention weight value (0.943) with the corresponding weight value (0.78) of the learnable spatial weight tensor to obtain a semantic modulation term (0.735). Then, it weights and fuses the normalized sub-pixel high-frequency detail feature value (0.82) with the semantic modulation term to obtain a high-precision anomaly response value (0.603). Performing the same operation on all sub-pixel grid coordinates generates a complete high-precision anomaly response map.

[0086] In the high-precision anomaly response map, the system performs connected component analysis on regions that meet the anomaly response threshold of 0.55, resulting in three connected regions. The first region has an area of ​​54 sub-pixels, a skeleton length of 17.3 sub-pixels, and an average curvature of 0.032; the second region has an area of ​​210 sub-pixels, a skeleton length of 48.6 sub-pixels, and an average curvature of 0.005; and the third region has an area of ​​8 sub-pixels. According to the topology consistency decision filtering rule, the third region, with an area less than the noise threshold of 10, is identified as a dust noise pattern region and discarded; the second region, with an average curvature lower than the lettering curvature threshold of 0.01 and an area greater than the area threshold of 150, is identified as a lettering geometric pattern region and discarded; the first connected region is retained as a microcrack defect region.

[0087] The system calculates the crack length of the microcrack defect area as 17.3 sub-pixel units, corresponding to an original pixel scale of approximately 4.3 pixels, which translates to a physical length of approximately 0.29 mm. The calculated average crack width is 1.9 sub-pixel units, and the continuity index is 0.92. After comparing these values ​​with the preset quality control thresholds of 0.20 mm for crack length, 0.05 mm for crack width, and 0.85 for continuity, the system determines that the amlodipine besylate tablet is a defective tablet. An abnormal record entry is generated on the control terminal, recording the image number, sub-pixel coordinate range of the abnormal area, crack length, crack width, and continuity index data. Simultaneously, a rejection command is sent to the rejection device.

[0088] Within the same continuous production cycle, the system performed online inspection on 100,000 tablets. Actual manual re-inspection confirmed 412 tablets with microcracks. The method of this invention detected 403 of these, with 9 missed, a miss rate of 2.18%; the traditional method detected 329, with 83 missed, a miss rate of 20.15%. In the sub-pixel level crack sample, a total of 158 tablets were found. The method of this invention detected 147, a detection rate of 93.04%; the traditional method detected 61, a detection rate of 38.61%. The number of misjudged engravings decreased from 176 using the traditional method to 14 using the method of this invention.

[0089] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A quality inspection and control system for amlodipine besylate tablets based on image processing, characterized in that, include: The image processing module acquires raw images of amlodipine besylate tablets from the pharmaceutical production line using an industrial camera, and performs preprocessing to obtain a standardized tablet image dataset. The image reconstruction module performs sub-pixel spatial reconstruction on a standardized pill image dataset based on an adaptive dynamic interpolation kernel, obtains high-resolution reconstructed sub-pixel images, and simultaneously outputs high-frequency detail features of sub-pixels. The training sample module uses the physical consistency diffusion anomaly generation module to perform an intensity-controlled diffusion reverse process on the standardized pill image dataset to construct a synthetic anomaly training sample set. The RealNet module is improved by training an improved RealNet anomaly detection network model based on a synthetic anomaly training sample set, resulting in a fully trained improved RealNet anomaly detection network model. The probability map generation module takes the high-resolution reconstructed sub-pixel image as input to the improved RealNet anomaly detection network model, generates a low-resolution anomaly probability map, and outputs anomaly feature embedding representation. The anomaly response map generation module performs a local Fourier transform on the high-resolution reconstructed image of the sub-pixels, calculates the high-frequency energy distribution map, aligns it with the anomaly feature embedding representation in the frequency domain, generates the sub-pixel spectral residual matrix, and feeds it back to the improved RealNet anomaly detection network model to update the anomaly probability map. It also inputs the high-frequency detail features of the sub-pixels into the cross-scale sub-pixel-semantic fusion interpolation mapping module to generate a high-precision anomaly response map. The detection and judgment module performs connected component analysis, skeleton extraction, and curvature statistics on the high-precision abnormal response graph, constructs topology consistency decision filtering rules, outputs the qualified or unqualified judgment result of amlodipine besylate tablets, and controls the rejection device to reject unqualified amlodipine besylate tablets.

2. The image processing-based quality inspection and control system for amlodipine besylate tablets according to claim 1, characterized in that, The preprocessing includes geometric correction, motion blur compensation, and illumination equalization.

3. The image processing-based amlodipine besylate tablet quality inspection and control system according to claim 1, characterized in that, The image reconstruction module includes: Construct sub-pixel grid coordinates based on sub-pixel magnification; Based on the correspondence between sub-pixel grid coordinates and original pixel coordinates, an adaptive dynamic interpolation kernel is constructed for each standardized pill image; Based on adaptive dynamic interpolation, sub-pixel space reconstruction is performed on standardized tablet images to obtain high-resolution sub-pixel reconstructed images; High-frequency detail features of subpixels are extracted from images reconstructed at high resolution based on subpixels.

4. The image processing-based amlodipine besylate tablet quality inspection and control system according to claim 1, characterized in that, The training sample module includes: Normal standardized pill images were selected from the standardized pill image dataset for diffusion anomaly synthesis to construct the synthesis input set; For each standardized pill image in the synthetic input set, a simulated illumination perturbation vector is constructed. Illumination perturbation is applied to the standardized pill image based on the simulated illumination perturbation vector to obtain an illumination perturbation image. Constructing a surface normal estimation field based on illumination perturbation images; Set the number of diffusion steps for the reverse diffusion process with controllable intensity, and define the diffusion time step as an integer sequence from one to the number of diffusion steps; A physically consistent diffusion anomaly generation model is constructed based on diffusion step number, diffusion time step, crack synthesis intensity coefficient, simulated illumination perturbation vector, and surface normal estimation field. By performing multi-value sampling on the crack synthesis intensity coefficient and multiple samplings on the random noise in the physical consistency diffusion anomaly generation model, multi-scale, multi-directional virtual microcrack sample images are generated. Multi-scale, multi-directional virtual microcrack sample images are paired with their corresponding standardized pill images to construct a synthetic anomaly training sample set.

5. The image processing-based amlodipine besylate tablet quality inspection and control system according to claim 1, characterized in that, The improved RealNet module includes: Construct an improved RealNet anomaly detection network model driven by physical consistency; Based on the crack synthesis strength coefficient, a strength monotonic consistency loss is constructed; Based on the simulated illumination perturbation vector, an illumination decoupling consistency loss is constructed. Based on the surface normal estimation field, physical weighting coefficients are defined, and directional consistency loss is constructed based on the physical weighting coefficients; Based on the anomaly-aware feature selection mechanism, a channel selection weight vector is constructed, and a channel selection sparse loss is constructed based on the channel selection weight vector. The total training loss function is constructed by weighting the intensity monotonic consistency loss, illumination decoupling consistency loss, orientation consistency loss and channel selection sparsity loss. Based on the total training loss function, iterative optimization and updates are performed on the parameters of the feature extraction network, the parameters of the anomaly perception feature selection mechanism, and the parameters of physical consistency modulation. After training convergence, the improved RealNet anomaly detection network model is output.

6. The image processing-based amlodipine besylate tablet quality inspection and control system according to claim 1, characterized in that, The probability map generation module includes: The high-resolution reconstructed image of the nth subpixel is input into the trained improved RealNet anomaly detection network model. During the forward propagation of the network, the corresponding multi-scale feature tensor is output at the lth feature layer. Based on the channel selection weight vector, channel weighting is performed on the multi-scale feature tensor of the l-th feature layer to obtain the anomaly-aware feature tensor. A low-resolution anomaly score map is constructed based on the anomaly perception feature tensor of all feature layers. The anomaly score at each low-resolution spatial coordinate position in the low-resolution anomaly score map is converted into a low-resolution anomaly probability map using the Sigmoid mapping function. The low-resolution anomaly probability map is mapped to the sub-pixel grid coordinate space through an interpolation upsampling operator to obtain the sub-pixel semantic attention weight map; Cross-layer aggregation is performed based on the anomaly-aware feature tensors of all feature layers to obtain anomaly feature embedding representations.

7. The image processing-based amlodipine besylate tablet quality inspection and control system according to claim 1, characterized in that, The anomaly response graph generation module includes: Perform a local Fourier transform on the sub-pixel high-resolution reconstructed image to calculate the high-frequency energy distribution map; The high-frequency energy distribution map and the embedded representation of abnormal features are aligned in the frequency domain to generate a sub-pixel spectral residual matrix. The sub-pixel spectral residual matrix is ​​fed back to the trained improved RealNet anomaly detection network model to update the low-resolution anomaly probability map; The updated low-resolution anomaly probability map and high-frequency detail features of sub-pixels are input into the cross-scale sub-pixel-semantic fusion interpolation mapping module. A learnable spatial weight tensor is used to complete the reprojection of anomaly information to the sub-pixel space and pixel-level weighted fusion to generate a high-precision anomaly response map.

8. The image processing-based quality inspection and control system for amlodipine besylate tablets according to claim 1, characterized in that, The detection and determination module includes: Perform connected component analysis on the high-precision anomaly response map. When the anomaly response value at the sub-pixel grid coordinate position is greater than or equal to the anomaly response threshold, mark the corresponding sub-pixel grid coordinate position as a candidate anomaly pixel and construct a binary anomaly mask map from all candidate anomaly pixels. Performing an eight-neighbor connected component labeling operation on the binary anomaly mask image will divide the spatially interconnected candidate anomaly pixels into several connected regions, resulting in a set of connected regions. For each connected region, perform skeleton extraction and curvature statistics; Construct topology consistency decision filtering rules to remove regions that conform to the lettering geometry pattern and dust noise pattern, and extract the connected regions after topology consistency decision filtering as microcrack defect regions. Crack length, average crack width, and continuity index are calculated based on the microcrack defect region. The crack length, average crack width, and continuity index are compared with the preset quality control thresholds to output the qualified or unqualified results of amlodipine besylate tablets.

9. The image processing-based amlodipine besylate tablet quality inspection and control system according to claim 8, characterized in that, The topology consistency decision filtering rules include: When the area of ​​a connected region is greater than or equal to the area threshold and the average curvature value of the connected region is less than or equal to the curvature threshold, the corresponding connected region is identified as a lettering geometry pattern region and is removed. When the area of ​​a connected region is less than or equal to the noise area threshold, the corresponding connected region is identified as a dust noise mode region and is removed.

10. The image processing-based amlodipine besylate tablet quality inspection and control system according to claim 8, characterized in that, The criteria for determining whether the amlodipine besylate tablets are qualified or unusable are as follows: When the crack length of any microcrack defect area is greater than the crack length threshold, or the average crack width is greater than the average crack width threshold, or the continuity index is less than the continuity threshold, amlodipine besylate tablets are determined to be scrap tablets. Amlodipine besylate tablets are considered qualified when the crack length of all microcrack defect areas is less than or equal to the crack length threshold, the average crack width is less than or equal to the average crack width threshold, and the continuity index is greater than or equal to the continuity threshold.