Method for analyzing defects in punch forming quality of medicinal rubber parts
By aligning and differentially calculating the standard template image and the inspection image of pharmaceutical rubber parts, key geometric parameters are extracted and a comprehensive defect score is generated. This solves the problem of the limitation of a single index for defect detection in the punching and forming process of pharmaceutical rubber parts, and realizes fully automated and quantitative defect identification and judgment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- QINGDAO SONGGONG AUTOMATION TECH CO LTD
- Filing Date
- 2026-03-06
- Publication Date
- 2026-06-09
AI Technical Summary
In the existing technology, defect detection during the punching and forming process of pharmaceutical rubber parts relies on a single-dimensional quantitative indicator, which results in limited ability to identify different types of defects and affects the comprehensiveness and reliability of the detection results.
By acquiring standard template images and detection images, aligning and differentially calculating them, key geometric parameters of the difference pixel regions are extracted, such as the total area of the difference regions, the maximum width of the bounding rectangle, and the proportion of pixels with high curvature of the contour. The comprehensive defect score is calculated by combining the weighted coefficients and compared with the preset threshold to achieve automatic judgment.
It has achieved fully automated and quantitative detection of appearance defects in pharmaceutical rubber parts, improving detection efficiency and result consistency. It can identify defects of various forms, especially fine structural defects, and meets the requirements of the Good Manufacturing Practice for Medical Devices.
Smart Images

Figure CN122175916A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to a defect analysis method for the punching and forming quality of pharmaceutical rubber parts. Background Technology
[0002] In the pharmaceutical rubber parts manufacturing industry, die-cutting is widely used in the production of products such as syringe stoppers and infusion bottle stoppers. To ensure that products meet the stringent quality standards of the pharmaceutical industry, manufacturers generally use visual inspection technology to screen for appearance defects in rubber parts. In existing technologies, images of standard qualified parts are typically acquired as reference templates. Under the same imaging conditions, images of the part to be tested are obtained. Image registration technology is used to achieve spatial alignment, followed by pixel-level grayscale comparison. A fixed threshold is set to identify areas of difference, and defects are determined based on the area or shape characteristics of these areas.
[0003] However, in existing technologies, the defect detection process mainly relies on a single-dimensional quantitative indicator, which limits the ability to identify different types of defects and affects the comprehensiveness and reliability of the detection results. Summary of the Invention
[0004] This application provides a defect analysis method for the punching and forming quality of pharmaceutical rubber parts, which can solve the technical problem that it is difficult to automatically and quantitatively detect appearance defects of pharmaceutical rubber parts during the punching and forming process.
[0005] To achieve the above objectives, this application provides the following technical solution: This application provides a defect analysis method for the punching and forming quality of pharmaceutical rubber parts, including the following steps: S1, Template establishment: Acquire a standard qualified pharmaceutical rubber part image as a standard template image; S2, Real-time acquisition: Acquire the inspection image of the pharmaceutical rubber part to be inspected under the same conditions; S3, Comparison and positioning: Align and calculate the difference between the inspection image and the standard template image to obtain the difference pixel region; S4, Defect quantification: Calculate the key geometric parameters of the difference pixel region, including: the total area of the difference region A_diff, the maximum width of the bounding rectangle of the difference region W_max, and the proportion of contour high curvature pixels R_curl that characterizes the sharpness of edge burrs; S5, Quality scoring: Calculate a comprehensive defect score S based on the key geometric parameters according to the predefined scoring rules; S6, Automatic judgment: Compare the comprehensive defect score S with the preset qualified threshold S_th. If S≤S_th, it is judged as qualified; if S>S_th, it is judged as unqualified.
[0006] In an optional embodiment, in step S3, the difference calculation is to calculate the absolute difference of the gray values of corresponding pixels after aligning the two images, and mark the pixels with a difference greater than a set sensitivity threshold as difference pixels.
[0007] In an optional embodiment, in step S5, the comprehensive defect score S is calculated using the following formula: S = k1 * (A_diff / A_template) + k2 * W_max + k3 * R_curl. Where A_template is the total pixel area of the rubber part body region in the standard template image, and k1, k2, and k3 are weighting coefficients.
[0008] In one alternative embodiment, the relative magnitudes of the weighting coefficients k1, k2, and k3 satisfy the following condition: k2 > k1 > k3.
[0009] In one alternative embodiment, the weighting coefficient k2 is 1.5 to 3 times that of k1, and k1 is 2 to 5 times that of k3.
[0010] In one optional embodiment, the sensitivity threshold is dynamically determined based on the standard deviation σ of the grayscale of the background region of the standard template image, specifically: sensitivity threshold = m * σ, where m is a constant ranging from 2.5 to 4.
[0011] In one optional embodiment, the method for calculating the proportion of high curvature pixels in the contour, R_curl, is as follows: extract the edge contour of the difference pixel region, calculate the curvature of each pixel on the contour, count the number of pixels whose curvature value exceeds n times the standard arc curvature, and the ratio of this number to the total number of pixels in the contour is R_curl, where n>1.
[0012] In one alternative embodiment, the standard circular curvature is determined by the equivalent circle radius calculated from the area A_diff of the difference pixel region.
[0013] In an optional embodiment, the method for determining the preset qualified threshold S_th in step S6 is as follows: S_th = S_avg + t * σ_s, where S_avg is the average value of the comprehensive defect score S of the qualified products in the current production batch, σ_s is its standard deviation, and t is a coefficient set according to the confidence level of the production process, with a value range of 2 to 4.
[0014] In one optional embodiment, when a preset number of products have a total defect score S greater than S_avg and less than S_th, a system calibration prompt is triggered, prompting the user to check the image acquisition unit or update the standard template image.
[0015] This application provides a defect analysis method for the punching and forming quality of pharmaceutical rubber parts. The method acquires a standard template image and an inspection image, aligns them, and performs differential calculations to obtain the difference pixel region, achieving precise defect localization. Based on the difference pixel region, it calculates key geometric parameters such as the total area of the difference region A_diff, the maximum width of the bounding rectangle of the difference region W_max, and the proportion of pixels with high curvature of the contour R_curl, which comprehensively quantifies the scale, extent, and sharp edge features of the defect. According to predefined scoring rules, the key geometric parameters are fused into a comprehensive defect score S, which is automatically judged by comparison with the pass threshold S_th, thus avoiding the risk of misjudgment caused by a single indicator. This design improves the comprehensiveness of defect detection, enabling the system to simultaneously identify defects of different forms such as missing material, overflow, and burrs. The introduction of the proportion of pixels with high curvature of the contour R_curl effectively captures the sharp features of edge burrs, improving the sensitivity to subtle structural defects. The generation mechanism of the comprehensive defect score S enhances the flexibility of the evaluation, facilitating the adjustment of quantitative standards according to different product requirements. Ultimately, this method achieves full automation and objectivity in the inspection of the appearance quality of pharmaceutical rubber parts, significantly improving inspection efficiency and result consistency. Attached Figure Description
[0016] Figure 1 A flowchart illustrating a defect analysis method for the punching and forming quality of pharmaceutical rubber parts provided in this application. Detailed Implementation
[0017] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments described, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] Pharmaceutical rubber parts play a crucial role in the sealing, barrier, and cushioning functions of drug packaging, such as injectable solutions, infusion bags, and vaccine vials. The quality of their die-cutting directly impacts the sterility and safety of the drugs. Currently, in production, pharmaceutical rubber parts often suffer from surface defects such as material shortages, overflows, edge burrs, and contour distortions due to mold wear, pressure fluctuations, or batch variations. These defects are minute in size (typically tens to hundreds of micrometers), irregular in shape, and exhibit low contrast under normal lighting. Manual visual inspection relies on the inspector's experience, resulting in high rates of missed detections, inconsistent judgment standards, and low inspection efficiency, making it difficult to meet GMP requirements for process quality traceability and 100% inspection.
[0019] Based on the above issues, please refer to Figure 1 The image shows a defect analysis method for the punching and forming quality of pharmaceutical rubber parts provided in this application embodiment. The method includes the following steps: Step 1: S1, Template Creation: Obtain a standard, qualified image of a pharmaceutical rubber part as the standard template image; Among them, the standard qualified pharmaceutical rubber part image can refer to a high-definition grayscale image that has been confirmed by an authoritative third party to have no visible appearance defects and is captured under imaging conditions that are completely consistent with the subsequent test image (including the same light source type, illuminance, angle, lens focal length, exposure time and image acquisition equipment); this image is used to construct a benchmark reference for subsequent comparison; the standard template image serves as a spatial and grayscale benchmark, with a pixel resolution no lower than that of the image to be tested, and the rubber part body area in the image is clear and complete with a uniform and stable background, which facilitates subsequent accurate alignment and region segmentation.
[0020] Step 2: S2, Real-time Acquisition: Acquire inspection images of the pharmaceutical rubber parts to be inspected under the same conditions; The "same conditions" strictly refer to all imaging parameters used in the acquisition of the template image, including but not limited to: LED ring cold light source (color temperature 5500K±200K, illuminance 800lx±50lx), industrial area array camera (resolution 2448×2048 pixels, pixel size 3.45μm), fixed object distance (75mm±0.5mm), automatic white balance and fixed gain settings; this constraint ensures that the only difference between the detected image and the standard template image is the structural difference of the object being tested, eliminating artifact interference introduced by the imaging system and providing a reliable premise for subsequent pixel-level differential imaging.
[0021] Step 3: S3, Comparison and Localization: Align the detected image with the standard template image and perform difference calculation to obtain the difference pixel region; Alignment can refer to achieving sub-pixel-level geometric consistency between two images in a spatial coordinate system through image registration algorithms. For example, this application may determine the spatial mapping relationship between two images based on an affine transformation model based on feature point matching; alternatively, it may determine the spatial mapping relationship based on a non-rigid registration model based on maximizing mutual information; further, it may determine the spatial mapping relationship based on a frequency domain alignment model based on phase correlation. This application obtains accurate spatial transformation parameters based on any of the above methods to resample the detection image to a coordinate system completely aligned with the standard template image. Differential calculation can refer to performing point-by-point grayscale operations on the two aligned images at the same pixel coordinate positions. For example, this application may identify the difference response based on the absolute difference of the grayscale values of corresponding pixels; alternatively, it may identify the difference response based on the normalized difference of the grayscale values of corresponding pixels; further, it may identify the difference response based on the weighted difference of the grayscale values of corresponding pixels. This application obtains the differential response intensity of each pixel location based on any of the above methods, and defines the set of pixels with response intensity higher than a set threshold as the differential pixel region. This region is visually represented as discrete bright spots or connected patches around the edge of the rubber part or inside the body, characterizing the spatial location of potential defects.
[0022] Step 4: S4, Defect Quantization: Calculate the key geometric parameters of the difference pixel region, including: the total area of the difference region A_diff, the maximum width of the bounding rectangle of the difference region W_max, and the proportion of contour high curvature pixels that characterize the sharpness of edge burrs R_curl; Among them, the total area of the difference region, A_diff, can refer to the total number of all pixels in the difference pixel region, in pixels; this parameter reflects the overall scale of the defect, the larger the area, the more severe the material shortage or overflow; the maximum width of the bounding rectangle of the difference region, W_max, can refer to the maximum side length obtained by projecting the minimum bounding rectangle of the difference pixel region along its principal axis, in pixels; this parameter describes the spatial extension range of the defect, especially having a strong characterizing ability for strip-shaped overflow and stringy defects; the proportion of pixels with high curvature in the contour, R_curl (curvature). Curvature can refer to the percentage of pixels on the edge contour of the differential pixel region whose curvature value exceeds n times the standard arc curvature, out of the total number of pixels in the contour. Curvature is used to quantify the degree of local bending at the edge direction, with high curvature points concentrated at burr tips, serrated protrusions, or the ends of microcracks. This application may estimate the curvature of each point in the contour using the Sobel gradient operator combined with the Hessian matrix. Alternatively, it may fit a local arc using Freeman chain code and inversely deduce the curvature. Further, it may calculate the discrete curvature using a three-point interpolation method for the contour point sequence. This application obtains the contour curvature distribution based on any of the above methods and filters high-curvature pixels according to a preset multiple n, thereby quantitatively characterizing the sharpness and micro-irregularity of burrs.
[0023] Step 5: S5, Quality Score: Based on the predefined scoring rules and key geometric parameters, a comprehensive defect score S is calculated. The predefined scoring rule can refer to mapping multiple dimensions of geometric parameters into a single numerical quality index through weighted fusion. This rule does not rely on human experience scoring, but is formed based on historical qualified sample statistics and defect severity classification. For example, this application can calculate the comprehensive defect score S based on a linear weighted combination model; it can also calculate the comprehensive defect score S based on a segmented threshold superposition model; furthermore, it can calculate the comprehensive defect score S based on a fuzzy membership degree synthesis model. This application obtains comparable and ranking defect severity values based on any of the above methods, enabling defects of different forms to be uniformly judged under the same dimension.
[0024] Step 6: S6 Automatic Judgment: Compare the comprehensive defect score S with the preset pass threshold S_th. If S≤S_th, it is judged as pass; if S>S_th, it is judged as fail. The preset pass / fail threshold S_th can be a pre-defined critical score value used to distinguish between pass and fail states. This threshold can be configured according to product grade requirements, process stability levels, or customer acceptance standards. For example, this application can set a dynamic threshold based on the statistical mean and variance of historical pass batch data. Alternatively, it can obtain a fixed threshold from a defect hazard level mapping table. Furthermore, this application can set a tiered threshold group based on multi-condition verification results. Based on any of the above methods, this application obtains a judgment boundary adapted to the current production line control requirements, achieving a closed-loop decision output from whether it is abnormal to whether it should be rejected.
[0025] For example, in a pharmaceutical brominated butyl rubber stopper production line, a standard stopper image (2448×2048 grayscale image) that has passed full physical and chemical and appearance re-inspection is first acquired as a standard template image; subsequently, 100 images of stoppers to be inspected are continuously acquired under the same optical platform; for each image to be inspected, registration, difference, region extraction and parameter calculation are performed sequentially to obtain A_diff∈[0,128] pixels, W_max∈[0,42] pixels, and R_curl∈[0%,18.7%]; based on the preset scoring rules, S∈[0.00,4.26] is calculated; when S_th is set to 2.5, a total of 7 samples with S>2.5 are detected, and after manual review, it is confirmed that they all have micron-level burrs or local material shortages that are difficult to be detected by the naked eye, which verifies the effective identification capability of this solution for fine structural defects.
[0026] This application precisely locates potential defect regions by spatially aligning and pixel-level differencing standard template images and detection images under strictly consistent imaging conditions. Then, it simultaneously extracts three complementary geometric parameters of the differing regions: area size (A_diff), spatial extension (W_max), and edge sharpness (R_curl). These parameters are then weighted and fused to generate a quantifiable comprehensive defect score S. Finally, it completes automated binary judgment based on a preset threshold S_th. This technical approach avoids reliance on modeling prior defect categories, requires no training samples or labeled data, and possesses strong generalization and plug-and-play characteristics. Simultaneously, the introduction of the R_curl parameter significantly enhances the sensitivity to burr-like defects unique to punching processes, compensating for the shortcomings of traditional area / perimeter indicators in characterizing microstructure. The entire process complies with the core requirements of Good Manufacturing Practice (GMP) for medical device manufacturing: verifiable testing processes, traceable results, and reproducible judgments.
[0027] This application also provides that the difference calculation in step S3 involves calculating the absolute difference of the gray values of corresponding pixels after aligning the two images, and marking pixels with a difference greater than a set sensitivity threshold as difference pixels, including: Step 1: After geometrically aligning the detection image with the standard template image, calculate the absolute difference of gray values for each pair of corresponding pixels at the same spatial coordinates to obtain the difference image; The absolute difference calculation can refer to the calculation of the gray values at the same pixel coordinates (x, y) of two registered images. and Calculate the absolute value of their difference. ; This calculation is a fundamental and deterministic pixel-level comparison operation in the field of image processing, used to quantify the degree of local gray-level deviation, independent of the semantics of image content, and only reflects the brightness consistency deviation; In this embodiment, the operation serves as a preliminary numerical mapping process for generating the difference region. Its output constitutes the original input data for subsequent binarization determination, providing a continuous grayscale response basis for the quantitative identification of difference pixels.
[0028] This application can obtain a differential image, for example, by pixel-by-pixel traversal and parallel gray-level subtraction; it can also obtain a differential image by GPU texture sampling and shader fragment execution; further, it can obtain a differential image by real-time output from a fixed-point differential unit in an FPGA image pipeline. This application obtains a continuous differential response map characterizing local brightness differences between images based on any of the above methods.
[0029] For example, in an industrial vision inspection station, a pharmaceutical rubber part is imaged under uniform lighting conditions and with a fixed focal length lens to acquire an 8-bit grayscale inspection image with a resolution of 1280×960; a standard template image is also acquired and stored with the same resolution and bit depth under the same imaging system; image alignment is performed using affine transformation correction based on feature point matching to make the center, edge contour, and key positioning holes of the two rubber parts coincide in pixel-level space; then the grayscale values of the two aligned images are read pixel by pixel, and absolute difference calculation is performed to generate a difference image with a dynamic range of 0–255, where the higher the grayscale value, the more significant the brightness difference at that position.
[0030] Step 2: Compare the gray value of each pixel in the difference image with the set sensitivity threshold point by point, and mark all pixels with a difference greater than the threshold as difference pixels to form a binarized difference pixel mask; Among them, the sensitivity threshold is a discrimination boundary parameter used to distinguish between real structural differences and random noise interference; This parameter can be a preset fixed constant or a variable that is dynamically adjusted according to the current imaging environment; In this embodiment, the threshold is used as the basis for difference determination, which directly determines the spatial coverage and connectivity of the final difference pixel area. Its value affects the balance between defect detection rate and false alarm rate.
[0031] This application may, for example, use a globally unified threshold scanning and logical judgment method to label differing pixels; it may also use an adaptive local window threshold segmentation method to label differing pixels; further, it may use a weighted threshold determination method after multi-scale differential response fusion to label differing pixels. Based on any of the above methods, this application obtains a binarized difference mask with clear pixel attribution identifiers, used to support the region limitation for subsequent geometric parameter extraction.
[0032] For example, this application can be based on the aforementioned difference image, setting a sensitivity threshold of 32 (corresponding to 8-bit grayscale value), and performing a >32 logic judgment on all pixels; pixels with a result of True are assigned a value of 255 (white), representing difference pixels; pixels with a result of False are assigned a value of 0 (black), representing a consistent background; thereby generating a binary mask image containing only two grayscale levels, 0 and 255, which is the basis for the original region definition used in step S4 to calculate A_diff, W_max and R_curl.
[0033] The synergistic effect of these technical features is as follows: This application ensures spatial consistency by geometrically aligning the detected image with a standard template image. Based on this, it constructs a continuous differential response reflecting local brightness deviations by calculating the absolute difference of corresponding pixel grayscale values. Then, it performs point-by-point binarization judgment in conjunction with a set sensitivity threshold, filtering out minor fluctuations below the threshold to generate a stable and robust difference pixel mask. This mask eliminates false differences caused by uneven illumination, sensor thermal noise, or mechanical micro-vibration, while retaining significant grayscale jump regions corresponding to real structural defects such as punching edge burrs, missing material, and foreign object indentations. This provides accurate and repeatable pixel-level region input for subsequent defect quantification steps, thereby ensuring the objectivity of the comprehensive defect score S and the reliability of the judgment results.
[0034] This application also provides that the comprehensive defect score S in step S5 is calculated using the following formula: S=k1*(A_diff / A_template)+k2*W_max+k3*R_curl, where A_template is the total pixel area of the rubber part body region in the standard template image, and k1, k2, and k3 are weighting coefficients, including: Step 1: S = k1 * (A_diff / A_template) + k2 * W_max + k3 * R_curl; Wherein, A_diff (total area of the difference region) is the total number of pixels covered by the difference pixel region obtained by difference calculation in step S4, used to characterize the overall coverage scale of the defect on the image plane; in this embodiment, this parameter is used as a normalized area term in the scoring calculation, and its ratio with A_template eliminates the absolute area deviation caused by the image acquisition scale or imaging scaling of pharmaceutical rubber parts, thus enhancing the adaptability of the scoring results to different batches and specifications of products; A_template (total pixel area of the rubber part body region in the standard template image) is the total number of pixels obtained by binarizing the standard template image and extracting the foreground connected components, used to provide a size benchmark; in this embodiment, this parameter is used as a denominator in the normalization operation to ensure that A_diff / A_template is a dimensionless ratio, thereby supporting cross-sample comparability; W_max (maximum width of the bounding rectangle of the difference region) is the minimum bounding rectangle fitted to the point set composed of all pixels in the difference pixel region, and the rectangle is horizontally or vertically... The maximum side length in the direction, in pixels; in this embodiment, this parameter reflects the extent of the defect's extension along a certain main direction, and is particularly sensitive to strip-shaped burrs and stringy defects. Its increase directly reflects the increased risk of spatial intrusion of the defect; R_curl (proportion of pixels with high curvature on the contour) is the proportion of pixels with significantly higher curvature than the reference arc on the edge contour of the difference pixel region to the total number of pixels on the contour, used to quantify the density of sharp abrupt changes in the edge; in this embodiment, this parameter focuses on micro-geometric distortion features and has a specific response to changes in burr sharpness caused by punching tool wear, uneven die clearance, etc.; k1, k2, k3 (weighting coefficients) are non-negative real numbers calibrated based on the stability of the pharmaceutical rubber parts manufacturing process, the level of defect hazard, and historical inspection data, used to adjust the contribution weight of each geometric parameter to the final score S; in this embodiment, the three together constitute the adjustable degrees of freedom of the scoring model, so that the same algorithm framework can be adapted to the quality judgment standards of different types of rubber parts (such as syringe stoppers and infusion bottle stoppers) by adjusting the coefficients.
[0035] This application determines the comprehensive defect score S, for example, by linearly weighting and summing the normalized area term, the maximum width term, and the contour curvature percentage term; it also determines the comprehensive defect score S by weighting and fusing each parameter after independent normalization; further, it determines the comprehensive defect score S by dynamically adjusting the weighting coefficients to match the quality emphasis of the current production stage. Based on any of the above methods, this application obtains an interpretable, debuggable, and cross-specification-transferable scalar quality score S, which supports the unified threshold judgment of conformity in subsequent automatic judgment steps.
[0036] For example, in an online inspection scenario for a batch of pre-filled syringe stoppers, the system acquires an inspection image, which, after processing in steps S3-S4, yields A_diff=186 pixels, W_max=14 pixels, and R_curl=0.32. Given that the standard template image corresponding to this type of stopper has A_template=9300 pixels, and setting k1=0.6, k2=1.2, and k3=0.15, substituting these values into the formula yields: S=0.6×(186 / 9300)+1.2×14+0.15×0.32≈0.012+16.8+0.048=16.86.
[0037] The score will be sent to step S6 and compared with the dynamically updated pass threshold S_th for the current batch to complete the single-item judgment.
[0038] This application achieves a unified dimensional representation of different types of punching defects (material shortage, burrs, wire drawing, edge chipping) by normalizing the total area A_diff of the difference region to a relative area, using the maximum width W_max of the circumscribed rectangle as a lateral expansion measure, and using the proportion of pixels with high curvature of the contour R_curl as an edge distortion intensity index, and assigning each to a configurable weighting coefficient k1, k2, k3. Based on this, the linear weighting structure ensures the separability and traceability of the influence of each parameter, enabling process engineers to locate the dominant defect type based on the contribution ratio of each item in S, and then optimize the mold state or punching parameters accordingly. Furthermore, this formula does not depend on a specific image resolution or equipment model; it only requires input of basic geometric parameters to maintain consistent judgment logic across different production line deployments, thereby improving the generalization ability and engineering reliability of the quality analysis system.
[0039] This application also provides that the relative magnitudes of the weighting coefficients k1, k2, and k3 satisfy the condition: k2 > k1 > k3, including: Step 1: The relative magnitudes of the weighting coefficients k1, k2, and k3 satisfy k2 > k1 > k3; Among them, k1 (first weighting coefficient), k2 (second weighting coefficient), and k3 (third weighting coefficient) are three independent adjustable parameters used in step S5 to calculate the comprehensive defect score S, which correspond to the normalization term of the total area of the difference region A_diff, the maximum width W_max of the bounding rectangle of the difference region, and the weight of the proportion of high curvature pixels in the contour R_curl, respectively. k1 can refer to the sensitivity adjustment factor for area-type defect features. Its function is to convert the ratio of A_diff to the total area A_template of the rubber part body region pixels in the standard template image into a comparable dimensionless contribution. k2 can refer to the dominant strengthening factor for defects in the shape and size. Its role is to amplify the influence of W_max in the comprehensive score, so that significant deviations in the width direction (such as lateral offset of the punching die or flash widening caused by uneven rubber rebound) receive higher weight response. k3 can refer to an auxiliary characterization factor for defects with abnormal micro-edge morphology. Its role is to retain the information on burr sharpness reflected by R_curl, but not to let it overly dominate the overall scoring result. In this application, the relative size relationship of k2>k1>k3 indicates that in the quality judgment logic of pharmaceutical rubber parts, the severity of defects in the spatial extension scale (W_max) is given the highest priority, followed by the defect coverage area (A_diff / A_template), and finally the degree of local geometric distortion at the edge (R_curl). This order is consistent with the quality control experience of the punching and forming process of pharmaceutical rubber parts—excessively wide flash can easily lead to sealing failure or assembly interference, while compact defects (such as small pits) or slight burrs of the same area usually do not affect the basic function.
[0040] This application determines the value relationship of k1, k2, and k3 based on a weight combination fitted from engineering verification data; it also sets the relative sizes of k1, k2, and k3 based on the actual hazard level ranking of various defects in historical non-conforming product re-inspection results; further, it maps the risk classification requirements for dimensional deviations, surface integrity, and edge conditions in the GMP appendix "Guidelines for Quality Control of Medical Rubber Products" to a numerical constraint relationship of k2>k1>k3. This application obtains a structured expression of the hazard of defect types based on any of the above methods, enabling the comprehensive defect score S to truly reflect the functional risk level of pharmaceutical rubber parts in actual use scenarios.
[0041] For example, in the punching test of a batch of butyl rubber stoppers, statistical analysis revealed that when W_max ≥ 0.8 mm, 92% of the samples experienced sealing leakage in the subsequent stopper insertion test; while when A_diff / A_template ≥ 0.5% but W_max < 0.3 mm, only 7% showed functional abnormalities; although samples with R_curl > 15% generally had visually visible burrs, all passed the puncture force test after accelerated aging. Based on this, k2 was set to 1.8, k1 to 1.0, and k3 to 0.4, satisfying k2 > k1 > k3, and conforming to the range requirement in Example 5 where k2 is 1.5–3 times k1 and k1 is 2–5 times k3.
[0042] This application achieves differentiated response capabilities to defects with different physical properties by setting a relative relationship of weighting coefficients k2>k1>k3 without introducing additional measurement dimensions; based on the inherent hazard gradient among the spatial extensibility (W_max), coverage breadth (A_diff / A_template), and edge sharpness (R_curl) of the defect, a scoring-oriented mechanism matching the functional failure modes of pharmaceutical rubber parts is constructed; thereby making the automatic judgment results more in line with the risk control logic of key quality attributes in the medical device manufacturing quality management standards.
[0043] This application also provides for weighting coefficients k2 being 1.5 to 3 times that of k1, and k1 being 2 to 5 times that of k3, including: Step 1: The weighting coefficient k2 is 1.5 to 3 times that of k1, and k1 is 2 to 5 times that of k3.
[0044] Among them, the weighting coefficients k1, k2, and k3 are non-negative real parameters used in the formula for calculating the comprehensive defect score S; k2 is 1.5 to 3 times k1 (i.e., 1.5 ≤ k2 / k1 ≤ 3), and this proportional relationship limits the relative weight strength of the maximum width W_max of the bounding rectangle of the difference region in the scoring model; k1 is 2 to 5 times k3 (i.e., 2≤k1 / k3≤5), and this ratio limits the dominance of the weight of the total area of the difference region A_diff relative to the proportion of high curvature pixels in the contour R_curl. In this embodiment, the range constraint of k2 / k1 ensures that the contribution of the W_max term to the comprehensive defect score S is always higher than that of the A_diff term, thereby strengthening the sensitive response to punching edge deformation defects (such as overcutting, offset, and collapse); the range constraint of k1 / k3 ensures that the A_diff term's ability to identify overall area defects (such as missing material and contamination coverage) is not lower than that of the R_curl term's ability to identify micro-burr sharpness defects, avoiding the systematic weakening of a certain type of defect due to coefficient imbalance.
[0045] This application can, for example, select a set of k1, k2, and k3 combinations that minimizes the false positive rate by cross-validating small batches of qualified / unqualified samples during the parameter calibration stage, based on preset proportional interval constraints. Alternatively, it can, based on the dispersion of the scoring distribution of qualified products and typical defective samples in historical batches, derive a feasible coefficient domain satisfying 1.5 ≤ k2 / k1 ≤ 3 and 2 ≤ k1 / k3 ≤ 5, while ensuring the discriminative power of S_th, and select the center value from this domain as the initial deployment parameter. Furthermore, during the production line debugging stage, it can use standard template images and detection images of known defect types to form training pairs, and employ a grid search method to traverse the two-dimensional parameter space of k2 / k1 ∈ [1.5, 3] and k1 / k3 ∈ [2, 5], selecting a set of coefficients that minimizes the variance of the S value within the qualified sample group, maximizes the mean within the unqualified sample group, and has no overlap with the qualified group. Based on any of the above methods, this application obtains a differentiated, reproducible, and comparable weighted fusion effect for three types of key geometric parameters.
[0046] For example, in a certain production line deployment, if k3=0.8, then according to k1∈[2×k3,5×k3], we get k1∈[1.6,4.0], and according to k2∈[1.5×k1,3×k1], we get k2∈[2.4,12.0]. After cross-validation, we select k1=2.6, k2=6.5, and k3=0.8. At this time, k2 / k1≈2.5 and k1 / k3=3.25, both of which fall within the specified range. After substituting this set of coefficients into S=k1×(A_diff / A_template)+k2×W_max+k3×R_curl, we calculate S=4.72 (qualified) and S=18.36 (including obvious edge burrs and local missing material) for the same rubber part punching sample. The two are significantly separated and form a clear judgment boundary with S_th=8.2.
[0047] This application, by limiting the numerical range relationship between k2 / k1 and k1 / k3, further narrows the adjustable range of the weighting coefficients while maintaining the k2>k1>k3 hierarchical structure. Through this dual proportional constraint, the W_max term continues to play a dominant role in the scoring, while ensuring that the A_diff term has a fundamental characterizing ability for the overall molding integrity, and the R_curl term participates in fine-tuning as a refined supplementary indicator. This allows the comprehensive defect score S to not only stably reflect the multidimensional degradation characteristics of the punching quality of pharmaceutical rubber parts, but also to have a consistent quantitative criterion basis under different equipment, batches, and operator conditions, thereby supporting a fully automated, standardized, and auditable quality assessment process.
[0048] This application also provides a method for setting a sensitivity threshold that is dynamically determined based on the standard deviation σ of the grayscale of the background area of a standard template image. Specifically, the sensitivity threshold is calculated as: sensitivity threshold = m × σ, where m is a constant ranging from 2.5 to 4.
[0049] Step 1: Set the sensitivity threshold. The sensitivity threshold is dynamically determined based on the standard deviation σ of the grayscale of the background area of the standard template image. Specifically, the sensitivity threshold is calculated as: sensitivity threshold = m × σ, where m is a constant ranging from 2.5 to 4.
[0050] The standard template image background region refers to the pixel region in the standard template image that does not contain the pharmaceutical rubber part itself, usually a uniform region outside the edges of the image or the outline of the rubber part; the standard deviation of gray level σ refers to the statistical dispersion of gray level values of all pixels in the background region of the image, a quantitative indicator used to characterize the inherent noise level of the region; m is an empirical adjustment coefficient used to adjust the sensitivity response intensity, with a value range limited to 2.5 to 4, indicating that a moderate amplification is applied based on the statistical characteristics of background noise to balance signal-to-noise separation and false detection suppression; the sensitivity threshold is a gray level absolute difference discrimination benchmark used to determine whether corresponding pixels in two images constitute different pixels, and its value changes dynamically with σ, thereby achieving adaptive adaptation to different imaging conditions.
[0051] For example, this application obtains the sensitivity threshold for difference calculation by statistically analyzing the gray-scale distribution of the background region of a standard template image, calculating its standard deviation σ, and multiplying σ by a preset constant m. For example, this application estimates the background noise intensity σ by fitting the image acquisition device calibration parameters and the gray-level histogram of the background region of the standard template image, and generates a sensitivity threshold by scaling the σ proportionally. Furthermore, this application traverses the background region of the standard template image through a sliding window, calculates the standard deviation of each sub-region, takes its mean as the global σ, and then multiplies it by m to obtain the final sensitivity threshold.
[0052] This application obtains a dynamic sensitivity threshold that matches the noise level of the current imaging environment based on any of the above methods, in order to support the accurate identification of difference pixels in step S3.
[0053] For example, in a certain actual inspection, the system first loads a standard template image, automatically identifies its background area (e.g., the area remaining after excluding the rubber part body through morphological dilation-erosion operation), and statistically analyzes the gray values of all pixels in the area, calculating σ=8.3; taking m=3.0, the sensitivity threshold = 3.0×8.3=24.9, that is, pixels with an absolute gray value difference greater than 24.9 are marked as difference pixels; when the background noise increases due to subsequent changes in lighting conditions, and σ rises to 12.1, the sensitivity threshold under the same m value is automatically increased to 36.3, thereby avoiding over-inspection caused by increased noise.
[0054] This application establishes a linear mapping relationship between the sensitivity threshold and the standard deviation σ of the gray level in the background region of the standard template image, and limits the scaling factor m to the range of 2.5 to 4, so that the differential discrimination benchmark can be adaptively adjusted according to the noise level of the imaging environment. On this basis, combined with the calculation of the absolute difference of pixel-level gray level after alignment in step S3, it ensures that only pixels that significantly deviate from the fluctuation range of background noise are included in the difference region. Thus, the key geometric parameters (A_diff, W_max, R_curl) quantified in step S4 truly reflect the characteristics of the punching and forming defects of pharmaceutical rubber parts, rather than imaging interference, thereby improving the robustness and consistency of the entire defect analysis method under different production line conditions.
[0055] This application also provides a method for calculating the proportion of pixels with high curvature in the contour, R_curl, including: Step 1: Extract the edge contour of the difference pixel region, calculate the curvature of each pixel on the contour, and count the number of pixels whose curvature value exceeds n times the standard arc curvature. The ratio of this number to the total number of pixels in the contour is R_curl, where n>1.
[0056] Among them, the proportion of high curvature pixels in the contour R_curl is a dimensionless normalized parameter used to characterize the degree of local geometric abrupt change at the edge of the difference pixel region; the edge contour of the difference pixel region can refer to the closed or open contour lines extracted by general edge detection algorithms such as Canny, Sobel or Freeman chain code after binarizing the difference pixel region, which constitute a set of ordered pixel sequence.
[0057] The curvature of each pixel is the reciprocal radius obtained by fitting a circle to three points in the neighborhood of that pixel, or the absolute value of the ratio of the first derivative to the second derivative calculated by discrete differentiation. Its physical meaning is the rate of change in the tangential direction per unit arc length. The standard circular arc curvature is a reference curvature value based on a unit length, or the standard curvature 1 / R_eq corresponding to the equivalent circle radius R_eq obtained by converting the area A_diff of the difference pixel region. Its function is to provide a dynamic benchmark that matches the current defect scale. n is a real number adjustment factor greater than 1, such as 1.2, 1.5, 2.0 or 3.0, used to set the strictness of the curvature screening threshold.
[0058] n>1 ensures that only sharp features that significantly deviate from the conventional curvature trend are retained, excluding normal edge fluctuations and image noise interference; pixels with curvature values exceeding n times the standard arc curvature are discrete pixels on the contour line that satisfy the condition κ_i>n×κ_ref, where κ_i is the calculated curvature of the i-th contour point and κ_ref is the standard arc curvature.
[0059] The ratio of this number to the total number of pixels in the contour is R_curl=N_high / N_total, where N_high is the number of pixels that meet the ultra-high curvature condition, and N_total is the total number of pixels in the extracted contour. This ratio makes R_curl scale-invariant and does not become distorted as the overall size of the defect area changes. It is suitable for lateral quality comparison of pharmaceutical rubber parts of different specifications.
[0060] This application calculates the curvature of each point, for example, by fitting a circle to the three neighborhood points of the contour point using the least squares method and taking the reciprocal radius; it also calculates the curvature by the absolute value of the ratio of the first-order difference to the second-order difference of the contour point coordinate sequence; further, it estimates the curvature based on the rate of change of the contour point normal offset. Based on any of the above methods, this application obtains the quantitative identification capability of sharp edge features in differential pixel regions, thereby supporting the effectiveness of R_curl as an independent defect sensitivity index.
[0061] For example, in this application: in a certain inspection, the differential pixel region is subjected to morphological closing operation and edge extraction to obtain a main contour containing 286 pixels; the curvature of the contour is calculated point by point, and the standard arc curvature κ_ref=0.025 (corresponding to an equivalent circle radius of 40 pixels) is taken, and n=2.0 is set, then the curvature threshold is 0.05; a total of 19 pixels with curvature values greater than 0.05 are found, and R_curl=19 / 286=6.64% is calculated; this value is higher than the historical average of qualified samples by 0.8% to 2.5%, indicating the presence of concentrated fine burrs, which is consistent with the results of manual re-inspection.
[0062] This application achieves highly sensitive and scale-resistant identification of early burr defects caused by micro-wear of the die edge during the punching process by comparing the local curvature of the edge contour of the difference pixel region with the standard arc curvature that is scale-adaptive, and using the proportion of ultra-high curvature points in the overall contour as the output. With the help of a strict screening mechanism of n>1, the influence of background noise and normal edge undulations is effectively suppressed. On this basis, R_curl, A_diff, and W_max together constitute a multi-dimensional geometric representation system, so that the comprehensive defect score S can more comprehensively reflect the edge quality status of pharmaceutical rubber parts, thereby improving the robustness of automatic judgment and clinical applicability and safety.
[0063] This application also provides a method for determining the equivalent circle radius obtained by converting the standard circular arc curvature from the area A_diff of the difference pixel region, including: Step 1: The standard circular arc curvature is determined by the equivalent circle radius obtained by converting the area A_diff of the difference pixel region.
[0064] The equivalent circular radius (R_eq) refers to the radius corresponding to the transformation of a pixel region of arbitrary shape into an ideal circle without changing the area. In the field of image processing, the equivalent circular radius is often used to characterize the scale features of irregular connected regions, and its mathematical definition is R_eq=\sqrt{A_{\text{diff}} / \pi}. In this embodiment, the equivalent circular radius is used to derive the standard circular curvature κ_ref that matches the scale of the current difference region, i.e., κ_ref=1 / R_eq, thereby providing a dynamic reference benchmark for the recognition of pixels with high curvature of the contour.
[0065] This application, for example, calculates the equivalent circle radius R_eq based on the area A_diff of the difference pixel region, and obtains the standard arc curvature κ_ref based on the reciprocal of R_eq to determine the judgment threshold of the high curvature pixel point of the contour; this application, for example, first normalizes A_diff to eliminate the influence of image resolution, and then substitutes it into the formula R_eq=\sqrt{A_{\text{diff}} / \pi} to calculate the equivalent circle radius, and then derives κ_ref to determine the judgment threshold of the high curvature pixel point of the contour.
[0066] Furthermore, this application maps A_diff to a preset lookup table interval and determines the threshold for high-curvature pixels by finding the corresponding standard arc curvature κ_ref in a pre-established A_diff–κ_ref mapping table. This application obtains a standard arc curvature adapted to the actual size of the difference region based on any of the above methods, ensuring the consistency of the R_curl index in judging the sharpness of burrs on defect edges at different scales.
[0067] For example, in this application: In a certain detection, the system calculates the total area of the difference pixel region A_diff = 314 pixels, then the equivalent circle radius R_eq = \sqrt{314 / \pi} = \sqrt{100} = 10 pixels, corresponding to the standard arc curvature κ_ref = 0.1 pixel^{-1}; if n=2 is set, then the high curvature judgment threshold is 2×κ_ref = 0.2 pixel^{-1}; then the system calculates the discrete curvature of each pixel on the edge contour of the difference region one by one, counts the number of pixels with curvature values greater than 0.2 pixel^{-1}, and compares it with the total number of pixels in the contour to obtain R_curl = 12.5%.
[0068] This process ensures that small-area defects (e.g., A_diff=31 pixels) correspond to a higher curvature benchmark (κ_ref=0.32 pixels^{-1}), while large-area defects (e.g., A_diff=3140 pixels) correspond to a lower curvature benchmark (κ_ref=0.032 pixels^{-1}), so that the sharpness evaluation is always anchored to the local geometric scale.
[0069] This application establishes a functional mapping relationship between the standard circular arc curvature κ_ref and the area of the differential pixel region A_diff, and achieves adaptive generation of the curvature benchmark by using the equivalent circle radius R_eq=\sqrt{A_{\text{diff}} / \pi}. On this basis, a dynamic high curvature judgment threshold is formed by combining an n-fold magnification mechanism, so that the proportion of high curvature pixels in the contour R_curl can truly reflect the relative sharpness of the edges of defects of different sizes. This supports the differentiated weighted response to burr-type defects in the comprehensive defect score S, and improves the physical rationality and engineering robustness of the quality judgment of the punching and forming of pharmaceutical rubber parts.
[0070] This application also provides a method for determining the preset qualified threshold S_th in step S6, specifically: S_th=S_avg+t*σ_s, where S_avg is the average value of the comprehensive defect score S of the qualified products in the current production batch, σ_s is its standard deviation, and t is a coefficient set according to the confidence level of the production process, with a value range of 2 to 4.
[0071] Step 1: S_th = S_avg + t * σ_s, where S_avg is the average of the comprehensive defect score S of the qualified products in the current production batch, σ_s is its standard deviation, and t is a coefficient set according to the confidence level of the production process, with a value range of 2 to 4.
[0072] Among them, S_avg (average comprehensive defect score) can refer to a statistic obtained by taking the arithmetic mean of the comprehensive defect scores S corresponding to all the qualified pharmaceutical rubber parts that have been inspected and determined to be qualified in the current production batch; this statistic reflects the central tendency of the defect levels of the qualified products in the current batch; σ_s (standard deviation of comprehensive defect score) is a statistic that characterizes the dispersion degree of the comprehensive defect scores S of the qualified products in the current batch, and its calculation is based on the S values of the same set of qualified samples, and is used to quantify the amplitude of quality fluctuations within this batch; t (confidence coefficient) is a dimensionless adjustment parameter used to control the upward offset of the qualified threshold S_th relative to S_avg; the larger its value, the higher the requirement for process stability and the smaller the allowable abnormal deviation.
[0073] This application can update S_avg and σ_s in real time in a sliding window manner according to the sequence of S values of historical qualified samples, and dynamically calculate S_th in combination with a preset t value; this application can also calculate the initial S_avg and σ_s at one time according to the first N qualified samples (N≥30) collected at the start of each new production batch, and keep S_th unchanged during the continuous process of this batch until the start of the next batch; further, this application can also configure the update mechanism of S_avg and σ_s as event-triggered - when the system receives a manually confirmed batch switching instruction or detects that M consecutive S values exceed the previous S_th by a preset ratio, the statistical window is automatically reset and S_avg and σ_s are recalculated. This application obtains a qualified judgment boundary that adapts dynamically with the production batch based on any of the above methods, enabling S_th to respond to normal process fluctuations and effectively identify real quality anomalies.
[0074] Exemplarily, in a certain punching production line of pharmaceutical rubber stoppers, a total of 120 qualified products are inspected in the current batch, and their comprehensive defect scores S form a data set ; after calculation, S_avg = 4.27 and σ_s = 0.83; setting t = 3 (corresponding to a 99.7% normal confidence level), then S_th = 4.27 + 3×0.83 = 6.76; for each subsequent newly inspected sample, if S≤6.76, it is determined to be qualified, otherwise it is determined to be unqualified; after 200 pieces have been inspected cumulatively in this batch, the system automatically recalculates S_avg and σ_s with the latest 200 qualified S values and updates S_th to ensure that the threshold is always anchored to the current process state.
[0075] This application constructs the pass threshold S_th as a linear combination of S_avg and σ_s, and limits t ∈ [2,4], so that the decision boundary no longer depends on empirical fixed values, but is based on the measured statistical distribution of the pass samples in the current batch. By leveraging the synergy of S_avg representing the center position, σ_s representing the degree of dispersion, and t controlling the confidence strength, it achieves adaptive tolerance to short-term process drift, while ensuring high sensitivity to substantial quality degradation. This design meets the requirements of process verification and continuous process validation (CPV) in the GMP environment, and can maintain the scientificity and robustness of the decision logic without frequent manual intervention.
[0076] The method also includes: when the comprehensive defect score S of a preset number of products is greater than S_avg and less than S_th, a system calibration prompt is triggered, prompting the user to check the image acquisition unit or update the standard template image.
[0077] The preset quantity is a positive integer, such as 3, 5 or 10, for example, 5. This value is set based on the production line cycle time, historical data on the stability of rubber part punching, and quality control level, and is used to balance the warning sensitivity and false alarm rate. S_avg is the average comprehensive defect score of the qualified products in the current production batch. Its statistical range is limited to the sample set that has been judged as qualified in step S6, and does not include any products that have been judged as unqualified.
[0078] The expression for S_th is S_th=S_avg+t×σ_S, where σ_S is the standard deviation of the comprehensive defect score S in the qualified sample set, and t is a coefficient ranging from 2 to 4. Both are greater than S_avg and less than S_th, which constitute a closed interval judgment condition, i.e., S∈(S_avg,S_th), which is used to identify the trend of the overall score moving upward but has not yet broken through the qualified boundary.
[0079] This application triggers a calibration prompt based, for example, on the interval assignment result of N consecutive qualified product S values within a real-time scrolling window; it triggers a calibration prompt based on the cumulative count of consecutive counters satisfying the condition S∈(S_avg,S_th) within a sliding time window reaching a preset number; further, it triggers a calibration prompt based on the length of the consecutive hit sequence in the high-order segment (i.e., the (S_avg,S_th) interval) of the S value distribution histogram of the current batch of qualified samples. Based on any of the above methods, this application obtains the ability to identify early performance degradation of the image acquisition system or inaccuracy of the standard template.
[0080] For example, in this application: on an automated punching production line for pharmaceutical rubber stoppers, the system outputs an S value after each rubber stopper is inspected; when five consecutive S values fall within the interval (1.8, 3.2) formed by S_avg=1.8 and S_th=3.2 for the current batch, the system pops up a prompt box: five consecutive qualified sample scores have been detected approaching the upper limit. It is recommended to check the cleanliness of the industrial camera lens or re-acquire the standard template image. At the same time, the subsequent automatic judgment process is paused, and the operator is asked to confirm or perform a calibration action.
[0081] This application identifies slow performance drift in the image acquisition system (such as light source intensity decay, slight lens contamination, or minor installation displacement) or mismatch between the standard template image and the current process state due to long-term use by monitoring the continuous occurrence of the comprehensive defect score S of multiple qualified products within the range of (S_avg, S_th). Using this trend-based judgment mechanism, calibration intervention is initiated before defects accumulate to the point of triggering a non-conformance judgment, thereby avoiding the risk of subsequent batches being mistakenly judged as qualified due to systematic bias. Furthermore, the application provides clear instructions indicating two actionable steps: inspecting the image acquisition unit or updating the standard template image. This makes the maintenance response highly targeted and executable, significantly improving the robustness and intelligent operation and maintenance level of the detection system.
[0082] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for defect analysis of the punching and forming quality of pharmaceutical rubber parts, characterized in that, Includes the following steps: S1. Obtain a standard, qualified image of a pharmaceutical rubber part as a standard template image; S2. Obtain inspection images of the pharmaceutical rubber parts to be inspected under the same conditions; S3. Align the detected image with the standard template image and perform difference calculation to obtain the difference pixel region; S4. Calculate the key geometric parameters of the difference pixel region, including: the total area of the difference region A_diff, the maximum width of the bounding rectangle of the difference region W_max, and the proportion of contour high curvature pixels that characterize the sharpness of edge burrs R_curl. S5. Calculate a comprehensive defect score S based on the key geometric parameters according to the predefined scoring rules; S6. Compare the comprehensive defect score S with the preset pass threshold S_th. If S≤S_th, it is judged as passable; if S>S_th, it is judged as failable.
2. The method according to claim 1, characterized in that, In step S3, the difference calculation is to calculate the absolute difference of the gray values of corresponding pixels after aligning the two images, and mark the pixels with a difference greater than a set sensitivity threshold as the difference pixels.
3. The method according to claim 1, characterized in that, In step S5, the comprehensive defect score S is calculated using the following formula: S=k1 (A_diff / A_template)+k2 W_max+k3 R_curl, where A_template is the total pixel area of the rubber part body region in the standard template image, and k1, k2, and k3 are weighting coefficients.
4. The method according to claim 3, characterized in that, The relative magnitudes of the weighting coefficients k1, k2, and k3 satisfy the following condition: k2 > k1 > k3.
5. The method according to claim 4, characterized in that, The weighting coefficient k2 is 1.5 to 3 times that of k1, and k1 is 2 to 5 times that of k3.
6. The method according to claim 3, characterized in that, The set sensitivity threshold is dynamically determined based on the standard deviation σ of the grayscale of the background region of the standard template image, specifically: the sensitivity threshold = m σ, where m is a constant ranging from 2.5 to 4.
7. The method according to claim 3, characterized in that, The calculation method for the proportion of high curvature pixels in the contour, R_curl, is as follows: extract the edge contour of the difference pixel region, calculate the curvature of each pixel on the contour, and count the number of pixels whose curvature value exceeds n times the standard arc curvature. The ratio of this number to the total number of pixels in the contour is R_curl, where n>1.
8. The method according to claim 7, characterized in that, The standard circular arc curvature is determined by the equivalent circle radius obtained by converting the area A_diff of the difference pixel region.
9. The method according to claim 1, characterized in that, The method for determining the preset qualified threshold S_th in step S6 is: S_th = S_avg + t σ_s, where S_avg is the average of the comprehensive defect score S of the qualified products in the current production batch, σ_s is its standard deviation, and t is a coefficient set according to the confidence level of the production process, with a value range of 2 to 4.
10. The method according to claim 9, characterized in that, When a preset number of products have a total defect score S greater than S_avg and less than S_th, a prompt will be made to check the image acquisition unit or update the standard template image.