Image bad pixel correction method, device and storage medium
By extracting strong and weak bad pixels from the image sensor, eliminating or reducing the weight parameters of weak bad pixels, and using FPGA to store and calculate the corrected pixel values, the problem of FPGA line memory resource limitation is solved, and the accuracy and efficiency of bad pixel correction are improved.
Patent Information
- Application Number
- CN202610550399.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-23
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies fail to effectively consider the limitations of field-programmable gate array (FPGA) line memory resources in image sensors, resulting in poor accuracy in bad pixel correction, especially when faced with complex bad pixel clusters, which can easily lead to misjudgment or a surge in the number of bad pixels.
By extracting strong and weak bad pixels from the image to be processed, removing or reducing the weight parameters of weak bad pixels, using a field-programmable gate array to store the list of strong bad pixels and repair types, and calculating the corrected pixel value based on the processed reference pixel value, the bottleneck of row memory resources is bypassed.
It improves the accuracy of strong bad pixel correction, reduces data pollution, avoids the limitation of row storage resources, and achieves efficient bad pixel correction.
Smart Images

Figure CN122492523A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image defect correction method, device and storage medium. Background Technology
[0002] Image sensors (such as complementary metal-oxide semiconductor (CMOS) and charge-coupled device (CCD)) will produce a certain number of dead pixels (i.e. defective pixels) during the manufacturing process. These appear as fixed bright or dark spots and will seriously affect the image quality.
[0003] Traditional defect detection typically uses a median filter with a preset-sized window. It then determines whether the difference between the original pixel value and the filtered value is greater than a threshold to identify defective pixels. After detection, it corrects the defect by averaging the neighboring pixels. However, it does not take into account the line memory resource limitations of the Field-Programmable Gate Array (FPGA) and has poor accuracy in defect correction. Summary of the Invention
[0004] To address the aforementioned technical problems, this application provides at least one method, apparatus, and storage medium for image defect correction.
[0005] The first aspect of this application provides an image defect correction method, the method comprising: acquiring an image to be processed; extracting strong defective pixels and weak defective pixels from the image to be processed, wherein the difference between strong defective pixels and surrounding pixels is greater than the difference between weak defective pixels and surrounding pixels; determining pixels adjacent to strong defective pixels to obtain initial reference pixels; removing weak defective pixels from the initial reference pixels or reducing the weight parameters of weak defective pixels in the initial reference pixels to obtain processed reference pixels corresponding to strong defective pixels; calculating corrected pixel values based on the pixel values of the processed reference pixels; and replacing the original pixel values of strong defective pixels with the corrected pixel values.
[0006] In one embodiment, extracting strong and weak bad pixels from the image to be processed includes: performing median filtering or mean filtering on the image to be processed to obtain the filtered value of the current pixel; calculating the difference between the original pixel value and the filtered value of the current pixel to obtain the pixel difference; if the pixel difference is greater than a first difference threshold, adding the current pixel as a strong bad pixel to the strong bad pixel list; if the pixel difference is greater than a second difference threshold, adding the current pixel as a weak bad pixel to the weak bad pixel list; wherein the second difference threshold is less than the first difference threshold.
[0007] In one embodiment, removing weak bad pixels from the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels includes: obtaining pixels that are adjacent to weak bad pixels but are not weak bad pixels to obtain normal reference pixels corresponding to weak bad pixels; determining weak bad pixels that are in the same position as strong bad pixels; and replacing the initial reference pixels of strong bad pixels based on the normal reference pixels corresponding to weak bad pixels in the same position to obtain the processed reference pixels corresponding to strong bad pixels.
[0008] In one embodiment, removing weak bad pixels from the initial reference pixels to obtain processed reference pixels corresponding to strong bad pixels includes: determining the initial reference pixels located at the same position as the weak bad pixels to obtain suspicious reference pixels; removing the suspicious reference pixels from each initial reference pixel to obtain processed reference pixels corresponding to strong bad pixels.
[0009] In one embodiment, reducing the weight parameter of weak bad pixels in the initial reference pixels to obtain the processed reference pixel corresponding to the strong bad pixel includes: determining the initial reference pixel at the same position as the weak bad pixel to obtain the suspicious reference pixel; determining the probability that the suspicious reference pixel belongs to the real bad pixel, determining the weight adjustment range of the suspicious reference pixel based on the probability, wherein the probability is positively correlated with the weight adjustment range; and reducing the weight parameter of the suspicious reference pixel based on the weight adjustment range to obtain the processed reference pixel corresponding to the strong bad pixel.
[0010] In one embodiment, removing weak bad pixels from the initial reference pixels or reducing the weight parameter of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels includes: determining the probability that a weak bad pixel belongs to a real bad pixel; if the probability is greater than a preset probability threshold, removing the weak bad pixels from the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels; if the probability is not greater than the preset probability threshold, reducing the weight parameter of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels.
[0011] In one embodiment, calculating the corrected pixel value based on the pixel values of the processed reference pixels includes: selecting the median of the pixel values of each processed reference pixel to obtain the corrected pixel value corresponding to the strong bad point; or, calculating the corrected pixel value corresponding to the strong bad point by performing a weighted average calculation on the pixel values of each processed reference pixel based on the weight parameters of each processed reference pixel.
[0012] In one embodiment, after obtaining initial reference pixels by acquiring pixels adjacent to the strong bad points, filtering the initial reference pixels based on the position of the weak bad points and / or adjusting the weight parameters of the initial reference pixels to obtain processed reference pixels corresponding to the strong bad points, the method further includes: constructing a list of strong bad points based on each strong bad point; marking the repair type of each strong bad point based on the processed reference pixels corresponding to the strong bad points; storing the list of strong bad points and the repair type using a field-programmable gate array (FPGA); calculating a corrected pixel value based on the pixel value of the processed reference pixels; and replacing the original pixel value of the strong bad points with the corrected pixel value. This includes: the FPGA calculating the pixel value of the processed reference pixels corresponding to the strong bad points based on the repair type of the strong bad points in the list of strong bad points to obtain the corrected pixel value, and replacing the original pixel value of the strong bad points with the corrected pixel value.
[0013] A second aspect of this application provides an image defect correction apparatus, comprising: a defect extraction module for acquiring an image to be processed and extracting strong defective pixels and weak defective pixels from the image to be processed, wherein the difference between a strong defective pixel and its surrounding pixels is greater than the difference between a weak defective pixel and its surrounding pixels; a reference pixel processing module for determining pixels adjacent to the strong defective pixels to obtain initial reference pixels, removing weak defective pixels from the initial reference pixels or reducing the weight parameters of weak defective pixels in the initial reference pixels to obtain processed reference pixels corresponding to the strong defective pixels; and a defect correction module for calculating corrected pixel values based on the pixel values of the processed reference pixels and replacing the original pixel values of the strong defective pixels with the corrected pixel values.
[0014] A third aspect of this application provides an electronic device, including a memory and a processor, wherein the processor is configured to execute program instructions stored in the memory to implement the above-described image defect correction method.
[0015] The fourth aspect of this application provides a computer-readable storage medium having program instructions stored thereon, which, when executed by a processor, implement the above-described image defect correction method.
[0016] The above scheme extracts strong and weak bad pixels from the image to be processed, determines the pixels adjacent to the strong bad pixels to obtain initial reference pixels, removes weak bad pixels from the initial reference pixels or reduces the weight parameters of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to the strong bad pixels, calculates the corrected pixel value based on the pixel value of the processed reference pixels, and replaces the original pixel value of the strong bad pixels with the corrected pixel value. It can filter or adjust the reference pixels of strong bad pixels based on weak bad pixels, reduce data pollution from unreliable pixels in the correction process, and calculate the corrected pixel value of strong bad pixels based on the pixel value of the processed reference pixels, thereby improving the accuracy of strong bad pixel correction. Moreover, weak bad pixels are only used to adjust the reference pixels of strong bad pixels and are not included in the final total number of bad pixels, thus bypassing the bottleneck of line storage resources.
[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.
[0019] Figure 1 This is a flowchart illustrating an exemplary embodiment of the image defect correction method of this application; Figure 2 This is an example diagram of neighboring pixels shown in an exemplary embodiment of this application; Figure 3 This is a schematic diagram illustrating defect correction in an exemplary embodiment of this application; Figure 4 This is a block diagram illustrating an image defect correction device according to an exemplary embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of this application; Figure 6 This is a schematic diagram illustrating the structure of a computer-readable storage medium, as shown in an exemplary embodiment of this application. Detailed Implementation
[0020] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0021] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0022] In this document, the term "and / or" is merely a description of the association information of related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of elements. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0023] Existing bad pixel detection methods do not take into account the limitations of FPGA line memory resources. When faced with complex bad pixel clusters, the reference value in the filtering window is easily contaminated by the clusters. Therefore, bad pixels in the clusters are easily misjudged as good pixels. If the difference threshold is reduced to avoid missing bad pixels, the number of bad pixels will surge. In hardware implementations such as FPGAs, the number of bad pixels is usually limited by line memory resources (e.g., no more than 2048).
[0024] The image defect correction method provided in the embodiments of this application is described below.
[0025] Please see Figure 1 , Figure 1 This is a flowchart illustrating an exemplary embodiment of an image defect correction method, which can be applied to any type of image acquisition device.
[0026] like Figure 1 As shown, the image defect correction method includes at least steps S110 to S130, which are described in detail below: Step S110: Obtain the image to be processed, and extract strong and weak bad pixels from the image to be processed. The difference between strong bad pixels and surrounding pixels is greater than the difference between weak bad pixels and surrounding pixels.
[0027] The image to be processed is usually in the original image format, i.e., RAW image. RAW image retains the sensor's most original response, which is convenient for bad pixel detection. Bad pixels refer to pixel units on the sensor that have abnormal responses.
[0028] When extracting bad pixels from an image, they are classified into strong bad pixels and weak bad pixels based on their degree of obviousness. Strong bad pixels have a greater difference from their surrounding pixels than weak bad pixels, such as abrupt white or black dots in the image. Weak bad pixels have a smaller difference from their surrounding pixels and are easily judged as random noise or edge pixels.
[0029] For example, strong and weak bad pixels can be extracted separately based on the difference threshold. For instance, the difference between the current pixel and the mean or median of its neighboring pixels can be calculated. If the difference is greater than a preset large threshold, the current pixel is determined to be a strong bad pixel; if the difference is greater than a preset small threshold, the current pixel is determined to be a weak bad pixel.
[0030] For example, strong and weak bad pixels can also be extracted based on pixel gradients. For instance, the gradient between the current pixel and its neighboring pixels can be calculated, and the gradient between neighboring pixels can be calculated. If the number of current pixel gradients greater than a preset value exceeds a preset large threshold, or the difference between the current pixel gradient and the gradient of its neighboring pixels exceeds a preset large threshold, then the current pixel is determined to be a strong bad pixel. If the number of current pixel gradients greater than a preset value exceeds a preset small threshold, or the difference between the current pixel gradient and the gradient of its neighboring pixels exceeds a preset small threshold, then the current pixel is determined to be a weak bad pixel.
[0031] Of course, in addition to the bad pixel extraction methods in the examples above, other methods can be used to extract bad pixels, such as extracting strong bad pixels and weak bad pixels based on a pre-learned neural network model. This application does not limit this method.
[0032] Step S120: Determine the pixels adjacent to the strong bad pixels to obtain the initial reference pixels, remove the weak bad pixels in the initial reference pixels or reduce the weight parameters of the weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to the strong bad pixels.
[0033] Obtain the pixels adjacent to the strong bad point to get the initial reference pixel corresponding to the strong bad point.
[0034] For example, please see Figure 2 , Figure 2 This is an example diagram of neighboring pixels shown in an exemplary embodiment of this application, such as... Figure 2 As shown, for the current pixel (i.e., the center pixel), select the 10 pixels closest to the current pixel and the pixels adjacent to the current pixel.
[0035] certainly, Figure 2 This is merely an illustrative example. In actual applications, more or fewer pixels can be selected, such as selecting only the 8 nearest pixels. This application does not limit this selection.
[0036] If strong bad pixels are directly corrected using the initial reference pixels, pixel values may be contaminated due to some unidentified or inconspicuous bad pixels in the initial reference pixels. Therefore, this application additionally identifies weak bad pixels. Weak bad pixels may be real bad pixels, or they may be random noise, edges, etc. in the image. For weak bad pixels contained in the initial reference pixels of strong bad pixels, they are directly removed or their weight is reduced to obtain processed reference pixels, so as to reduce the negative impact of weak bad pixels with questionable pixel values and improve the correction accuracy of strong bad pixels.
[0037] Step S130: Calculate the corrected pixel value based on the pixel value of the processed reference pixel, and replace the original pixel value of the strong bad pixel with the corrected pixel value.
[0038] Calculate the corrected pixel value corresponding to the strong bad pixel based on the pixel value of the reference pixel after processing.
[0039] For example, determine the median of the pixel values of the reference pixel after processing, and use the median as the corrected pixel value.
[0040] For example, calculate the average pixel value of the reference pixel after processing, and use the average value as the corrected pixel value.
[0041] Then, the original pixel values of the strong bad pixels are replaced with the corrected pixel values to achieve the correction of the strong bad pixels.
[0042] By filtering or weighting the reference pixels of strong bad pixels based on weak bad pixels, processed pixels are obtained. The corrected pixel values of strong bad pixels are then calculated based on the pixel values of the processed reference pixels, improving the accuracy of strong bad pixel correction. Furthermore, weak bad pixels are only used to adjust the reference pixels of strong bad pixels and are not included in the final total number of bad pixels, thus bypassing the bottleneck of line storage resources.
[0043] The following describes some embodiments of this application in detail.
[0044] In some implementations, step S110 extracts strong and weak bad pixels in the image to be processed, including steps S111 to S115 below.
[0045] Step S111: Perform median filtering or mean filtering on the image to be processed to obtain the filtered value of the current pixel.
[0046] The window size selected for median filtering or mean filtering can be 3×3 and / or 5×5, depending on the actual application scenario. This application does not impose any restrictions on this.
[0047] By using median filtering or mean filtering, a smoothed image can be obtained. The pixel value at the current pixel position in the smoothed image can then be obtained as the filtered value.
[0048] Step S112: Calculate the difference between the original pixel value and the filtered value of the current pixel to obtain the pixel difference.
[0049] The pixel difference is obtained by calculating the difference between the original pixel value and the filtered value of the current pixel in the image to be processed.
[0050] Defective pixels are typically extremely isolated pixels whose pixel values differ significantly from the median or mean of their neighborhood. The location of a defective pixel is determined by calculating the difference between the original pixel value and the filtered value, and the location of the defective pixel will produce a significant residual.
[0051] Step S113: If the pixel difference is greater than the first difference threshold, then proceed to step S114; if the pixel difference is greater than the second difference threshold, then proceed to step S115, wherein the second difference threshold is less than the first difference threshold.
[0052] The first difference threshold Thresh1 is greater than the second difference threshold Thresh2.
[0053] Thresh2 can be dynamically adjusted according to the characteristics of the sensor (e.g., by 3 to 5).
[0054] Step S114: Add the current pixel as a strong bad pixel to the strong bad pixel list.
[0055] Pixels with a pixel difference greater than Thresh1 are extracted and added to the strong bad pixel list BP1 as strong bad pixels. In addition to storing the pixel coordinates of the strong bad pixels, the strong bad pixel list BP1 can also store the pixel coordinates of the initial reference pixel of the strong bad pixels.
[0056] Optionally, to facilitate the description of the initial reference pixel's position, pixels with different positional relationships to the defective pixel are treated as different repair types. For example, see [link to previous section]. Figure 2 The left pixel of the current pixel is designated as type1, the right pixel as type2, the top pixel as type3, the bottom pixel as type4, and so on. Different repair types are assigned to different positions. The positional relationship between the initial reference pixel and the current bad pixel is known through the repair type, thereby determining the specific pixel coordinates of the initial reference pixel.
[0057] Step S115: Add the current pixel as a weak defect to the weak defect list.
[0058] Extract pixels whose pixel difference is greater than Thresh2 and add them as weak bad pixels to the weak bad pixel list BP2.
[0059] It should be noted that when pixels with a pixel difference greater than Thresh2 are directly selected as weak bad pixels, strong bad pixels are included among the weak bad pixels; however, if pixels with a pixel difference greater than Thresh2 and less than Thresh1 are selected as weak bad pixels, then strong bad pixels are not included among the weak bad pixels. The specific selection method can be determined according to the actual application scenario, and this application does not limit it.
[0060] Then, the pixels adjacent to the strong bad pixels are determined to obtain the initial reference pixels. The weak bad pixels in the initial reference pixels are removed or the weight parameters of the weak bad pixels in the initial reference pixels are reduced to obtain the processed reference pixels corresponding to the strong bad pixels.
[0061] An example is provided to illustrate an embodiment of removing weak dead pixels from the initial reference pixels in step S120: Example 1: If weak bad pixels contain strong bad pixels, then the weak bad pixels in the initial reference pixels are removed to obtain the processed reference pixels corresponding to the strong bad pixels. This includes: obtaining pixels that are adjacent to the weak bad pixels but are not weak bad pixels to obtain the normal reference pixels corresponding to the weak bad pixels; determining the weak bad pixels that are in the same position as the strong bad pixels; and replacing the initial reference pixels of the strong bad pixels based on the normal reference pixels corresponding to the weak bad pixels in the same position to obtain the processed reference pixels corresponding to the strong bad pixels.
[0062] Referring to the aforementioned embodiment, after obtaining the weak bad point list BP2, BP2 contains the strong bad points in the strong bad point list BP1 and the added weak bad points.
[0063] Obtain the pixels that are adjacent to the weak defective pixel but are not the weak defective pixel, and obtain the normal reference pixel corresponding to the weak defective pixel. In addition to storing the pixel coordinates of the weak defective pixel, BP2 can also further store the pixel coordinates of the normal reference pixel of the weak defective pixel. Similarly, the pixel position can be represented by the repair type.
[0064] For examples, please refer to Figure 2 In the Figure 2 When extracting bad pixels, if the current pixel is detected as a strong bad pixel, the initial reference pixels adjacent to the strong bad pixel include type1-type10. If the current pixel is directly corrected using the initial reference pixels, some bad pixels in type1-type10 may not be detected, affecting the correction accuracy. Therefore, weak bad pixel detection is further performed. If the current pixel, type1, type2, and type3 are detected as weak bad pixels, pixels adjacent to the current pixel that are not weak bad pixels are obtained. The resulting normal reference pixels include type4-type10. It is determined that the current pixel is simultaneously identified as a strong bad pixel and a weak bad pixel at the same location. Therefore, the normal reference pixels type4-type10 obtained by identifying the current pixel as a weak bad pixel are used to replace the initial reference pixels type1-type10 identified as strong bad pixels. The final processed reference pixels are type4-type10. Weak bad pixels with low reliability are removed to ensure the accuracy of subsequent correction value calculations.
[0065] Example 2, removing weak bad pixels from the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels, includes: determining the initial reference pixels that are in the same position as the weak bad pixels to obtain suspicious reference pixels; removing the suspicious reference pixels from each initial reference pixel to obtain the processed reference pixels corresponding to the strong bad pixels.
[0066] Initial reference pixels that are located in the same position as weak or defective pixels can be directly removed, while high-reliability initial reference pixels are retained as processed reference pixels.
[0067] An example is provided to illustrate an implementation of reducing the weight parameters of weak bad pixels in the initial reference pixels in step S120: Example 3, reducing the weight parameter of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels, includes: determining the initial reference pixels at the same position as the weak bad pixels to obtain suspicious reference pixels; determining the probability that the suspicious reference pixels belong to real bad pixels, determining the weight adjustment range of the suspicious reference pixels based on the probability, the probability being positively correlated with the weight adjustment range; and reducing the weight parameter of the suspicious reference pixels based on the weight adjustment range to obtain the processed reference pixels corresponding to strong bad pixels.
[0068] For example, the probability that a suspicious reference pixel belongs to a real bad pixel can be determined based on the degree of difference between the suspicious reference pixel and its surrounding pixels; the greater the difference, the higher the probability, and the smaller the difference, the lower the probability. And / or, based on the number of times a pixel at the same location is identified as a weak bad pixel in multiple images, the more times it is identified, the higher the probability that the pixel at that location belongs to a real bad pixel, and vice versa. Of course, the probability that a suspicious reference pixel belongs to a real bad pixel can also be identified based on a pre-trained neural network model; this application does not limit this approach.
[0069] Let's take the difference between a suspicious reference pixel and its surrounding pixels as an example: The difference between a suspicious reference pixel and its surrounding pixels can be the difference between the suspicious reference pixel and the median or mean of the surrounding pixels, and the calculation results from bad pixel detection can be directly reused. Based on the difference between the suspicious reference pixel and its surrounding pixels, the weight adjustment range of the suspicious reference pixel is determined. Specifically, the greater the difference between the suspicious reference pixel and its surrounding pixels, the greater the probability that it is a real bad pixel, and therefore the greater the weight adjustment range of the suspicious reference pixel, i.e., the smaller the weight parameter of the suspicious reference pixel after reduction; conversely, the smaller the difference between the suspicious reference pixel and its surrounding pixels, the smaller the probability that it is a real bad pixel, and therefore the smaller the weight adjustment range of the suspicious reference pixel, i.e., the larger the weight parameter of the suspicious reference pixel after reduction.
[0070] Example 4: Reducing the weight parameter of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels includes: determining the initial reference pixels that are in the same position as the weak bad pixels to obtain the suspicious reference pixels; changing the weight parameter of the suspicious reference pixels to the preset minimum weight to obtain the processed reference pixels corresponding to the strong bad pixels.
[0071] For example, there are 10 initial reference pixels, and each initial reference pixel is pre-assigned a weight parameter of 0.1. For suspicious reference pixels among the initial reference pixels, the weight parameter of the suspicious reference pixels is directly changed to the preset minimum weight of 0.05.
[0072] Of course, in order to ensure the normalization of the weight parameters, in the above embodiments, when reducing the weight parameters of suspicious reference pixels, the weight parameters of other initial reference pixels are increased accordingly.
[0073] In some implementations, it is also possible to flexibly determine, based on the actual application, whether to remove weak bad pixels from the initial reference pixels or to reduce the weight parameters of weak bad pixels in the initial reference pixels.
[0074] For example, step S120, which involves removing weak bad pixels from the initial reference pixels or reducing the weight parameters of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels, includes: determining the probability that a weak bad pixel belongs to a real bad pixel; if the probability is greater than a preset probability threshold, removing the weak bad pixels from the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels; if the probability is not greater than the preset probability threshold, reducing the weight parameters of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to strong bad pixels.
[0075] Similar to the method used in the previous embodiments to determine the probability that a suspicious reference pixel belongs to a real bad pixel, the probability that each weak bad pixel belongs to a real bad pixel is determined.
[0076] If the probability that a weak bad pixel belongs to a real bad pixel is greater than a preset probability threshold, then the weak bad pixel in the initial reference pixel is directly removed; if the probability that a weak bad pixel belongs to a real bad pixel is not greater than the preset probability threshold, then the weight parameter of the weak bad pixel in the initial reference pixel is reduced.
[0077] In addition to the examples above, we can also count the number of weak bad pixels in the initial reference pixels of strong bad pixels. If the number of weak bad pixels exceeds a preset threshold, then the weak bad pixels in the initial reference pixels are directly removed. If the number of weak bad pixels does not exceed the preset threshold, then the weight parameter of the weak bad pixels in the initial reference pixels is reduced. Alternatively, we can count the number of weak bad pixels in the initial reference pixels of strong bad pixels whose probability of being a real bad pixel is greater than a preset probability threshold. Similarly, if the number of weak bad pixels exceeds the preset threshold, then the weak bad pixels in the initial reference pixels whose probability of being a real bad pixel is greater than the preset probability threshold are directly removed. If the number of weak bad pixels does not exceed the preset threshold, then the weight parameter of the weak bad pixels in the initial reference pixels whose probability of being a real bad pixel is greater than the preset probability threshold is reduced.
[0078] Then, for each strong bad pixel after processing the reference pixel, the corrected pixel value corresponding to each strong bad pixel is calculated.
[0079] In some embodiments, calculating the corrected pixel value based on the pixel values of the processed reference pixels in step S130 includes: selecting the median of the pixel values of each processed reference pixel to obtain the corrected pixel value corresponding to the strong defective pixel; or, performing a weighted average calculation on the pixel values of each processed reference pixel based on the weight parameters of each processed reference pixel to obtain the corrected pixel value corresponding to the strong defective pixel.
[0080] If weak defective pixels in the initial reference pixels are removed, the median of the pixel values of the processed reference pixels can be selected, or the average value of the pixel values of the processed reference pixels can be calculated to obtain the corrected pixel value corresponding to the strong defective pixel.
[0081] If the weight parameters of the weak defective pixels in the initial reference pixels are reduced, a weighted average calculation is performed on the pixel values of each processed reference pixel based on the weight parameters of each processed reference pixel to obtain the corrected pixel value corresponding to the strong defective pixel.
[0082] Then, the original pixel value of the strong defective pixel is replaced with the corrected pixel value to obtain the corrected image.
[0083] Taking a specific application scenario as an example for illustration, please refer to Figure 3 , Figure 3 is a schematic diagram of defective pixel correction shown in an exemplary embodiment of the present application. As shown in Figure 3 , through a software algorithm, defective pixel detection and reference pixel analysis are performed. A list of strong defective pixels is constructed based on each strong defective pixel, and the repair type of each strong defective pixel is marked based on the processed reference pixel corresponding to the strong defective pixel. Then, a field-programmable gate array (FPGA) stores the list of strong defective pixels and the repair type. The FPGA calculates the pixel value of the processed reference pixel corresponding to the strong defective pixel based on the repair type of the strong defective pixel in the list of strong defective pixels to obtain the corrected pixel value, replaces the original pixel value of the strong defective pixel with the corrected pixel value, and outputs the corrected image.
[0084] [ For example, as shown in Figure 3 , first, defective pixel detection is performed with Thresh1 to generate a list of strong defective pixels BP1; then, the threshold is switched to Thresh2, and defective pixel detection is performed again to generate a list of weak defective pixels BP2. The specific generation method is as described in the foregoing embodiments; each strong defective pixel in the BP1 list is traversed to determine the weak defective pixel at the same position as the strong defective pixel, and the repair type of the strong defective pixel is updated based on the repair type of the weak defective pixel at the same position to form the final BP1' list. The total number of strong defective pixels in the BP1' list is the same as the total number of strong defective pixels in the BP list; the FPGA performs defective pixel correction on BP1'. After repair, only a few weak defective pixels remain, avoiding the appearance of a "square" structure after repairing a cluster of defective pixels.
[0085] By pre-detecting bad pixels and analyzing reference pixels through software algorithms, the FPGA only needs to correct bad pixel values, and only strong bad pixels need to be corrected, thus reducing the FPGA's resource consumption.
[0086] Figure 4 This is a block diagram illustrating an image defect correction device according to an exemplary embodiment of this application. Figure 4 As shown, the exemplary image defect correction device 400 includes: The defective pixel extraction module 410 is used to acquire the image to be processed and extract strong and weak defective pixels in the image to be processed. The difference between strong defective pixels and surrounding pixels is greater than the difference between weak defective pixels and surrounding pixels. The reference pixel processing module 420 is used to determine the pixels adjacent to the strong bad points to obtain the initial reference pixels, remove the weak bad points in the initial reference pixels or reduce the weight parameters of the weak bad points in the initial reference pixels to obtain the processed reference pixels corresponding to the strong bad points. The bad pixel correction module 430 is used to calculate the corrected pixel value based on the pixel value of the processed reference pixel, and replace the original pixel value of the strong bad pixel with the corrected pixel value.
[0087] It should be noted that the image defect correction device and the image defect correction method provided in the above embodiments belong to the same concept. The specific operation methods of each module and unit have been described in detail in the method embodiments and will not be repeated here. In practical applications, the image defect correction device provided in the above embodiments can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. This is not a limitation here.
[0088] Please see Figure 5 , Figure 5 This is a schematic diagram illustrating the structure of an electronic device according to an exemplary embodiment of this application. The electronic device 500 includes a memory 510 and a processor 520. The processor 520 executes program instructions stored in the memory 510 to implement the steps in any of the above-described embodiments of the image defect correction method. In a specific implementation scenario, the electronic device 500 may include, but is not limited to, a microcomputer or a server. Furthermore, the electronic device 500 may also include mobile devices such as laptops and tablets, without limitation.
[0089] Specifically, processor 520 controls itself and memory 510 to implement the steps in any of the above-described image defect correction method embodiments. Processor 520 can also be referred to as a Central Processing Unit (CPU). Processor 520 may be an integrated circuit chip with signal processing capabilities. Processor 520 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 520 can be implemented using integrated circuit chips.
[0090] Please see Figure 6 , Figure 6 This is a schematic diagram illustrating the structure of a computer-readable storage medium in an exemplary embodiment of this application. The computer-readable storage medium 600 stores program instructions 610 that can be executed by a processor. The program instructions 610 are used to implement the steps in any of the above-described embodiments of the image defect correction method.
[0091] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0092] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0093] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0094] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. If the integrated unit is implemented as 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 this application, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. An image bad pixel correction method, characterized by, The method includes: Acquire an image to be processed, and extract strong and weak bad pixels from the image to be processed, wherein the difference between the strong bad pixel and the surrounding pixels is greater than the difference between the weak bad pixel and the surrounding pixels. Pixels adjacent to the strong bad point are identified to obtain an initial reference pixel. Weak bad points in the initial reference pixel are removed or the weight parameters of weak bad points in the initial reference pixel are reduced to obtain the processed reference pixel corresponding to the strong bad point. The corrected pixel value is calculated based on the pixel value of the processed reference pixel, and the original pixel value of the strong bad pixel is replaced with the corrected pixel value.
2. The method of claim 1, wherein, The extraction of strong and weak bad pixels from the image to be processed includes: The image to be processed is subjected to median filtering or mean filtering to obtain the filtered value of the current pixel; Calculate the difference between the original pixel value and the filtered value of the current pixel to obtain the pixel difference; If the pixel difference is greater than the first difference threshold, then the current pixel is added as a strong bad pixel to the strong bad pixel list; If the pixel difference is greater than the second difference threshold, then the current pixel is added to the weak bad pixel list as a weak bad pixel; wherein the second difference threshold is less than the first difference threshold.
3. The method of claim 2, wherein, Removing weak bad pixels from the initial reference pixels to obtain the processed reference pixels corresponding to the strong bad pixels includes: Obtain the pixels that are adjacent to the weak defective pixel but are not weak defective pixels, and obtain the normal reference pixels corresponding to the weak defective pixel; Identify weak bad pixels that are in the same position as the strong bad pixels. Based on the normal reference pixels corresponding to the weak bad pixels in the same position, replace the initial reference pixels of the strong bad pixels to obtain the processed reference pixels corresponding to the strong bad pixels.
4. The method of claim 1, wherein, Removing weak bad pixels from the initial reference pixels to obtain the processed reference pixels corresponding to the strong bad pixels includes: An initial reference pixel located at the same position as the weak defective pixel is determined to obtain a suspicious reference pixel; By removing suspicious reference pixels from each of the initial reference pixels, the processed reference pixels corresponding to the strong bad pixels are obtained.
5. The method of claim 1, wherein, Reducing the weight parameters of weak defects in the initial reference pixels to obtain the processed reference pixels corresponding to the strong defects includes: An initial reference pixel located at the same position as the weak defective pixel is determined to obtain a suspicious reference pixel; Determine the probability that the suspicious reference pixel belongs to a real bad pixel, and determine the weight adjustment range of the suspicious reference pixel based on the probability, wherein the probability is positively correlated with the weight adjustment range; Based on the weight adjustment range, the weight parameters of the suspicious reference pixels are reduced to obtain the processed reference pixels corresponding to the strong bad pixels.
6. The method according to claim 1, characterized in that, The step of removing weak bad pixels from the initial reference pixels or reducing the weight parameters of weak bad pixels in the initial reference pixels to obtain the processed reference pixels corresponding to the strong bad pixels includes: Determine the probability that the weak defective pixel belongs to a true defective pixel; If the probability is greater than a preset probability threshold, then weak bad pixels in the initial reference pixels are removed to obtain the processed reference pixels corresponding to the strong bad pixels. If the probability is not greater than the preset probability threshold, then the weight parameter of the weak bad pixels in the initial reference pixels is reduced to obtain the processed reference pixels corresponding to the strong bad pixels.
7. The method according to claim 1, characterized in that, The calculation of the corrected pixel value based on the pixel value of the processed reference pixel includes: The median of the pixel values of each of the processed reference pixels is selected to obtain the corrected pixel value corresponding to the strong bad point. Alternatively, based on the weight parameters of each of the processed reference pixels, a weighted average is calculated on the pixel values of each of the processed reference pixels to obtain the corrected pixel value corresponding to the strong bad pixel.
8. The method according to any one of claims 1 to 7, characterized in that, After obtaining initial reference pixels by acquiring pixels adjacent to the strong bad point, filtering the initial reference pixels based on the position of the weak bad point, and / or adjusting the weight parameters of the initial reference pixels to obtain the processed reference pixels corresponding to the strong bad point, the method further includes: A list of strong bad pixels is constructed based on each of the strong bad pixels, and the repair type of each strong bad pixel is marked based on the processed reference pixel corresponding to the strong bad pixel. The list of major bad pixels and the repair type are stored using a field-programmable gate array (FPGA). The step of calculating the corrected pixel value based on the pixel value of the processed reference pixel, and replacing the original pixel value of the strong bad pixel with the corrected pixel value, includes: The field-programmable gate array (FPGA) calculates the pixel value of the processed reference pixel corresponding to the strong bad pixel based on the repair type of the strong bad pixel in the strong bad pixel list, obtains the corrected pixel value, and replaces the original pixel value of the strong bad pixel with the corrected pixel value.
9. An electronic device, comprising: The electronic device includes a memory and a processor, the processor being configured to execute program instructions stored in the memory to implement the steps of the method as described in any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions that can be executed by a processor to implement the steps of the method as described in any one of claims 1-8.