Adaptive image bad pixel detection and correction method based on robust statistics and edge perception
By employing an adaptive image defect detection method based on robust statistics and edge awareness, defective pixels are screened by calculating the median absolute deviation and variance of neighboring pixels, and differential correction is performed based on the directional gradient information of the neighborhood. This solves the problems of low detection accuracy and insufficient edge protection in existing technologies, and achieves higher detection accuracy and improved image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHONGQING UNIV OF POSTS & TELECOMM
- Filing Date
- 2026-02-27
- Publication Date
- 2026-06-02
AI Technical Summary
Existing image defect detection methods suffer from problems such as unrobust statistical measures, low detection accuracy, and insufficient edge protection.
An adaptive image defect detection method based on robust statistics and edge awareness is adopted. Candidate defective pixels are screened by calculating the median absolute deviation and variance of neighboring pixels, and differential correction is performed based on the neighborhood directional gradient information.
It improves the accuracy of bad pixel detection, reduces missed and false detections, effectively protects image edge details, and enhances image clarity and sharpness.
Smart Images

Figure CN122134679A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to an adaptive image defect detection and correction method based on robust statistics and edge awareness. Background Technology
[0002] During the manufacturing process of image sensors, due to process defects, material inhomogeneity, and other reasons, some pixels with abnormal responses may be generated, called defective pixels. Defective pixels typically appear as bright spots (abnormally high pixel values) or dark spots (abnormally low pixel values), severely affecting image quality. Defective pixels are mainly divided into two categories: static defects and dynamic defects. Static defects have fixed locations and are present at the factory; they can be recorded and corrected using a bad pixel map; however, this requires additional storage space and cannot handle newly added defective pixels. Dynamic defects have variable locations that change with temperature, exposure time, and operating conditions; static defects cannot effectively handle them; real-time detection and correction are required.
[0003] Common technical solutions in the prior art include:
[0004] 1. The detection method based on median filtering (point algorithm) calculates the difference between a pixel and the median of its neighborhood. If the difference exceeds a fixed threshold, it is judged as a bad pixel. However, the fixed threshold cannot adapt to different texture areas, flat areas are prone to missed detection, and improper edge processing can easily lead to blurred edges.
[0005] 2. Dynamic threshold-based detection methods calculate dynamic thresholds using the statistical characteristics of neighboring pixels. However, if other bad pixels exist in the neighborhood, the reference value will be contaminated; the statistics are not robust and are easily affected by outliers; and the directional characteristics of image edges are not considered.
[0006] 3. An adaptive threshold detection method based on local variance is used to calculate the variance using all 8 neighboring pixels; if there are bad pixels in the neighborhood, the variance will be abnormally amplified; the mean will also be skewed by outliers, resulting in inaccurate detection and low precision.
[0007] Therefore, there is an urgent need for a more efficient method for detecting and correcting image defects. Summary of the Invention
[0008] In view of this, this application discloses an adaptive image defect detection and correction method based on robust statistics and edge awareness, to solve the problems of statistical instability, low detection accuracy, and insufficient edge protection in existing image defect detection and correction techniques, including:
[0009] S1. Obtain the pixel P to be detected, and the set of pixels N within the neighborhood window of the pixel to be detected;
[0010] S2. Calculate the median and absolute deviation of the median of the neighborhood pixel set N, and filter out candidate bad pixels based on the median and absolute deviation of the median.
[0011] S3. Sort the neighborhood pixel set N, remove the maximum and minimum values, and obtain the truncated neighborhood pixel set;
[0012] S4. Calculate the pixel mean and variance of the truncated neighborhood pixel set, and use the variance as a robust statistic; calculate the adaptive threshold based on the robust statistic.
[0013] S5. Filter candidate bad pixels based on pixel mean and adaptive threshold to obtain a set of bad pixels;
[0014] S6. Set a gradient threshold and calculate the directional gradient information of the neighborhood of the bad point; select the largest directional gradient and compare it with the gradient threshold to determine the type of the region where the bad point is located.
[0015] S7. Differentiate correction of dead pixels based on the type of region where the dead pixel is located.
[0016] The beneficial effects of this application include:
[0017] In performing defect detection and correction, this application removes extreme values and selects more stable statistical values as the detection and correction benchmark, avoiding contamination of the statistical quantity by neighboring defective pixels, improving detection accuracy, and reducing missed detections and false detections. Through an edge-aware mechanism, an adaptive correction strategy is adopted in the edge region, which can effectively protect image edge details, avoid edge blurring, and maintain image clarity and sharpness. The test results show that the image quality after correction based on the method designed in this application is significantly better than that of traditional methods, with significant improvements in both peak signal-to-noise ratio (PSNR) and structural similarity score (SSIM). Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the adaptive image defect detection and correction method based on robust statistics and edge awareness in the embodiments of this application.
[0019] Figure 2 This is a schematic diagram of the pixel to be detected and its neighboring window pixel set in an embodiment of this application;
[0020] Figure 3 This is a schematic diagram of the input conditions for adaptive defect detection and correction in Embodiment 2 of this application;
[0021] Figure 4 This is a schematic diagram of the input conditions for adaptive defect detection and correction in Embodiment 3 of this application;
[0022] Figure 5 This is a comparison between the adaptive defect detection and correction method in this application and existing technologies. Detailed Implementation
[0023] To make the objectives, technical solutions, features, and advantages of this application clearer and to enable those skilled in the art to better understand the technical solutions of this application, the following detailed description of this application is provided in conjunction with the accompanying drawings and embodiments.
[0024] Example 1:
[0025] This embodiment includes an adaptive image defect detection and correction method based on robust statistics and edge awareness, such as... Figure 1 As shown, it includes:
[0026] S1. Obtain the pixel P to be detected, and the set of pixels N within the neighborhood window of the pixel to be detected.
[0027] For pixels located at the image boundary, if the complete neighborhood window cannot be obtained, the unobtainable neighborhood is mirrored and filled.
[0028] S2. Calculate the median and absolute deviation of the median of the neighborhood pixel set N, and filter out candidate bad pixels based on the median and absolute deviation of the median.
[0029] Specifically, if If P is a candidate for a bad pixel, then P is considered a normal pixel and no further testing is needed. This represents the preset MAD threshold coefficient, typically The range is 1.5 to 3.5.
[0030] The formula for calculating the median of the neighborhood pixel set N is: median = median(N); the formula for calculating the median absolute deviation (MAD) is: , ~ Represents the elements of the neighborhood pixel set N, such as Figure 2 As shown, if Then adopt Standard deviation replace.
[0031] S3. Sort the neighborhood pixel set N, remove the maximum and minimum values, and obtain the truncated neighborhood pixel set. .
[0032] S4. Calculate the variance of the truncated neighborhood pixel set. , as a robust statistic; and an adaptive threshold is calculated based on the robust statistic.
[0033] Specifically, based on variance The formula for calculating the adaptive threshold is:
[0034]
[0035] in, This represents the coefficient of variance, typically chosen to be between 2.0 and 3.5. This represents the variance of the truncated neighborhood pixel set. It is robust statistical information within a region based on variance representation. Indicates an adaptive threshold. This represents the minimum threshold protection value, typically selected between 0.02 and 0.10. This is used to prevent normal pixels from being mistaken for bad pixels in extremely flat areas.
[0036] S5. Filter candidate bad pixels according to the adaptive threshold to obtain a set of bad pixels. ;like If so, candidate bad pixel P is determined to be a bad pixel and added to the bad pixel set. Otherwise, it is considered normal and no further processing is required.
[0037] S6. Set a gradient threshold and calculate the neighborhood gradient information of the bad point; select the largest gradient direction and compare it with the gradient threshold to determine the type of the region where the bad point is located; the region type includes flat regions and edge regions.
[0038] The neighborhood directional gradient information includes horizontal gradient, vertical gradient, main diagonal gradient, and secondary diagonal gradient, and the calculation formula includes: Horizontal gradient: Vertical gradient: Main diagonal gradient: Secondary diagonal gradient: ; Choose the maximum gradient .in, , , , , , , , These are the left, right, top, bottom, upper left, lower right, upper right, and lower left neighboring pixels of the pixel to be detected, P.
[0039] like If it is, then it is determined to be a flat region; otherwise, it is a marginal region. This represents a preset gradient threshold, typically selected between 0.05 and 0.20. In this preferred embodiment, a threshold of 0.05 is used. .
[0040] S7. Differentiate correction of dead pixels based on the type of region where the dead pixel is located.
[0041] Specifically, for flat areas, use the pixel average. For defective pixels, correction is performed. If the defective pixel is in an edge region, the average of two pixels parallel to the edge direction is used as the correction value. For example, if the gradient is vertical, the average of two adjacent pixels in the horizontal direction is used; the same applies to the horizontal, diagonal, and sub-diagonal directions, which more effectively protects the edges. The formula for differential correction is:
[0042]
[0043] in, This represents the dead pixel correction value. This indicates that the defective pixel is located in a flat area. This indicates that the defective pixel is located in the edge region.
[0044] Furthermore, the defective pixel adaptive detection and correction method designed in this application is compared with the prior art, and the comparison results are as follows: Figure 5 As shown, PSNR represents the peak signal-to-noise ratio of the image, and SSIM represents the structural similarity of the image. It can be seen that, under the condition of a total of 39837 defective pixels, the method of this application achieves 38992 correct detections, only 133 false positives, and 845 false negatives, corresponding to a detection accuracy of 99.7%, significantly better than the comparative methods. Taking the point method as an example, the number of false positives in this application method decreased from 551 to 133 (approximately a decrease of 75.9%), and the number of false negatives decreased from 4145 to 845 (approximately a decrease of 79.6%). Compared to the dual threshold method, the number of false positives decreased from 5209 to 133 (approximately a decrease of 97.4%), and the number of false negatives decreased from 6249 to 845 (approximately a decrease of 86.5%). This indicates that the method designed in this application can effectively suppress false positives while maintaining a high detection rate, avoiding erroneous replacement of normal pixels, thereby better preserving the true edges and detailed textures of the image. In terms of image quality, the method in this application achieves the highest PSNR and SSIM (PSNR=43.69, SSIM=0.9959). Compared with the point method, PSNR is improved by approximately 0.78dB and SSIM by approximately 0.0151; compared with the variance method and the double threshold method, PSNR is improved by approximately 7.00dB and 3.93dB, respectively.
[0045] Example 2:
[0046] This embodiment includes an adaptive image defect detection and correction method based on robust statistics and edge awareness. The difference from Embodiment 1 is that, in this embodiment, the input conditions are as follows: Figure 3 As shown, the image size is 1920×1080. The pixel value range is normalized to [0,1], the detection position is [10,10], and the pixel to be detected is P=0.95.
[0047] S1. Obtain the 8 neighboring pixels of the 3×3 window, N = {0.48, 0.50, 0.52, 0.49, 0.51, 0.50, 0.48, 0.49}.
[0048] S2. Select candidate bad pixels based on the median and the absolute deviation of the median.
[0049] Calculate the median:
[0050] N_sorted = {0.48, 0.48, 0.49, 0.49, 0.50, 0.50, 0.51, 0.52}, median = (0.49 + 0.50) / 2 = 0.495.
[0051] Calculate MAD: Deviation = {|0.48-0.495|, |0.50-0.495|, ..., |0.49-0.495|} = {0.015, 0.005, 0.025, 0.005, 0.015, 0.005, 0.015, 0.005}; MAD = median {0.015,0.005, 0.025, 0.005, 0.015, 0.005, 0.015, 0.005} = 0.01.
[0052] Initial screening results: |P-median| = |0.95 - 0.495| = 0.455; K1 × MAD = 3 × 0.01 = 0.03; Since 0.455 > 0.03, P is a candidate for bad pixel and proceeds to the next step of verification.
[0053] S3. Remove extreme values, perform robust variance adaptive verification, and filter out bad points.
[0054] Remove extreme values: N_sorted = {0.48, 0.48, 0.49, 0.49, 0.50, 0.50, 0.51, 0.52}, remove the maximum and minimum values: N_trimmed = {0.48, 0.49, 0.49, 0.50, 0.50, 0.51}.
[0055] Calculate the robust statistic: μ_trimmed = (0.48 + 0.49 + 0.49 + 0.50 + 0.50 + 0.51) / 6 = 0.495.
[0056] σ 2 _trimmed = var(N_trimmed)= [(0.48-0.495) 2+ (0.49-0.495) 2 + ... +(0.51-0.495) 2 ] / 6 = 0.000108. σ_trimmed = sqrt(0.000108) = 0.0104.
[0057] Calculate the adaptive threshold: T_adaptive = max{ k2 × sqrt(σ 2 _trimmed),T_min} = max{0.026, 0.05} = 0.05.
[0058] Bad pixel confirmation: |P - μ_trimmed| = |0.95 - 0.495| = 0.455. Since 0.455 > 0.05, P is confirmed as a bad pixel.
[0059] S4. Perform gradient direction detection.
[0060] Get adjacent pixels: P_left = 0.49, P_right = 0.51, P_top = 0.50, P_bottom = 0.48, P_topleft = 0.48, P_bottomright = 0.49, P_topright = 0.52, P_bottomleft = 0.50.
[0061] Calculate the gradients: G_h = |0.49 - 0.51| = 0.02, G_v = |0.50 - 0.48| = 0.02, G_d1 = |0.48 - 0.49| = 0.01, G_d2 = |0.52 - 0.50| = 0.02.
[0062] Since G_max = 0.02 < T_gradient = 0.1, the bad pixel is determined to be in a flat region.
[0063] S5. Perform flat area correction.
[0064] In this embodiment, the area where the bad pixels are located is a flat area, so a truncated mean is used: P_corrected = μ_trimmed = 0.495. Output results: Original value: P = 0.95. Corrected value: P_corrected = 0.495.
[0065] Example 3:
[0066] This embodiment includes an adaptive image bad pixel detection and correction method based on robust statistics and edge awareness. The difference from Embodiment 2 is that this embodiment performs edge region bad pixel correction, and the input pixel to be detected is located at the image edge; the pixel value to be detected is P = 0.95, such as... Figure 4 As shown, the corresponding neighboring pixels are N = {0.10, 0.12, 0.80, 0.11, 0.82, 0.13, 0.14, 0.78}. After MAD filtering and robust variance adaptive verification, these pixels were confirmed as bad pixels.
[0067] S4. Calculate the neighborhood gradient information of the bad pixel: G_h = |0.11 - 0.82| = 0.71, G_v = |0.12 - 0.14| = 0.02, G_d1 = |0.10 - 0.78| = 0.68, G_d2 = |0.13 - 0.80| = 0.67; the largest gradient direction is the horizontal gradient, G_max = G_h = 0.71 > T_gradient = 0.1.
[0068] S5. Perform edge region correction. Since the maximum gradient is horizontal, use the average of the two pixels in the vertical direction. P_corrected = (0.12+0.14) / 2 = 0.13.
[0069] Traditional dead pixel correction methods typically use the mean value directly. If the mean value of 0.347 is used as the dead pixel correction value, the edges will become blurred. The dead pixel detection and correction method designed in this application performs adaptive region discrimination on the dead pixels, calculates an adaptive threshold based on stable neighborhood statistics, and then obtains an edge protection value of 0.13 as the correction value, which can effectively maintain the brightness characteristics of the edges.
[0070] Example 4:
[0071] This embodiment includes an adaptive image bad pixel detection and correction method based on robust statistics and edge awareness. The difference from Embodiment 1 is that when obtaining the pixel set N in the neighborhood window of the pixel to be detected in S1, the size of the neighborhood window is selected as 5×5 or 7×7. Accordingly, the neighborhood pixel set N contains 24 or 48 neighborhood pixels. The truncation operation removes the first two maximum values and the last two minimum values, or the first three maximum values and the last three minimum values.
[0072] Finally, it should be noted that the above description only depicts some embodiments of this application. For those skilled in the art, various changes, modifications, substitutions, and variations can be conceived of these embodiments without departing from the principles and spirit of this application. The scope of protection of this application is defined by the appended claims and their equivalents, and all the above-mentioned behaviors should be covered within the scope of protection of this application.
Claims
1. An adaptive image defect detection and correction method based on robust statistics and edge awareness, characterized in that, include: S1. Obtain the pixel P to be detected, and the set of pixels N within the neighborhood window of the pixel to be detected; S2. Calculate the median and absolute deviation of the median of the neighborhood pixel set N, and filter out candidate bad pixels based on the median and absolute deviation of the median. S3. Sort the neighborhood pixel set N, remove the maximum and minimum values, and obtain the truncated neighborhood pixel set; S4. Calculate the pixel mean and variance of the truncated neighborhood pixel set, and use the variance as a robust statistic; calculate the adaptive threshold based on the robust statistic. S5. Filter candidate bad pixels based on pixel mean and adaptive threshold to obtain a set of bad pixels; S6. Set the gradient threshold and calculate the neighborhood gradient information of the bad point. The largest directional gradient is compared with the gradient threshold to determine the type of region where the bad pixel is located. S7. Differentiate correction of dead pixels based on the type of region where the dead pixel is located.
2. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 1, characterized in that, The process of selecting candidate bad pixels based on the median and the absolute deviation of the median is as follows: If P is a candidate for a bad pixel, then P is a normal pixel; otherwise, P is a normal pixel. This represents the preset MAD threshold coefficient. Indicates the median. This indicates the absolute deviation of the median.
3. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 2, characterized in that, like Then adopt Standard deviation replace.
4. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 1, characterized in that, The adaptive threshold calculated based on robust statistics is calculated using the following formula: ; in, Indicates an adaptive threshold. Represents the variance coefficient. This represents the variance of the truncated neighborhood pixel set. This represents the minimum threshold protection value.
5. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 1, characterized in that, The process of filtering candidate defective pixels, if... If P is a candidate bad point, then it is determined to be a bad point; otherwise, it is a normal point. Represents the set of truncated neighborhood pixels The average pixel value, This indicates an adaptive threshold.
6. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 1, characterized in that, The neighborhood directional gradient information includes horizontal gradient, vertical gradient, main diagonal gradient, and secondary diagonal gradient.
7. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 1, characterized in that, The region types include flat regions and edge regions.
8. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 7, characterized in that, When determining the type of region where a bad pixel is located, if If it is true, it is determined to be a flat region; otherwise, it is an edge region. This represents the maximum directional gradient. This represents the gradient threshold.
9. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 8, characterized in that, The optimal value for the gradient threshold is 0.
1.
10. The adaptive image defect detection and correction method based on robust statistics and edge awareness according to claim 8, characterized in that, When performing differential correction on defective pixels based on the type of region where the defective pixel is located, if the region is flat, the pixel mean is used. Correct for bad pixels; if it is an edge region, use the average of two pixels parallel to the edge direction as the correction value, the formula is: ; in, This represents the dead pixel correction value. This indicates that the defective pixel is located in a flat area. This indicates that the defective pixel is located in the edge region.