OCA defect detection method and system based on visual recognition
By using a method based on local texture flatness and cross-entropy, the normal background of the OCA bonding area is automatically filtered, the global grayscale distribution is adaptively estimated, and a precise defect location mask is generated. This solves the problem of grayscale variation interference in OCA bonding defect detection and achieves high-precision and stable automated detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DONGGUAN HANGDA ELECTRONICS
- Filing Date
- 2026-05-10
- Publication Date
- 2026-07-10
AI Technical Summary
Existing OCA bonding defect detection technology has difficulty distinguishing between grayscale changes caused by normal process fluctuations and actual defects, resulting in insufficient detection efficiency and production line adaptability, making it difficult to meet the detection needs of high-speed production and multi-specification products.
By acquiring the original grayscale image of the OCA bonding area, the candidate set of normal regions is automatically selected based on the local texture flatness. The global background joint grayscale distribution is estimated by bootstrapping, and the empirical joint grayscale distribution of the local neighborhood window is extracted pixel by pixel. The minimum information projection distribution and cross-entropy are calculated to generate a cross-entropy map of pixel-level anomaly representation. Finally, adaptive threshold segmentation and morphological optimization are performed to output an accurate defect location mask.
It achieves unsupervised background modeling without the need for preset standard templates and defect samples, effectively filters out interference from normal process fluctuations, improves the accuracy and stability of OCA bonding defect detection, and adapts to automated detection under different working conditions.
Smart Images

Figure CN122368024A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect detection, and more specifically to a visual recognition-based method and system for detecting defects in OCA bonding. Background Technology
[0002] Optical transparent adhesive (OCA) is a core functional material in the bonding process of optical devices such as touch display panels, automotive displays, and flexible foldable screens. The quality of the adhesive layer after bonding directly determines the optical display effect of the end product. However, existing visual inspection solutions for OCA bonding defects mostly use fixed template matching, single-pixel grayscale threshold segmentation, or deep learning detection models trained based on labeled defect samples. In actual production line applications, fixed template and fixed threshold solutions are difficult to adapt to the grayscale drift caused by unavoidable lighting fluctuations on the production line. They are also insufficient in detecting micron-level defects with low contrast, and are prone to batch missed detections and false detections. This makes it difficult to meet the inspection needs of rapid product changeover and high-cycle production of multi-specification products on the production line. Summary of the Invention
[0003] This application provides a visual recognition-based OCA bonding defect detection method and system, aiming to solve the technical problem that existing OCA bonding defect detection technologies are unable to distinguish between grayscale changes caused by normal process fluctuations and real defects, resulting in insufficient detection efficiency and production line adaptability.
[0004] In view of the above problems, this application provides a method and system for detecting OCA bonding defects based on visual recognition.
[0005] The first aspect disclosed in this application provides a visual recognition-based method for detecting OCA bonding defects, the method comprising: Acquire the original grayscale image of the OCA bonding region; automatically filter the candidate set of normal regions in the original grayscale image based on local texture flatness, and estimate the global background joint grayscale distribution based on the candidate set of normal regions; extract the empirical joint grayscale distribution of the local neighborhood window for each pixel position in the original grayscale image; calculate the minimum information projection distribution of the empirical joint grayscale distribution onto the global background joint grayscale distribution under exponential family constraints, and calculate the cross-entropy between the global background joint grayscale distribution and the minimum information projection distribution to obtain a cross-entropy map; perform threshold segmentation on the cross-entropy map and output the defect location mask.
[0006] Another aspect of this application discloses a vision-based OCA bonding defect detection system, which includes: The system comprises the following modules: an acquisition module for acquiring the original grayscale image of the OCA bonding region; a filtering module for automatically filtering a candidate set of normal regions in the original grayscale image based on local texture flatness, and estimating the global background joint grayscale distribution based on the candidate set of normal regions; an extraction module for extracting the empirical joint grayscale distribution of a local neighborhood window for each pixel position in the original grayscale image; a calculation module for calculating the minimum information projection distribution of the empirical joint grayscale distribution onto the global background joint grayscale distribution under exponential family constraints, and calculating the cross-entropy between the global background joint grayscale distribution and the minimum information projection distribution to obtain a cross-entropy map; and a segmentation module for thresholding the cross-entropy map and outputting a defect location mask.
[0007] One or more technical solutions provided in this application have at least the following technical effects or advantages: By acquiring the original grayscale image of the OCA bonding area, the system automatically filters the candidate set of normal regions based on local texture flatness and estimates the global background joint grayscale distribution through bootstrapping. Then, it extracts the empirical joint grayscale distribution of local neighborhood windows pixel by pixel. Through solving the minimum information projection distribution under exponential family constraints and calculating cross-entropy, it generates a cross-entropy map representing pixel-level anomalies. Finally, through adaptive threshold segmentation and morphological optimization, it outputs an accurate defect location mask. Without the need for pre-labeling defect samples and preset standard templates, unsupervised background modeling and defect detection can be completed based on only a single image to be detected. This can effectively filter out detection interference caused by various normal process fluctuations on the production line, and ultimately achieve high-precision and high-stability automated detection of all types of OCA bonding defects, improving the defect detection rate of the OCA bonding process and the adaptability of the detection scheme.
[0008] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application and to implement it in accordance with the contents of the specification, and to make the above and other objects, features and advantages of this application more obvious and understandable, the following are specific embodiments of this application. Attached Figure Description
[0009] Figure 1 A flowchart illustrating a vision-based OCA bonding defect detection method is provided for embodiments of this application. Figure 2 A schematic diagram of the structure of an OCA bonding defect detection system based on visual recognition is provided for the embodiments of this application.
[0010] Figure labeling: Acquisition module 11, Filtering module 12, Extraction module 13, Calculation module 14, Segmentation module 15. Detailed Implementation
[0011] To further illustrate the technical means and effects of the present invention in achieving its intended purpose, the following detailed description of the specific implementation methods, structures, features, and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.
[0012] The overall concept of the technical solution provided in this application is as follows: By acquiring the original grayscale image of the OCA-fitting region, the system automatically filters the candidate set of normal regions based on local texture flatness and estimates the global background joint grayscale distribution through bootstrapping. Then, it extracts the empirical joint grayscale distribution of local neighborhood windows pixel by pixel. Through solving the minimum information projection distribution under exponential family constraints and calculating cross-entropy, it generates a cross-entropy map representing pixel-level anomalies. Finally, it outputs an accurate defect location mask through adaptive threshold segmentation and morphological optimization. It does not rely on preset standard templates and a large number of defect annotation samples. It can complete the adaptive statistical modeling of the normal background based on only a single image to be detected, which effectively improves the efficiency of automated detection.
[0013] After introducing the basic principles of this application, various non-limiting embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0014] Example 1, as Figure 1 As shown in the embodiment of this application, a method for detecting OCA bonding defects based on visual recognition is provided. The method includes: S100: Acquire the original grayscale image of the OCA bonding area.
[0015] Specifically, the goal is to acquire high-fidelity, low-distortion, and linearly consistent original grayscale images of the OCA bonding area. OCA, short for Optically Clear-Adhesive, is a material used in the bonding process of optical devices such as displays and touch panels. Defects in the bonded area directly affect the display effect and yield rate of optical devices. The original grayscale image refers to a digital image containing only single-channel brightness information, with pixel grayscale values typically ranging from 0 (pure black) to 255 (pure white). The value of each pixel directly corresponds to the optical reflection / transmission brightness at the corresponding position in the OCA bonding area. Without any additional image enhancement, noise reduction, cropping, or other post-processing operations, the original texture and grayscale distribution characteristics of the bonding area can be completely preserved. First, an image acquisition hardware platform consisting of an industrial area / line scan camera, a telecentric optical lens, and a coaxial light source system is built. The telecentric optical lens can eliminate perspective distortion and ensure consistent imaging magnification at different positions in the OCA bonding area. The coaxial light source system can avoid specular reflection on the OCA bonding surface and highlight the subtle grayscale differences within the bonding layer.
[0016] Subsequently, the OCA-bonded workpiece to be inspected is fixed at the preset inspection station by a mechanical positioning mechanism, ensuring that the OCA bonding area falls completely within the camera's field of view and that the bonding plane remains strictly parallel to the camera's imaging plane. After the station calibration is completed, the industrial camera is triggered to complete a single exposure imaging, acquiring the original RGB color image of the OCA bonding area. This original RGB color image is a digital image directly output by the camera's image sensor, containing red, green, and blue color information. It has not undergone any preprocessing operations such as compression, filtering, or contrast stretching, and can retain the original optical information of the bonding area to the greatest extent.
[0017] Next, the acquired raw RGB color image is converted to grayscale using a standard grayscale conversion method that matches the visual sensitivity of the human eye. The three-channel color pixels are converted to single-channel grayscale pixels using the formula: grayscale value = 0.299 × R channel pixel value + 0.587 × G channel pixel value + 0.114 × B channel pixel value. Simultaneously, before the formal acquisition, the camera's dark field correction and flat field correction are performed. Dark field correction is used to eliminate the fixed noise caused by dark current in the camera's image sensor, while flat field correction is used to correct the grayscale deviation across the entire field of view caused by uneven illumination and lens vignetting. This ensures that the grayscale value of the final output raw grayscale image has a linear correspondence with the actual optical characteristics of the OCA bonding area, avoiding interference from system errors in subsequent algorithm processing. Finally, a raw grayscale image of the OCA bonding area that meets the algorithm requirements is generated.
[0018] S200: Automatically filter the candidate set of normal regions in the original grayscale image based on local texture flatness, and estimate the global background joint grayscale distribution based on the candidate set of normal regions.
[0019] Specifically, the first step is to automatically filter the candidate set of normal regions based on local texture flatness. The candidate set of normal regions refers to the set of pixels and neighborhood windows that are likely to be defect-free OCA-fitted normal backgrounds selected from the original grayscale image. Local texture flatness is the core indicator used to quantify the grayscale uniformity and texture smoothness of local regions of an image. The lower the value, the more the region fits the textureless and low-fluctuation characteristics of the normal OCA-fitted surface.
[0020] After constructing the candidate set of normal regions, bootstrap estimation of the global background joint grayscale distribution based on this candidate set is carried out. The global background joint grayscale distribution represents the probability distribution of grayscale value combinations of pixel pairs that satisfy a preset spatial adjacency relationship in the normal background region of OCA fitting. Bootstrap estimation is a statistical method that achieves accurate background distribution estimation through iterative optimization based solely on the normal candidate set selected by the current image itself without additional training samples. It can adapt to OCA fitting images under different batches and working conditions and has strong scene robustness. Specifically, it first extracts multiple neighborhood windows contained in the candidate set of normal regions, and calculates the corresponding values for each window one by one. The joint grayscale distribution is obtained by counting the frequency of grayscale value combinations of pixel pairs that satisfy a preset spatial adjacency relationship within each window, and then dividing by the total number of pixel pairs within the window to convert it into a probability distribution. Subsequently, based on the joint grayscale distribution of all candidate windows, the initial global background distribution is obtained by median aggregation of histogram bins. Histogram bins are several continuous intervals that divide the range of grayscale values and are the basic unit for grayscale distribution statistics. Median aggregation is the median of the probability values of all windows corresponding to each bin. By utilizing the characteristic that the median is not sensitive to outliers, the interference of a small number of potentially defective windows mixed in with the candidate set on the initial background distribution is effectively avoided, ensuring the stability of the initial distribution.
[0021] Then, the KL divergence between the joint grayscale distribution of all candidate windows and the initial global background distribution is calculated. KL divergence, or relative entropy, is used to measure the degree of difference between two probability distributions. The larger the value, the greater the difference between the distribution of the window and the background distribution, and the higher the probability of it being an abnormal defect window. Abnormal windows with KL divergence greater than a preset divergence threshold are then removed. The arithmetic mean of the joint grayscale distribution of the remaining qualified windows is calculated for each histogram bin as the updated global background distribution. The above abnormal window removal and background distribution re-estimation operations are repeated until the change between the global background distributions obtained from two consecutive iterations is less than the preset convergence threshold. Finally, a stable and converged global background joint grayscale distribution is output.
[0022] S300: For each pixel position in the original grayscale image, extract the empirical joint grayscale distribution of the local neighborhood window.
[0023] Specifically, firstly, a square local neighborhood window with an odd number of pixels on each pixel to be calculated in the original grayscale image is defined as the center. The local neighborhood window is a fixed-size pixel block used to statistically analyze local grayscale features. Choosing an odd number of pixels on each pixel ensures that the pixel to be detected is strictly at the geometric center of the window. The side length of the window is usually an odd number between 9 and 31 pixels. At the same time, for pixels at the image boundary, since the central window will exceed the effective range of the original image, mirror filling or symmetrical filling is used to expand the edge region. Mirror filling refers to symmetrically copying the pixels inside the boundary to the blank area outside the boundary with the image boundary as the axis of symmetry, compared to zero filling and other methods.
[0024] After completing the window delineation and boundary filling, statistics are performed on all pixel pairs within each square window that satisfy the preset spatial adjacency relationship. The preset spatial adjacency relationship is a predefined pixel spatial pairing rule used to construct the joint grayscale distribution. It usually adopts 4 adjacency, i.e., top, bottom, left, and right, or 8 adjacency, i.e., the pairing of adjacent pixels including diagonal directions.
[0025] Subsequently, the grayscale value combination of each pixel pair that meets the pairing rules within the window is obtained one by one. That is, the two-dimensional numerical combination composed of the grayscale values of the two pixels in each pixel pair is obtained. The frequency of occurrence of all grayscale value combinations within the window is counted. Then, the frequency of occurrence of each grayscale value combination is divided by the total number of pixel pairs that meet the requirements within the window. Finally, the empirical joint grayscale distribution of the local neighborhood window corresponding to the central pixel is obtained. The empirical joint grayscale distribution is a two-dimensional discrete probability distribution obtained by frequency statistics based entirely on the actual pixel observation data within the current local window. It represents the grayscale correlation characteristics of adjacent pixels in the current local area. The above empirical joint grayscale distribution extraction operation can be repeated for each pixel with at least two neighborhood windows of different sizes to obtain multiple sets of local distributions corresponding to different window scales.
[0026] S400: Calculate the minimum information projection distribution of the empirical joint gray-level distribution onto the global background joint gray-level distribution under the exponential family constraints, and calculate the cross-entropy between the global background joint gray-level distribution and the minimum information projection distribution to obtain a cross-entropy map.
[0027] Specifically, the first step is to solve for the minimum information projection distribution under the exponential family constraint. The exponential family constraint requires that the target distribution must belong to a set of probability distributions with a unified exponential expression and sufficient statistical properties. This family of distributions can completely represent all the information of the distribution through a finite number of low-dimensional statistical features. Introducing this constraint can filter out local random noise interference while locking in the distribution structure anomalies caused by OCA fitting defects. The minimum information projection distribution refers to the probability distribution with the smallest information difference (KL divergence) compared to the reference distribution, using the global background joint grayscale distribution as a reference benchmark, while satisfying the exponential family constraint and the pre-set statistical features. KL divergence, also known as relative entropy, measures the information distance between two probability distributions; the smaller the value, the higher the similarity between the two distributions. Its essence is to solve for the information distance between two probability distributions when the global background joint grayscale distribution is used as a reference benchmark. Under the premise of conforming to the statistical law of normal OCA bonding, the theoretical distribution of the front local window best fits its own characteristics. This is used to separate the local overall gray-level fluctuations from the structural anomalies caused by real defects. Specifically, firstly, for the empirical joint gray-level distribution of the corresponding local neighborhood window generated for each pixel in the previous steps, the first-order gray-level mean, second-order gray-level variance, and gray-level covariance of adjacent pixels are extracted as window statistical features. The first-order gray-level mean represents the overall gray-level level within the window, the second-order gray-level variance represents the overall dispersion of gray-level within the window, and the gray-level covariance of adjacent pixels represents the gray-level spatial correlation of adjacent pixels within the window. This correlation is the stable feature of normal OCA bonding. Defects such as bubbles, scratches, foreign objects, and bonding delamination will directly destroy this correlation. These three features together constitute sufficient statistics of the exponential family distribution.
[0028] Then, using the global background joint grayscale distribution obtained by the pre-bootstrap estimation as the reference distribution, and under the constraint of strictly maintaining the statistical features of the above three windows unchanged, the minimum information projection distribution is solved by the iterative scaling fitting algorithm. The specific process is as follows: First, the projection distribution is initialized as the global background joint grayscale distribution. Then, each statistical feature constraint of the current local window is traversed in turn. The probability value of the projection distribution is adjusted by the scaling factor for each grayscale combination so that the adjusted distribution strictly satisfies the current statistical feature constraint. At the same time, it is ensured that the adjusted distribution maintains the minimum KL divergence with the distribution of the previous iteration. All constraints are traversed repeatedly to complete multiple iterations until the convergence condition is met, that is, the maximum probability change of the projection distribution in two consecutive iterations is less than the preset probability change threshold. Finally, the converged distribution is output as the minimum information projection distribution corresponding to the local window.
[0029] Then, cross-entropy calculation and cross-entropy map generation are performed. Cross-entropy is a quantitative indicator that measures the degree of difference between two probability distributions. Its physical meaning is the average information uncertainty when using a reference distribution to describe the target distribution. The greater the difference between the two distributions, the higher the cross-entropy value. In this scheme, the cross-entropy value directly corresponds to the degree of anomaly at the pixel position. The higher the value, the greater the structural difference between that position and the normal OCA, and the higher the probability of it being a defective area. The specific calculation is as follows: for each local window, the global background joint grayscale distribution and the minimum information projection distribution are used to calculate the product of the logarithm of the empirical joint grayscale distribution and the probability value of the grayscale combination corresponding to the minimum information projection distribution for each grayscale combination. The calculation results of all grayscale combinations are summed and the negative value is taken. The cross-entropy value corresponding to the center pixel of the window is obtained, and then all pixel positions of the original grayscale image are traversed to complete the cross-entropy calculation of all pixels in the image, forming an initial cross-entropy map with the same size as the original grayscale image. In order to take into account the detection sensitivity of defects of different sizes, the cross-entropy map can also be optimized by multi-scale window fusion. That is, at least two neighborhood windows of different sizes are used respectively, and the above-mentioned empirical joint grayscale distribution extraction, minimum information projection solution and cross-entropy calculation process are repeatedly executed to obtain multiple cross-entropy sub-maps corresponding to different window scales. Then, all cross-entropy sub-maps are fused by taking the maximum value pixel by pixel to obtain the final cross-entropy map. At the same time, it covers OCA bonding defects of different scales, such as tiny dot bubbles, foreign objects and large-area bonding layering, warping, etc.
[0030] S500: Perform threshold segmentation on the cross-entropy map and output a defect location mask.
[0031] Specifically, the adaptive global threshold is first calculated and set. A full-image pixel-level statistical analysis is performed on the input cross-entropy map, calculating the global mean and global standard deviation of the cross-entropy values for all pixels in the image. The global mean represents the average level of the cross-entropy across the entire image, characterizing the overall background anomaly baseline. The global standard deviation represents the dispersion of the cross-entropy values, characterizing the fluctuation range of anomaly scores within the image. Then, according to the formula: Global threshold = global mean + preset sensitivity coefficient × global standard deviation; Set a segmentation threshold. The preset sensitivity coefficient is an adjustable parameter that is pre-set based on the detection accuracy requirements of the OCA bonding process and the acceptable balance between false positives and false negatives. The larger the coefficient, the higher the threshold and the stricter the detection judgment. It can filter out more false positives caused by background noise, but there is a risk of missing small defects. The smaller the coefficient, the lower the threshold and the higher the detection sensitivity for small defects with low contrast, but it may introduce more false positives. It can be flexibly adjusted according to the yield control standards of the production line.
[0032] After setting the threshold, pixel-by-pixel thresholding and candidate defect pixel labeling are performed on the cross-entropy map. Pixels with cross-entropy values higher than the global threshold are labeled as candidate defect pixels and assigned a foreground value of 1. Pixels with cross-entropy values lower than or equal to the global threshold are labeled as normal background pixels and assigned a background value of 0. A preliminary binary candidate defect mask map is generated, completing the core decision transformation from continuous anomaly scores to discrete binary judgment.
[0033] Next, connected component analysis and isolated noise removal are performed on the initially generated binary candidate defect mask image. Connected component analysis is an analysis method in digital image processing that aggregates spatially adjacent foreground pixels with the same value into independent connected regions. The 8-adjacency rule is adopted, that is, adjacent pixels in the top, bottom, left, right and four diagonal directions are considered connected. Each aggregated connected region corresponds to a potential defect region. Then, the pixel area of all candidate defect connected regions is calculated one by one, and isolated small regions with an area smaller than the preset minimum defect area are removed. The preset minimum defect area is the minimum detectable defect size set according to the defect control standard of OCA bonding process, which corresponds to the minimum defect specification acceptable to the production line. This operation can effectively filter isolated false detection points caused by image sensor noise and random gray-scale fluctuations in the cross-entropy image, and significantly reduce the false detection probability of the solution without losing the effective defect detection rate.
[0034] After noise removal, morphological closing operations are performed on the remaining valid defect connected regions. The morphological closing operation is a combination of morphological processing steps, which first dilates the image and then performs erosion at the same scale. The dilation operation can fill the small holes inside the defect connected regions and connect adjacent tiny fracture defects. The erosion operation can restore the dilated region to the original defect outer contour size. The overall closing operation can fill the holes inside the defect and smooth the defect edges without changing the overall position, size and contour boundary of the defect. This solves the mask breakage and hole problems caused by uneven gray levels inside the defect, making the output result more consistent with the actual physical contour of the real defect.
[0035] Finally, a standardized binary defect location mask is generated. This mask has the same size as the original OCA bonding area grayscale image. All pixels in the defect area are uniformly assigned a value of 1, and pixels in the normal background area are uniformly assigned a value of 0. This can accurately and completely mark the location, outline, size and spatial distribution of all defects in the OCA bonding area. If multiple sets of cross-entropy sub-images are generated using at least two windows of different sizes, and the final cross-entropy map is obtained by fusing the maximum value of each pixel, it can simultaneously cover OCA bonding defects of different scales, such as tiny dot bubbles, fine scratches and large-area bonding layering, warping, etc.
[0036] Furthermore, in the method provided in the application embodiment, the normal region candidate set in the original grayscale image is automatically filtered based on local texture flatness, and the global background joint grayscale distribution is estimated by bootstrapping based on the normal region candidate set, including: calculating the texture flatness index within the neighborhood window for each pixel of the original grayscale image; selecting pixels in the entire image whose texture flatness index is less than a preset flatness threshold based on the texture flatness index and aggregating adjacent pixels to construct the normal region candidate set; calculating the joint grayscale distribution of each window in the normal region candidate set, obtaining the initial global background distribution by aggregating the median of each histogram bin, and iteratively performing abnormal window removal and background distribution reestimation to generate the global background joint grayscale distribution.
[0037] Specifically, the texture flatness index is first calculated pixel-by-pixel within the neighborhood window of the original grayscale image. This texture flatness index is a core quantification metric used to measure the grayscale uniformity and texture smoothness of local image regions. A lower value indicates that the region closely matches the inherent characteristics of a normal OCA (Optical Color Accuracy) surface—no texture and low grayscale fluctuation. The neighborhood window is a fixed-size square pixel block centered on the target pixel. The window side length is typically an odd number between 9 and 31 pixels. For pixels at the image boundary that cannot completely cover the window, mirror filling or symmetrical filling is used to expand the edge region, ensuring that the calculation basis of boundary pixels is completely consistent with that of pixels inside the image, avoiding boundary calculation deviations. The specific process is as follows: For each pixel in the original grayscale image, the grayscale values of all pixels within its corresponding neighborhood window are extracted, and the local standard deviation is calculated. This local standard deviation is a measure of the dispersion of grayscale values within the window. The gradient value is calculated by multiplying the gradient values of all pixels within the window. A smaller gradient value indicates a more uniform grayscale within the window, which better matches the flatness of a normal background. The gradient magnitude of each pixel within the window is also calculated. This gradient magnitude represents the modulus of the rate of change of the pixel's grayscale value in both horizontal and vertical directions, accurately characterizing the edge strength and texture abruptness of a local area. A smaller gradient magnitude indicates the absence of obvious structural edges or texture jumps within the window, better matching the characteristics of a normal OCA (Optical Characteristic) area. The mean gradient magnitude of all pixels within the window is then calculated to obtain the local gradient magnitude mean. Subsequently, the obtained local standard deviation and the local gradient magnitude mean are normalized to the 0-1 range. This normalization process maps two indicators with different dimensions and value ranges to the same numerical range, eliminating the influence of dimensional differences on weight allocation. The two normalized indicators are then linearly added according to preset weights to obtain the texture flatness index corresponding to that pixel, completing the pixel-by-pixel calculation for the entire image.
[0038] Subsequently, based on the calculated texture flatness index, pixels with texture flatness indices less than a preset flatness threshold in the entire image are selected for neighboring pixel aggregation to construct a candidate set of normal regions. This preset flatness threshold is a critical judgment value pre-set based on the texture characteristics of the OCA (Optical Color Accuracy) normal fit region, used to distinguish between flat, normal regions that meet the requirements and potentially defective regions with texture abrupt changes. The candidate set of normal regions refers to a sample set composed of pixels selected from the original grayscale image that are highly likely to belong to a defect-free OCA-fit normal background and their corresponding neighborhood windows. It serves as the pure sample basis for subsequent estimation of the global background distribution, fundamentally avoiding the baseline deviation caused by defective regions mixing into the background modeling process. The specific process is as follows: complete the full image pixel... After calculating the texture flatness index, pixels with a texture flatness index less than the preset flatness threshold in the entire image are first selected. These pixels are located in areas with high flatness and low texture fluctuation, and are highly likely to be normal backgrounds. Then, adjacent pixel aggregation is performed on the selected qualified pixels. Adjacent pixel aggregation means merging spatially adjacent qualified pixels into continuous blocks, eliminating scattered and isolated qualified pixels, and avoiding statistical errors caused by isolated pixels. Finally, all pixels in the aggregated continuous area and their corresponding neighborhood windows are integrated to complete the automated construction of the normal region candidate set. The entire selection process is based entirely on the texture features of the image to be detected, without the need for pre-labeled samples or preset standard templates.
[0039] Finally, the joint grayscale distribution of each window in the normal region candidate set is calculated. An initial global background distribution is obtained by median aggregation of histogram bins. Abnormal window removal and background distribution reestimation are then iteratively performed to generate a global background joint grayscale distribution. This joint grayscale distribution represents the probability distribution of grayscale value combinations of pixel pairs within a region that satisfy a preset spatial adjacency relationship, typically 4 or 8 adjacent pixels. Histogram bins divide the range of grayscale values into several continuous intervals, typically 0-255, and are the basic unit for grayscale distribution statistics. Median aggregation takes the median of the probability values of all candidate windows corresponding to each histogram bin. Utilizing the robustness of the median's insensitivity to outliers, the interference of a small number of potentially defective windows mixed into the candidate set on the initial distribution is avoided. KL divergence, also known as relative entropy, is a core indicator for measuring the information difference between two probability distributions. A larger value indicates a greater difference between the two distributions, and a higher probability that the corresponding window is an abnormal or defective window. The specific process is as follows: First, all neighboring windows contained in the normal region candidate set are extracted, and the probability of each window pair being an abnormal or defective window is calculated. The corresponding joint grayscale distribution is obtained by counting the frequency of grayscale value combinations of pixel pairs that meet the preset spatial adjacency relationship within each window, and then dividing the frequency by the total number of pixel pairs that meet the requirements within the window to transform it into a standardized probability distribution. Subsequently, based on the joint grayscale distribution of all candidate windows, the median aggregation method of histogram bin-by-bin is adopted to take the median of the probability values of all windows corresponding to each bin to obtain the initial global background distribution. This ensures that the initial distribution is not affected by a small number of abnormal windows and has strong stability. After the initial distribution is constructed, the iterative optimization stage is immediately entered. First, the KL divergence between the joint grayscale distribution of all candidate windows and the current global background distribution is calculated. Abnormal windows with KL divergence greater than the preset divergence threshold are removed. Then, the arithmetic mean of the joint grayscale distribution of the remaining qualified windows is calculated for each histogram bin as the updated global background distribution. The above abnormal window removal and background distribution re-estimation operations are repeated until the change between the global background distributions obtained from two consecutive iterations is less than the preset convergence threshold. Finally, a stable and converged global background joint grayscale distribution is output.
[0040] Furthermore, in the method provided in the application embodiment, the joint grayscale distribution of each window in the normal region candidate set is calculated, and an initial global background distribution is obtained by median aggregation of histogram bins. Abnormal window removal and background distribution reestimation are then iteratively performed to generate the global background joint grayscale distribution. This includes: extracting multiple windows from the normal region candidate set and calculating the joint grayscale distribution of the multiple windows; obtaining the initial global background distribution based on the median aggregation of histogram bins based on the joint grayscale distribution of the multiple windows; calculating the KL divergence between the joint grayscale distribution of the multiple windows and the initial global background distribution; removing windows with KL divergence greater than a preset divergence threshold; using the joint grayscale distribution of the remaining windows, calculating the arithmetic mean of the histogram bins as the updated global background distribution; repeating this process until the change between the global background distributions of two consecutive iterations is less than a convergence threshold; and outputting the global background joint grayscale distribution.
[0041] Specifically, firstly, all valid neighborhood windows in the normal region candidate set are extracted, and the joint gray-level distribution of each window is calculated one by one. The normal region candidate set is a set of neighborhood windows corresponding to continuous regions aggregated by high-flatness pixels selected in the previous step. The windows are square windows with odd-numbered sizes between 9 and 31 pixels in side length. Mirror filling is used for image boundary windows to ensure calculation consistency. The windows in this set are likely to be defect-free OCA (Optical Characteristic Association) properly fitted to the background, and are the original pure sample pool for background modeling. The joint gray-level distribution is a two-dimensional probability distribution that is different from the traditional single-pixel gray-level histogram. It is used to characterize the pre-set spatial adjacency relationship within the window, that is, 4 adjacencies (top, bottom, left, and right adjacent) or 8 adjacencies (including diagonal directions). The probability of occurrence of gray value combinations of adjacent pixel pairs can simultaneously capture the gray value distribution characteristics of the region and the spatial correlation between adjacent pixels. This strong spatial correlation is precisely the characteristic of the normal OCA bonding surface. Defects such as bubbles, scratches, foreign objects, and bonding delamination will directly destroy this correlation. The specific process is as follows: For each effective neighborhood window, first traverse all pixel pairs that conform to the preset spatial adjacency rules within the window, record the two-dimensional gray value combination formed by the gray value of each pair of pixels, count the frequency of occurrence of all gray value combinations within the window, and then divide the frequency of each gray value combination by the total number of pixel pairs that conform to the rules within the window to convert it into a standardized probability value. Finally, the joint gray value distribution corresponding to each window is obtained, and the distribution calculation of all candidate windows is completed.
[0042] Subsequently, based on the joint grayscale distribution of all candidate windows, the initial global background distribution is obtained by median aggregation of histogram bins. Histogram bins are several consecutive equal-width intervals dividing the 0-255 grayscale value range commonly used in industrial images; they are the basic unit for grayscale distribution statistics. The bins of the two-dimensional joint grayscale distribution are the Cartesian product of two single-channel grayscale bins. Each bin corresponds to a unique combination of grayscale values and a corresponding probability value. Median aggregation refers to collecting the probability values of all candidate windows at each histogram bin of the joint grayscale distribution and taking the median as the probability value of the initial global background distribution at that bin. Choosing median aggregation instead of arithmetic mean utilizes the robustness of the median's insensitivity to outliers, avoiding interference from a small number of defective windows mixed in with the candidate set. Specifically, after traversing all histogram bins of the joint grayscale distribution and calculating and assigning the median for each bin, a complete initial global background distribution is generated.
[0043] The optimization process then proceeds iteratively, involving the removal of abnormal windows and reassessment of the background distribution, until the distribution converges. KL divergence, also known as relative entropy, is a core quantitative indicator measuring the information difference between two probability distributions. A larger value indicates a greater information distance between the two distributions, a greater difference between the window distribution and the normal background distribution, and a higher probability of it being a defective or abnormal window. The preset divergence threshold is a critical judgment value pre-set based on the normal grayscale fluctuation range of the OCA bonding process, used to distinguish between clean windows that conform to normal background characteristics and abnormally contaminated windows. The convergence threshold is a pre-set critical value used to determine whether the iteration is stable. When the change in background distribution is less than this value in two consecutive iterations, the distribution is considered to have converged to a stable state. The specific iteration is as follows: First, calculate the KL divergence between the joint grayscale distribution of all candidate windows and the current global background distribution, i.e., the initial global background distribution generated in the first iteration, to obtain the quantitative value of the distribution difference for each window. Then, remove all windows with KL divergence greater than the preset threshold. An anomaly window with a divergence threshold is set. Only pure windows with KL divergence less than or equal to the threshold and that fully conform to the statistical characteristics of normal background are retained. Then, the arithmetic mean of the joint gray-scale distribution of the remaining pure windows is calculated for each histogram bin. The mean of each bin is used as the updated global background distribution. The arithmetic mean is chosen here because after the initial median aggregation and the first round of anomaly removal, the remaining windows are high-purity normal background samples. The arithmetic mean can more accurately fit the true statistical characteristics of the normal OCA fit surface. Then, the change between the updated global background distribution and the global background distribution of the previous iteration is calculated. The change is quantified by the KL divergence of the two distributions or the difference in the probability of the maximum bin. If the change is greater than the preset convergence threshold, the process of KL divergence calculation-anomaly window removal-background distribution re-estimation is repeated until the change between the global background distributions of two consecutive iterations is less than the convergence threshold. Finally, a stable and converged distribution is output as the global background joint gray-scale distribution.
[0044] Furthermore, in the method provided in the application embodiment, calculating the texture flatness index within the neighborhood window for each pixel of the original grayscale image includes: for each pixel in the original grayscale image, calculating the standard deviation of the grayscale values of all pixels within the neighborhood window, and simultaneously calculating the gradient magnitude of each pixel within the window and taking the mean, to obtain the local standard deviation and the mean of the local gradient magnitude; after normalizing the local standard deviation and the mean of the local gradient magnitude respectively, adding them together according to a preset weight to obtain the texture flatness index of each pixel.
[0045] Specifically, for each pixel to be calculated in the original grayscale image, a neighborhood window with that pixel as its geometric center is first defined. This neighborhood window is a fixed-size square pixel block used to statistically analyze local texture and grayscale features. The side length of the window is uniformly selected as an odd number between 9 and 31 pixels. Choosing an odd side length is to ensure that the pixel to be calculated is strictly in the center of the window. At the same time, for pixels at the image boundary, since their center window will exceed the effective pixel range of the original image, a mirror filling or symmetrical filling method is used to expand the edge region. Mirror filling refers to symmetrically copying the pixels inside the boundary to the outer blank area with the image boundary as the axis of symmetry. Compared with zero-value filling, constant filling, and other methods.
[0046] Two core statistics were calculated simultaneously. The first was the calculation of the local standard deviation. The local standard deviation is a core statistical indicator that quantifies the dispersion of grayscale values of all pixels within a neighborhood window. The smaller the value, the smaller the fluctuation range of grayscale values within the window, the more uniform the grayscale in the region, and the more it conforms to the flat characteristics of a defect-free area in a normal OCA bonding surface. The specific calculation process involves extracting the grayscale values of all pixels within the current neighborhood window, calculating the standard deviation of this set of grayscale values, and obtaining the local standard deviation corresponding to the central pixel. The second was the calculation of the mean local gradient magnitude. Gradient magnitude is the magnitude of the rate of change of pixel grayscale values in both the horizontal and vertical directions. It can be calculated using the classic Sobel or Prewitt operator. The calculation formula is as follows: ; This value characterizes the edge strength and texture abruptness of a local region in an image. The larger the value, the more obvious the gray-level jump, structural edge, or texture fluctuation at that location, and the greater the probability of OCA bonding defects such as scratches, bubbles, foreign objects, or bonding delamination. In contrast, in a flat region of normal OCA bonding, the gray-level changes between adjacent pixels are minimal, and the gradient magnitude approaches 0. The local gradient magnitude mean is the arithmetic mean of the gradient magnitudes of all pixels within the neighborhood window, used to quantify the overall texture abruptness within the entire window. The smaller the value, the less obvious the edges and texture jumps within the window, and the more consistent it is with the flat characteristics of a normal bonding background. The specific calculation process is as follows: first, calculate the horizontal gray-level gradient Gx and the vertical gray-level gradient Gy of each pixel within the neighborhood window, solve the gradient magnitude pixel by pixel, and then calculate the arithmetic mean of the gradient magnitudes of all pixels within the window to obtain the local gradient magnitude mean corresponding to the central pixel.
[0047] Subsequently, the local standard deviation and mean local gradient magnitude of all pixels in the entire image are normalized. This normalization uses min-max normalization, which linearly maps the two indicators—local standard deviation and mean local gradient magnitude—which have completely different dimensions and ranges, to a unified numerical range of 0-1. This eliminates the influence of dimensional differences on subsequent weight allocation. Specifically, the local standard deviation of all pixels in the entire image is calculated using the formula: Normalized local standard deviation = (local standard deviation of current pixel - minimum local standard deviation of the whole image) / (maximum local standard deviation of the whole image - minimum local standard deviation of the whole image); After mapping, the mean local gradient magnitude of all pixels in the entire image is mapped to the 0-1 interval using the same minimum-maximum normalization method, resulting in the normalized mean local gradient magnitude. Finally, the normalized local standard deviation and the normalized mean local gradient magnitude for each pixel are linearly added according to preset weights to obtain the texture flatness index for each pixel. The texture flatness index is a composite quantitative index that combines local gray-level uniformity and the degree of local texture abruptness. The lower the value, the more uniform the gray level of the local area where the pixel is located, the less obvious the texture edge, and the higher the probability that it belongs to the OCA normal background. The higher the value, the greater the gray-level fluctuation of the area, the more obvious the texture abruptness, and the higher the probability that it belongs to the defect area. The specific calculation formula is as follows: Texture flatness index = α × normalized local standard deviation + β × normalized local gradient magnitude mean; α and β are pre-set weighting coefficients that satisfy α+β=1. They can be flexibly adjusted according to the process characteristics and testing requirements of OCA bonding products. For example, for products with slight uniform grayscale fluctuations in the adhesive layer itself, the weight of β can be appropriately increased to enhance the ability to identify edge defects. For high-precision bonding products with extremely high requirements for grayscale uniformity, the weight of α can be appropriately increased to enhance the ability to capture small grayscale discrete defects. Finally, the texture flatness index of all pixels in the original grayscale image is calculated pixel by pixel.
[0048] Furthermore, in the method provided in the application embodiment, for each pixel position in the original grayscale image, the empirical joint grayscale distribution of the local neighborhood window is extracted, including: delineating a square window with an odd number of pixels as the center of each pixel in the original grayscale image; for all pixel pairs in the square window that satisfy a preset spatial adjacency relationship, obtaining the grayscale value combination of each pixel pair, counting the frequency of all grayscale value combinations, dividing by the total number of pixel pairs in the window, to obtain the empirical joint grayscale distribution.
[0049] Specifically, firstly, a square local neighborhood window with an odd number of pixels on each pixel to be calculated in the original grayscale image is delineated as the geometric center. The local neighborhood window is a square pixel block of a fixed size that is delineated around the target pixel and is used to statistically analyze the local grayscale space features. The reason for choosing an odd number of pixels on each side is to ensure that the target pixel to be calculated is strictly located at the geometric center of the window. The side length of the window is usually an odd number between 9 and 31 pixels, which can be flexibly adjusted according to the minimum detection size of OCA bonding defects. At the same time, for pixels at the image boundary, since the central window will exceed the effective pixel range of the original image, a mirror filling or symmetrical filling method is used to expand the edge region. Mirror filling refers to symmetrically copying the pixels inside the boundary to the outer blank area with the image boundary as the axis of symmetry.
[0050] Subsequently, statistics are performed on all pixel pairs within each square window that satisfy the preset spatial adjacency relationship. The preset spatial adjacency relationship is a predefined pixel spatial pairing rule used to construct the joint grayscale distribution. It usually adopts the 4-adjacency rule, which only pairs adjacent pixels in the four positive directions of up, down, left, and right, or the 8-adjacency rule, which includes adjacent pixels in the four diagonal directions of up, down, left, right, and right. The purpose of this rule is to capture the strong grayscale spatial correlation naturally present in adjacent pixels in the OCA normal bonding background. That is, the adhesive layer thickness in the OCA normal bonding area is uniform, without impurities, bubbles, and structural defects, and the grayscale values of adjacent pixels have a very strong linkage. However, various OCA bonding defects such as bubbles, scratches, foreign objects, and bonding delamination will directly destroy this grayscale correlation characteristic of adjacent pixels.
[0051] Subsequently, the grayscale value combinations of each pixel pair that meets the pairing rules within the window are obtained one by one. A grayscale value combination refers to a two-dimensional numerical pair formed by the grayscale values of two pixels in a pixel pair that conforms to a preset spatial adjacency relationship. For 8-bit grayscale images commonly used in industrial inspection, the grayscale value range of each pixel is 0-255. Therefore, the total number of grayscale value combinations is 256 × 256, and each combination corresponds to a unique two-dimensional grayscale state. The total frequency of all grayscale value combinations appearing within the current window is then counted, i.e., the number of times each grayscale value combination appears in a pixel pair that conforms to the rules within the window. Finally, the frequency of each grayscale value combination is divided by the number of pixels in the window that conform to the preset spatial adjacency relationship. The total number of pixel pairs gives the probability of a gray value combination appearing in the current window. The probabilities corresponding to all gray value combinations together constitute the empirical joint gray value distribution corresponding to the center pixel of the window. The empirical joint gray value distribution is a two-dimensional discrete probability distribution obtained by frequency statistics based entirely on the actual pixel observation data in the current local window. It does not have any additional prior assumptions or model fitting, and can completely and faithfully capture the gray space correlation characteristics of adjacent pixels in the current local area. It forms a direct comparison benchmark with the global background joint gray value distribution that normally fits the intrinsic statistical characteristics of the background. The degree of difference between the two directly corresponds to the degree of anomaly of the current pixel position.
[0052] Furthermore, in the method provided in the application embodiment, the minimum information projection distribution of the empirical joint gray-level distribution onto the global background joint gray-level distribution under the constraint of the exponential family is calculated, and the cross-entropy between the global background joint gray-level distribution and the minimum information projection distribution is calculated to obtain a cross-entropy map. This includes: for the empirical joint gray-level distribution of each local window, extracting the first-order gray-level mean, second-order gray-level variance, and gray-level covariance of adjacent pixels as window statistical features; using the global background joint gray-level distribution as a reference distribution, under the constraint of keeping the window statistical features unchanged, finding the exponential family distribution with the smallest KL divergence with the reference distribution through an iterative proportional fitting algorithm as the minimum information projection distribution; calculating the product of the logarithm of the empirical joint gray-level distribution and the projection distribution probability in the minimum information projection distribution for gray-level combination, accumulating and taking the negative value to obtain the cross-entropy, and traversing all local windows to form the cross-entropy map.
[0053] Specifically, firstly, for the empirical joint grayscale distribution of the corresponding local neighborhood window generated for each pixel in the previous steps—that is, the two-dimensional discrete probability distribution representing the probability of grayscale combinations of pixel pairs conforming to the preset spatial adjacency relationship within the window, which is obtained entirely from the statistical data of actual pixel observations of the current local window—the first-order grayscale mean, second-order grayscale variance, and grayscale covariance of adjacent pixels are extracted as window statistical features. The first-order grayscale mean is the arithmetic mean of the grayscale values of all pixels within the window, used to represent the overall brightness level of the window, which can offset interference from normal process fluctuations such as unavoidable uneven lighting on the production line and overall grayscale drift caused by slight workpiece tilt. The second-order grayscale variance is the grayscale value of all pixels within the window relative to the mean. The degree of dispersion of the value is used to characterize the overall fluctuation range of gray level within the window. It can adapt to the overall gray level dispersion changes caused by the uniform thickness deviation of the OCA adhesive layer itself and the difference in light transmittance between batches. The gray level covariance of adjacent pixels is the core feature that characterizes the degree of linear correlation between gray levels of pixel pairs that meet the preset adjacent relationship within the window. The gray levels of adjacent pixels in the normal OCA bonding area have a very strong positive correlation. However, various defects such as bubbles, scratches, foreign objects, and bonding delamination will directly destroy this spatial correlation. Therefore, this covariance is the core underlying basis for distinguishing normal background and defective areas. At the same time, these three features together constitute a sufficient statistic for the exponential family distribution. All the information of the corresponding exponential family distribution can be completely characterized by these three low-dimensional features alone. Subsequently, the global background joint grayscale distribution obtained from the pre-bootstrap estimation, i.e., the baseline two-dimensional probability distribution characterizing the intrinsic grayscale spatial correlation characteristics of the normal OCA bonding surface, is used as the reference distribution. Under the constraint of strictly maintaining the previously extracted window statistical features, an iterative proportional fitting algorithm is used to find the exponential family distribution with the smallest KL divergence to the reference distribution, which is then used as the minimum information projection distribution. The exponential family constraint means that the target distribution to be solved must belong to a set of probability distributions with a unified exponential expression and sufficient statistical properties. Introducing this constraint can filter out invalid interference caused by random noise and normal grayscale fluctuations within the local window, while locking in the distribution structure anomalies caused by defects, thereby reducing the probability of false detection from the root. KL divergence, also known as relative entropy, is a core quantitative indicator for measuring the information difference between two probability distributions. The smaller the value, the closer the information distance between the two distributions and the higher the similarity. The essence of the minimum information projection distribution is that the current local window "conforms to the normal OCA bonding background". Under the premise of "statistical regularity and maintaining its own core statistical characteristics", the theoretical distribution that best fits the normal background is the one whose difference from the original empirical joint gray-scale distribution comes entirely from the structural anomaly caused by the defect, which cannot be explained by the statistical characteristics of the normal background. The iterative proportional fitting algorithm is an efficient iterative algorithm for solving the minimum divergence probability distribution with multi-dimensional marginal constraints. Its specific solution is as follows: First, initialize the projection distribution as the global background joint gray-scale distribution. Then, iterate through each statistical feature constraint of the current local window in turn. Adjust the probability value of the projection distribution by gray-scale combination through scaling factor so that the adjusted distribution strictly meets the current statistical feature constraint. At the same time, ensure that the adjusted distribution maintains the minimum KL divergence with the distribution of the previous iteration. Repeat the iteration of all constraints to complete multiple rounds of iteration until the convergence condition is met, that is, the maximum probability change of the projection distribution in two consecutive rounds of iteration is less than the preset probability change threshold. Finally, output the converged distribution as the minimum information projection distribution corresponding to the local window.
[0054] Next, cross-entropy calculation and cross-entropy map generation are performed. First, let's explain cross-entropy. It's a core quantitative indicator that measures the degree of difference between two probability distributions. Physically, it represents the average information uncertainty when using a reference distribution to describe the target distribution. The greater the structural difference between the two distributions, the higher the cross-entropy value. The cross-entropy value directly corresponds to the degree of anomaly of the center pixel of the window. A higher value indicates a greater difference between that location and the normal OCA background, and a higher probability that it belongs to a defective area. Specifically, for each local window, the empirical joint grayscale distribution and the minimum information projection distribution are combined grayscale values one by one to calculate the corresponding value of the empirical joint grayscale distribution. The product of the logarithm of the probability and the projection distribution probability of the corresponding gray-level combination in the minimum information projection distribution is summed and the negative value is taken to obtain the cross-entropy value corresponding to the center pixel of the window. Then, all pixel positions of the original gray-level image are traversed to complete the cross-entropy calculation of all pixels in the image, forming a cross-entropy map with the same size as the original gray-level image. If the previous steps used at least two neighborhood windows of different sizes to extract multiple sets of empirical joint gray-level distributions, multiple cross-entropy sub-maps can be generated. Then, the maximum value is taken pixel by pixel to merge them into the final cross-entropy map, so as to take into account the detection sensitivity of defects of different sizes.
[0055] Furthermore, in the method provided in the application embodiment, the exponential family distribution with the smallest KL divergence with the reference distribution is found by an iterative proportional fitting algorithm as the minimum information projection distribution. This includes: initializing the projection distribution as the global background joint grayscale distribution; sequentially traversing each statistical feature constraint of each local window, adjusting the projection distribution to satisfy each statistical feature constraint, and simultaneously maintaining the minimum KL divergence between the adjusted projection distribution and the previous round distribution; wherein, in each round of adjustment, the probability value of each grayscale combination in the projection distribution is updated by a scaling factor until the projection distribution converges, and the output is used as the minimum information projection distribution. The convergence condition is that the maximum probability change of the projection distribution in two consecutive iterations is less than a preset threshold probability change threshold.
[0056] Specifically, the projection distribution is first initialized by initializing it to the global background joint grayscale distribution generated in the previous step. The projection distribution is the target probability distribution to be solved in this iteration. The global background joint grayscale distribution is a benchmark two-dimensional probability distribution that is estimated by bootstrapping the candidate set of normal regions and characterizes the grayscale spatial correlation characteristics of adjacent pixels on the normal OCA bonding surface. It is the statistical benchmark for determining normal and abnormal.
[0057] After initialization, iterative optimization with constraints is then performed using an iterative proportional fitting algorithm. This algorithm ensures that each adjustment minimizes the KL divergence between the distribution and the reference distribution while satisfying preset statistical constraints. It also achieves the dual objectives of maintaining the window's statistical features and minimizing the difference from the normal background distribution. Specifically, it iterates through each statistical feature constraint of the current local window. These constraints are the three sufficient statistics extracted previously: the first-order gray-level mean, the second-order gray-level variance, and the gray-level covariance of adjacent pixels. These three features together constitute the complete marginal constraints of the exponential family distribution. Keeping them constant filters out distribution changes caused by unavoidable uneven lighting, deviations in the overall uniformity of adhesive layer thickness, and slight workpiece tilting—normal process fluctuations that are unavoidable on the production line. These normal fluctuations only change the overall statistical features of the window and do not disrupt the gray-level spatial correlation structure of the normal OCA bonding surface. Defects such as bubbles, scratches, foreign objects, and bonding delamination, however, will cause abnormal distribution structures that cannot be explained by the three constraints. This achieves a balance between normal fluctuations and true... To decouple the real-world defects, during the traversal of each constraint, the projected distribution is synchronously adjusted to strictly satisfy the statistical feature constraints of the current traversal, while ensuring that the adjusted projected distribution maintains the minimum KL divergence with the distribution of the previous iteration. KL divergence, also known as relative entropy, is a core quantitative indicator that measures the information difference between two probability distributions. The smaller the value, the higher the similarity between the two distributions. Each round of constraint adjustment updates the projected distribution through a scaling factor. The scaling factor is a proportional coefficient generated based on the ratio of the statistical calculation value of the current projected distribution to the target constraint value. The gray-level combination is the basic statistical unit of the joint gray-level distribution, that is, a two-dimensional numerical pair consisting of two gray-level values of pixel pairs that meet the preset spatial adjacency relationship within the window. Each gray-level combination corresponds to a probability value in the projected distribution. During adjustment, the probability value of each gray-level combination in the projected distribution is updated proportionally one by one through the scaling factor, so that the updated projected distribution fully satisfies the current statistical feature constraints. At the same time, this proportional update method naturally ensures that the KL divergence of the distribution before and after adjustment is minimized, without introducing additional statistical bias.
[0058] After completing one round of fully constrained traversal adjustment, the projected distribution updated in this iteration is obtained. Then, a convergence test is performed. The convergence condition is that the maximum probability change of the projected distribution in two consecutive iterations is less than a preset probability change threshold. The maximum probability change refers to the maximum absolute difference between the probability values of all gray-level combinations in the projected distribution of this iteration and the corresponding probability values in the previous iteration. The preset probability change threshold is a minimum value pre-set according to the detection accuracy requirements of OCA bonding defects, usually in the range of 1e-6 to 1e-8. When this convergence condition is met, it means that the projected distribution has converged stably and no longer undergoes statistically significant changes. The distribution at this time is the exponential family distribution with the smallest KL divergence between the joint gray-level distribution and the global background gray-level distribution, which is the target minimum information projection distribution, under the constraint of keeping the window statistical characteristics unchanged.
[0059] Furthermore, in the method provided in the application embodiment, threshold segmentation is performed on the cross-entropy map to output a defect location mask, including: calculating the global mean and global standard deviation of the cross-entropy of the entire image for the cross-entropy map, setting the global threshold as the global mean plus the product of a preset sensitivity coefficient and the global standard deviation; based on the cross-entropy map, marking pixels with cross-entropy higher than the global threshold as candidate defect pixels; performing connected component analysis on the candidate defect pixels, removing isolated small regions with an area smaller than a preset minimum defect area, performing morphological closing operations on the retained connected components to fill holes, and generating the defect location mask.
[0060] Specifically, firstly, full-image statistical characteristics are calculated on the input cross-entropy map. The global mean and global standard deviation of the cross-entropy values for all pixels in the entire image are calculated. The global mean is the arithmetic mean of the cross-entropy values, representing the overall background anomaly baseline of the entire image under test, reflecting the overall grayscale fluctuation and process characteristics of the OCA bonding surface. The global standard deviation is the dispersion of the cross-entropy values relative to the global mean, representing the overall fluctuation amplitude of the anomaly scores within the image, and can quantitatively distinguish between random fluctuations in normal backgrounds and significant anomalies caused by real defects. Then, according to the formula... Global threshold = global mean + preset sensitivity coefficient × global standard deviation; The adaptive setting of the segmentation threshold is completed. The preset sensitivity coefficient is an adjustable parameter pre-set based on the detection accuracy requirements of the OCA bonding process and the acceptable balance between false detections and missed detections on the production line. The larger the coefficient, the higher the global threshold and the stricter the detection judgment. It can filter out more false detections caused by background noise and thermal noise of the image sensor, but there is a risk of missing low-contrast micro-defects. The smaller the coefficient, the lower the global threshold and the higher the detection sensitivity for low-contrast and micron-level micro-defects, but it may introduce more false detections caused by random background fluctuations. It can be flexibly adjusted according to the yield control standards and product specifications of the production line. This adaptive threshold setting method is generated entirely based on the statistical characteristics of a single image to be detected. There is no need to manually preset a fixed threshold. It can adaptively match the cross-entropy baseline offset caused by unavoidable lighting fluctuations, batch characteristics differences of adhesive layers, and slight changes in the posture of the workpiece on the production line.
[0061] Then, pixel-by-pixel thresholding and candidate defect pixel labeling are performed on the cross-entropy map. Each pixel position of the cross-entropy map is traversed, and pixels with cross-entropy values higher than the global threshold are labeled as candidate defect pixels and assigned a foreground value of 1. Pixels with cross-entropy values lower than or equal to the global threshold are labeled as normal background pixels and assigned a background value of 0. A preliminary binary candidate defect mask map is generated, completing the core decision transformation from continuous anomaly scores to discrete binary judgments. All previous statistical modeling and anomaly quantification results are transformed into intuitive defect / background binary classification results.
[0062] Next, connected component analysis and isolated noise removal are performed on the initially generated binary candidate defect mask image. Connected component analysis, in digital image processing, is an analysis method that aggregates spatially adjacent foreground pixels with the same values into independent connected regions. It adopts the 8-adjacency rule matching the previous joint gray-level distribution statistics, that is, adjacent pixels in the four positive directions (up, down, left, right) and four diagonal directions of a pixel are considered spatially connected. Each aggregated independent connected region corresponds to a potential defect region, which can accurately distinguish different defect individuals. After completing the connected component aggregation, the pixel area of all candidate defect connected regions is calculated one by one, and isolated small regions with an area smaller than the preset minimum defect area are removed. The preset minimum defect area is the minimum detectable defect size set according to the defect control standards and product yield requirements of the OCA bonding process, which corresponds to the minimum defect specification acceptable to the production line. This operation can effectively filter isolated false detection points caused by image sensor noise and random gray-level fluctuations in the cross-entropy image, and significantly reduce the false detection probability of the solution without losing the effective defect detection rate, thus balancing detection sensitivity and production line operating efficiency.
[0063] Subsequently, morphological closing operations are performed on the retained effective defect connected regions for optimization. The morphological closing operation is a combined morphological processing flow that first performs dilation on the image and then performs isoscale erosion. The first dilation operation fills in the small holes inside the defect connected regions and connects adjacent micro-fracture defects, solving the mask breakage and internal hole problems caused by uneven gray levels and fluctuations in local cross-entropy values within the defects. The subsequent isoscale erosion operation restores the dilated region to the original defect outer contour size, ensuring that the position, overall size and contour boundary of the defect do not shift. The overall closing operation fills in the holes inside the defect and smooths the defect edges without changing the core geometric features of the defect, making the output mask result more consistent with the actual physical contour of the real defect. Finally, after all optimization processing is completed, a standardized binary defect location mask is generated. This mask has the same gray level image size as the original OCA bonding area. All pixels in the defect area are uniformly assigned a value of 1, and pixels in the normal background area are uniformly assigned a value of 0, which can accurately and completely mark the position, contour, size and spatial distribution of all defects within the OCA bonding area.
[0064] Furthermore, in the method provided in the application embodiment, obtaining the cross-entropy map further includes: repeatedly performing empirical joint grayscale distribution and cross-entropy acquisition with at least two windows of different sizes to obtain multiple cross-entropy sub-maps; and fusing the multiple cross-entropy sub-maps into the cross-entropy map by the pixel-wise maximum value.
[0065] Specifically, the process begins with setting up multi-scale neighborhood windows and generating parallel cross-entropy subgraphs. At least two neighborhood windows of different sizes are selected. A neighborhood window is a square pixel block defined around the target pixel in the original grayscale image, used to statistically analyze the grayscale correlation characteristics of adjacent pixels in a local area. The window side length is uniformly selected as an odd number of pixels to ensure the target pixel is strictly at the geometric center of the window, avoiding spatial statistical bias. Different window sizes correspond to different spatial statistical scales. Small windows are highly sensitive to minor local grayscale correlation anomalies, while large windows can capture large-scale, low-gradient spatial distribution anomalies. Window sizes covering small, medium, and large gradients are selected, including a 9-15 pixel small window suitable for micron-level microbubbles, fine scratches, and point-like foreign objects; a 17-23 pixel medium window suitable for medium-sized scratches and adhesive layer wrinkles; and a 25-31 pixel large window suitable for large-area bonding delamination, warping, and uneven adhesive layer thickness. For each selected window size, calculations are performed: a square window of the corresponding size is defined centered on each pixel in the original grayscale image, and calculations are performed on the image edges. To ensure computational consistency, pixels at the boundary are expanded using a mirror-fill method. Statistical results of grayscale combinations of pixel pairs within the window that conform to a preset spatial adjacency relationship are extracted to generate the empirical joint grayscale distribution for the corresponding window. Then, the minimum information projection distribution of this empirical joint grayscale distribution onto the global background joint grayscale distribution under exponential family constraints is calculated. Finally, pixel-by-pixel cross-entropy calculation is completed, generating a cross-entropy sub-map that corresponds to the window size and is completely consistent with the original grayscale image size. The cross-entropy sub-map is a pixel-level anomaly score map generated at a single window scale. The value of each pixel in the map corresponds to the degree of difference between the local distribution of the target location and the normal background distribution at the corresponding spatial scale. Cross-entropy sub-maps of different sizes show significant differences in anomaly response sensitivity to defects of different scales. The small window sub-map has the highest response peak for small defects, while the large window sub-map captures the anomaly signal of large-area low-contrast defects most completely. All cross-entropy sub-maps maintain the same pixel size and spatial coordinates as the original image, ensuring that the same pixel position in different sub-maps strictly corresponds to the same physical position in the original image.
[0066] Subsequently, multi-scale sub-image fusion is performed. The cross-entropy sub-images generated by all different window sizes are fused using a pixel-by-pixel maximum value fusion method to generate the final cross-entropy map. Pixel-by-pixel maximum value fusion means that for the same pixel coordinate position in the original grayscale image, the cross-entropy values of all cross-entropy sub-images at that position are extracted, and the maximum value is taken as the pixel value of the final cross-entropy map at that position. This fusion method is based on the fact that for a defect of a specific size, only a window that matches its spatial scale can generate the highest abnormal response, i.e., the maximum cross-entropy value. Small defects show the highest abnormal score in small window sub-images, and large-area defects show the highest abnormal score in large window sub-images. Taking the maximum value ensures that the highest abnormal signal is retained in the final cross-entropy map regardless of the defect size, and the defect signal will not be diluted or missed due to window size mismatch. For normal background areas that fit the OCA, the cross-entropy values of windows of different scales are at a low baseline level, and taking the maximum value will not introduce additional false detection risks.
[0067] In summary, the visual recognition-based OCA bonding defect detection method provided in this application has the following technical effects: By acquiring the original grayscale image of the OCA bonding area, the system automatically filters the candidate set of normal regions based on local texture flatness and estimates the global background joint grayscale distribution through bootstrapping. Then, it extracts the empirical joint grayscale distribution of local neighborhood windows pixel by pixel. Through solving the minimum information projection distribution under exponential family constraints and calculating cross-entropy, it generates a cross-entropy map representing pixel-level anomalies. Finally, through adaptive threshold segmentation and morphological optimization, it outputs an accurate defect location mask. Without the need for pre-labeling defect samples and preset standard templates, unsupervised background modeling and defect detection can be completed based on only a single image to be detected. This can effectively filter out detection interference caused by various normal process fluctuations on the production line, and ultimately achieve high-precision and high-stability automated detection of all types of OCA bonding defects, improving the defect detection rate of the OCA bonding process and the adaptability of the detection scheme.
[0068] Example 2, based on the same inventive concept as the visual recognition-based OCA bonding defect detection method in the foregoing examples, such as... Figure 2 As shown in the figure, this application provides a vision-based OCA bonding defect detection system, which includes: The acquisition module 11 is used to acquire the original grayscale image of the OCA bonding area; the filtering module 12 is used to automatically filter the candidate set of normal regions in the original grayscale image based on the local texture flatness, and estimate the global background joint grayscale distribution based on the candidate set of normal regions; the extraction module 13 is used to extract the empirical joint grayscale distribution of the local neighborhood window for each pixel position in the original grayscale image; the calculation module 14 is used to calculate the minimum information projection distribution of the empirical joint grayscale distribution onto the global background joint grayscale distribution under the exponential family constraint, and calculate the cross-entropy between the global background joint grayscale distribution and the minimum information projection distribution to obtain a cross-entropy map; the segmentation module 15 is used to perform threshold segmentation on the cross-entropy map and output a defect location mask.
[0069] Furthermore, the filtering module 12 is also used to perform the following steps: calculate the texture flatness index within the neighborhood window for each pixel of the original grayscale image; select pixels in the entire image whose texture flatness index is less than a preset flatness threshold based on the texture flatness index and perform pixel aggregation at adjacent positions to construct the normal region candidate set; calculate the joint grayscale distribution of each window in the normal region candidate set, obtain the initial global background distribution by aggregating the median of each histogram bin, and iteratively perform abnormal window removal and background distribution reestimation to generate the global background joint grayscale distribution.
[0070] Furthermore, the filtering module 12 is also used to perform the following steps: extracting multiple windows from the candidate set of the normal region, and calculating the joint gray-scale distribution of the multiple windows; based on the joint gray-scale distribution of the multiple windows, aggregating the median of each histogram bin to obtain the initial global background distribution; calculating the KL divergence between the joint gray-scale distribution of the multiple windows and the initial global background distribution, removing windows with KL divergence greater than a preset divergence threshold, using the joint gray-scale distribution of the remaining windows, calculating the arithmetic mean of each histogram bin as the updated global background distribution, repeating until the change between the global background distributions of two consecutive iterations is less than the convergence threshold, and outputting the joint gray-scale distribution of the global background.
[0071] Furthermore, the filtering module 12 is also used to perform the following steps: for each pixel in the original grayscale image, calculate the standard deviation of the grayscale values of all pixels in the neighborhood window, and at the same time calculate the gradient magnitude of each pixel in the window and calculate the mean to obtain the local standard deviation and the mean of the local gradient magnitude; after normalizing the local standard deviation and the mean of the local gradient magnitude respectively, add them together according to the preset weight to obtain the texture flatness index of each pixel.
[0072] Furthermore, the extraction module 13 is also used to perform the following steps: taking each pixel in the original grayscale image as the center, delineating a square window with a side length of an odd number of pixels; for all pixel pairs in the square window that satisfy a preset spatial adjacency relationship, obtaining the grayscale value combination of each pixel pair, counting the frequency of all grayscale value combinations, dividing by the total number of pixel pairs in the window, to obtain the empirical joint grayscale distribution.
[0073] Furthermore, the calculation module 14 is also used to perform the following steps: for the empirical joint gray-level distribution of each local window, extract the first-order gray-level mean, second-order gray-level variance, and gray-level covariance of adjacent pixels as window statistical features; taking the global background joint gray-level distribution as a reference distribution, under the constraint of keeping the window statistical features unchanged, find the exponential family distribution with the smallest KL divergence with the reference distribution through an iterative proportional fitting algorithm, as the minimum information projection distribution; calculate the product of the logarithm of the empirical joint gray-level distribution and the projection distribution probability in the minimum information projection distribution by combining gray levels one by one, accumulate and take the negative value to obtain the cross-entropy, and traverse all local windows to form the cross-entropy map.
[0074] Furthermore, the calculation module 14 is also used to perform the following steps: initialize the projection distribution as the global background joint grayscale distribution; sequentially traverse each statistical feature constraint of each local window, adjust the projection distribution to satisfy each statistical feature constraint, and synchronously maintain the minimum KL divergence between the adjusted projection distribution and the previous round distribution; wherein, in each round of adjustment, the probability value of each grayscale combination in the projection distribution is updated by a scaling factor until the projection distribution converges, and the output is used as the minimum information projection distribution, and the convergence condition is that the maximum probability change of the projection distribution in two consecutive rounds of iteration is less than a preset threshold probability change threshold.
[0075] Furthermore, the segmentation module 15 is also used to perform the following steps: calculate the global mean and global standard deviation of the cross-entropy of the entire image for the cross-entropy map, and set the global threshold as the global mean plus the product of the preset sensitivity coefficient and the global standard deviation; based on the cross-entropy map, mark pixels with cross-entropy higher than the global threshold as candidate defect pixels; perform connected component analysis on the candidate defect pixels, remove isolated small regions with an area smaller than the preset minimum defect area, perform morphological closing operation on the retained connected components to fill holes, and generate the defect location mask.
[0076] Furthermore, the calculation module 14 is also used to perform the following steps: repeatedly perform empirical joint grayscale distribution and cross-entropy acquisition with at least two windows of different sizes to obtain multiple cross-entropy sub-images; and fuse the multiple cross-entropy sub-images into the cross-entropy map by the pixel-wise maximum value.
[0077] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A visual recognition-based method for detecting OCA bonding defects, characterized in that, include: Acquire the original grayscale image of the OCA bonding area; The normal region candidate set in the original grayscale image is automatically filtered based on local texture flatness, and the global background joint grayscale distribution is estimated by bootstrapping based on the normal region candidate set. For each pixel location in the original grayscale image, extract the empirical joint grayscale distribution of the local neighborhood window; Calculate the minimum information projection distribution of the empirical joint gray-level distribution onto the global background joint gray-level distribution under the exponential family constraints, and calculate the cross-entropy between the global background joint gray-level distribution and the minimum information projection distribution to obtain a cross-entropy map; The cross-entropy map is thresholded to output a defect location mask.
2. The visual recognition-based OCA bonding defect detection method as described in claim 1, characterized in that, Automatically filter candidate sets of normal regions in the original grayscale image based on local texture flatness, and estimate the global background joint grayscale distribution based on the candidate sets of normal regions, including: Calculate the texture flatness index within the neighborhood window pixel by pixel for the original grayscale image; Based on the texture flatness index, pixels with texture flatness indices less than a preset flatness threshold in the entire image are selected and their adjacent pixels are aggregated to construct the normal region candidate set. The joint grayscale distribution of each window in the candidate set of normal regions is calculated. The initial global background distribution is obtained by aggregating the median of each histogram bin. Abnormal window removal and background distribution re-estimation are then performed iteratively to generate the global background joint grayscale distribution.
3. The visual recognition-based OCA bonding defect detection method as described in claim 2, characterized in that, Calculate the joint grayscale distribution of each window in the candidate set of normal regions, obtain the initial global background distribution by aggregating the median of each histogram bin, and iteratively perform abnormal window removal and background distribution reestimation to generate the global background joint grayscale distribution, including: Extract multiple windows from the candidate set of the normal region and calculate the joint grayscale distribution of the multiple windows; The initial global background distribution is obtained by aggregating the median of each histogram bin level based on the joint grayscale distribution of the multiple windows. Calculate the KL divergence between the joint grayscale distribution of the multiple windows and the initial global background distribution. Remove windows whose KL divergence is greater than a preset divergence threshold. Calculate the arithmetic mean of the joint grayscale distribution of the remaining windows for each histogram bin and use it as the updated global background distribution. Repeat this process until the change between the global background distributions of two consecutive iterations is less than the convergence threshold. Output the joint grayscale distribution of the global background.
4. The visual recognition-based OCA bonding defect detection method as described in claim 2, characterized in that, Calculate the texture flatness index within a neighborhood window pixel by pixel for the original grayscale image, including: For each pixel in the original grayscale image, the standard deviation of the grayscale values of all pixels in the neighborhood window is calculated. At the same time, the gradient magnitude of each pixel in the window is calculated and the mean is obtained to obtain the local standard deviation and the mean of the local gradient magnitude. The local standard deviation and the mean local gradient magnitude are normalized and then added together with preset weights to obtain the texture flatness index of each pixel.
5. The visual recognition-based OCA bonding defect detection method as described in claim 1, characterized in that, For each pixel location in the original grayscale image, the empirical joint grayscale distribution of the local neighborhood window is extracted, including: A square window with an odd number of pixels on each side is defined, centered on each pixel in the original grayscale image. For all pixel pairs within the square window that satisfy a preset spatial adjacency relationship, obtain the grayscale value combination of each pixel pair, count the frequency of all grayscale value combinations, divide by the total number of pixel pairs within the window, and obtain the empirical joint grayscale distribution.
6. The visual recognition-based OCA bonding defect detection method as described in claim 1, characterized in that, Calculate the minimum information projection distribution of the empirical joint gray-level distribution onto the global background joint gray-level distribution under exponential family constraints, and calculate the cross-entropy between the global background joint gray-level distribution and the minimum information projection distribution to obtain a cross-entropy map, including: For the empirical joint gray-level distribution of each local window, the first-order gray-level mean, second-order gray-level variance, and gray-level covariance of adjacent pixels are extracted as window statistical features. Using the global background joint grayscale distribution as a reference distribution, and under the constraint of keeping the window statistical characteristics unchanged, the exponential family distribution with the smallest KL divergence with the reference distribution is found by the iterative proportional fitting algorithm, and is used as the minimum information projection distribution. The product of the logarithm of the empirical joint gray-level distribution and the projection probability in the minimum information projection distribution is calculated by combining gray levels one by one. The negative value is obtained after summing the results to obtain the cross-entropy. The cross-entropy map is formed by traversing all local windows.
7. The visual recognition-based OCA bonding defect detection method as described in claim 6, characterized in that, The exponential family distribution with the smallest KL divergence to the reference distribution is found through an iterative proportional fitting algorithm, and is used as the minimum information projection distribution, including: The initial projection distribution is the global background joint grayscale distribution; Iterate through each statistical feature constraint of each local window in turn, adjust the projection distribution to satisfy each statistical feature constraint, and simultaneously maintain the minimum KL divergence between the adjusted projection distribution and the previous distribution. In each round of adjustment, the probability value of each gray-level combination in the projection distribution is updated by a scaling factor until the projection distribution converges. The output is the minimum information projection distribution. The convergence condition is that the maximum probability change of the projection distribution in two consecutive iterations is less than a preset threshold probability change threshold.
8. The visual recognition-based OCA bonding defect detection method as described in claim 1, characterized in that, Threshold segmentation is performed on the cross-entropy map to output a defect location mask, including: Calculate the global mean and global standard deviation of the cross-entropy of the entire graph for the cross-entropy graph, and set the global threshold as the global mean plus the product of the preset sensitivity coefficient and the global standard deviation; Based on the cross-entropy map, pixels with cross-entropy higher than the global threshold are marked as candidate defect pixels; Connectivity analysis is performed on the candidate defect pixels to remove isolated small regions with an area smaller than the preset minimum defect area. Morphological closing operations are then performed on the remaining connected regions to fill the holes, thereby generating the defect location mask.
9. The visual recognition-based OCA bonding defect detection method as described in claim 8, characterized in that, The cross-entropy graph also includes: The empirical joint grayscale distribution and cross-entropy acquisition were repeatedly performed using at least two windows of different sizes to obtain multiple cross-entropy subgraphs; The multiple cross-entropy subgraphs are merged into the cross-entropy graph by using the maximum value of each pixel.
10. A visual recognition-based OCA bonding defect detection system, characterized in that, The system is used to execute the visual recognition-based OCA bonding defect detection method as described in any one of claims 1-9, and the system comprises: The acquisition module is used to acquire the original grayscale image of the OCA bonding area; The filtering module is used to automatically filter the candidate set of normal regions in the original grayscale image based on the local texture flatness, and to estimate the global background joint grayscale distribution based on the candidate set of normal regions. The extraction module is used to extract the empirical joint grayscale distribution of the local neighborhood window for each pixel position in the original grayscale image; The calculation module is used to calculate the minimum information projection distribution of the empirical joint gray-level distribution onto the global background joint gray-level distribution under the exponential family constraints, and to calculate the cross-entropy between the global background joint gray-level distribution and the minimum information projection distribution to obtain a cross-entropy map. The segmentation module is used to perform threshold segmentation on the cross-entropy map and output a defect location mask.