A method for target segmentation and detection in an image with non-uniform brightness
By applying gradient and grayscale threshold settings and K-mean clustering methods on the LCD screen, the problem of low detection accuracy caused by uneven brightness of the LCD screen is solved, and efficient and reliable target defect segmentation detection is achieved.
Patent Information
- Application Number
- CN202211463421.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-21
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-11-21
AI Technical Summary
The brightness of the LCD screen is uneven due to production processes and equipment, which affects the target defect detection accuracy and reliability. The manual detection efficiency is low and the cost is high, making it difficult to collect sufficient defect samples.
The non-uniform brightness image processing method is used to identify and segment target defects through gradient and grayscale threshold settings, combining K-mean clustering and morphological processing.
It improves the accuracy and reliability of target defect detection of LCD screens, reduces false detection and missed detection, and reduces labor costs.
Smart Images

Figure CN115760786B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of object detection in image processing, and in particular to a method for object segmentation and detection in an image with non-uniform brightness. Background Art
[0002] Currently, since liquid crystals have been widely used in display devices such as vehicle-mounted devices, home appliances, and smart phones that interact with users, due to irresistible factors such as the production process and manufacturing equipment of liquid crystal screens, it is inevitable that the produced liquid crystal screens will have display target defects such as bright spots, color spots, and Mura. To ensure normal display of the liquid crystal screen and not affect the user experience, at the same time, manual detection of the liquid crystal screen has low detection efficiency, and visual fatigue is prone to cause missed detection and false detection. In addition, the labor cost is relatively high. In addition, the method based on the artificial neural network model requires a large number of defect samples, and with the progress of the production process, the number of defective screens is getting smaller and smaller, and it is difficult to collect a large number of samples in a short time. Therefore, there is an urgent need to develop a set of efficient and reliable object defect segmentation and detection algorithms based on image processing.
[0003] For the target defects in the liquid crystal screen, it is necessary to display different color standard backgrounds on the liquid crystal screen, and then collect through a camera for image processing and detection. However, due to the settings of parameters such as the collection position and exposure of the camera and the screen display brightness, the brightness distribution of the collected display image is uneven, which affects the accuracy and reliability of the target defect detection and segmentation. Summary of the Invention
[0004] A method for object segmentation and detection in an image with non-uniform brightness proposed by the present invention solves the problem that the uneven brightness of the collected pictures due to hardware reasons in the existing target defect detection of liquid crystal screens affects the image processing method and reduces the measurement accuracy.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] A method for object segmentation and detection in an image with non-uniform brightness, comprising the following steps:
[0007] S1. Use a camera to collect the data of the screen to be detected and the calibration screen sample;
[0008] S2. Divide the area to be detected and the calibration sample into modules of a fixed size;
[0009] S3. Calculate the gradient value corresponding to each module, set the first threshold according to the gradient value, and detect the defect position;
[0010] S4. Detect the position of the target according to the gradient threshold, set the second threshold, exclude false detections, and separate the target foreground;
[0011] S5. Perform morphological processing and identify the target defect type information.
[0012] Preferably, in S1, first, sample calibration is performed on the model of the screen to be detected, that is, N groups of normal screen display situations under different color backgrounds are collected, and then the screen to be detected under the corresponding color background is collected.
[0013] Preferably, in S2, corner points are extracted from the calibration images and the images to be detected collected in S1, and the screen display area images are segmented from each image, as Figure 3 shown; and each image is divided into several modules of size W*H according to the image size and brightness uniformity, as Figure 4 shown.
[0014] Preferably, in S3, for each module area of each calibration sample screen area image in S2, the gradient corresponding to each pixel is obtained using the Sobel operator, the maximum value of the pixel gradients in each corresponding position module in N calibration images is statistically calculated, and the first gradient threshold is set with it; the gradient of each module of the screen image to be measured is also obtained using Sobel, and the pixels with gradients greater than the threshold are detected according to the first threshold of the calibration module in the same position.
[0015] Preferably, in S4, the target defect position coordinates are detected according to S3:
[0016] 1. Take the position area of the screen to be measured, perform K-means clustering of two seeds on this area of the screen to be measured, divide it into two categories F1 and F2, and respectively statistically calculate the gray mean value, gray maximum value, and gray minimum value of the two categories in the area to be detected;
[0017] 2. Take the slider areas corresponding to N calibration samples, and respectively take their interquartile range, maximum value, minimum value, and mean value;
[0018] 3. Set the second threshold according to the parameters obtained in steps 1 and 2 to perform target defect detection, exclude the misdetection area to find the target defect, and at the same time achieve foreground segmentation.
[0019] Preferably, in S5, according to the approximate position of the target defect found in S4, first perform morphological processing on it, then detect its outermost contour, calculate the contour side length and width parameter values to determine the target defect category, and finally output the schematic diagram of the target defect position.
[0020] Preferably, the maximum values of the gradients in the N calibrated sample slider areas are selected. Taking N = 7 as an example: their gradient maximum values are T1, T2, T3, T4, T5, T6, and T7 respectively;
[0021] 1. The expression of its threshold K1 is as follows:
[0022]
[0023] Where Tmax is the maximum value among the maximum values of the gradient seven sub-gradient maps, and a is the sample constant in the gradient map slider area;
[0024] 2. Perform threshold binarization on the area to be measured to find its approximate position. The thresholding expression is:
[0025]
[0026] Where Img(row, col) is the gradient value at the position (row, col) of the slider area of the screen to be measured.
[0027] Preferably, for the setting of the second threshold K2, first take the gray mean value, gray maximum value, and gray minimum value of the two categories F1 and F2 obtained by K-means clustering as F1: Gray_min1, Gray_max1, Gray_avg1; F2: Gray_min2, Gray_max2, Gray_avg2; then count the gray minimum value, gray maximum value, mean value, and gray interquartile range of N samples. Taking N = 7 as an example, the obtained data is (i = 1, 2, 3,..., 7):
[0028] Sample_min_i, Sample_max_i, Sample_avg_i, Sample_Q;
[0029] 1. Then, according to the above parameters, the threshold K2 can be set as:
[0030]
[0031] Where i is the number of the sample data, i = 1, 2, 3,..., 7, and b is the system constant of the sample to be detected captured;
[0032] 2. Perform a secondary judgment on the screen to be measured according to the obtained threshold K2. The judgment expression is as follows:
[0033] When F1 is the foreground:
[0034]
[0035] Where Gray_min1 and Gray_max1 are the foreground gray minimum value and maximum value respectively, Gray_avg2 is the background gray mean value, and K2 is the threshold parameter;
[0036] When F2 is the foreground:
[0037]
[0038] where Gray_min2 and Gray_max2 are the minimum and maximum foreground grayscale values respectively, Gray_avg1 is the average background grayscale value, and K2 is the threshold parameter;
[0039] Set the two categories F1 and F2 obtained by K-means clustering as the foreground and background respectively. If the area detected by the first threshold is the target defect, the following determination can be obtained based on the above:
[0040] 。
[0041] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0042] The present invention effectively solves the problem of low detection accuracy of target defects caused by uneven brightness distribution of the image to be detected; by setting a slider for area detection, the detection range is reduced to exclude some cases of uneven brightness, and then false detections and missed detections are excluded through the secondary threshold settings of gradient and grayscale, greatly improving the detection accuracy of target defects in the screen display, and finally outputting a schematic diagram of the detection result. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a schematic diagram of the collected data of a method for target segmentation and detection in a non-uniform brightness image proposed by the present invention;
[0044] Figure 2 It is a flowchart of the image processing algorithm of a method for target segmentation and detection in a non-uniform brightness image proposed by the present invention;
[0045] Figure 3 It is a schematic diagram of the screen image collected in a method for target segmentation and detection in a non-uniform brightness image proposed by the present invention;
[0046] Figure 4 It is a schematic diagram of the module division of the screen image collected in a method for target segmentation and detection in a non-uniform brightness image proposed by the present invention.
[0047] Figure 5 It is a statistical summary diagram of the partial area parameters of the samples of a method for target segmentation and detection in a non-uniform brightness image proposed by the present invention; DETAILED DESCRIPTION OF THE EMBODIMENTS
[0048] The technical solutions in the embodiments of the present invention will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Embodiment
[0049] Refer to Figures 1-4 A method for target segmentation and detection in a non-uniform brightness image includes the following steps:
[0050] S1. Data collection: Collect the screen to be detected and sample data for calibration.
[0051] S2. Image preprocessing (setting sliders, cutting and saving samples): Divide the area to be detected and the calibration samples into modules of a fixed size.
[0052] S3. First threshold setting: Calculate the gradient parameter values corresponding to the modules, set the first threshold according to the gradient values, and detect the pixels whose gradient thresholds are greater than the threshold.
[0053] S4. Second threshold setting: According to the positions detected by the first threshold, set the second threshold of the gray level, conduct a second discrimination, and achieve foreground segmentation.
[0054] S5. Result preview: Conduct morphological processing to distinguish information such as the type of target defect.
[0055] In this embodiment, in S1, first, sample calibration is performed on the model of the screen to be detected, that is, N normal screen displays are collected, and then the display image of the screen to be detected is collected.
[0056] In this embodiment, in S2, according to the sample data collected in S1, the corner points of the screen to be detected are extracted to obtain the screen display area, the samples are saved on the PC for detecting screens of the same model, and then the corner points of the display area of the screen to be measured are extracted. A sliding window with a window size of W*H is set, and the window is used to traverse the screen to be measured and N groups of calibration samples.
[0057] In this embodiment, in S3, according to the slider regions corresponding to the screen to be detected and the calibration samples in S1 and S2, the slider regions are subjected to gradient transformation using the Soble operator to obtain N+1 gradient slider regions. The maximum gradient value in each sample region is statistically calculated, and the first gradient threshold is set using it to complete the detection of the approximate position of the target defect.
[0058] In this embodiment, in S4, according to the approximate target defect position coordinates detected in S3:
[0059] 1. Take the position region of the screen to be measured, perform K-means clustering of two seeds on this region of the screen to be measured, divide it into two categories, F1 and F2, and respectively statistically calculate the gray level mean, gray level maximum value, and gray level minimum value of the two categories in the area to be detected.
[0060] 2. Take the slider regions corresponding to N calibration samples, and respectively take their interquartile range, maximum value, minimum value, and mean value.
[0061] 3. Set the second threshold according to the parameters obtained in steps 1 and 2 for target defect detection, exclude the misdetection regions, and find the ready position of the target defect.
[0062] In this embodiment, in S5, according to the target defect position found in S4, first perform morphological processing on it, then detect its outermost contour, obtain the contour side length and width parameter values to determine the target defect category, and finally output the schematic diagram of the target defect position.
[0063] In this embodiment, select the maximum gradient values in each of the calibrated N sample slider regions. Taking N = 7 as an example: its maximum gradient values are T1, T2, T3, T4, T5, T6, and T7 respectively;
[0064] Refer to Figure 5 , and the sample gradient parameter statistics are shown in Figure 5 as follows; Figure 5 It is the statistical chart of the sample data in the upper left corner when the liquid crystal screen shows a white background and the slider size is selected as 100 * 100.
[0065] 1. The expression of its threshold K1 is as follows:
[0066]
[0067] Where Tmax is the maximum value among the maximum values of the seven gradient maps of the gradient, and a is the sample constant in the slider region of the gradient map;
[0068] 2. Perform threshold binaryzation on the area to be measured to find its approximate position. The thresholding expression is:
[0069]
[0070] Where Img(row, col) is the gradient value at the position (row, col) of the slider region of the screen to be measured.
[0071] In this embodiment, for the setting of the second threshold K2, first take the gray mean value, gray maximum value, and gray minimum value of the two categories F1 and F2 obtained by K-means clustering as F1: Gray_min1, Gray_max1, Gray_avg1; F2: Gray_min2, Gray_max2, Gray_avg2; then count the gray minimum value, gray maximum value, mean value, and gray interquartile range of N samples. Taking N = 7 as an example, the obtained data is (i = 1, 2, 3,..., 7):
[0072] Sample_min_i, Sample_max_i, Sample_avg_i, Sample_Q; the sample gray parameter statistics are shown in Figure 5 as follows.
[0073] 1. Then, according to the above parameters, the threshold K2 can be set as:
[0074]
[0075] where \(i\) is the \(i\)-th sample data, \(i = 1, 2, 3, \cdots, 7\), and \(b\) is the system constant of the sample to be photographed for detection;
[0076] 2. Make a secondary judgment on the screen to be measured according to the obtained threshold \(K2\), and the judgment expression is as follows:
[0077] When \(F1\) is the foreground:
[0078]
[0079] where \(Gray\_min1\) and \(Gray\_max1\) are the minimum and maximum foreground grayscale values respectively, \(Gray\_avg2\) is the average background grayscale value, and \(K2\) is the threshold parameter;
[0080] When \(F2\) is the foreground:
[0081]
[0082] where \(Gray\_min2\) and \(Gray\_max2\) are the minimum and maximum foreground grayscale values respectively, \(Gray\_avg1\) is the average background grayscale value, and \(K2\) is the threshold parameter;
[0083] Set the two categories \(F1\) and \(F2\) obtained by \(K -\)means clustering as the foreground and background respectively. If the area detected by the first threshold is the target defect, the following determination can be obtained based on the above:
[0084] .
[0085] As described above, it is only the preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention, according to the technical solution of the present invention and its inventive concept, makes equivalent replacements or changes, and should be covered by the protection scope of the present invention..
Claims
1. A method for target segmentation and detection in a non-uniform brightness image, characterized in that, Including the following steps: S1. Use a camera to collect the data of the screen to be detected and the calibration screen samples; S2. Divide the area to be detected and the calibration samples into modules of a fixed size; S3. Calculate the gradient value corresponding to each module, set the first threshold according to the gradient value, and detect the defect position; S4. Detect the position of the target according to the gradient threshold, set the second threshold, exclude false detections, and separate the target foreground; S5. Perform morphological processing and identify the information on the type of target defect; In S2, corner extraction is performed on the calibration image and the image to be detected collected in S1, and the screen display area image is segmented from each image; and each image is divided into several modules of size W*H according to the image size and brightness uniformity; In S3, for each module area of each calibration sample screen area image in S2, the gradient corresponding to each pixel is obtained using the Sobel operator, the maximum value of the pixel gradients in each corresponding position module in N calibration images is statistically calculated, and the first gradient threshold is set using it; the gradient of each module of the screen image to be measured is also obtained using Sobel, and the pixels with gradients greater than the threshold are detected according to the first threshold of the calibration module in the same position; In S4, according to the pixel position coordinates detected in S3 where the gradient is greater than the threshold; (1) Take the area of the screen to be measured, perform K-means clustering of two seeds on this area of the screen to be measured, divide it into two categories F1 and F2, and respectively statistically calculate the gray mean value, gray maximum value, and gray minimum value of the two categories in the area to be detected; (2) Take the slider areas corresponding to N calibration samples, and respectively take their interquartile range, maximum value, minimum value, and mean value; (3) Set the second threshold according to the parameters obtained in steps (1) and (2) for target defect detection, exclude false detection areas to find the target defect, and at the same time achieve foreground segmentation; In S5, according to the target defect foreground found in S4, first perform morphological processing on it, then detect its outermost contour, obtain the contour side length and width parameter values to determine the target defect category, and finally output the schematic diagram of the target defect position.
2. The method for target segmentation and detection in a non-uniform brightness image according to claim 1, characterized in that, In S1, use a camera to collect the image of the screen display. First, collect the images of N defect-free screens as the calibration images for threshold setting; then, collect the image of 1 screen to be detected.
3. The method for target segmentation and detection in a non-uniform brightness image according to claim 1, characterized in that, Select the maximum gradient values in each of the N calibrated sample slider areas. Taking N = 7 as an example: their gradient maximum values are T1, T2, T3, T4, T5, T6, T7 respectively; (1) The expression of its threshold K1 is as follows: , , where Tmax is the maximum value among the maximum values of the gradients of the seven gradient maps, and a is the sample constant in the gradient map slider area; (2) Perform threshold binaryzation on the area to be measured to find its approximate position, and the thresholding expression is: , where Img(row, col) is the gradient value at the position (row, col) of the slider area of the screen to be measured.
4. A method for target segmentation and detection in a non-uniform brightness image according to claim 1, characterized in that, For the setting of the second threshold K2, first take the gray mean value, gray maximum value, and gray minimum value of the two categories F1 and F2 divided by K-means clustering as F1: Gray_min1, Gray_max1, Gray_avg1; F2: Gray_min2, Gray_max2, Gray_avg2; then count the minimum gray value, maximum gray value, average value, and gray quartile deviation of N samples, Sample_min_i, Sample_max_i, Sample_avg_i, Sample_Q; (1) Then the threshold K2 can be set according to the above parameters as: , where i is the number of the sample data, i = 1, 2, 3,..., 7, and b is the system constant of the sample to be detected in the captured image; (2) Make a secondary judgment on the screen to be measured according to the obtained threshold K2, and the judgment expression is as follows: When F1 is the foreground: , where Gray_min1 and Gray_max1 are the minimum and maximum foreground gray values respectively, Gray_avg2 is the average background gray value, and K2 is the threshold parameter; When F2 is the foreground: , where Gray_min2 and Gray_max2 are the minimum and maximum foreground gray values respectively, Gray_avg1 is the average background gray value, and K2 is the threshold parameter; Set the two categories F1 and F2 obtained by K-means clustering as the foreground and background respectively. If the area detected by the first threshold is the target defect, the following judgments can be obtained based on the above: 。
Citation Information
Patent Citations
LCD rough spot defect detection method
CN108830851A
Visual inspection method and system
CN111882537A