Soft blister film surface defect detection method based on machine vision
By using machine vision-based methods to generate grayscale images using transmitted and reflected light information, establishing a floating coordinate system for pixel-level registration, and combining frequency domain transformation and gradient vector field analysis, the problems of detection benchmark failure and texture defect identification in high-speed production of soft blister film are solved, achieving non-contact and accurate detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU PAKION MEDICAL MATERIAL CO LTD
- Filing Date
- 2026-01-12
- Publication Date
- 2026-04-21
AI Technical Summary
Existing technologies are ill-suited to the failure of detection benchmarks caused by positional drift during high-speed production of flexible blister films, and cannot accurately identify minute texture defects, especially crystal points and bubbles, resulting in a high misjudgment rate. Furthermore, contact pressure can damage the film material.
A machine vision-based approach is adopted to generate grayscale images through transmitted and reflected light information, establish a floating coordinate system for pixel-level registration, and use frequency domain transformation and local gradient vector field analysis, combined with directional consistency entropy value to determine defects, thereby achieving non-contact detection.
It enables accurate identification of texture defects during high-speed transport of soft blister film, reduces the false judgment rate, avoids physical damage, and improves the safety and reliability of detection.
Smart Images

Figure CN121904014A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect detection technology, specifically a method for detecting surface defects in soft blister films based on machine vision. Background Technology
[0002] With the automation transformation of precision manufacturing, optoelectronic displays, new energy, and high-end packaging industries, the surface quality inspection of flexible transparent film materials, as key basic materials, is of paramount importance. Machine vision technology, leveraging its non-contact and high-speed advantages, is gradually replacing manual inspection. However, these flexible materials generally share common characteristics such as high light transmittance, complex surface textures, and a high susceptibility to flexible deformation during high-speed winding or transport. These physical properties lead to strong interference in the image's optical path, and the spatial positioning of the target within the image background poses a significant challenge to the anti-background interference capability, weak feature recovery, and dynamic capabilities of fixed detection algorithms.
[0003] In the prior art, patent document CN120064114A discloses a surface defect detection method based on machine vision. By employing static region segmentation logic, the object to be inspected is divided into several equal-area regions, and the central region is marked. The length and width of the defects are obtained and compared with preset standards for judgment. Furthermore, this technology also relies heavily on physical contact verification, that is, applying pressure to the central detection area using a preset pressure, and determining whether the object is qualified based on the change in defect size before and after pressure application.
[0004] However, the aforementioned technologies have significant limitations when applied to high-speed online inspection of flexible blister films. First, the production of flexible blister films involves a continuous flow and high-frequency lateral serpentine deviation; existing static, fixed-coordinate-based region division cannot adapt to the real-time drift of the film material, rendering the inspection benchmark ineffective. Second, crystal points and bubbles on the surface of the flexible film are mostly weak-contrast texture defects, which are difficult to distinguish from normal textures using only simple geometric dimensions such as length and width, resulting in a high false positive rate. Most importantly, for fragile flexible films with a thickness of only micrometers, the contact pressure method relied upon by existing technologies not only fails to meet the millisecond-level real-time inspection requirements but also directly damages the film surface. Therefore, there is an urgent need for an inspection method that can adapt to the dynamic positional changes of flexible films and accurately identify minute texture defects through non-contact methods.
[0005] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] The purpose of this invention is to provide a machine vision-based method for detecting surface defects in soft blister films, so as to solve the problems mentioned in the background art.
[0007] To achieve the above objectives, the present invention provides the following technical solution:
[0008] A machine vision-based method for detecting surface defects in flexible blister films includes the following steps:
[0009] Step 1: Collect the light intensity information after the light passes through the soft blister film to generate a transmission grayscale image, and simultaneously collect the light reflection information on the surface of the soft blister film to generate a reflection grayscale image;
[0010] Step 2: Extract the edge contour features of the soft blister film, construct a floating coordinate system with the position of the edge contour features in the image coordinates as the reference, perform coordinate mapping processing on the reflective grayscale image under the floating coordinate system, and register the pixel coordinates of the reflective grayscale image and the transmittance grayscale image to the same spatial reference.
[0011] Step 3: Perform frequency domain transformation on the registered transmission grayscale image and apply a high-pass filtering rule to it in the frequency domain. After filtering, perform inverse transformation on the result to obtain a high-frequency response image. In the high-frequency response image, filter pixels whose high-frequency response values exceed the preset benchmark and perform connectivity analysis to form candidate defect connected components.
[0012] Step 4: Extract the pixel region corresponding to the connected component of the candidate defect from the spatially registered grayscale image, and construct a set of local gradient vectors within the pixel region according to a fixed neighborhood range. Form a local gradient vector field based on the set of local gradient vectors, and perform statistical processing on the distribution of each gradient direction in the local gradient vector field to obtain the corresponding directional consistency entropy value.
[0013] Step 5: Compare the directional consistency entropy value corresponding to each candidate defect connected region with the preset wrinkle threshold. When the directional consistency entropy value is higher than the preset wrinkle threshold, the corresponding candidate defect connected region is determined to be a substantial defect target. Geometric parameters of the substantial defect target are then identified to obtain the detection result.
[0014] Furthermore, the soft blister film is backlit, and the real-time luminous flux penetrating the soft blister film is collected. The state where the real-time luminous flux reaches full saturation is set as the gray-level extreme value, and the state where the real-time luminous flux is completely cut off is set as the gray-level zero point. A linear mapping interval is constructed based on the gray-level extreme value and the gray-level zero point. The real-time luminous flux is linearly mapped into a transmitted gray-level image using the linear mapping interval.
[0015] The flexible blister film is illuminated by a coaxial light source, and the real-time reflected light intensity on the surface of the flexible blister film is collected. The real-time reflected light intensity is digitized and converted into reflected grayscale data. Based on the two-dimensional spatial distribution of the reflected grayscale data, a reflected grayscale image of the flexible blister film is constructed.
[0016] Furthermore, the membrane edge position information of the transmission grayscale image is extracted, and the membrane edge position information is used to construct the membrane edge contour feature;
[0017] A floating coordinate system is established to follow the displacement of the soft blister film by establishing the direction of movement of the soft blister film and the contour features of the film edge. The lateral offset of the contour features of the film edge in the floating coordinate system relative to the preset alignment reference is calculated. The lateral offset is used to perform reverse translation compensation on the reflective grayscale image, and the pixel coordinates of the reflective grayscale image and the transmittance grayscale image are registered to the same spatial reference. The preset alignment reference is the center coordinate value of the camera's field of view.
[0018] Furthermore, a fast Fourier transform is performed on the grayscale distribution data of the registered transmission grayscale image to obtain the frequency domain spectrum.
[0019] Using the zero-frequency center of the frequency domain spectrum as the center, the radial cumulative energy is statistically calculated. The frequency radius corresponding to the radial cumulative energy reaching a specific percentage of the total energy is determined as the cutoff frequency. The frequency domain spectrum is then high-pass filtered using the cutoff frequency. Finally, an inverse Fourier transform is performed on the filtered frequency domain spectrum to obtain the high-frequency response image.
[0020] The maximum inter-class variance is calculated on the high-frequency response image to obtain the segmentation threshold. Pixels with high-frequency response values higher than the segmentation threshold are marked as outliers, and adjacent outliers are aggregated into candidate defect connected regions.
[0021] Furthermore, the spatially registered grayscale image is extracted, and the corresponding pixel region in the spatially registered grayscale image is locked based on the pixel coordinate set of the candidate defect connected domain. The grayscale gradients in the horizontal and vertical directions of each pixel in the pixel region are calculated and the gradient vectors are synthesized. A local gradient vector field is constructed based on the set of orientation angles of the gradient vectors of all pixels in the candidate defect connected domain.
[0022] The candidate defect connected domain is divided into bins based on the total number of pixels. The bins are then divided equally to obtain bin intervals. The frequency of the orientation angle data of the local gradient vector field falling into the bin interval is counted to obtain the probability distribution within each bin interval. The probability distribution is calculated based on the Shannon entropy formula to obtain the orientation consistency entropy value of the candidate defect connected domain.
[0023] Furthermore, the expression for the directional consistency entropy value is:
[0024]
[0025] In the formula, The entropy value represents the direction consistency. The total number of pixels in the candidate defect connected region. For the first Probability distribution within each bin interval To numerically calculate the stability constant, The maximum possible entropy value, This is the box number.
[0026] Furthermore, the directional consistency entropy value is compared with a preset wrinkle threshold. If the directional consistency entropy value is greater than the preset wrinkle threshold, the candidate defect connected component is determined to be a substantial defect target.
[0027] Furthermore, wrinkled samples from historical detection data are selected, and the maximum directional consistency entropy value of the wrinkled samples is used as the wrinkle threshold.
[0028] Furthermore, extract the minimum bounding rectangle of the substantial defect target;
[0029] Calculate the pixel area of a target with substantial defects;
[0030] The geometric span information of the minimum bounding rectangle is combined with the pixel area to generate the detection result of surface defects of the soft blister film.
[0031] Compared with the prior art, the beneficial effects of the present invention are:
[0032] This invention leverages the characteristic of lateral drift that easily occurs in flexible blister films during high-speed transport. It extracts the film edge contour features from the transmitted grayscale image to establish a floating coordinate system, and uses the lateral offset of this floating coordinate system to perform inverse displacement compensation on the reflected grayscale image. This process overcomes the detection position misalignment problem caused by static fixed region division in existing technologies, ensuring that even if the film material experiences irregular shaking, the detection algorithm can achieve accurate pixel-level registration through dynamic coordinate following. Furthermore, by performing frequency domain transformation processing on the registered transmitted grayscale image and selecting pixel regions with high-frequency response values exceeding a preset benchmark as candidate defect connected regions, it can sensitively capture abrupt texture changes on the surface of the flexible blister film. Compared to traditional technologies that rely solely on simple geometric dimensions such as length and width for initial screening, this frequency response-based extraction method can effectively separate the background from weak crystal points or bubbles, improving the detection capability for low-contrast latent defects.
[0033] This invention also establishes a non-contact defect verification logic by constructing a local gradient vector field using the pixel grayscale distribution at the corresponding position in the spatially registered reflection gradient image of the candidate defect connected components and calculating the directional consistency entropy value. Based on the physical difference that wrinkled textures have directional regularity while substantial defect textures have chaotic direction, the substantial defect target can be accurately identified by comparing the directional consistency entropy value with a preset wrinkle threshold. This method completely abandons the contact-based approach in existing technologies that relies on physical pressure to distinguish the nature of defects, completely eliminating the risk of physical damage to micron-level fragile membrane materials, and also breaking through the speed bottleneck of contact operations on high-speed production lines. Finally, by combining the geometric morphological parameters of the substantial defect target with the lateral offset of the floating coordinate system to generate detection results, the precise location of the defect's physical position is achieved, improving the safety of the detection process and the reliability of the results. Attached Figure Description
[0034] Figure 1 This is a schematic diagram of the overall method flow of the present invention.
[0035] Figure 2 This diagram illustrates the surface defect detection rate of soft blister film samples of different thicknesses. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.
[0037] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0038] Example:
[0039] Please see Figures 1 to 2 The present invention provides a technical solution:
[0040] A machine vision-based method for detecting surface defects in flexible blister films includes the following steps:
[0041] Step 1: Collect the light intensity information after the light passes through the soft blister film to generate a transmission grayscale image, and simultaneously collect the reflected light information on the surface of the soft blister film to generate a reflection grayscale image.
[0042] In this embodiment, the soft blister film is backlit, and the real-time luminous flux penetrating the soft blister film is collected. The state where the real-time luminous flux reaches full saturation is set as the gray-level extreme value, and the state where the real-time luminous flux is completely cut off is set as the gray-level zero point. A linear mapping interval is constructed based on the gray-level extreme value and the gray-level zero point, and the real-time luminous flux is linearly mapped into a transmitted gray-level image using the linear mapping interval.
[0043] The flexible blister film is illuminated by a coaxial light source, and the real-time reflected light intensity on the surface of the flexible blister film is collected. The real-time reflected light intensity is digitized and converted into reflected grayscale data. Based on the two-dimensional spatial distribution of the reflected grayscale data, a reflected grayscale image of the flexible blister film is constructed.
[0044] Flexible thermoforming films typically possess high light transmittance and reflective properties, making it difficult to comprehensively cover all types of defects using a single illumination method. The strategy of simultaneously acquiring illumination and reflection data is employed because illumination is highly sensitive to opaque impurities within the film material, such as black spots, foreign objects, or density variations; these defects can suddenly create noticeable dark spots. Meanwhile, the reflected light path focuses on capturing surface texture variations. For transparent surface scratches, crystal points, or wrinkles, light will refract or scatter at the surface, resulting in grayscale differences in the reflected grayscale image. This combination achieves comprehensive inspection of both the internal structure and the surface, effectively preventing missed detections.
[0045] Due to the high light transmittance of flexible blister film, directly acquired light intensity signals often have a narrow dynamic range or are too concentrated. By defining complete saturation and complete cutoff of the light flux as grayscale extremes (e.g., 255) and grayscale zeros (e.g., 0), respectively, and constructing a linear mapping interval, the image is essentially subjected to grayscale stretching and normalization. This processing method can fully utilize the camera's dynamic range, enhance image contrast, and make subtle differences in light transmittance in grayscale images more apparent.
[0046] The reason for constructing a reflective grayscale image based on two-dimensional spatial distribution is that the reflected light intensity may initially be one-dimensional or discrete data collected through linear arrays or sensor points. For subsequent morphological and texture orientation analysis, these discrete light intensity data must be reconstructed into a two-dimensional matrix image according to their physical positions on the membrane surface. This provides the necessary spatial data foundation for subsequent steps such as extracting membrane edges, constructing a floating coordinate system, and calculating the gradient field. The surface defect detection rate data in this embodiment are shown in Table 1.
[0047] Table 1: Schematic diagram of surface defect detection rate of flexible blister film samples of different thicknesses
[0048] Membrane thickness (mm) Surface defect detection rate of single reflection optical path Surface defect detection rate of single transmission optical path The surface defect detection rate of the method in this embodiment 0.02 60 18 97.5 0.03 61.5 20 97.6 0.04 63 22 97.8 0.05 72 29 98.5 0.06 73.5 30.5 98.6 0.07 75 32 98.7 0.08 79 36 99 0.09 80 37 99 0.1 81 38 99.2 0.11 81.2 38.5 99.2 0.12 82 40 99.3 0.13 82.2 40.5 99.3 0.14 82.5 41 99.3 0.15 83 42 99.4 0.16 83.2 42.5 99.4 0.17 83.5 43 99.4 0.18 85 45 99.5 0.19 85.2 45.5 99.5 0.2 86 48 99.6 0.21 86.2 48.5 99.6 0.22 86.5 49 99.6 0.23 86.6 49.2 99.6 0.24 86.8 49.5 99.6 0.25 87 50 99.6 0.26 87.1 50.2 99.6 0.27 87.2 50.5 99.6 0.28 87.3 50.8 99.6 0.29 87.4 51 99.6 0.3 87.5 51.2 99.6 0.31 87.6 51.5 99.6
[0049] According to Table 1 and Figure 2 Data analysis shows that the surface defect detection method for soft blister film in this embodiment is significantly better than the surface defect detection method using a single transmission optical path.
[0050] Step 2: Extract the edge contour features of the soft blister film, construct a floating coordinate system using the position of the edge contour features in the image coordinates as a reference, perform coordinate mapping processing on the reflective grayscale image under the floating coordinate system, and register the pixel coordinates of the reflective grayscale image and the transmittance grayscale image to the same spatial reference.
[0051] In this embodiment, the membrane edge position information of the transmission grayscale image is extracted, and the membrane edge position information is used to construct the membrane edge contour feature.
[0052] A floating coordinate system is established to follow the displacement of the soft blister film by establishing the direction of movement of the soft blister film and the contour features of the film edge. The lateral offset of the contour features of the film edge in the floating coordinate system relative to the preset alignment reference is calculated. The lateral offset is used to perform reverse translation compensation on the reflective grayscale image, and the pixel coordinates of the reflective grayscale image and the transmittance grayscale image are registered to the same spatial reference. The preset alignment reference is the center coordinate value of the camera's field of view.
[0053] Flexible thermoforming film is a type of flexible material. During high-speed winding or conveying in automated production lines, it is prone to high-frequency lateral serpentine deviation or irregular shaking due to uneven traction or mechanical vibration. If a traditional static fixed coordinate system is used, the physical position of the film material changes in each frame of the image. This means that a defect point at a coordinate in the transmitted grayscale image may have shifted in the reflected grayscale image. This randomness in position makes it impossible to lock onto the same physical target in subsequent images, rendering the detection reference ineffective.
[0054] The acquired transmission grayscale image is Gaussian smoothed to remove random noise and prevent it from being misidentified as edges. The gradient intensity and direction of each pixel in the image are calculated to identify regions with abrupt changes in grayscale. Edge lines are thinned, retaining only local maxima along the gradient direction to ensure that the extracted edges are single-pixel wide lines. Two thresholds are set: points above the higher threshold are identified as strong edges, and points between the two thresholds that are connected to strong edges are identified as weak edges. The final output is a set containing the coordinates of all pixels along the membrane edge, representing the membrane edge contour feature.
[0055] Because the membrane material's position drifts in real time, traditional static fixed coordinate systems based on the camera sensor boundary become ineffective. The membrane edge features are the most prominent and relatively fixed geometric features of the membrane material. Constructing a floating coordinate system based on the membrane edge essentially establishes a relatively static reference system. Regardless of how the membrane material vibrates, this coordinate system remains anchored to the membrane material itself, rather than to the camera, thus shielding the positional interference caused by mechanical motion at the algorithm level.
[0056] The lateral offset precisely quantifies the distance the membrane material deviates from its ideal center. This amount is used to perform inverse translation compensation on the reflective grayscale image, offsetting physical jitter at the algorithmic level and forcibly pulling the membrane material in both images back to the same alignment baseline. If the membrane in the transmittance image is offset 10 pixels to the right, the entire reflective grayscale image is shifted 10 pixels to the left. This action pulls the membrane material in the reflective grayscale image back to the center of the field of view, eliminating physical displacement.
[0057] Only by registering two images to the same spatial reference can the connected components of candidate defects in the transmission grayscale image be accurately projected onto the corresponding texture regions in the reflection grayscale image. Without registration, if a black dot is detected in the transmission grayscale image, subsequent algorithms may incorrectly extract the normal, smooth region next to that black dot for texture analysis in the reflection grayscale image, leading to the erroneous conclusion of high texture consistency and missed detections. Precise registration ensures that the subsequently calculated local gradient vector field and orientation consistency entropy value are strictly targeted at the same defect target, thereby improving the accuracy of determining whether a defect is genuine or fake and achieving precise capture of subtle defects.
[0058] Step 3: Perform frequency domain transformation on the registered transmission grayscale image and apply a high-pass filter rule to it in the frequency domain. After filtering, perform inverse transformation on the result to obtain a high-frequency response image. In the high-frequency response image, select pixels with high-frequency response values exceeding the preset benchmark and perform connectivity analysis to form candidate defect connected components.
[0059] In this embodiment, a fast Fourier transform is performed on the grayscale distribution data of the registered transmission grayscale image to obtain the frequency domain spectrum.
[0060] Using the zero-frequency center of the frequency domain spectrum as the center, the radial cumulative energy is statistically calculated. The frequency radius corresponding to the radial cumulative energy reaching a specific percentage of the total energy is determined as the cutoff frequency. The frequency domain spectrum is then high-pass filtered using the cutoff frequency. Finally, an inverse Fourier transform is performed on the filtered frequency domain spectrum to obtain the high-frequency response image.
[0061] The maximum inter-class variance is calculated on the high-frequency response image to obtain the segmentation threshold. Pixels with high-frequency response values higher than the segmentation threshold are marked as outliers, and adjacent outliers are aggregated into candidate defect connected regions.
[0062] The transmitted grayscale image is treated as a two-dimensional discrete signal matrix, with values representing grayscale light intensity. A two-dimensional Fast Fourier Transform (FFT) algorithm is applied to this matrix to transform the image data from the spatial domain to the frequency domain. The output is a complex matrix. To facilitate subsequent calculations, the spectrum is typically centered to generate a visualized frequency domain spectrum. In this case, the center of the spectrum represents the average grayscale of the image, while outward diffusion represents the degree of grayscale variation. In the original image, subtle defects are often obscured by complex backgrounds caused by uneven illumination or gradual changes in film thickness, making simple grayscale thresholding difficult. Background changes are usually slow and smooth, while defect edges typically show abrupt grayscale changes. The FFT decouples these two aspects in the frequency dimension, providing a mathematical basis for subsequent one-size-fits-all separation.
[0063] Using the zero-frequency center of the frequency spectrum as the center, a radius is set. The total energy of all frequency components within the circular region covered by the radius is calculated. The proportion of the current accumulated energy to the total spectral energy is calculated. A specific proportion threshold is preset, such as 95%. The radius is gradually increased from the center, and the current radius value is recorded when the proportion first reaches the preset percentage. This radius value is determined as the cutoff frequency. Most of the energy in the image is concentrated in the low-frequency region at the center of the spectrum. Different batches of soft blister films have different material texture roughness, and the background energy distribution range is also different. If a fixed cutoff frequency is used, it may result in over-filtering on smooth films or under-filtering on rough films. By statistically analyzing the energy proportion, the algorithm can automatically determine where the main energy caused by the background is concentrated, thereby adaptively defining the boundary between the background and details.
[0064] Using the cutoff frequency as the stopband radius, a filter transfer function is constructed, and the frequency domain spectrum is multiplied by the filter transfer function. This operation zeroes out or significantly attenuates the central region with a radius smaller than the cutoff frequency, while retaining the outer region with a radius larger than the cutoff frequency. An inverse Fourier transform is performed on the filtered spectrum, and its magnitude is taken to reconstruct a two-dimensional image matrix. The resulting image is the high-frequency response image. In the high-frequency response image, the original macroscopic background, such as uneven illumination and gradual changes in film thickness, is completely eliminated, and the image background becomes a near-black low grayscale value. Defects such as crystal points and bubbles, because they retain high-frequency edge information, appear as bright or obvious grayscale jump points, greatly enhancing the signal-to-noise ratio of defects.
[0065] Statistical analysis is performed on the gray-level histogram of the high-frequency response image. The maximum inter-class variance (MOV) algorithm is used to traverse all possible gray levels, calculating the inter-class variance between the suspected defect and residual noise classes, separated by gray levels. The threshold that maximizes the inter-class variance is selected as the optimal segmentation threshold. Pixels with gray values greater than the specified gray level are marked as outliers, while those less than the specified gray level are marked as background. The binarized image is then subjected to 8-neighbor connectivity, aggregating spatially adjacent outlier pixels to form independent pixel sets, i.e., candidate defect connected components.
[0066] Although the filtered image removes the background, it still contains high-frequency random noise. The Otsu's algorithm utilizes statistical principles to automatically find the optimal boundary between signal and noise. This avoids subjective errors caused by manually setting fixed thresholds and can adapt to varying contrast levels. It transforms discrete pixels into connected components with geometric features, providing precise spatial coordinate indices for subsequent gradient vector field analysis of specific regions.
[0067] Step 4: Extract the pixel region corresponding to the connected component of the candidate defect from the spatially registered grayscale image, and construct a set of local gradient vectors within the pixel region according to a fixed neighborhood range. Form a local gradient vector field based on the set of local gradient vectors, and perform statistical processing on the distribution of each gradient direction in the local gradient vector field to obtain the corresponding directional consistency entropy value.
[0068] In this embodiment, the spatially registered grayscale image is extracted, and the corresponding pixel region in the spatially registered grayscale image is locked based on the pixel coordinate set of the candidate defect connected domain. The grayscale gradients in the horizontal and vertical directions of each pixel in the pixel region are calculated and the gradient vectors are synthesized. A local gradient vector field is constructed based on the set of direction angles of the gradient vectors of all pixels in the candidate defect connected domain.
[0069] The candidate defect connected domain is divided into bins based on the total number of pixels. The bins are then divided equally to obtain bin intervals. The frequency of the orientation angle data of the local gradient vector field falling into the bin interval is counted to obtain the probability distribution within each bin interval. The probability distribution is calculated based on the Shannon entropy formula to obtain the orientation consistency entropy value of the candidate defect connected domain.
[0070] The process involves obtaining the set of pixel coordinates for the identified candidate defect connected components in the transmission grayscale image and directly mapping this set onto the spatially registered reflection grayscale image. In the reflection grayscale image, only the grayscale data of these coordinate points and their surrounding fixed neighborhoods are extracted as the pixel regions to be analyzed. The transmission grayscale image shows black dots, while the reflection grayscale image shows texture. By locking the coordinates, full-image calculations are avoided, reducing computational cost, while ensuring that the analyzed texture region strictly corresponds to the anomalous point found in the transmission image.
[0071] For each pixel within the extracted region, the grayscale gradient in the horizontal and vertical directions is calculated using gradient operators. The orientation angles of all pixels are then aggregated to form a local gradient vector field describing the texture flow direction of the region. Simple grayscale values cannot describe the direction of texture. The gradient vector field can convert image brightness into geometric direction. Wrinkles are typically linear waves with highly consistent gradient directions of reflected light; while crystal points or bubbles are convex spheres that scatter reflected light in all directions, resulting in radial gradient directions. Constructing a vector field is the mathematical foundation for capturing this physical difference.
[0072] The number of bins in the histogram is determined based on the total number of pixels in the candidate region. The total number of pixels in the connected component of the candidate defect is 100, and the azimuth angle range of 0° to 360° is divided into 10 equal intervals. The number of pixels in the vector field whose azimuth angle falls into each bin interval is counted. The number of pixels falling into the azimuth bin is calculated. The probability of each bin is used to obtain the probability distribution. The direction of a single pixel is meaningless; we need to know the overall trend of the entire region. The complex vector field is transformed into a standard mathematical distribution, preparing for the next step of using the directional consistency entropy formula.
[0073] In this embodiment, the expression for the directional consistency entropy value is:
[0074]
[0075] In the formula, The entropy value represents the direction consistency. The total number of pixels in the candidate defect connected region. For the first Probability distribution within each bin interval To numerically calculate the stability constant, The maximum possible entropy value, This is the box number.
[0076] The total number of pixels is introduced as a normalization factor into the denominator of the formula. Its purpose is to eliminate the influence of defect area size on entropy calculation. Without normalization, large defects might result in a large entropy value simply because they contain a large amount of information. By dividing by the theoretically maximum possible entropy value, directional consistency is ensured; the entropy value reflects only the structural properties of the texture and is decoupled from the geometric properties of the defect.
[0077] The probability distribution determines the calculated directional uniformity entropy. For wrinkles, due to their physical structure being parallel stripes, the gradient direction of reflected light is highly concentrated in a few bin intervals, resulting in a large probability distribution in these intervals while other intervals are close to 0. This concentrated distribution leads to a smaller summation term, thus resulting in a smaller calculated directional uniformity entropy. Conversely, for crystal points or bubbles, their surfaces are typically convex or concave structures, and reflected light scatters in all directions. The gradient direction is evenly distributed across each bin interval, with little difference in probability distribution values. This uniform distribution leads to the summation term reaching its maximum value, thus resulting in a larger calculated directional uniformity entropy.
[0078] The numerical calculation of the stability constant involves logarithmic operations in the formula for calculating information entropy. In actual detection, if it is a wrinkle, the texture direction is highly consistent, which may result in some directional bins having no gradient vector falling into them, i.e., the probability is zero. Mathematically, If it is negative infinity, it will cause the program to report an error or the calculation result to overflow.
[0079] As the number of bins increases, the maximum possible entropy value naturally increases as well. Without dividing by this term, large-area defects will naturally have a larger entropy value than small-area defects, even if their texture disorder is the same. This achieves normalization of texture and geometric features. By dividing the original entropy value by the theoretical maximum entropy value, the result is effectively normalized to the [0,1] interval.
[0080] The directional consistency entropy value specifically reflects the degree of disorder in the surface texture direction within the candidate defect region. It enables non-contact quantitative differentiation between true and false defects: the higher the entropy value, the more disordered the texture direction, and the greater the probability of being judged as a substantial defect; the lower the entropy value, the more ordered the texture direction, and the greater the probability of being judged as a false defect.
[0081] Step 5: Compare the directional consistency entropy value corresponding to each candidate defect connected region with the preset wrinkle threshold. When the directional consistency entropy value is higher than the preset wrinkle threshold, the corresponding candidate defect connected region is determined to be a substantial defect target. Geometric parameters of the substantial defect target are then identified to obtain the detection result.
[0082] In this embodiment, the directional consistency entropy value is compared with a preset wrinkle threshold. If the directional consistency entropy value is greater than the preset wrinkle threshold, the candidate defect connected component is determined to be a substantial defect target.
[0083] This comparison achieves the technical goal of accurately separating real defects such as crystal points and bubbles from a complex wrinkled background under non-contact conditions, solving the problem of high false positive rates in traditional methods. Its purpose is to determine whether the currently detected texture anomalies constitute quality damage that needs to be removed. The preset wrinkle threshold represents the physical limit of surface texture direction disorder when the film material undergoes elastic deformation. The orientation consistency entropy value represents the actual texture state of the currently detected object. When the orientation consistency entropy value is greater than the preset wrinkle threshold, it means that the degree of light scattering has exceeded the physical scope of unidirectional folding, and must be caused by multidirectional scattering microstructures, such as the spherical surface of a bubble.
[0084] In this embodiment, wrinkle samples from historical detection data are selected, and the maximum directional consistency entropy value of the wrinkle samples is used as the wrinkle threshold.
[0085] The preset wrinkle threshold is directly determined by the maximum directional consistency entropy value of historical wrinkle samples. Wrinkle morphologies are diverse, ranging from slight ripples to deep creases, with varying degrees of breakage in the texture direction. Choosing the maximum directional consistency entropy value as the threshold follows the reverse logic of the "weakest link" principle, aiming to cover all possible wrinkle morphologies.
[0086] In this embodiment, the minimum bounding rectangle of the substantial defect target is extracted.
[0087] Calculate the pixel area of the target with substantial defects.
[0088] The geometric span information of the minimum bounding rectangle is combined with the pixel area to generate the detection result of surface defects of the soft blister film.
[0089] By traversing all pixels of the substantial defect, a set of its two-dimensional pixel coordinates in the image coordinate system is obtained. The outermost edge points in this set are then selected, and a rectangle enclosing the connected region is constructed. The minimum bounding rectangle determines the spatial span and directionality of the defect. For common long scratches or diagonal cracks in flexible films, area alone cannot assess the impact on subsequent processing. The minimum bounding rectangle can determine the physical boundary of the defect, clearly defining its specific physical location within the flexible film.
[0090] Within the scope of substantial defects, the total number of pixels marked as abnormal is counted. Pixel area determines the severity of the defect. It reflects the actual physical size of the defect and is a core indicator for judging whether the defect reaches the standard of being visible to the naked eye or affects the strength of the film material. The severity of the defect indicated by the test results is positively correlated with the pixel area. The larger the pixel area, the more severe the physical damage to the film surface, and the higher the grade of the test results. The scope of influence indicated by the test results is positively correlated with the geometric span of the minimum bounding rectangle. The larger the length and width values of the minimum bounding rectangle, the wider the extension range of the defect on the film surface, and the greater the potential interference to subsequent processes.
[0091] The detection results depend on the simultaneous presence of geometric span information and pixel count. Using only pixels makes it impossible to distinguish between circular crystal points and fine scratches; using only the minimum bounding rectangle for rectangular defects will include a large amount of non-defect background area, leading to misjudgments of damage severity. Feature stitching, by combining shape and size information, complements their respective blind spots.
[0092] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0093] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0094] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0095] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A machine vision-based method for detecting surface defects in flexible blister films, characterized in that, The specific steps include: Step 1: Collect the light intensity information after the light passes through the soft blister film to generate a transmission grayscale image, and simultaneously collect the reflected light information on the surface of the soft blister film to generate a reflection grayscale image; Step 2: Extract the edge contour features of the soft blister film, construct a floating coordinate system with the position of the edge contour features in the image coordinates as the reference, perform coordinate mapping processing on the reflective grayscale image under the floating coordinate system, and register the pixel coordinates of the reflective grayscale image and the transmittance grayscale image to the same spatial reference. Step 3: Perform frequency domain transformation on the registered transmission grayscale image and apply a high-pass filtering rule to it in the frequency domain. After filtering, perform inverse transformation on the result to obtain a high-frequency response image. In the high-frequency response image, filter pixels whose high-frequency response values exceed the preset benchmark and perform connectivity analysis to form candidate defect connected components. Step 4: Extract the pixel region corresponding to the connected component of the candidate defect in the spatially registered grayscale image, and construct a set of local gradient vectors in the pixel region according to a fixed neighborhood range. Form a local gradient vector field based on the set of local gradient vectors, and perform statistical processing on the distribution of each gradient direction in the local gradient vector field to obtain the corresponding directional consistency entropy value. Step 5: Compare the directional consistency entropy value corresponding to each candidate defect connected region with the preset wrinkle threshold. When the directional consistency entropy value is higher than the preset wrinkle threshold, the corresponding candidate defect connected region is determined to be a substantial defect target. Geometric parameters of the substantial defect target are then identified to obtain the detection result.
2. The machine vision-based method for detecting surface defects in soft blister film according to claim 1, characterized in that: The soft blister film is backlit, and the real-time luminous flux penetrating the soft blister film is collected. The state where the real-time luminous flux reaches full saturation is set as the gray-level extreme value, and the state where the real-time luminous flux is completely cut off is set as the gray-level zero point. A linear mapping interval is constructed based on the gray-level extreme value and the gray-level zero point. The real-time luminous flux is linearly mapped into a transmitted gray-level image using the linear mapping interval. The flexible blister film is illuminated by a coaxial light source, and the real-time reflected light intensity on the surface of the flexible blister film is collected. The real-time reflected light intensity is digitized and converted into reflected grayscale data. Based on the two-dimensional spatial distribution of the reflected grayscale data, a reflected grayscale image of the flexible blister film is constructed.
3. The machine vision-based method for detecting surface defects in soft blister film according to claim 1, characterized in that: Extract the membrane edge position information from the transmission grayscale image, and use the membrane edge position information to construct the membrane edge contour feature; A floating coordinate system is established to follow the displacement of the soft blister film by establishing the direction of movement of the soft blister film and the contour features of the film edge. The lateral offset of the contour features of the film edge in the floating coordinate system relative to the preset alignment reference is calculated. The lateral offset is used to perform reverse translation compensation on the reflective grayscale image, and the pixel coordinates of the reflective grayscale image and the transmittance grayscale image are registered to the same spatial reference. The preset alignment reference is the center coordinate value of the camera's field of view.
4. The machine vision-based method for detecting surface defects in soft blister film according to claim 1, characterized in that: Fast Fourier transform is performed on the grayscale distribution data of the registered transmission grayscale image to obtain the frequency domain spectrum; Using the zero-frequency center of the frequency domain spectrum as the center, the radial cumulative energy is statistically calculated. The frequency radius corresponding to the radial cumulative energy reaching a specific percentage of the total energy is determined as the cutoff frequency. The frequency domain spectrum is then high-pass filtered using the cutoff frequency. Finally, an inverse Fourier transform is performed on the filtered frequency domain spectrum to obtain the high-frequency response image. The maximum inter-class variance is calculated on the high-frequency response image to obtain the segmentation threshold. Pixels with high-frequency response values higher than the segmentation threshold are marked as outliers, and adjacent outliers are aggregated into candidate defect connected regions.
5. The machine vision-based method for detecting surface defects in soft blister film according to claim 1, characterized in that: Extract the spatially registered grayscale reflection image, lock the corresponding pixel region in the spatially registered grayscale reflection image based on the pixel coordinate set of the candidate defect connected domain, calculate the grayscale gradient in the horizontal and vertical directions of each pixel in the pixel region, and synthesize the gradient vector. Construct a local gradient vector field based on the set of orientation angles of the gradient vectors of all pixels in the candidate defect connected domain. The candidate defect connected domain is divided into bins based on the total number of pixels. The bins are then divided equally to obtain bin intervals. The frequency of the orientation angle data of the local gradient vector field falling into the bin interval is counted to obtain the probability distribution within each bin interval. The probability distribution is calculated based on the Shannon entropy formula to obtain the orientation consistency entropy value of the candidate defect connected domain.
6. The machine vision-based method for detecting surface defects in soft blister film according to claim 5, characterized in that: The expression for the directional consistency entropy is: In the formula, The entropy value represents the direction consistency. The total number of pixels in the candidate defect connected region. For the first The probability distribution within each bin interval To numerically calculate the stability constant, The maximum possible entropy value, This is the box number.
7. The machine vision-based method for detecting surface defects in soft blister film according to claim 1, characterized in that: The directional consistency entropy value is compared with the preset wrinkle threshold. If the directional consistency entropy value is greater than the preset wrinkle threshold, the candidate defect connected component is determined to be a substantial defect target.
8. The machine vision-based method for detecting surface defects in soft blister film according to claim 7, characterized in that: Wrinkle samples from historical detection data are selected, and the maximum directional consistency entropy value of the wrinkle samples is used as the wrinkle threshold.
9. The machine vision-based method for detecting surface defects in soft blister film according to claim 1, characterized in that: Extract the minimum bounding rectangle of the substantial defect target; Calculate the pixel area of a target with substantial defects; The geometric span information of the minimum bounding rectangle is combined with the pixel area to generate the detection result of surface defects of the soft blister film.
Citation Information
Patent Citations
Surface defect detection method based on machine vision
CN120064114A