An AF film surface defect identification method and system based on image recognition
Patent Information
- Application Number
- CN202511392376.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2026-10-13
AI Technical Summary
[0003]在一种现有技术中,在应对复杂表面缺陷时仍存在明显不足
(1)本发明通过在图像采集阶段同步获取光谱分布数据和环境光补偿数据,并与原始图像进行关联存储,从而实现了多维信息融合。基于该融合数据,可以在后续处理中通过光照校正和色彩均衡有效削弱环境光照变化及光谱差异对检测精度的干扰。由此,本发明能够在复杂光照环境下保持图像质量的稳定性,为后续缺陷识别提供可靠的数据基础,提高了检测的鲁棒性。
Smart Images

Figure CN122905916A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of AF film surface defect identification technology, and in particular to an AF film surface defect identification method and system based on image recognition. Background Technology
[0002] Currently, surface defect detection is a crucial step in ensuring product quality in modern industrial manufacturing, especially in the production of precision materials such as anti-fingerprint films (AF films), where surface quality directly affects the product's appearance and functionality. With the development of computer vision technology, automated inspection has gradually replaced traditional manual visual inspection, becoming an important means to improve inspection efficiency and consistency. AF films are widely used in high-precision devices such as mobile phone screens and lenses, requiring extremely high standards for surface uniformity, color difference, and color spots. This places higher demands on the accuracy and robustness of computer vision-based inspection methods.
[0003] Existing technologies still have significant limitations in dealing with complex surface defects. Traditional methods often rely on single optical imaging or manual judgment, which shows limitations when dealing with minute color defects on AF film surfaces. Optical imaging systems are extremely sensitive to ambient light; when lighting conditions or the reflective properties of the film material change slightly, computer vision algorithms are easily interfered with, leading to deviations in detection results. Manual visual inspection is further limited by human eye resolution and subjective judgment, making it difficult to maintain stability and consistency, thus resulting in false positives and false negatives.
[0004] Existing technologies have the problem of making it difficult to reliably identify minute color difference defects on the surface of AF films under complex lighting conditions. Summary of the Invention
[0005] This invention provides a method and system for identifying surface defects of AF film based on image recognition, so as to achieve accurate detection of minute color difference defects.
[0006] In a first aspect, to solve the above-mentioned technical problems, the present invention provides an image recognition-based method for identifying surface defects of an AF film, comprising: The original image of the AF film surface is acquired. During the acquisition process, the spectral distribution data and ambient light compensation data corresponding to the original image are recorded simultaneously. The original image, the spectral distribution data and the ambient light compensation data are associated and stored to form an initial image set. Based on the initial image set, illumination parameter adjustment and color channel equalization are performed to obtain a standardized image after illumination correction. Based on the standardized image, pixel discrimination and region recognition operations are performed to generate a preliminary defect region map; Clustering and defect region refinement extraction operations are performed on the preliminary defect region map to obtain a refined defect region set; Extract the boundary contours of the refined defect region set and smooth the boundary contours to obtain a quantized color difference boundary description. Based on the quantized color difference boundary description and the preset defect shape classification label, the coordinate mapping and surface area partition of the minor color difference defect are determined, thereby generating a shape partition association description; Based on the shape partition association description and the preset spectral template, and combined with the spectral distribution data, the location distribution and partition assignment of the minute color difference defects on the AF film surface are determined, and the location distribution and partition assignment of the defects are obtained.
[0007] Secondly, the present invention provides an image recognition-based AF film surface defect identification system, comprising: The data acquisition module is used to acquire the original image of the AF film surface. During the acquisition process, it synchronously records the spectral distribution data and ambient light compensation data corresponding to the original image, and associates and stores the original image, the spectral distribution data and the ambient light compensation data to form an initial image set. The standard correction module is used to perform illumination parameter adjustment and color channel equalization processing based on the initial image set to obtain a standardized image after illumination correction. The preliminary defect module is used to perform pixel discrimination and region recognition operations based on the standardized image, thereby generating a preliminary defect region map; The refining and extraction module is used to perform clustering and refining extraction operations on the preliminary defect region map to obtain a refined defect region set. The color difference boundary module is used to extract the boundary contour of the set of refining defect regions and smooth the boundary contour to obtain a quantized color difference boundary description. The shape partitioning module is used to determine the coordinate mapping and surface area partitioning of minute color difference defects based on the quantized color difference boundary description and the preset defect shape classification label, thereby generating a shape partitioning association description. The defect determination module is used to determine the location distribution and partition assignment of minute color difference defects on the AF film surface based on the shape partition association description and preset spectral template, and in combination with the spectral distribution data, thereby obtaining the location distribution and partition assignment of defects.
[0008] Thirdly, the present invention also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the image recognition-based AF film surface defect identification method described in any one of the above.
[0009] Fourthly, the present invention also provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the image recognition-based AF film surface defect identification method described above.
[0010] Compared with the prior art, the present invention has the following beneficial effects: (1) This invention achieves multi-dimensional information fusion by simultaneously acquiring spectral distribution data and ambient light compensation data during the image acquisition stage and storing them in association with the original image. Based on this fused data, the interference of ambient light changes and spectral differences on detection accuracy can be effectively reduced in subsequent processing through illumination correction and color equalization. Thus, this invention can maintain the stability of image quality under complex lighting conditions, providing a reliable data foundation for subsequent defect identification and improving the robustness of detection.
[0011] (2) In the defect region identification process, this invention enhances the coherence and integrity of the defect region through multi-level processing such as pixel discrimination, clustering and grouping, and boundary refinement extraction. This hierarchical identification mechanism can not only accurately separate potential defect pixels, but also avoid the problem of regional fragmentation. It can be seen that this invention can extract the boundary features of small color difference defects more accurately, making the detection results closer to the actual defect morphology, thereby effectively improving the accuracy of identification.
[0012] (3) In the defect confirmation stage, this invention introduces a joint judgment mechanism of spectral template matching and shape partitioning description, and verifies it in conjunction with spectral distribution data. Through this multi-dimensional cross-verification method, the misjudgment and omission caused by a single feature can be effectively reduced. Thus, this invention can not only accurately output the location distribution of defects, but also clearly define the partitioning of defects, achieving high-precision positioning and classification of small color difference defects on the AF film surface, thereby improving the application value and industrial practicality of the detection system. Attached Figure Description
[0013] Figure 1 This is a schematic diagram of the process for identifying surface defects of an AF film based on image recognition, provided in the first embodiment of the present invention. Figure 2 This is a schematic diagram of the AF film surface defect identification system based on image recognition provided in the second embodiment of the present invention. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0015] Reference Figure 1 The first embodiment of the present invention provides a method for identifying surface defects of AF film based on image recognition, including the following steps: S11, acquire the original image of the AF film surface, and simultaneously record the spectral distribution data and ambient light compensation data corresponding to the original image during the acquisition process, and associate and store the original image, the spectral distribution data and the ambient light compensation data to form an initial image set; S12, based on the initial image set, perform illumination parameter adjustment and color channel equalization processing to obtain a standardized image after illumination correction; S13, Based on the standardized image, perform pixel discrimination and region recognition operations to generate a preliminary defect region map; S14, perform clustering and defect region refinement extraction operations on the preliminary defect region map to obtain a refined defect region set; S15, extract the boundary contour of the set of refining defect regions, and smooth the boundary contour to obtain a quantized color difference boundary description. S16, Based on the quantized color difference boundary description and the preset defect shape classification label, determine the coordinate mapping and surface area partition of the small color difference defect, thereby generating a shape partition association description; S17. Based on the shape partition association description and preset spectral template, and combined with the spectral distribution data, determine the location distribution and partition assignment of the minute color difference defects on the AF film surface, and obtain the location distribution and partition assignment of the defects.
[0016] In step S11, it is necessary to acquire the original image of the AF film surface. During the acquisition process, spectral distribution data and ambient light compensation data corresponding to the original image are recorded simultaneously. The original image, the spectral distribution data, and the ambient light compensation data are then associated and stored to form an initial image set, including: First, data acquisition of the AF film surface is required. In this embodiment, a high-resolution optical sensor is used as the acquisition device to obtain the original image of the AF film surface. The resolution of this optical sensor is preferably no less than 1920×1080 pixels to ensure clear recording of minute color difference defects on the AF film surface. Simultaneously with acquiring the original image, the sensor is also equipped with a spectral detection unit and an ambient light intensity detection unit, used to record spectral distribution data and ambient light compensation data, respectively. The spectral distribution data reflects the reflection, absorption, or transmission characteristics of the AF film surface to different wavelengths of light. With the visible light band from 400nm to 700nm as the main detection range, a spectral curve reflecting the surface optical properties can be obtained through fine sampling of the light intensity at each wavelength. This curve can reveal the film thickness, coating uniformity, and optical differences in local defect areas. For example, if an area shows an abnormal decrease in reflectivity at a wavelength of 550nm, it indicates the presence of coating inhomogeneity or color difference defects in that area.
[0017] Ambient light compensation data is used to record external lighting conditions during the acquisition process, including key parameters such as light intensity and light source color temperature. Light intensity information reflects the ambient illuminance level (e.g., 500–2000 lux) and can be used to correct image underexposure or overexposure caused by excessively strong or weak lighting. Light source color temperature information (e.g., 4000K–6500K) reflects the tendency of the lighting to be yellowish or bluish; without compensation, this can easily cause an overall color cast in the original image. By recording ambient light compensation data in real time, subsequent processing can correct the brightness and color of the image, ensuring that the defect detection results come from the film itself rather than from lighting interference.
[0018] To ensure data consistency and comparability, this embodiment synchronously acquires three types of data at the same time: the original image, spectral distribution data, and ambient light compensation data. The purpose of synchronization is to avoid mismatches between image and spectral information due to differences in acquisition time, thereby improving the reliability of subsequent defect analysis. For example, if the external illumination changes during acquisition, a time deviation between the image and spectral data will produce incorrect illumination correction results, thus affecting defect identification. To achieve synchronous acquisition, this embodiment preferably uses an optical sensing module with multi-channel input, and triggers the sampling operations of the image sensor and spectral sensor through a unified clock controller, enabling both sensors to start simultaneously with millisecond-level accuracy. Ambient light compensation data is recorded in real time by an integrated photosensitive detector and timestamped uniformly. To ensure accuracy, this embodiment controls the synchronization error to within 10 milliseconds; if the error exceeds this threshold during detection, the internal clock of the sensor is adjusted through a calibration mechanism, such as realigning the trigger signal frequency or interpolating the data acquisition timestamp at the software level. After acquisition, the original image, spectral distribution data, and ambient light compensation data need to be uniformly managed and stored. In this embodiment, the system's built-in data association module timestamps and indexes the three types of data to form a corresponding relationship, which is then stored as an initial image set. This initial image set not only contains the original image of each frame, but also records the spectral curve and ambient lighting parameters for that frame, forming a complete multidimensional data set.
[0019] For example, on an actual production line, when the optical sensor acquires AF film images at a rate of 100 frames per second, the system simultaneously records the spectral distribution (wavelength range 400nm–700nm, with real-time sampling using 10–20nm intervals and key bands densified to 10nm; full-spectrum high-resolution 5nm is only enabled during periodic calibration) and ambient light intensity data (detection range 500–2000 lux). If a frame of the original image shows a localized area with low brightness, comparing its spectral distribution data reveals a significant decrease in reflectivity at the 550nm band, while the ambient light compensation data indicates stable illumination. Therefore, it can be inferred that the anomaly is caused by a film defect, rather than a change in external illumination. In this way, by constructing an initial image set, a reliable data source is provided for subsequent illumination correction and defect identification.
[0020] In step S12, illumination parameter adjustment and color channel equalization processing are performed based on the initial image set to obtain a standardized image after illumination correction, including: White balance adjustment is performed based on the spectral distribution data in the initial image set to obtain the first corrected image; Based on the ambient light compensation data in the initial image set, the first corrected image is brightness equalized to obtain the second corrected image; The RGB color channels of the second corrected image are subjected to equalization processing to obtain a standardized image after illumination correction.
[0021] In the first step of white balance adjustment, color correction is performed on the original image based on the spectral distribution data in the initial image set. This embodiment uses the gray-world method as the white balance algorithm. Its basic principle is that in a normally exposed image, each RGB channel should have a near-uniform gray level at the perceptual level. In specific implementation, the average intensity values of the current image in the red, green, and blue bands are first extracted from the spectral distribution data, for example, R=120, G=100, and B=150 respectively. Then, a weighted average method is used to calculate the overall average gray value to conform to the characteristics of human eye sensitivity to different color channels. For example, Gray=0.3R+0.59G+0.11B=119, and the gain coefficient of each channel is obtained accordingly, where the gain of the red channel is about 0.99, the gain of the green channel is about 1.19, and the gain of the blue channel is about 0.79. The RGB channels of the original image are multiplied by the corresponding gain coefficients to obtain the first corrected image. After adjustment, the problem of the overall blue tint of the image is eliminated, the brightness levels of the three channels are more balanced, and the surface color of the AF film is restored to a near-realistic visual effect. It should be noted that the weighting coefficients (0.3, 0.59, 0.11) used in this embodiment are derived from the characteristics of human visual perception and the brightness model of the commonly used YUV color space, which can more scientifically reflect the contribution of color channels to the overall brightness. In a specific embodiment, the overall brightness of the first corrected image is corrected based on the ambient light compensation data in the initial image set. The ambient light compensation data includes the illuminance value and light source color temperature parameters at the time of acquisition, which can accurately reflect the external lighting conditions. In this embodiment, the ambient light intensity is first read. For example, if the current illuminance is detected to be 1800 lux, which exceeds the set upper limit threshold of 1500 lux, the system performs brightness correction on the image using a linear compression method, compressing the original grayscale range [0, 255] to [0, 200], thereby reducing the overall brightness and avoiding the loss of detail caused by overexposure. Conversely, when the ambient light intensity is low, for example, only 500 lux, below the set lower threshold of 600 lux, the system will perform grayscale stretching, expanding the image grayscale range from [30, 180] to [0, 255] to improve overall brightness and restore details in dark areas. With the assistance of color temperature parameters, if the ambient light source color temperature is found to be low (e.g., below 4000K, yellowish), the blue channel will be moderately enhanced while adjusting brightness to avoid overall color cast in the image. The aforementioned thresholds of 1500 lux and 600 lux were determined by combining the common illuminance range (500–2000 lux) in the AF film production workshop and the adaptability range of the testing equipment to light intensity. This ensures coverage of practical application scenarios while maintaining usable image quality even under extreme lighting conditions. After the above processing, the second corrected image tends to be more uniform in brightness, avoiding overexposure and overcoming underexposure, ensuring that subtle color difference defects on the AF film surface are clearly visible.
[0022] In a specific embodiment, the red, green, and blue channels of the second corrected image need to be equalized separately to further improve the color consistency and contrast of the image. This embodiment uses the Contrast-Limited Adaptive Histogram Equalization (CLAHE) method to process each channel image. Specifically, the image is first divided into several small regions (such as an 8×8 grid), and then a gray-level histogram is calculated in each region, limiting the contrast enhancement of the histogram. For example, a contrast limit factor of 2.0 is set to avoid noise amplification due to excessive stretching. During the processing, if the pixel distribution of the red channel is mainly concentrated in the [80, 120] range, it can be extended to [0, 255] through equalization to enhance details in both dark and bright areas; if the gray-level distribution of the green channel is narrow, it will also be stretched to improve the overall contrast; the blue channel will receive additional enhancement when the lighting is yellowish, thereby offsetting the influence of the ambient color temperature on the color. The above parameter settings are mainly based on the imaging characteristics of the detection equipment and the common color difference range on the AF film surface. For example, a contrast limit factor selected between 1.5 and 2.5 can ensure detail enhancement while avoiding the introduction of artifacts. After processing, the grayscale distribution of the three channels is more balanced, the color reproduction of the image is improved, and the small color difference areas on the surface of the AF film are highlighted, providing high-quality input data for subsequent defect identification.
[0023] In step S13, pixel discrimination and region recognition operations need to be performed based on the standardized image to generate a preliminary defect region map, including: Extract the RGB color channel values of each pixel from the standardized image; Calculate the Euclidean distance of color difference between pixels based on the RGB color channel values; When the color difference Euclidean distance exceeds a preset distance threshold, the pixel corresponding to the color difference Euclidean distance exceeding the preset distance threshold is marked as a potential defect pixel; The potential defective pixels are aggregated based on spatial adjacency to generate a preliminary defective region map.
[0024] First, when extracting the RGB color channel values of each pixel from a standardized image, the image needs to be stored as a pixel matrix, where each pixel corresponds to a position coordinate and three color components. In this embodiment, after standardization, the image is stored in memory as a two-dimensional matrix, with the rows and columns corresponding to the image's height and width, respectively. The system scans the image row by row and column by column, reading the values of the red, green, and blue channels for each pixel and recording them as a three-dimensional data unit. For example, in a 1920×1080 resolution image, the values of the red, green, and blue channels for the (100, 200)th pixel are 120, 135, and 140, respectively, representing the color information of that pixel. Through this point-by-point extraction method, the RGB channel values of all pixels in the entire image can be obtained completely, providing basic data for subsequent color difference calculations and defect identification.
[0025] After obtaining the RGB color channel values of each pixel, it is necessary to further calculate the color difference between pixels to quantify the color differences between different regions. In this embodiment, the Euclidean distance method is used to characterize the magnitude of the color difference between two pixels. Specifically, firstly, a pixel is selected, and the values of its red, green, and blue channels are read; then, the red, green, and blue channel values of its adjacent pixels are read, and the differences between the three channels are compared respectively. The difference values of the red, green, and blue channels are combined to obtain the overall color difference between the two pixels. If the difference is small, it means that the colors of the two pixels are similar and belong to the normal area; if the difference is large, it means that the colors of the two pixels deviate significantly, and there is a defect on the corresponding surface. For a specific example, the RGB value of a certain pixel is (120, 135, 140), and the RGB value of its adjacent pixel is (110, 115, 118). The overall color difference obtained after calculation is large, which significantly exceeds the preset threshold. Therefore, it can be considered that this pixel has an abnormal color difference from its surroundings. In this way, the color difference distribution of the entire image can be quantified, providing a basis for subsequent defect marking.
[0026] After calculating the color difference between pixels, a preset distance threshold is used to determine if any pixels are abnormal. When the color difference between a pixel and its surrounding pixels exceeds the preset threshold, the system marks the pixel as a potential defect pixel for subsequent region aggregation. In this embodiment, the color difference calculation is based on the CIE Lab color space. This space better matches the human eye's color perception characteristics, where L represents luminance, a represents the red-green component, and b represents the yellow-blue component. In the Lab space, the Euclidean distance value can intuitively correspond to the human eye's sensitivity to color differences. According to experimental results, the minimum color difference that the human eye can perceive is approximately ΔE = 2 to 3. However, in industrial inspection scenarios, if the threshold is too low, normal textures or minor luminance changes can easily be misjudged as defects. Considering the common color difference levels on AF film surfaces and noise fluctuations in the production environment, this embodiment sets the threshold range to ΔE = 8 to 15, with a preferred value of ΔE = 10. This ensures sensitivity to minor color differences while reducing false detections caused by lighting fluctuations or image noise.
[0027] For example, when the threshold is set to ΔE=10, if the color difference between a pixel and its surrounding pixels is 12, the pixel is identified as a potential defect pixel; if the color difference is 7, it is identified as a normal pixel. In terms of marking, the system creates a binary mask matrix in memory with the same size as the image, where a value of "1" represents a potential defect pixel and a value of "0" represents a normal pixel, facilitating subsequent retrieval. During actual display, the system can also highlight potential defect pixels in red on the original image, helping inspectors visually observe the defect distribution. Through this method, potential defect pixels are not only effectively identified but also stored simultaneously in both data and visualization formats, providing a stable input foundation for subsequent region identification and boundary extraction.
[0028] After marking the potentially defective pixels, these pixels need to be further aggregated into spatially adjacent regions to form preliminary defect regions. This embodiment uses a connected component analysis method to merge adjacent pixels that are also marked as potentially defective into a continuous region. Specifically, the system first scans the binary mask matrix of the entire image, using the potentially defective pixel as a seed point, and determines whether its eight neighboring pixels in the top, bottom, left, right, and diagonal directions are also potentially defective pixels. If a neighboring pixel meets the condition, it is added to the same region, and the iterative check of its neighboring pixels continues until the region can no longer be expanded. In this way, all mutually adjacent potentially defective pixels are grouped into a connected component, thus forming an independent defect region.
[0029] In this embodiment, considering that defects on the AF film surface often exhibit a strip-like or block-like distribution, an eight-neighbor approach (i.e., including adjacent pixels along the diagonal) is chosen to improve the integrity of region aggregation. For example, in an image, a dozen or so adjacent potentially defective pixels form a continuous linear region. Through connected component analysis, these pixels are aggregated into a strip-like defect region, rather than being identified as multiple discrete points in isolation. To avoid noise causing too many scattered regions, this embodiment also sets a minimum region size threshold. For example, when the number of pixels in a connected component is less than 5, the region is considered noise and filtered out, not included in the initial defect region map.
[0030] After completing the above processing, the system marks each connected region with a unique number and highlights it in the image with different colors, forming a preliminary defect region map. This not only visually reflects the location and morphology of potential defects on the AF film surface, but also provides clear input data for subsequent clustering, grouping, and boundary refinement.
[0031] In step S14, clustering and defect region refinement extraction operations need to be performed on the preliminary defect region map to obtain a refined defect region set, including: Extract the color difference markers of the pixels in the preliminary defect area image; Based on the color difference markers, pixels are grouped to obtain defect region groups; Cluster centers are calculated based on the defective regions, and the cluster centers are updated using the mean shift method to obtain the updated clustering results; The adjacent pixels of the same type in the updated clustering results are merged, and continuous defect regions are extracted to obtain a refined defect region set.
[0032] Before further processing the preliminary defect area map, it is necessary to extract the color difference markers for each pixel. In this embodiment, the preliminary defect area map is obtained in the previous step through threshold judgment and spatial aggregation, where all potential defect pixels have been marked as outliers. To facilitate subsequent clustering analysis, each potential defect pixel needs to be accompanied by a numerical color difference marker, which is derived from the color difference between the pixel and its surrounding normal pixels. In specific implementation, the system scans the preliminary defect area map pixel by pixel. For each marked potential defect pixel, its RGB channel difference information is read from the stored dataset and converted into a unified color difference marker value, for example, taking the average color difference of adjacent pixels as the representative value of the pixel. In this way, each potential defect pixel in the preliminary defect area map not only has spatial location information but also a corresponding color difference value.
[0033] In one specific embodiment, to achieve pixel grouping based on color difference markers, the system first performs statistical analysis on the color difference marker values in the preliminary defect area map, calculating their distribution range and central tendency. Based on the statistical results, the number of clusters is preset. For example, if the color difference marker values are concentrated between 8 and 20, the system sets the number of clusters to 3, corresponding to minor defects, moderate defects, and severe defects, respectively. Subsequently, starting from three randomly selected initial cluster centers, the system iteratively assigns each pixel to the cluster center closest to its color difference marker, and updates the cluster center to the mean of the color difference markers of all pixels in that group at the end of each iteration. In actual operation, if the color difference markers of pixels in a certain area are mainly concentrated between 9 and 11, they are classified as minor defects; if concentrated between 13 and 15, they are classified as moderate defects; and when the color difference markers reach 16 or higher, they are classified as severe defects. After multiple iterations, the cluster centers gradually converge to stable values. For example, the cluster center for minor defects is 10.2, for moderate defects it is 14.1, and for severe defects it is 17.8. The final grouping results can accurately reflect the distribution differences in color difference among defective regions. Through this grouping process, different types of defective regions are clearly distinguished in the image. Minor defects often correspond to small color difference points, moderate defects form local spots, while severe defects are more like scratches or large areas of unevenness.
[0034] After grouping pixels based on color difference markers, a mean-shift clustering method is used to iteratively update the cluster centers using the color difference markers as the feature space. In this embodiment, the initial value of the cluster center is defined as the average value of the color difference markers of all pixels within the group, which reflects the overall color difference level of the defective pixels in that group. For example, in a defective group with 50 pixels whose color difference marker values are between 12 and 16, the initial cluster center can be calculated as an average value of 14. Subsequently, to gradually bring the cluster centers closer to the high-density areas of the data distribution, a mean-shift method is used for iterative updates. In specific implementation, using the current cluster center as a reference, a Gaussian kernel function is used to calculate the weight of each pixel in the color difference marker space. Pixels closer to the center have higher weights, while pixels farther away have progressively lower weights. The system calculates a weighted average based on these weights and uses this value as the new cluster center. If the difference between the old and new cluster centers is greater than a preset threshold (e.g., 0.5), iterative updates continue until the difference is less than the threshold. In this way, the cluster centers continuously move towards the peak region of the probability density of the color difference distribution, more accurately reflecting the true characteristics of the defective group, rather than being influenced by a small number of discrete points. For example, in the pixel group with color differences marked as 12–16, the initial cluster center is 14. After one mean shift, the center is updated to 14.5; after another iteration, the center stabilizes at 14.8, which better matches the main distribution of pixels in the group. The final updated clustering result effectively reduces the interference of extreme values on the group centers, making the defective groups more representative and stable.
[0035] After updating the cluster centers, the updated clustering results need to be spatially integrated. This embodiment uses a region merging method to merge adjacent pixels belonging to the same category in the updated clustering results, thereby extracting continuous defect regions. Specifically, the system scans the image pixel by pixel. When a pixel is identified as a defect of a certain type, its eight neighboring pixels in the top, bottom, left, right, and diagonal directions are detected. If these neighboring pixels belong to the same category, they are merged into the same region. This process is recursively expanded in a connected component manner until all adjacent pixels of the same category have been merged.
[0036] To avoid noise interference with the results, this embodiment sets a region size threshold. For example, when the area of the merged region is less than 5 pixels, the system classifies it as isolated noise and discards it, excluding it from the final result. Conversely, when the region area is large and its shape is continuous, it is retained as a valid defect region. In this way, originally scattered pixels of the same type are integrated into a whole region with certain morphological characteristics, such as stripes, spots, or blocks.
[0037] In practical applications, for example, if a thin, elongated scratch exists on the surface of a batch of AF films, the scratch is initially identified as multiple small segments. After the merging of adjacent pixels of the same type in this step, these segments are successfully integrated into a complete, continuous defect region. The resulting refined defect region set not only has clearer boundaries but also accurately reflects the overall morphology of the defect, providing reliable input for subsequent boundary extraction and smoothing processes.
[0038] In step S15, it is necessary to extract the boundary contours of the set of refining defect regions and smooth the boundary contours to obtain a quantized color difference boundary description, including: Edge detection is performed on the set of refined defect regions to obtain a set of boundary pixels; The initial boundary contour of the defect region is constructed based on the set of boundary pixels. The initial boundary contour is smoothed to remove jagged edges and noise, resulting in a smooth boundary contour. The color difference markers of pixels within the smooth boundary contour are extracted and statistical features are calculated to form a quantized color difference boundary description.
[0039] After obtaining the refined defect region set, edge detection is first performed to extract the set of pixels constituting the defect boundary. In this embodiment, the Canny edge detection algorithm is preferably used, and its process includes Gaussian filtering for noise reduction, pixel gradient calculation, non-maximum suppression, and double threshold connection. Gaussian filtering effectively removes random noise in the image, avoiding the generation of false boundaries. During gradient calculation, brightness changes in the horizontal and vertical directions are extracted to identify the locations of gray-level abrupt changes. After non-maximum suppression, the boundary is refined to a single pixel width, ensuring boundary accuracy. Finally, double threshold connection is used to reasonably combine strong and weak edges to obtain continuous boundary lines. Taking an AF film with scratches as an example, after edge detection, the system identifies approximately 250 boundary pixels, which together constitute the outer contour of the defect region. This step obtains the set of boundary pixels, providing basic data for subsequent construction of the initial boundary contour and smoothing processing.
[0040] In a specific embodiment, the selection of edge detection parameters is particularly crucial. In this embodiment, the kernel size of the Gaussian filter is set to 5×5, and the standard deviation is set to 1.0 to balance smoothing effect and boundary preservation; the low threshold of the dual threshold is set to 50, and the high threshold is set to 150, which can effectively distinguish between real defect boundaries and background noise edges. Through this setting, noise boundaries caused by over-detection are avoided, while ensuring the boundary integrity of the actual defect area. For example, when a small scratch of about 30 pixels in length is detected, the system can completely extract the edge contour of the scratch without producing broken or false boundaries due to uneven brightness or noise interference.
[0041] After obtaining the set of boundary pixels, the initial boundary contour of the defect region needs to be constructed based on this set. In this embodiment, the system first connects the boundary pixels according to their spatial coordinates to form a closed polygonal curve. Specifically, the system uses a contour tracking algorithm (such as Moore's neighborhood tracking or chain code method) to start from a boundary pixel in the set and extend it step by step along its adjacent boundary pixels until it returns to the starting point, thus obtaining a complete boundary path. This process avoids boundary breaks or omissions, ensuring the closure of the contour.
[0042] In one specific embodiment, if the boundary pixel set contains approximately 250 points, the system will connect them sequentially according to their coordinates and use linear interpolation between adjacent points to fill in missing points and repair any small gaps. The resulting initial boundary contour is an irregular closed curve that can approximately reflect the shape of the defective area. This contour data is stored in the form of a coordinate sequence, such as recording the two-dimensional coordinates of each boundary pixel in sequence, thus providing a reliable input basis for subsequent smoothing processing and color difference statistics.
[0043] After obtaining the initial boundary contour, it needs to be smoothed to remove jagged edges and burrs caused by pixel dispersion and noise interference. In this embodiment, a Gaussian filtering combined with spline curve fitting is preferably used to smooth the boundary contour. Specifically, the contour coordinate sequence composed of boundary pixels is first input into a Gaussian filter for smoothing. The Gaussian filter effectively weakens the interference of local abrupt changes on the overall contour by weighted averaging of each boundary point and its neighboring points, thereby eliminating sharp jagged edges caused by pixel dispersion. In this embodiment, the kernel size of the Gaussian filter is set to 5, and the standard deviation is set to 1.0, so as to preserve the main contour features of the boundary as much as possible while ensuring the smoothing effect. For example, in a scratch contour containing 250 boundary points, some points deviate from their true positions due to noise. After Gaussian filtering, these abnormal points are pulled back to the average level of the neighborhood, and the overall boundary becomes smoother and more coherent.
[0044] Subsequently, B-spline curve fitting is performed on the boundary points after Gaussian filtering to further improve the smoothness and continuity of the boundary. In this embodiment, the coordinate sequence of the boundary points is first input as control points into the spline fitting module, and a continuous curve is generated using cubic B-spline interpolation. This method can ensure the smoothness of the curve as a whole, while preserving the basic outline of the defect morphology locally. Unlike simple straight line connections, B-spline curves have local controllability, that is, a small adjustment of a certain control point only affects a small segment of the curve around it, thereby avoiding distortion of the overall boundary morphology. In a specific embodiment, if the boundary point set contains about 230 points, the curve output after B-spline fitting consists of 180 control nodes, and the boundary length is shortened by about 12% compared with the initial outline, indicating that the original jagged fluctuations are effectively suppressed. The final boundary curve appears visually as a continuous, smooth closed line, which is closer to the real defect boundary morphology, providing a stable data foundation for subsequent color difference statistics and regional quantitative analysis.
[0045] In one specific embodiment, the system smooths the contour containing 250 boundary pixels. First, a Gaussian filter with a kernel size of 5 and a standard deviation of 1.0 is used to smooth the boundary point coordinates, eliminating approximately 20 local anomalies caused by noise. Then, a cubic B-spline fitting method is used to reconstruct the curves of the remaining boundary points, transforming the originally jagged contour into a continuous and smooth curve. The resulting smooth boundary contour more closely resembles the actual defect morphology, while avoiding the problem of excessive boundary complexity caused by noise.
[0046] After obtaining the smoothed boundary contour, further color difference marker extraction and statistical analysis are needed for the pixels inside the boundary to form a quantified color difference boundary description. In this embodiment, the system first establishes a closed region mask based on the coordinate range of the smoothed contour to lock the set of pixels enclosed by the contour. Within this region, the system reads the color difference marker value of each pixel point by point. This color difference marker value is calculated based on the color difference between the pixel and its neighboring pixels in the previous step and stored in integer form.
[0047] In one specific embodiment, a defect region contains approximately 120 pixels within its smooth boundary. The system extracts the color difference marker values for each pixel, with the resulting values ranging from 10 to 18. Subsequently, the system performs statistical processing on these color difference values: first, it calculates the arithmetic mean of the color difference values for all pixels to reflect the overall color difference level of the defect boundary region; then, it calculates the variance to measure the dispersion of the color difference values and determine the uniformity of the defect; simultaneously, it extracts the maximum and minimum values to clarify the limit range of color difference variation at the boundary.
[0048] For example, in the aforementioned area, the average color difference value is 13.5, indicating a relatively high degree of deviation from normal color; the variance is 2.1, indicating that the color difference distribution in the boundary area is relatively concentrated and has strong stability; the maximum value is 18 and the minimum value is 10, indicating that there is some color difference fluctuation at the defect boundary. Further analysis shows that this distribution characteristic of high mean and low variance corresponds to continuous defects such as scratches or uneven coatings, while if a low mean but high variance occurs, it is more likely to be a spot-like or granular defect.
[0049] This statistical process transforms discrete pixel color difference information into representative numerical features, thereby quantifying the overall color difference at defect boundaries. In a specific embodiment, if the calculated mean color difference is greater than 12 and the variance is less than 3, it indicates that the boundary of the region has stable color difference characteristics, corresponding to continuous scratches or overall uneven coating, etc., indicating stable defects. If the mean color difference is less than 11 and the variance is greater than 4, it indicates that the color difference distribution at the boundary of the region is uneven, often caused by spot-like defects, particulate impurities, or local stains. When the mean color difference and variance are within the above critical range, it is necessary to further confirm the defect type by combining preset defect shape classification labels or spectral features.
[0050] In step S16, based on the quantized color difference boundary description and the preset defect shape classification label, it is necessary to determine the coordinate mapping and surface area partitioning of the minor color difference defects, thereby generating a shape partitioning association description, including: The color difference value distribution is extracted from the quantized color difference boundary description, and the color difference statistical characteristics of the defect area are calculated based on the color difference value distribution; Based on the color difference statistical features and the preset defect shape classification labels, clustering is performed to determine the defect shape category; Extract the coordinates of the boundary pixels of the defect region based on the defect shape category, and generate the coordinate mapping of the defect region; Based on preset surface region partitioning rules, the coordinate mapping is merged or divided to form the final shape partition association description.
[0051] In the implementation of this invention, defect shape classification labels need to be pre-defined to provide a unified reference standard for cluster analysis and subsequent classification processing. The classification labels are based on the morphological characteristics of common defects on the AF film surface. In a preferred embodiment, the defect shape classification labels include three categories: first, strip-shaped defects, which are long, continuous areas with an aspect ratio greater than 3 and consistent boundary direction, commonly seen in scratches or abrasions; second, dot-shaped defects, which have a small area, are nearly circular or elliptical in shape, and often appear in isolated distributions, commonly seen in particulate impurities or bubbles; and third, patch-shaped defects, which have a large area, irregular shape, and obvious boundary undulations, caused by uneven coating or localized contamination. In a specific embodiment, when the aspect ratio of a region reaches 5:1 and the mean color difference is high while the variance is small, the system will classify it as a strip-shaped defect; if the region area is less than 30 pixels and the roundness is greater than 0.7, it is determined to be a dot-shaped defect; if the region area exceeds 200 pixels and the boundary is complex, it is classified as a patch-shaped defect. By setting the above classification labels, defects of different forms can be accurately distinguished during the identification process, and a reliable basis can be provided for subsequent coordinate mapping and partition association.
[0052] After obtaining the quantized color difference boundary description, the first step is to extract the color difference value distribution of the defect area to further calculate statistical features. In this embodiment, the system traverses the set of pixels covered by the smooth boundary contour, reads its color difference marker value one by one, and summarizes these values according to pixel position to form a color difference value distribution map of the defect area. Subsequently, statistical features, including the mean, variance, range, and median, are calculated based on this distribution data to reflect the overall color difference level and distribution characteristics of the defect area.
[0053] For example, 150 pixels were extracted within a certain boundary region, with color difference values ranging from 9 to 17, showing a relatively concentrated distribution. Statistical calculations revealed that the average color difference value for this region was 13.1, the variance was 2.2, the range was 8, and the median was 13. These statistical results can quantitatively describe the color difference characteristics of the defect region boundary: a higher average value indicates that the region deviates from the normal color overall, a smaller variance suggests a relatively uniform color difference distribution, while a larger range indicates the presence of local color difference anomalies. In this way, the originally discrete pixel-level color difference information is transformed into numerical statistical features, providing a quantitative basis for subsequent defect classification and coordinate mapping.
[0054] When performing clustering based on the color difference statistical features and preset defect shape classification labels to determine the defect shape category, a feature vector for clustering is first constructed. The feature sources include two parts: firstly, statistical quantities obtained from the color difference boundary description, such as the mean, variance, range, and median of color difference among pixels within the boundary, used to characterize the intensity and stability of color anomalies; secondly, geometric and morphological features extracted from the boundary contour in step S15, used to characterize the "shape". Morphological features may include: region area (number of pixels within the boundary), perimeter length (number of pixels on the boundary), aspect ratio (principal axis / secondary axis, which can be estimated from the principal component direction), roundness index (obtained by combining area and perimeter, used to measure the degree of approximation to a circle), convex hull compactness (ratio of the region's area to its convex hull), and thinness length (continuous length along the principal axis direction), etc. To eliminate the influence of different dimensions, the above features are first normalized (e.g., scaled to the 0-1 range) and weighted empirically (e.g., morphological features account for 60%-70% of the weight, and color difference statistical features account for 30%-40%), resulting in a unified feature vector representation.
[0055] Clustering is then performed. This embodiment uses k-means clustering, with the number of clusters k set to be the same as the number of preset defect shape classification labels (e.g., k=3 for "strip", "dot", and "patch" categories). During initialization, the prototype features of each category calculated from historical calibration samples can be used as initial centers to improve convergence stability; if calibration samples are lacking, multiple random initializations are performed, and the one with the higher profile coefficient is taken as the result. The clustering process sets a maximum number of iterations (e.g., 50 times) and a convergence threshold (e.g., stopping when the center change is less than 1e-3), and calculates intra-cluster compactness and inter-cluster separation after each iteration. If obvious tiny clusters (less than 1% of samples) or inter-cluster overlap occur, re-initialization can be automatically triggered to avoid undesirable local solutions. After clustering, each cluster is mapped to a preset label based on its dominant morphological features. For example, when the aspect ratio is ≥3, the roundness is low (e.g., <0.4), and the mean color difference is high while the variance is small (e.g., mean >12, variance <3), it is preferentially classified as "strip". When the area is small (e.g., <30 pixels), the roundness is high (e.g., >0.7), and the variance of the color difference is large (greater than 4), it is classified as "dot". When the area is large and both the roundness and aspect ratio are in the middle range, it is classified as "patch". To enhance robustness, simple rule checks can be added as post-processing: for example, "strip" must meet the thin length threshold (e.g., continuous length in the main axis direction ≥20 pixels), otherwise it will revert to "patch". If the area threshold of "dot" is exceeded, it will revert to "patch". In a real-world case, a certain defect area exhibited the following characteristics: mean color difference of 13.5, variance of 2.1, aspect ratio of approximately 5:1, roundness of approximately 0.35, and thinness of approximately 28 pixels. After clustering, it was found to be closest to the "strip" prototype and met the rule verification criteria. Therefore, it was ultimately determined to be a "strip" defect category.
[0056] After determining the defect shape category, the boundary pixel coordinates of the defect region are extracted in a targeted manner based on the category, and a coordinate mapping is generated. Specifically, a contour tracking strategy matching the shape is first executed on the refined defect region—for strip-shaped defects, priority tracking is performed along the principal axis estimated by the principal component direction; for point-shaped defects, the outermost closed equidistant contour is extracted first; for patch-shaped defects, the entire boundary is tracked and adaptively encrypted sampling is performed according to local curvature. The obtained boundary points are recorded as a set of pixel coordinate sequences in connected order. To ensure mapping accuracy, key points are retained and redundant points are removed based on the degree of inflection and the arc length spacing between adjacent points. Then, cubic B-spline fitting is performed on the boundary to obtain a smooth curve, and resampling is performed at a fixed arc length spacing to form a uniformly distributed set of boundary coordinates.
[0057] A two-level coordinate mapping is then established. The first level is a pixel coordinate mapping: it stores the absolute pixel position and index of each boundary point in the image, facilitating the retrieval of the original image and the association of attributes such as color difference and spectrum. The second level is a normalized coordinate mapping: it establishes a local coordinate system based on the minimum bounding rectangle of the defect, with the principal axis as the vertical axis and the secondary axis as the horizontal axis, and normalizes the coordinates to a uniform scale according to the length and width of the rectangle, facilitating the comparison and statistics between different defects. For different morphologies, corresponding additional geometric descriptions are also output: for strip-shaped defects, the coordinate sequence of the centerline obtained by fitting the centerlines of the two side boundaries and the horizontal width distribution along the centerline are given; for point-shaped defects, the geometric center position and the radius sequence of the equidistant contour from the outside to the inside are given; for patch-shaped defects, the convex hull coordinate sequence and the concavity depth distribution of the boundary relative to the convex hull are given.
[0058] After completing the coordinate mapping of the defect area, the mapping results are merged or segmented according to the preset surface area partitioning rules to form the final shape partitioning association description. Specifically, the process-defined surface partitioning layer (e.g., functional area, workstation area, edge buffer, etc.) is loaded first. The defect boundary coordinates are projected point by point onto the partitioning layer, and the overlap area, boundary crossing situation, and center point location of each defect with each partition are calculated. If multiple defect fragments with the same shape category and a distance of less than five pixels exist within the same partition, the region is merged according to the "same type and nearest neighbor" rule. If two defects in the same partition have an overlap rate greater than 60% and their boundaries are adjacent, they are preferentially merged into a single region to avoid fragmented recording. If a single defect spans multiple partitions, it is segmented according to the "majority overlap priority" principle: using the partition boundary as the cutting line, the portion of the defect in different partitions is split into independent sub-regions. When the overlap rate of a certain partition is less than 20%, the residual small fragments within that partition are considered as incidental parts and are removed to avoid invalid loading. To improve the robustness of the rules, minimum effective area thresholds and minimum width thresholds are set. For example, sub-regions with an area less than twenty pixels or a minimum width of less than two pixels are considered noise and deleted. For thin, elongated defects that fall exactly on the partition boundary, a two-pixel boundary buffer is introduced, prioritizing their assignment to the partition where the center line is located, reducing assignment instability caused by boundary jitter. If the same defect has conflicting assignments in adjacent partitions, the partition priority table is used for adjudication, for example, functional critical areas take precedence over decorative areas.
[0059] In one specific embodiment, the minimum effective area threshold and the minimum width threshold are determined based on the resolution of the detection device and the typical defect scale of the AF film surface. For example, when the image resolution is 1920×1080 and the actual size corresponding to a single pixel is approximately 10 micrometers, the area is less than 20 pixels (approximately 0.002 mm). 2 The area marked as "(0 pixels)" represents dust noise or random detection errors, therefore a minimum effective area threshold of 20 pixels is set. For strip-shaped or elongated defects, to avoid overly fine noise edges being misjudged as defects, a minimum width threshold of 2 pixels (approximately 20 micrometers) can be set. Areas smaller than this width are mostly noise interference or invalid edges and can be automatically removed during processing.
[0060] In step S17, based on the shape partition association description and preset spectral template, and in conjunction with the spectral distribution data, it is necessary to determine the location distribution and partition assignment of minute color difference defects on the AF film surface, thereby obtaining the location distribution and partition assignment of defects, including: The matching degree is calculated based on the shape partition association description and the preset spectral template; When the matching degree is higher than a preset matching degree threshold, a valid defect marker is generated by combining the spectral distribution data. The effective defect markers are mapped to preset surface area partitions to obtain the location distribution and partition affiliation of the defects.
[0061] After obtaining the shape partition association description, it needs to be compared with a preset spectral template to calculate the matching degree. Specifically, the system first selects the corresponding spectral template from the template library based on the morphological category and partition affiliation of the defect. The template library is constructed using historical samples, with data sourced from typical defect areas collected during production and manually confirmed. When constructing the template, the collected raw spectral data is first preprocessed, including noise reduction, baseline correction, and smoothing filtering, to eliminate the influence of measurement errors and environmental fluctuations. Subsequently, the processed spectral curves are normalized to ensure comparability at the same wavelength sampling points, and reflectance or transmittance features at key wavelengths (such as 450nm, 550nm, and 600nm) are extracted as template vectors. The template library can be updated regularly according to process batches, for example, by adding newly sampled defect samples monthly, and using statistical analysis methods to screen out abnormal curves to ensure the representativeness and timeliness of the templates. In another embodiment, supervised learning methods can also be combined to classify and train historical spectral data, so that the templates not only contain static curves but also have automatic optimization capabilities to adapt to changes in production conditions.
[0062] During the comparison process, the system samples spectral data within the defect area based on coordinate mapping and performs robust averaging on the sampled points to eliminate interference caused by environmental noise or individual abnormal pixels. To ensure accuracy, the system unifies the acquired spectral distribution with the template curve to the same wavelength sampling points and performs normalization. Subsequently, the system extracts the reflectance variation trend and peak-valley features of the curve at key wavelengths to form a spectral feature vector, which is then compared with the template features. Simultaneously, it incorporates geometric features from the shape partitioning description for consistency verification, such as whether aspect ratio, roundness, or slenderness fall within the allowable range of the template for that category, to avoid misjudgment based solely on spectral similarity.
[0063] In the matching degree calculation, spectral features and geometric features are assigned weights and fused into a comprehensive score. In this embodiment, the preferred method is to use a weighted summation model, where the matching degree equals the product of α and spectral similarity plus the product of β and morphological consistency, where α + β = 1. The weight coefficients α and β are set according to actual detection requirements. For example, in the display area, where color difference sensitivity is higher, α = 0.7 and β = 0.3 can be used; in the border area, where morphological requirements are higher, α = 0.5 and β = 0.5 can be used. If the trend of key wavelength variation is completely consistent with the template, an additional score (e.g., +0.05) is given in the spectral similarity part, while if abnormal peak and valley features that do not match the template appear, a deduction is given (e.g., -0.05). Finally, the system will obtain a comprehensive matching degree value between 0 and 1 and compare it with a preset threshold, for example, 0.88 in the display functional area and relaxed to 0.83 in the border area, thereby determining whether the defect is a real defect.
[0064] When the matching degree is higher than a preset matching degree threshold, the system will further combine spectral distribution data to generate a valid defect label. Specifically, the system will extract the spectral reflectance or transmittance curve at key wavelengths within the defect area and compare it point by point with the template features to confirm that its variation trend is within the allowable deviation range (e.g., no more than ±5%). If the verification is successful, the system will confirm the defect area as a real defect and generate a valid defect label for it, including the defect number, category label, boundary coordinate range, average color difference value, and the partition it belongs to.
[0065] In one embodiment, the spectral curve of a strip-shaped defect matches the template with a degree of 0.91, which is higher than the threshold of 0.85. The system detects a reflectance decrease at wavelengths of 450 nm and 550 nm that differs from the template by 3%, which is below the allowable deviation of 5%, thus confirming the validity of the defect and generating a marker. This marker records the center position of the defect, an area of approximately 120 pixels, an average color difference value of 13.5, and a "strip-shaped" category label.
[0066] The threshold setting should be adjusted based on detection accuracy and application scenario. A matching degree greater than 0.90 is considered a highly reliable result; a matching degree between 0.85 and 0.90 is considered acceptable; and a matching degree below 0.80 is considered an unreliable result. In critical areas (such as display function areas), it is recommended to set the threshold to 0.88 to 0.90 to ensure a low false alarm rate; in non-critical areas (such as border areas or buffer zones), the threshold can be appropriately reduced to 0.83 to 0.85 to avoid missed detections.
[0067] After generating valid defect markers, they need to be mapped to preset surface area partitions to clarify the specific location and attribution of defects on the AF film. Specifically, the system first calls the surface partitioning rules defined in the process, which divide the film surface into multiple functional areas, such as display areas, touch sensing areas, border areas, and buffer protection areas, each with clear boundary coordinate information.
[0068] In a preferred embodiment, if the center point of a defect is located within the display area, and more than 70% of the defect outline falls within the display area, the defect is directly determined to belong to the display area. If a defect spans two zones simultaneously, it is assigned according to the maximum overlap principle; for example, if more than 60% of the area falls within the border area, it is assigned to the border area. For long, thin strip-shaped defects, if they span two functional areas but are less than 5 pixels wide, they are divided into two sub-regions and mapped to their respective functional areas, thereby avoiding ambiguity in assignment.
[0069] In another embodiment, for some special process areas (such as the fingerprint recognition sensing window in the display area), the system sets priority rules. When a defect crosses the boundary of the area, even if the overlapping area is less than 50%, it will be given priority to be classified as belonging to the high-priority partition, so as to ensure that the detection of critical areas is more rigorous.
[0070] Finally, the system generates a complete record for each defect, including "location distribution + partition affiliation". For example, defect number 001, category "strip", located in the upper left corner of the display area, center coordinates (120, 240), area of about 150 pixels, and belongs to the display function area.
[0071] To ensure the accuracy of defect mapping, surface area partitioning rules need to be pre-defined. These rules are established by combining product design drawings with actual process requirements, using a combination of coordinate mapping and partition priority. Specifically, firstly, based on the structural design of the AF film, the film surface is divided into several functional areas in the image coordinate system, such as the central display area, fingerprint recognition sensing area, border area, and buffer protection area. The boundary of each area can be defined by polygonal coordinate points or rectangular frames and stored in the partitioning database. Secondly, priorities are assigned to different areas to reflect their importance in product quality. The display area and fingerprint recognition area have the highest priority, followed by the border area, and finally the buffer protection area.
[0072] In practical applications, when a defect spans multiple partitions, the system will determine its classification according to priority rules. For example, a strip-shaped defect may cover both the display area and the border area. Although its area in the border area is larger, the display area has a higher priority, so the entire defect is classified as belonging to the display area. To avoid over-merging, an area ratio threshold can be introduced. When the area of a defect in a low-priority area exceeds 70%, the system will segment the defect and label it in different partitions to ensure the accuracy of the records.
[0073] Furthermore, to accommodate alignment errors or imaging distortions that may occur in actual production, boundary buffer zones can be set in the partitioning rules, for example, extending 2 to 3 pixels outside the partition boundary line as a transition area. If the defect mainly falls within the buffer zone, it will be preferentially assigned to the nearest functional partition based on its center point location and surrounding area distribution.
[0074] It should be noted that all numerical parameters involved in this invention (including but not limited to color difference threshold, edge detection parameters, region merging threshold, matching degree threshold, etc.) are set based on a large amount of experimental data and the actual situation of AF film production process. For example, the color difference threshold ΔE=10 is determined based on the minimum perceptible color difference (JND, Just Noticeable Difference) of the human eye and the actual noise level of the production line; the high and low thresholds for Canny edge detection are set to 50 and 150, which are empirical values to control the false detection rate while ensuring the detection rate; the region merging distance threshold of 5 pixels corresponds to the minimum physical interval of actual defects (approximately 50μm) at the image resolution. Those skilled in the art can appropriately adjust the above parameters according to the actual imaging resolution, noise level and product requirements, and the above values should not be construed as a limitation on the scope of protection.
[0075] In summary, this invention provides an image recognition-based method and system for identifying surface defects in AF films, enabling accurate detection of minute color difference defects.
[0076] Reference Figure 2 The second embodiment of the present invention provides an image recognition-based AF film surface defect identification system, comprising: The data acquisition module is used to acquire the original image of the AF film surface. During the acquisition process, it synchronously records the spectral distribution data and ambient light compensation data corresponding to the original image, and associates and stores the original image, the spectral distribution data and the ambient light compensation data to form an initial image set. The standard correction module is used to perform illumination parameter adjustment and color channel equalization processing based on the initial image set to obtain a standardized image after illumination correction. The preliminary defect module is used to perform pixel discrimination and region recognition operations based on the standardized image, thereby generating a preliminary defect region map; The refining and extraction module is used to perform clustering and refining extraction operations on the preliminary defect region map to obtain a refined defect region set. The color difference boundary module is used to extract the boundary contour of the set of refining defect regions and smooth the boundary contour to obtain a quantized color difference boundary description. The shape partitioning module is used to determine the coordinate mapping and surface area partitioning of minute color difference defects based on the quantized color difference boundary description and the preset defect shape classification label, thereby generating a shape partitioning association description. The defect determination module is used to determine the location distribution and partition assignment of minute color difference defects on the AF film surface based on the shape partition association description and preset spectral template, and in combination with the spectral distribution data, thereby obtaining the location distribution and partition assignment of defects.
[0077] It should be noted that the image recognition-based AF film surface defect identification system provided in this embodiment of the invention is used to execute all the process steps of the image recognition-based AF film surface defect identification method in the above embodiment. The working principles and beneficial effects of the two are one-to-one, so they will not be described again.
[0078] This invention also provides an electronic device. The electronic device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, such as a standard calibration program. When the processor executes the computer program, it implements the steps in the various embodiments of the image recognition-based AF film surface defect identification method described above, for example... Figure 1 The step S11 shown. Alternatively, when the processor executes the computer program, it implements the functions of each module / unit in the above-described device embodiments, such as the standard calibration module.
[0079] For example, the computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the electronic device.
[0080] The electronic device may be a desktop computer, laptop, handheld computer, or smart tablet, etc. The electronic device may include, but is not limited to, a processor and memory. Those skilled in the art will understand that the above components are merely examples of electronic devices and do not constitute a limitation on the electronic device. It may include more or fewer components than described above, or combine certain components, or different components. For example, the electronic device may also include input / output devices, network access devices, buses, etc.
[0081] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the electronic device, connecting various parts of the electronic device through various interfaces and lines.
[0082] The memory can be used to store the computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory and by calling data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital card (SD card), flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0083] If the modules / units integrated in the electronic device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0084] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0085] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A method for identifying surface defects of an AF film based on image recognition, characterized in that, include: The original image of the AF film surface is acquired. During the acquisition process, the spectral distribution data and ambient light compensation data corresponding to the original image are recorded simultaneously. The original image, the spectral distribution data and the ambient light compensation data are associated and stored to form an initial image set. Based on the initial image set, illumination parameter adjustment and color channel equalization are performed to obtain a standardized image after illumination correction. Based on the standardized image, pixel discrimination and region recognition operations are performed to generate a preliminary defect region map; Clustering and defect region refinement extraction operations are performed on the preliminary defect region map to obtain a refined defect region set; Extract the boundary contours of the refined defect region set and smooth the boundary contours to obtain a quantized color difference boundary description. Based on the quantized color difference boundary description and the preset defect shape classification label, the coordinate mapping and surface area partition of the minor color difference defect are determined, thereby generating a shape partition association description; Based on the shape partition association description and the preset spectral template, and combined with the spectral distribution data, the location distribution and partition assignment of the minute color difference defects on the AF film surface are determined, and the location distribution and partition assignment of the defects are obtained.
2. The image recognition-based AF film surface defect identification method according to claim 1, characterized in that, The step of performing illumination parameter adjustment and color channel equalization processing based on the initial image set to obtain an illumination-corrected standardized image includes: White balance adjustment is performed based on the spectral distribution data in the initial image set to obtain the first corrected image; Based on the ambient light compensation data in the initial image set, the first corrected image is brightness equalized to obtain the second corrected image; The RGB color channels of the second corrected image are subjected to equalization processing to obtain a standardized image after illumination correction.
3. The image recognition-based AF film surface defect identification method according to claim 1, characterized in that, The step of performing pixel discrimination and region recognition operations based on the standardized image to generate a preliminary defect region map includes: Extract the RGB color channel values of each pixel from the standardized image; Calculate the Euclidean distance of color difference between pixels based on the RGB color channel values; When the color difference Euclidean distance exceeds a preset distance threshold, the pixel corresponding to the color difference Euclidean distance exceeding the preset distance threshold is marked as a potential defect pixel; The potential defective pixels are aggregated based on spatial adjacency to generate a preliminary defective region map.
4. The image recognition-based AF film surface defect identification method according to claim 1, characterized in that, The process of performing clustering and defect region refinement extraction operations on the preliminary defect region map to obtain a refined defect region set includes: Extract the color difference markers of the pixels in the preliminary defect area image; Based on the color difference markers, pixels are grouped to obtain defect region groups; Cluster centers are calculated based on the defective regions, and the cluster centers are updated using the mean shift method to obtain the updated clustering results; The adjacent pixels of the same type in the updated clustering results are merged, and continuous defect regions are extracted to obtain a refined defect region set.
5. The image recognition-based AF film surface defect identification method according to claim 1, characterized in that, The step of extracting the boundary contours of the refined defect region set and smoothing the boundary contours to obtain a quantized color difference boundary description includes: Edge detection is performed on the set of refined defect regions to obtain a set of boundary pixels; The initial boundary contour of the defect region is constructed based on the set of boundary pixels. The initial boundary contour is smoothed to remove jagged edges and noise, resulting in a smooth boundary contour. The color difference markers of pixels within the smooth boundary contour are extracted and statistical features are calculated to form a quantized color difference boundary description.
6. The method for identifying AF film surface defects based on image recognition according to claim 1, characterized in that, The step of determining the coordinate mapping and surface region partitioning of minute color difference defects based on the quantized color difference boundary description and preset defect shape classification labels, thereby generating a shape partitioning association description, includes: The color difference value distribution is extracted from the quantized color difference boundary description, and the color difference statistical characteristics of the defect area are calculated based on the color difference value distribution; Based on the color difference statistical features and the preset defect shape classification labels, clustering is performed to determine the defect shape category; Extract the coordinates of the boundary pixels of the defect region based on the defect shape category, and generate the coordinate mapping of the defect region; Based on preset surface region partitioning rules, the coordinate mapping is merged or divided to form the final shape partition association description.
7. The method for identifying AF film surface defects based on image recognition according to claim 1, characterized in that, The step of determining the location distribution and zoning of minute color difference defects on the AF film surface based on the shape zoning association description and preset spectral template, and in conjunction with the spectral distribution data, to obtain the location distribution and zoning of defects, includes: The matching degree is calculated based on the shape partition association description and the preset spectral template; When the matching degree is higher than a preset matching degree threshold, a valid defect marker is generated by combining the spectral distribution data. The effective defect markers are mapped to preset surface area partitions to obtain the location distribution and partition affiliation of the defects.
8. A surface defect identification system for AF film based on image recognition, characterized in that, include: The data acquisition module is used to acquire the original image of the AF film surface. During the acquisition process, it synchronously records the spectral distribution data and ambient light compensation data corresponding to the original image, and associates and stores the original image, the spectral distribution data and the ambient light compensation data to form an initial image set. The standard correction module is used to perform illumination parameter adjustment and color channel equalization processing based on the initial image set to obtain a standardized image after illumination correction. The preliminary defect module is used to perform pixel discrimination and region recognition operations based on the standardized image, thereby generating a preliminary defect region map; The refining and extraction module is used to perform clustering and refining extraction operations on the preliminary defect region map to obtain a refined defect region set. The color difference boundary module is used to extract the boundary contour of the set of refining defect regions and smooth the boundary contour to obtain a quantized color difference boundary description. The shape partitioning module is used to determine the coordinate mapping and surface area partitioning of minute color difference defects based on the quantized color difference boundary description and the preset defect shape classification label, thereby generating a shape partitioning association description. The defect determination module is used to determine the location distribution and partition assignment of minute color difference defects on the AF film surface based on the shape partition association description and preset spectral template, and in combination with the spectral distribution data, thereby obtaining the location distribution and partition assignment of defects.