Mobile phone glass cover plate defect detection method, system and equipment and storage medium

By comparing the grayscale images of the glass cover to be detected and the standard glass cover, and using the Otsu algorithm to perform binary processing, the problems of missed detection, false detection and inefficiency in traditional detection methods are solved, and more efficient and accurate Defect detection.

CN119417836APending Publication Date: 2025-02-11GUIZHOU UNIV +1

Patent Information

Application Number
CN202510025720.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

Traditional mobile phone glass cover detection methods rely on artificial vision or simple image processing algorithms, which have problems such as missed detection, missed detection and inefficiency, especially in complex production environments.

Method used

Using a detection method based on grayscale image comparison, the grayscale image of the glass cover to be detected and the standard glass cover is obtained, pixel-level alignment is performed, and the grayscale value difference is calculated to generate residual images. The Otsu algorithm is used to perform the best threshold selection. , and accurately locate defect areas through binarization.

Benefits of technology

It improves the accuracy of detection, reduces manual intervention, adapts to complex production environments, and improves the overall detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119417836A_ABST
    Figure CN119417836A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a mobile phone glass cover plate defect detection method, system and equipment and a storage medium, which are used for improving the accuracy of detecting a mobile phone glass cover plate. The method provided by the embodiment of the invention comprises the following steps: acquiring a first grayscale image of a to-be-detected glass cover plate and a second grayscale image of a standard glass cover plate; aligning the second gray level image with the first gray level image pixel by pixel; calculating a gray value difference value of each pixel of the first gray image and the second gray image to obtain a residual image; calculating an optimal Otsu threshold value of the residual image; performing binarization processing on the residual image according to the optimal Otsu threshold to obtain a binary image; and determining the defect position of the to-be-detected glass cover plate according to the binary image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of glass detection technology, and in particular to a method, system, device and storage medium for detecting defects in a mobile phone glass cover. Background Art

[0002] With the rapid development of the smartphone market, quality inspection of mobile phone glass cover plates has become an important task in the production process. Traditional inspection methods mainly rely on artificial vision or simple image processing algorithms, which usually have problems such as missed detection, false detection and inefficiency. Artificial visual inspection is not only limited by the experience and fatigue of the inspector, but is also easily affected by changes in ambient light, resulting in insufficient detection accuracy. Simple image processing algorithms cannot effectively guarantee accuracy when dealing with complex background noise or subtle defects.

[0003] Current technologies still lack efficient and automated solutions, especially in large-scale production environments, where traditional methods often require manual intervention and cannot meet the needs of efficiency and precision. In addition, complex production environments, such as contamination and scratches on the glass surface, also increase the difficulty of detection, and existing technologies perform poorly in these situations.

[0004] In order to solve the above problems, a glass cover defect detection method based on grayscale image comparison is proposed. This method obtains the grayscale images of the glass cover to be detected and the standard glass cover, performs pixel-level alignment, calculates the grayscale value difference to generate a residual image, applies the Otsu algorithm to select the optimal threshold, and finally accurately locates the defect area through binarization processing. This method can improve the accuracy of detection, reduce manual intervention, adapt to complex production environments, and improve overall detection efficiency. Summary of the invention

[0005] The embodiments of the present application provide a method, system, device and storage medium for detecting defects in a mobile phone glass cover, which can improve the accuracy of detecting a mobile phone glass cover.

[0006] A first aspect of an embodiment of the present application provides a method for detecting defects in a mobile phone glass cover, comprising: Acquire a first grayscale image of the glass cover plate to be inspected and a second grayscale image of a standard glass cover plate; aligning the second grayscale image with the first grayscale image pixel by pixel; Calculate the grayscale value difference of each pixel between the first grayscale image and the second grayscale image to obtain a residual image; Calculating the Otsu optimal threshold of the residual image; Performing binarization processing on the residual image according to the Otsu optimal threshold to obtain a binary image; The defect position of the glass cover plate to be inspected is determined according to the binary image.

[0007] Optionally, calculating the Otsu optimal threshold of the residual image includes: Dividing the residual image into region I and region II according to an Otsu predefined threshold; Calculate the intra-class variance and inter-class variance of region I and region II; Calculate the variance ratio of between-class variance to within-class variance; The variance ratios corresponding to all Otsu predefined thresholds are compared, and the Otsu predefined threshold corresponding to the largest variance ratio is determined as the Otsu optimal threshold.

[0008] Optionally, calculating the intra-class variance and the inter-class variance of region I and region II includes: According to the formula , Calculate the probability of pixels with gray level i in region I and region II; where L represents the number of gray levels in the target region; According to the formula , , Calculate the grayscale values ​​of region I and region II; where ω I and ω II Respectively represent the grayscale values ​​of region I and region II, ω represents the grayscale mean value of the entire residual image; Calculated according to the formula The intra-class variance is calculated according to the formula Calculate the between-class variance; where σ in and σ out represent the within-class variance and between-class variance respectively.

[0009] Optionally, before aligning the second grayscale image with the first grayscale image pixel by pixel, the method further includes: A median filter is performed on the second grayscale image using a 3*3 window.

[0010] Optionally, performing median filtering on the second grayscale image using a 3*3 window includes: Determine a filtering area from the second grayscale image using a 3*3 window; Sort each row of the filter area in ascending order from left to right to obtain three first sequences; According to the grayscale medians of the three first sequences, the three first sequences are sorted in ascending order from top to bottom to obtain three second sequences; Excluding the leftmost two grayscale values ​​of the second sequence in the first row and the rightmost two grayscale values ​​of the second sequence in the third row; Determine a target grayscale median value according to the three remaining grayscale values ​​of the second sequence; Modify all grayscale values ​​of the filter area to the target grayscale median value; Use a 3*3 window to traverse the second grayscale image and execute the above steps.

[0011] Optionally, after performing median filtering on the second grayscale image using a 3*3 window, the method further includes: Perform fuzzy processing on the second grayscale image, wherein the fuzzy processing formula is:

[0012] Among them, M(i,j) represents the grayscale value of the second grayscale image at the pixel point (i,j), i and j represent the horizontal and vertical coordinates, and 2*c+1 and 2*d+1 represent the horizontal and vertical sizes of the second grayscale image respectively.

[0013] Optionally, performing binarization processing on the residual image according to the Otsu optimal threshold to obtain a binary image includes: The pixels in the residual image that are less than the Otsu optimal threshold are modified to the minimum grayscale value, and the pixels in the residual image that are greater than or equal to the Otsu optimal threshold are modified to the maximum grayscale value, so as to obtain a binary image.

[0014] A second aspect of the embodiment of the present application provides a mobile phone glass cover defect detection system, comprising: An acquisition unit, used for acquiring a first grayscale image of the glass cover plate to be inspected and a second grayscale image of the standard glass cover plate; an alignment unit, configured to align the second grayscale image with the first grayscale image pixel by pixel; A first calculation unit, used for calculating the gray value difference of each pixel between the first gray image and the second gray image to obtain a residual image; A second calculation unit, used for calculating the Otsu optimal threshold of the residual image; An execution unit, configured to perform binarization processing on the residual image according to the Otsu optimal threshold to obtain a binary image; A determination unit is used to determine the defect position of the glass cover plate to be inspected according to the binary image.

[0015] Optionally, the second computing unit includes: A division module, used for dividing the residual image into region I and region II according to an Otsu predefined threshold; The first calculation module is used to calculate the intra-class variance and inter-class variance of region I and region II; The second calculation module is used to calculate the variance ratio of the between-class variance to the within-class variance; The determination module is used to compare the variance ratios corresponding to all Otsu predefined thresholds, and determine the Otsu predefined threshold corresponding to the largest variance ratio as the Otsu optimal threshold.

[0016] Optionally, the first calculation module is specifically used for: According to the formula , Calculate the probability of pixels with gray level i in region I and region II; where L represents the number of gray levels in the target region; According to the formula , , Calculate the grayscale values ​​of region I and region II; where ω I and ω II Respectively represent the grayscale values ​​of region I and region II, ω represents the grayscale mean value of the entire residual image; Calculated according to the formula The intra-class variance is calculated according to the formula Calculate the between-class variance; where σ in and σ out represent the within-class variance and between-class variance respectively.

[0017] Optionally, the mobile phone glass cover defect detection system further includes: The median filtering unit is used to perform median filtering on the second grayscale image using a 3*3 window.

[0018] Optionally, the median filtering unit is specifically used for: Determine a filtering area from the second grayscale image using a 3*3 window; Sort each row of the filter area in ascending order from left to right to obtain three first sequences; According to the grayscale medians of the three first sequences, the three first sequences are sorted in ascending order from top to bottom to obtain three second sequences; Excluding the leftmost two grayscale values ​​of the second sequence in the first row and the rightmost two grayscale values ​​of the second sequence in the third row; Determine a target grayscale median value according to the three remaining grayscale values ​​of the second sequence; Modify all grayscale values ​​of the filter area to the target grayscale median value; Use a 3*3 window to traverse the second grayscale image and execute the above steps.

[0019] Optionally, the mobile phone glass cover defect detection system further includes: A fuzzy processing unit is used to perform fuzzy processing on the second grayscale image, wherein the fuzzy processing formula is:

[0020] Among them, M(i,j) represents the grayscale value of the second grayscale image at the pixel point (i,j), i and j represent the horizontal and vertical coordinates, and 2*c+1 and 2*d+1 represent the horizontal and vertical sizes of the second grayscale image respectively.

[0021] Optionally, the execution unit is specifically used for: The pixels in the residual image that are less than the Otsu optimal threshold are modified to the minimum grayscale value, and the pixels in the residual image that are greater than or equal to the Otsu optimal threshold are modified to the maximum grayscale value, so as to obtain a binary image.

[0022] A third aspect of the embodiments of the present application provides a mobile phone glass cover defect detection device, comprising: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; A program is stored in the memory, and the processor calls the program to execute the method in the first aspect and any possible implementation manner of the first aspect.

[0023] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the computer executes the method in the first aspect and any possible implementation of the first aspect.

[0024] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: In this embodiment, by accurately comparing the difference between the glass cover plate to be inspected and the standard glass cover plate and optimizing the segmentation of the residual image using the Otsu algorithm, the defect position can be accurately identified and located, thereby reducing the difficulty of manual inspection and improving the degree of automation and accuracy of inspection. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a flow chart of an embodiment of a method for detecting defects in a mobile phone glass cover in an embodiment of the present application; Figure 2 A schematic diagram of a flow chart of an embodiment of calculating the Otsu optimal threshold of a residual image in an embodiment of the present application; Figure 3 A schematic diagram of a flow chart of an embodiment of calculating intra-class variance and inter-class variance of region I and region II in an embodiment of the present application; Figure 4This is a flow chart of an embodiment of performing median filtering on a second grayscale image in an embodiment of the present application; Figure 5 This is a flow chart of an embodiment of performing blur processing on a second grayscale image in an embodiment of the present application; Figure 6 This is a schematic diagram of the structure of an embodiment of a mobile phone glass cover defect detection system in an embodiment of the present application; Figure 7 This is a schematic structural diagram of an embodiment of a mobile phone glass cover defect detection device in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The embodiments of the present application provide a method, system, device and storage medium for detecting defects in a mobile phone glass cover, which are used to improve the accuracy of detecting a mobile phone glass cover.

[0027] The method of the present application can be applied to a server, a terminal or other devices with logic processing capabilities, and the present application does not limit this. For the convenience of description, the following description is made by taking the execution subject as a server as an example.

[0028] The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0029] See also Figure 1 In the embodiment of the present application, one embodiment of the method for detecting defects in a mobile phone glass cover includes: 101. Acquire a first grayscale image of a glass cover plate to be inspected and a second grayscale image of a standard glass cover plate; First, the server needs to obtain two grayscale images: one is the image of the glass cover to be inspected, and the other is the image of the standard glass cover. The first image contains the grayscale information of the cover to be inspected, and the second image is the grayscale information of the standard cover. These two images will serve as the basis for subsequent comparative analysis.

[0030] 102. Align the second grayscale image with the first grayscale image pixel by pixel; Next, the server will align the second grayscale image of the standard glass cover with the first grayscale image of the glass cover to be inspected pixel by pixel. Image alignment is to adjust the position of the second image through some algorithms (such as feature matching or transformation algorithms) so that it can overlap with the corresponding area in the first image. This step ensures the accuracy of subsequent comparison calculations because the size and position of the images must be exactly the same.

[0031] 103. Calculate the grayscale value difference between each pixel of the first grayscale image and the second grayscale image to obtain a residual image; The server will perform a pixel-level comparison between the first grayscale image and the second grayscale image, calculate the grayscale value difference of each pixel, and generate a residual image. The difference of each pixel is the difference in grayscale values of the two images at that position. The value of each pixel in the residual image reflects the difference between the glass cover plate to be detected and the standard glass cover plate, thereby helping to identify potential defect areas.

[0032] 104. Calculate the Otsu optimal threshold of the residual image; Then, the server will apply the Otsu algorithm to calculate the optimal threshold of the residual image. The Otsu algorithm is an algorithm for automatically selecting a threshold. It divides an image by maximizing the between-class variance and is suitable for binarization operations. In this step, the Otsu algorithm determines a threshold to divide the pixels in the residual image into two categories: normal areas and possible defect areas.

[0033] 105. Perform binarization processing on the residual image according to the Otsu optimal threshold to obtain a binary image; After obtaining the optimal threshold calculated by the Otsu algorithm, the server will perform binarization processing on the residual image. All pixels with grayscale values greater than or equal to the threshold will be set to 1 (indicating possible defect areas), while pixels with grayscale values less than the threshold will be set to 0 (indicating normal areas). The binary image generated at this time clearly marks the potential defect areas.

[0034] Optionally, step 105 may specifically include: Modify the pixels in the residual image with grayscale values less than the Otsu optimal threshold to the minimum grayscale value, and modify the pixels in the residual image with grayscale values greater than or equal to the Otsu optimal threshold to the maximum grayscale value to obtain a binary image.

[0035] The server traverses each pixel of the residual image one by one and classifies and modifies the grayscale values according to the magnitude relationship with the Otsu optimal threshold T. Specifically, if the grayscale value of a certain pixel is less than T (i.e., g(i,j) < T, where g(i,j) represents the grayscale value of the residual image at the pixel point (i,j)), the server modifies the grayscale value of this pixel to the minimum grayscale value in the image (usually 0); if the grayscale value of a certain pixel is greater than or equal to T (i.e., g(i,j) ≥ T), the server modifies the grayscale value of this pixel to the maximum grayscale value in the image (usually 255). Through this operation, the originally continuous grayscale values are binarized, that is, the grayscale range of the residual image is compressed to only contain two values (the minimum value and the maximum value), thereby generating a binary image.

[0036] Through such binarization processing, the grayscale information in the residual image is converted into a more intuitive high-contrast area, which can clearly highlight the pixels with large differences, and further provide an accurate binary data basis for detecting the defect location.

[0037] 106. Determine the defect position of the glass cover plate to be inspected according to the binary image.

[0038] Finally, the server uses the defect area in the binary image to determine the specific defect location of the glass cover to be inspected. By analyzing the continuous area or isolated area in the binary image, the server can accurately locate the defect area in the image and provide a basis for subsequent processing or manual inspection.

[0039] In this embodiment, by accurately comparing the difference between the glass cover plate to be inspected and the standard glass cover plate and optimizing the segmentation of the residual image using the Otsu algorithm, the defect position can be accurately identified and located, thereby reducing the difficulty of manual inspection and improving the degree of automation and accuracy of inspection.

[0040] See also Figure 2 In some embodiments of the present application, step 104 in the above embodiment calculates the Otsu optimal threshold of the residual image, which may include the following steps: 201. Divide the residual image into region I and region II according to the Otsu predefined threshold; First, according to the predefined threshold in the Otsu algorithm, the server divides the residual image into two regions: Region I (usually representing the background or normal area) and Region II (representing the possible defect area). The segmentation is based on grayscale values, and pixels in the residual image that are less than the predefined threshold are classified as Region I, and pixels that are greater than the threshold are classified as Region II. In this way, the two types of pixels in the image can be preliminarily divided to prepare for further threshold optimization.

[0041] 202. Calculate the intra-class variance and inter-class variance of region I and region II; Next, the server calculates the intra-class variance and inter-class variance of Region I and Region II. The intra-class variance measures the dispersion of the grayscale values ​​of pixels in each region, while the inter-class variance measures the difference in grayscale values ​​between Region I and Region II. Specifically, a smaller intra-class variance indicates that the grayscale values ​​inside the region are more concentrated, and a larger inter-class variance indicates that the grayscale difference between Region I and Region II is obvious, which helps determine an effective threshold.

[0042] 203. Calculate the variance ratio of the between-class variance to the within-class variance; The server then calculates the variance ratio of the inter-class variance to the intra-class variance. This ratio reflects the effectiveness of the current threshold in distinguishing the two types of pixels (region I and region II). If the inter-class variance is large and the intra-class variance is small, it means that the threshold can better separate the two types of regions, so the threshold is more ideal.

[0043] 204. Compare the variance ratios corresponding to all Otsu predefined thresholds, and determine the Otsu predefined threshold corresponding to the largest variance ratio as the Otsu optimal threshold.

[0044] Finally, the server will compare the ratio of the inter-class variance to the intra-class variance corresponding to all Otsu predefined thresholds, and select the predefined threshold corresponding to the largest ratio as the Otsu optimal threshold. This optimal threshold can optimize the image segmentation effect to the greatest extent, that is, it can most clearly separate the normal area and the defect area.

[0045] In this embodiment, by accurately calculating the intra-class and inter-class variances, the threshold selection is optimized, so that the binarization of the residual image is more accurate and the defective area of ​​the glass cover can be effectively distinguished. Through the optimization of the Otsu algorithm, the threshold selection is more automated and efficient, which significantly improves the accuracy and stability of defect detection.

[0046] See also Figure 3 In some embodiments of the present application, step 202 in the above embodiment of calculating the intra-class variance and inter-class variance of region I and region II may include the following steps: 301. According to the formula (Formula 1), (Formula 2) Calculate the probability of pixels with gray level i in region I and region II; where L represents the number of gray levels in the target region; The purpose of this step is to divide the entire grayscale image into two parts (region I and region II) to provide basic data for the subsequent calculation of the grayscale mean and intra-class and inter-class variance of each region.

[0047] 302. According to the formula (Formula 3), (Formula 4), (Formula 5) Calculate the grayscale value of region I and region II; where ω I and ω II Represent the grayscale values ​​of region I and region II respectively, and ω represents the grayscale mean of the entire residual image; This step can provide a basis for calculating the intra-class and inter-class variance of the image by calculating the mean grayscale of the regions respectively.

[0048] 303. According to the formula (Formula 6) Calculate the intra-class variance and use the formula (Formula 7) calculates the between-class variance; where σ in and σ out represent the within-class variance and between-class variance respectively.

[0049] The intra-class variance is used to measure the degree of grayscale dispersion within a region, while the inter-class variance represents the difference in grayscale mean between two regions. Through these two calculations, the server can quantify the grayscale differences between different regions and provide evaluation indicators for selecting the optimal threshold.

[0050] In this embodiment, the server can calculate the grayscale distribution, grayscale mean, and intra-class and inter-class variance of region I and region II based on each predefined threshold, providing a reliable basis for subsequently finding the optimal threshold corresponding to the maximum variance ratio. This calculation method can accurately capture the changes in the grayscale distribution of the image, thereby improving the accuracy and robustness of defect detection, and ultimately improving the accuracy of mobile phone glass cover defect detection.

[0051] See also Figure 4 In some embodiments of the present application, before step 102 in the above embodiment aligns the second grayscale image with the first grayscale image pixel by pixel, the method for detecting defects in a mobile phone glass cover may further include the following steps: 401. Determine a filtering area from the second grayscale image using a 3*3 window; Before pixel-by-pixel alignment of the second grayscale image, the server first gradually selects the filter area in the second grayscale image through a 3×3 window. The window covers a small area of ​​the image each time, and the filter area is the part covered by the window. Each window represents a part of the image. The purpose is to perform local processing on the image, thereby reducing the impact of noise on subsequent image alignment.

[0052] 402. Sort each row of the filtering area in ascending order from left to right to obtain three first sequences; Next, the server processes each row in each filter area. The pixel grayscale values ​​of each row are sorted in ascending order from left to right to obtain three first sequences. This step helps to eliminate grayscale unevenness caused by local noise or illumination changes, ensuring that the sorted grayscale features can be reflected more stably, which is convenient for subsequent calculations.

[0053] 403. According to the grayscale medians of the three first sequences, the three first sequences are sorted in ascending order from top to bottom to obtain three second sequences; Next, the server will further sort the three first sequences in ascending order from top to bottom according to the median grayscale value in each first sequence to obtain three second sequences. This is done to eliminate irregular grayscale distribution, make the sorting of each row more uniform, and further improve the robustness and stability of image processing.

[0054] 404. Exclude the leftmost two grayscale values ​​of the second sequence in the first row and the rightmost two grayscale values ​​of the second sequence in the third row; Next, the server will refine the sorted second sequence, excluding the two leftmost grayscale values ​​in the first row and the two rightmost grayscale values ​​in the third row. The purpose of this step is to remove extreme values, further eliminate extreme noise or outliers that may exist in the image, and ensure that the remaining grayscale values ​​more accurately reflect the actual grayscale distribution in the area.

[0055] 405. Determine a target grayscale median value according to the remaining grayscale values ​​of the three second sequences; Next, the server will calculate the target grayscale median based on the remaining grayscale values ​​(i.e., the grayscale values ​​after excluding the extreme values). The target grayscale median represents the central grayscale level of the filter area and is a standardized grayscale value of the area with high stability and representativeness.

[0056] 406. Modify all grayscale values ​​in the filter area to the target grayscale median value; According to the calculated target grayscale median, the server will modify all grayscale values ​​in the entire filtering area to the median. In this way, the filtering operation can effectively reduce the impact of local noise and make the local area of ​​the image smoother and more consistent.

[0057] 407. Use a 3*3 window to traverse the second grayscale image and execute the above steps 401-406.

[0058] Finally, the server traverses the entire second grayscale image through a 3×3 window and performs the above steps 401-406 for each filter area. This process will perform local smoothing on the entire image, reduce the impact of noise, and provide more stable image data for subsequent image alignment.

[0059] In this embodiment, the noise and outliers in the second grayscale image are effectively removed by local filtering, and the stability and consistency of the image are improved. By optimizing the grayscale value of the filtering area, the image processing is smoother, providing more accurate data for the subsequent pixel-by-pixel alignment, thereby helping to improve the accuracy of image alignment, and further improve the accuracy of the entire glass cover defect detection.

[0060] See also Figure 5 In some embodiments of the present application, after step 407 in the above embodiment uses a 3*3 window to traverse the second grayscale image and executes the above steps 401-406, the mobile phone glass cover defect detection method may further include the following steps: 501. Perform blur processing on the second grayscale image, wherein the blur processing formula is:

[0061] Wherein, M(i,j) represents the grayscale value of the second grayscale image at the pixel point (i,j), i and j represent the horizontal and vertical coordinates, and 2*c+1 and 2*d+1 represent the horizontal and vertical sizes of the second grayscale image respectively.

[0062] The server completes the fuzzy processing by calculating the mean of all grayscale values ​​in the window, so that the grayscale value of the pixel is affected by the grayscale value in its neighborhood, thereby achieving smoothing of the grayscale value.

[0063] Through this fuzzy processing step, the server can effectively reduce the random noise in the second grayscale image, making the grayscale value of the image smoother and more uniform in the local range, providing more stable basic data for subsequent image alignment and defect detection. This operation can significantly improve the accuracy of detection, especially in the presence of background noise.

[0064] See also Figure 6 In the embodiment of the present application, an embodiment of the mobile phone glass cover defect detection system includes: An acquisition unit 601 is used to acquire a first grayscale image of the glass cover plate to be inspected and a second grayscale image of the standard glass cover plate; An alignment unit 602, configured to align the second grayscale image with the first grayscale image pixel by pixel; A first calculation unit 603 is used to calculate the grayscale value difference of each pixel between the first grayscale image and the second grayscale image to obtain a residual image; A second calculation unit 604 is used to calculate the Otsu optimal threshold of the residual image; An execution unit 605 is used to perform a binarization process on the residual image according to an Otsu optimal threshold to obtain a binary image; The determination unit 606 is used to determine the defect position of the glass cover plate to be inspected according to the binary image.

[0065] In this embodiment, by accurately comparing the difference between the glass cover plate to be inspected and the standard glass cover plate and optimizing the segmentation of the residual image using the Otsu algorithm, the defect position can be accurately identified and located, thereby reducing the difficulty of manual inspection and improving the degree of automation and accuracy of inspection.

[0066] Optionally, the second computing unit includes: A partitioning module, used for dividing the residual image into region I and region II according to an Otsu predefined threshold; The first calculation module is used to calculate the intra-class variance and inter-class variance of region I and region II; The second calculation module is used to calculate the variance ratio of the between-class variance to the within-class variance; The determination module is used to compare the variance ratios corresponding to all Otsu predefined thresholds, and determine the Otsu predefined threshold corresponding to the largest variance ratio as the Otsu optimal threshold.

[0067] Optionally, the first computing module is specifically used for: According to the formula , Calculate the probability of pixels with gray level i in region I and region II; where L represents the number of gray levels in the target region; According to the formula , , Calculate the grayscale values ​​of region I and region II; where ω I and ω II Represent the grayscale values ​​of region I and region II respectively, and ω represents the grayscale mean of the entire residual image; Calculated according to the formula The intra-class variance is calculated according to the formula Calculate the between-class variance; where σ in and σ out represent the within-class variance and between-class variance respectively.

[0068] Optionally, the mobile phone glass cover defect detection system also includes: The median filtering unit is used to perform median filtering on the second grayscale image using a 3*3 window.

[0069] Optionally, the median filtering unit is specifically used for: Determine the filtering area from the second grayscale image using a 3*3 window; Sort each row of the filter area in ascending order from left to right to obtain three first sequences; According to the grayscale medians of the three first sequences, the three first sequences are sorted in ascending order from top to bottom to obtain three second sequences; Exclude the leftmost two grayscale values ​​of the second sequence in the first row and the rightmost two grayscale values ​​of the second sequence in the third row; Determine the target grayscale median value according to the remaining grayscale values ​​of the three second sequences; Modify all grayscale values ​​in the filter area to the target grayscale median value; Use a 3*3 window to traverse the second grayscale image and execute the above steps.

[0070] Optionally, the mobile phone glass cover defect detection system also includes: The fuzzy processing unit is used to perform fuzzy processing on the second grayscale image, wherein the fuzzy processing formula is:

[0071] Wherein, M(i,j) represents the grayscale value of the second grayscale image at the pixel point (i,j), i and j represent the horizontal and vertical coordinates, and 2*c+1 and 2*d+1 represent the horizontal and vertical sizes of the second grayscale image respectively.

[0072] Optionally, the execution unit is specifically used for: The pixels in the residual image that are less than the Otsu optimal threshold are modified to the minimum grayscale value, and the pixels in the residual image that are greater than or equal to the Otsu optimal threshold are modified to the maximum grayscale value to obtain a binary image.

[0073] In this implementation, the functions of each unit and module are the same as those described above. Figures 1 to 5 The steps in the illustrated embodiments correspond to each other and will not be described again here.

[0074] See also Figure 7 In the embodiment of the present application, an embodiment of a mobile phone glass cover defect detection device includes: Processor 701, memory 702, input and output unit 703 and bus 704; The processor 701 is connected to the memory 702, the input and output unit 703 and the bus 704; The memory 702 stores a program, and the processor 701 calls the program to execute Figures 1 to 5 Steps in the illustrated embodiment.

[0075] In this embodiment, the function of the processor 701 is the same as that of the aforementioned Figures 1 to 5 The steps in the illustrated embodiments correspond to each other and will not be described again here.

[0076] The embodiment of the present application also provides a computer-readable storage medium on which a program is stored. When the program is executed on a computer, the computer executes the aforementioned Figures 1 to 5 A method in any possible implementation.

[0077] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0078] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0079] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0080] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0081] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.

Claims

1. A method for detecting defects in a mobile phone glass cover, characterized in that: include: Acquire a first grayscale image of the glass cover plate to be inspected and a second grayscale image of a standard glass cover plate; aligning the second grayscale image with the first grayscale image pixel by pixel; Calculate the grayscale value difference of each pixel between the first grayscale image and the second grayscale image to obtain a residual image; Calculating the Otsu optimal threshold of the residual image; Performing binarization processing on the residual image according to the Otsu optimal threshold to obtain a binary image; The defect position of the glass cover plate to be inspected is determined according to the binary image.

2. The method according to claim 1, characterized in that The calculating of the Otsu optimal threshold of the residual image comprises: Dividing the residual image into region I and region II according to an Otsu predefined threshold; Calculate the intra-class variance and inter-class variance of region I and region II; Calculate the variance ratio of between-class variance to within-class variance; The variance ratios corresponding to all Otsu predefined thresholds are compared, and the Otsu predefined threshold corresponding to the largest variance ratio is determined as the Otsu optimal threshold.

3. The method according to claim 2, characterized in that The calculation of the intra-class variance and the inter-class variance of region I and region II includes: According to the formula , Calculate the probability of pixels with gray level i in region I and region II; where L represents the number of gray levels in the target region; According to the formula , , Calculate the grayscale values ​​of region I and region II; where ω I and ω II Respectively represent the grayscale values ​​of region I and region II, ω represents the grayscale mean value of the entire residual image; Calculated according to the formula The intra-class variance is calculated according to the formula Calculate the between-class variance; where σ in and σ out represent the within-class variance and between-class variance respectively.

4. The method according to claim 1, characterized in that: Before aligning the second grayscale image with the first grayscale image pixel by pixel, the method further includes: A median filter is performed on the second grayscale image using a 3*3 window.

5. The method according to claim 4, characterized in that The performing median filtering on the second grayscale image using a 3*3 window comprises: Determine a filtering area from the second grayscale image using a 3*3 window; Sort each row of the filter area in ascending order from left to right to obtain three first sequences; According to the grayscale medians of the three first sequences, the three first sequences are sorted in ascending order from top to bottom to obtain three second sequences; Excluding the leftmost two grayscale values ​​of the second sequence in the first row and the rightmost two grayscale values ​​of the second sequence in the third row; Determine a target grayscale median value according to the three remaining grayscale values ​​of the second sequence; Modify all grayscale values ​​of the filter area to the target grayscale median value; Use a 3*3 window to traverse the second grayscale image and execute the above steps.

6. The method according to claim 4, characterized in that After performing median filtering on the second grayscale image using a 3*3 window, the method further includes: Perform fuzzy processing on the second grayscale image, wherein the fuzzy processing formula is: Among them, M(i,j) represents the grayscale value of the second grayscale image at the pixel point (i,j), i and j represent the horizontal and vertical coordinates, and 2*c+1 and 2*d+1 represent the horizontal and vertical sizes of the second grayscale image respectively.

7. The method according to any one of claims 1 to 6, characterized in that The performing binarization processing on the residual image according to the Otsu optimal threshold to obtain a binary image comprises: The pixels in the residual image that are less than the Otsu optimal threshold are modified to the minimum grayscale value, and the pixels in the residual image that are greater than or equal to the Otsu optimal threshold are modified to the maximum grayscale value, so as to obtain a binary image.

8. A mobile phone glass cover defect detection system, characterized in that: include: An acquisition unit, used for acquiring a first grayscale image of the glass cover plate to be inspected and a second grayscale image of the standard glass cover plate; an alignment unit, configured to align the second grayscale image with the first grayscale image pixel by pixel; A first calculation unit, used for calculating the gray value difference of each pixel between the first gray image and the second gray image to obtain a residual image; A second calculation unit, used for calculating the Otsu optimal threshold of the residual image; An execution unit, configured to perform binarization processing on the residual image according to the Otsu optimal threshold to obtain a binary image; A determination unit is used to determine the defect position of the glass cover plate to be inspected according to the binary image.

9. A mobile phone glass cover defect detection device, characterized in that: include: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, which, when executed, enables the processor to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, wherein a program is stored in the computer-readable storage medium, and when the program is executed on a computer, the computer executes the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for detecting defects

    CN108230321A

  • Infrared image segmentation method based on genetic optimization threshold method

    CN111462157A

  • Defect detection method and device, computer equipment and computer readable storage medium

    CN117726579A

Cited By

  • Mobile phone glass quality detection method and system based on image detection

    CN120833320A

  • Mobile phone curved glass cover plate detection method and device and electronic equipment

    CN121120657A

  • A mobile phone curved glass cover plate detection method, device and electronic equipment

    CN121120657B

  • Glass cover plate defect detection method and system based on image processing

    CN121544528A

  • A glass cover plate defect detection method and system based on image processing

    CN121544528B