Pixel value acquisition method and image sensor
By constructing the Bayer pixel matrix and performing prejudgment and edge judgment, the accuracy of bad point determination and correction in the image sensor is solved, and the accuracy of pixel values and the retention of image edge details are improved.
Patent Information
- Application Number
- CN202411673518.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-11
AI Technical Summary
In the image sensor, the pixel values incorrectly caused by production process defects or optical signal conversion errors form bad points, and the number of bad points increases with time and environment, resulting in damage to image clarity and integrity. At the same time, the traditional bad point correction method does not retain enough image edge details, and the corrected pixel values are not accurate enough.
By constructing a Bayer pixel matrix, prejudgment and edge judgment are made based on the pixel values and preset number of bad points in the same color and non-same color pixel groups, to determine whether the pixel point to be processed is an edge pixel point or a bad point, and to perform corresponding correction processing.
It effectively solves the problems of missed detection and missed detection in pixel point determination, improves the accuracy of bad point correction, especially in the retention of image edge details, ensuring the accuracy of pixel values.
Smart Images

Figure CN119603569A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electronic circuits, and in particular relates to a method for acquiring pixel values and an image sensor. Background Art
[0002] When the light signal collected by each pixel of the image sensor is converted into an electrical signal through photoelectric conversion, due to defects in the manufacturing process of the image sensor or errors in the process of converting the light signal into an electrical signal, the final pixel value obtained will be inaccurate, forming defective pixels, that is, bad pixels. And with the influence of the use time and use environment of the image sensor, the clarity and integrity of the image will be affected, further increasing the number of bad pixels.
[0003] When determining whether a pixel is a bad pixel, if only the pixel value of the pixel is compared with the pixel value of the same color pixel in the construction window, it is determined whether the pixel is a bad pixel. When continuous bad pixels appear in the window, there is a possibility of missed judgment. If the maximum and minimum values of the same color pixels in the construction window are removed, and then the pixel is determined to be a bad pixel, misjudgment may occur, resulting in image distortion. In addition, when there are bad pixels in the image sensor, the image signal processing (ISP) will affect the pixel values of the surrounding pixels when performing difference and filtering processing, so it is necessary to correct it before the image signal processing. However, the traditional correction method does not retain enough details of the bad pixels on the edge of the image, and the corrected pixel values are not accurate enough. Summary of the invention
[0004] The object of the present invention is to provide a method for obtaining pixel values and an image sensor, which can solve the problems of missed detection and wrong detection when determining pixel points, and inaccurate correction of bad pixels.
[0005] To achieve the above object, the present invention provides a method for obtaining pixel values, which at least comprises the following steps:
[0006] Acquire the original image captured by the image sensor;
[0007] Construct a Bayer pixel matrix with the pixel to be processed as the center;
[0008] Pre-judgment of the pixel to be processed is performed based on the pixel values of the pixels in the same color pixel group where the pixel to be processed is located and the number of preset bad pixels;
[0009] Determining whether the pixel to be processed is an edge pixel according to the number of preset bad pixels in the non-same-color pixel group or the number and position of preset bad pixels in the same-color pixel group; and
[0010] If the pixel point to be processed is an edge pixel point, the pixel value is obtained according to the pixel point to be processed; if the pixel point to be processed is a bad pixel, the pixel value of the pixel point to be processed is corrected.
[0011] In one embodiment of the present invention, the Bayer pixel matrix includes pixels of multiple colors, the pixels of multiple colors form a 5x5 pixel matrix, and the pixel to be processed is located at the center of the Bayer pixel matrix.
[0012] In one embodiment of the present invention, pre-judging the pixel to be processed includes the following steps:
[0013] Obtain two median pixels from the other pixels in the same-color pixel group except the pixel to be processed, and obtain a first median absolute difference of pixel values and a first mean value of pixel values of the two median pixels;
[0014] Determine whether the first median absolute difference between the pixel values of the two median pixels is less than an edge threshold; if the first median absolute difference between the pixel values of the two median pixels is greater than or equal to the edge threshold, determine that the pixel to be processed is an edge pixel.
[0015] In one embodiment of the present invention, if the first median absolute difference between the pixel values of the two median pixels is less than the edge threshold, the pixel value of the pixel to be processed is subtracted from the first mean of the pixel values of the two median pixels as the first mean absolute difference;
[0016] Determine whether the pixel to be processed is a preset bad pixel according to the relationship between the first mean absolute difference and the bright bad pixel threshold and the dark bad pixel threshold, and the relationship between the pixel value of the pixel to be processed and the first mean of the pixel values of the two median pixels;
[0017] If the pixel value of the pixel to be processed is greater than the first mean of the pixel values of the two median pixels and the first mean absolute difference is greater than the bright bad pixel threshold, or the pixel value of the pixel to be processed is less than the first mean of the pixel values of the two median pixels and the first mean absolute difference is greater than the dark bad pixel threshold, then the pixel to be processed is a preset bad pixel;
[0018] When the pixel to be processed is not the preset bad pixel, it is determined that the pixel to be processed is the edge pixel.
[0019] In one embodiment of the present invention, when the pixel to be processed is not the preset bad pixel, it is determined whether other pixels in the same-color pixel group are preset bad pixels, and the number of the preset bad pixels in the same-color pixel group is obtained;
[0020] Determine whether the number of the preset bad pixels in the same-color pixel group is less than a first preset threshold value. If the number of the preset bad pixels in the same-color pixel group is less than the first preset threshold value, perform secondary edge judgment on the pixel to be processed. If the number of the preset bad pixels in the same-color pixel group is greater than or equal to the first preset threshold value, determine that the pixel to be processed is the edge pixel point.
[0021] In one embodiment of the present invention, judging whether the pixel to be processed is an edge pixel according to the number of preset bad pixels in the non-same-color pixel group or the number and position of preset bad pixels in the same-color pixel group includes the following steps:
[0022] Determine whether a pixel point in each other non-same-color pixel group is an edge pixel point according to the edge threshold;
[0023] Determine whether there is a pixel point in each of the other non-same-color pixel groups that is the edge pixel point. If there is a pixel point in the other non-same-color pixel groups that is the edge pixel point, determine that the pixel point to be processed is an edge pixel point; if there is no pixel point in the other non-same-color pixel groups that is the edge pixel point, obtain the number and position of preset bad pixels in each of the other non-same-color pixel groups, and obtain the total number and position of all the preset bad pixels in the other non-same-color pixel groups, and determine whether the pixel point to be processed is a bad pixel based on the total number of all the preset bad pixels in the other non-same-color pixel groups and the number and position of the preset bad pixels in the same-color pixel group.
[0024] In one embodiment of the present invention, determining whether a pixel point in each other non-same-color pixel group is an edge pixel point according to an edge threshold comprises the following steps:
[0025] In each other non-same-color pixel group, two median pixel points of the plurality of pixel points are obtained, and the median absolute difference of the pixel values of the two median pixel points and the mean pixel value are obtained;
[0026] It is determined whether the median absolute difference of the pixel values of the two median pixels in each other non-same-color pixel group is less than the edge threshold. If the median absolute difference of the pixel values of the two median pixels is greater than or equal to the edge threshold, the pixel in the corresponding non-same-color pixel group is determined to be an edge pixel. If the median absolute difference of the pixel values of the two median pixels is less than the edge threshold, the re-determination process is entered.
[0027] In one embodiment of the present invention, obtaining the number and position of the preset bad pixels in each other non-same-color pixel group includes the following steps:
[0028] In each of the non-same-color pixel groups, the pixel value of each pixel point is subtracted from the average of the pixel values of the two median pixels to obtain the average absolute difference; and
[0029] According to the relationship between the average absolute difference of each pixel to be verified in each of the non-same-color pixel groups and the bright bad pixel threshold and the dark bad pixel threshold, and the relationship between the pixel value of each pixel and the average of the pixel values of the two median pixels, it is determined whether each pixel is a preset bad pixel.
[0030] In one embodiment of the present invention, judging whether the pixel to be processed is a bad pixel according to the total number of all the preset bad pixels in other non-same-color pixel groups and the number and position of the preset bad pixels in the same-color pixel group includes the following steps:
[0031] Determine whether the total number of all preset bad pixels in the other pixel groups is less than a second preset threshold value, and if the total number of all preset bad pixels in the other pixel groups is greater than or equal to the second preset threshold value, determine that the pixel to be processed is the edge pixel point;
[0032] If the total number of all preset bad pixels in the other pixel groups is less than the second preset threshold, then it is determined whether the pixel to be processed is the preset bad pixel based on the number and position of the preset bad pixels in the same-color pixel group.
[0033] In one embodiment of the present invention, when there is no preset bad pixel in the same-color pixel group, it is determined whether two preset bad pixels appear in the same direction between the adjacent pixels of the pixel to be processed. If two preset bad pixels appear in the same direction between the adjacent pixels of the pixel to be processed, the pixel to be processed is determined to be the edge pixel. If two preset bad pixels do not appear in the same direction between the adjacent pixels of the pixel to be processed, the pixel to be processed is determined to be a bad pixel.
[0034] When there is a preset bad pixel in the same-color pixel group, determine whether the preset bad pixels appear in the same direction between the pixel to be processed and the adjacent pixel points of the preset bad pixel of the same color; if the preset bad pixels appear in the same direction between the pixel to be processed and the adjacent pixel points of the preset bad pixel of the same color, determine that the pixel to be processed is the edge pixel; if the preset bad pixels do not appear in the same direction between the pixel to be processed and the adjacent pixel points of the preset bad pixel of the same color, determine that the pixel to be processed is a bad pixel;
[0035] When there are two preset bad pixels in the same-color pixel group, determine whether the two preset bad pixels of the same color of the pixel to be processed are located in the same direction, or whether the two preset bad pixels of the same color are located in the same half area. When the two preset bad pixels of the same color of the pixel to be processed are located in the same direction, or the two preset bad pixels of the same color are located in the same half area, the pixel to be processed is determined to be the edge pixel. If the two preset bad pixels of the same color of the pixel to be processed are located in different directions, or the two preset bad pixels of the same color are located in different half areas, the pixel to be processed is determined to be a bad pixel.
[0036] In one embodiment of the present invention, correcting the pixel value of the pixel to be processed includes the following steps:
[0037] Correcting the same-color bad pixels in the same-color pixel group except the pixel to be processed; and
[0038] Correct the pixel to be processed.
[0039] In one embodiment of the present invention, when correcting the same-color bad pixels in the same-color pixel group except the pixel to be processed, the correction value of the same-color bad pixel is obtained according to the pixel value of the same-color pixel in the horizontal and / or numerical gradient direction of the same-color bad pixel.
[0040] In one embodiment of the present invention, correcting the pixel to be processed includes the following steps:
[0041] First, the correction direction of the pixel to be processed is obtained, and the correction direction is obtained by the following formula: G = Gx / Gy, and
[0042] Among them, Gx is the gradient in the horizontal direction, Gy is the gradient in the vertical direction, P11 is the pixel value of pixel point P11, P13 is the pixel value of pixel point P13, P15 is the pixel value of pixel point P15, P31 is the pixel value of pixel point P31, P33 is the pixel value of pixel point P33, P35 is the pixel value of pixel point P35, P51 is the pixel value of pixel point P51, P53 is the pixel value of pixel point P53, and P55 is the pixel value of pixel point P55.
[0043] In one embodiment of the present invention, correcting the pixel to be processed further includes the following steps:
[0044] A first intersection point and a second intersection point of the gradient direction and the Bayer pixel matrix are obtained to obtain a correction value of the pixel to be processed according to the pixel values of the first intersection point and the second intersection point, and the correction value of the pixel to be processed is:
[0045] P33_correct = (PP + PQ) / 2; and
[0046] PP=P13×(1 / G)+P15×(1-1 / G);
[0047] PQ=P53×(1 / G)+P51×(1-1 / G);
[0048] Among them, PP is the pixel value of the first intersection, PQ is the pixel value of the second intersection, and 1 / G is the ordinate of the first intersection and the abscissa of the second intersection.
[0049] The present invention also provides an image sensor, using any one of the above pixel value acquisition methods to correct the pixel points in the image sensor
[0050] In summary, the present invention provides a method for obtaining pixel values and an image sensor. With the pixel to be processed as the center, a 5x5 Bayer pixel matrix is constructed, and double edge judgment is performed on edge pixels with strong correlation. Even if multiple consecutive bad pixels appear, it is possible to detect whether the pixel to be processed is a real bad pixel, not a pixel located at the edge of the image. After determining that the point to be processed is a bad pixel, other bad pixels of the same color are interpolated and calculated based on the number and position of bad pixels in the neighborhood, and then the gradient direction of the pixel to be processed is obtained, and the target pixel value is obtained by interpolation calculation based on the gradient direction, which can effectively retain edge details. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0052] Figure 1 It is a flow chart of a method for obtaining pixel values in the present invention.
[0053] Figure 2 It is a color distribution diagram of pixel points in a Bayer pixel matrix in the present invention.
[0054] Figure 3 This is a schematic diagram of pixel point distribution in a Bayer pixel matrix in the present invention.
[0055] Figure 4 This is a flow chart for pre-judging pixels to be processed in the present invention.
[0056] Figure 5 This is a flow chart of performing secondary edge judgment on a pixel to be processed in the present invention.
[0057] Figure 6 This is a flowchart of the present invention for judging whether a pixel in a non-same color pixel group is an edge pixel based on a threshold value.
[0058] Figure 7 It is a flow chart of obtaining the preset bad pixels in each other non-same color pixel group in the present invention.
[0059] Figure 8 This is a flow chart of correcting the pixels to be processed in the present invention.
[0060] Fig. 9 It is a structural schematic diagram of the present invention in which adjacent pixel points of a pixel point to be processed are located in the same direction.
[0061] Fig.10 It is a schematic diagram of the position structure of the pixels to be processed and the pixels of the same color in the present invention.
[0062] Fig.11 It is a structural schematic diagram of two preset bad pixels of the same color of the pixel point to be processed in the present invention located in the same direction.
[0063] Fig.12 It is a structural schematic diagram of two preset bad pixels of the same color of the pixel point to be processed in the present invention being located in the same half area.
[0064] Fig.13 It is a schematic diagram of the structure in which the gradient direction intersects with the Bayer pixel matrix in the present invention. DETAILED DESCRIPTION
[0065] In order to facilitate the understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. The preferred embodiments of the present application are given in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thoroughly and comprehensively understood.
[0066] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0067] In the description of the present invention, it should be understood that the orientations or positional relationships indicated by the terms "center", "upper", "lower", "front", "back", "left", "right", etc. are based on the orientations or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or component referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.
[0068] In image sensors, bad pixels are divided into static bad pixels and dynamic bad pixels, and static bad pixels include static bright spots and static dark spots. When a pixel is a static bright spot, the brightness value of the pixel is proportional to the incident light, and the brightness value of the static bright spot is significantly greater than the incident light multiplied by the corresponding ratio, and as the exposure time increases, the brightness of the static bright spot will increase significantly. When a pixel is a static dark spot, the brightness value of the static dark spot is close to 0 regardless of the incident light. When a pixel is a dynamic bad pixel, within a certain pixel range, the dynamic bad pixel behaves normally, and beyond this pixel range, the dynamic bad pixel behaves brighter than the surrounding pixels, and the brightness value of the dynamic bad pixel is also related to the temperature and gain of the image sensor. When the temperature of the image sensor rises or the gain increases, the increase in the brightness value of the dynamic bad pixel will be more obvious.
[0069] See also Figure 1 As shown, in one embodiment of the present invention, a method for obtaining pixel values is provided, which can effectively determine whether a pixel is a bad pixel, ensure that edge pixels are not misjudged as bad pixels, and when a pixel is a bad pixel, effectively correct the bad pixel and protect the information of the edge pixel. Specifically, the method for obtaining pixel values provided by the present invention includes steps S10 to S40.
[0070] Step S10: Acquire the original image captured by the image sensor.
[0071] Step S20: construct a Bayer pixel matrix with the pixel to be processed as the center.
[0072] Step S30 , pre-judge the pixel to be processed according to the pixel values of the pixels in the same color pixel group where the pixel to be processed is located and the number of preset bad pixels.
[0073] Step S40: determining whether the pixel to be processed is an edge pixel according to the number of preset bad pixels in the non-same-color pixel group or the number and position of preset bad pixels in the same-color pixel group.
[0074] Step S50: when the pixel to be processed is an edge pixel, a pixel value is obtained according to the pixel to be processed; if the pixel to be processed is a bad pixel, the pixel value of the pixel to be processed is corrected.
[0075] See also Figure 1 As shown, in one embodiment of the present invention, when obtaining the pixel value of each pixel point, the image sensor is first used to collect the image to obtain the original image. Due to defects in the process of the image sensor or errors in the process of converting the optical signal into the electrical signal, the original image obtained may have bad pixels.
[0076] See also Figure 2 and Figure 3 As shown, in one embodiment of the present invention, the Bayer pixel matrix constructed in the present application is a 5×5 pixel matrix, and the pixel to be processed is located at the center of the pixel matrix. Each pixel is represented by Pij, where i is the number of rows and j is the number of columns. P12 is the pixel in the first row and second column of the pixel matrix, and P21 is the pixel in the second row and first column of the pixel array, then the pixel to be processed is P33. In the Bayer pixel matrix, four colors of pixels are arranged, and the four colors are R, Gr, B and Gb. Among them, R is red, B is blue, Gr and Gb are green, and Gr and Gb are two colors of green. The Bayer pixel matrix is a 5x5 pixel matrix arranged based on the GRBG Bayer array, and the pixels of the four colors are arranged in a 2×2 pixel matrix.
[0077] See also Figure 2 and Figure 3 As shown, in one embodiment of the present invention, when the image sensor collects an image, the correlation between adjacent pixels is very strong, and the edge judgment of the pixel to be processed can be performed based on the adjacent pixels of other colors, but the light intake of filters of different colors in the image sensor is different, resulting in different pixel values of different colors. Therefore, in this application, the pixels in the Bayer pixel matrix are divided into four pixel groups according to the color of the pixels, and the pixel group where the pixel to be processed is located is the same color pixel group, and is the first pixel group. In this embodiment, the color of the pixel to be processed is Gr, then the same color pixel group includes all pixels with the color Gr in the Bayer pixel matrix, that is, the same color pixel group includes pixel points P11, P13, P15, P31, P33, P35, P51, P53 and P55. Except for the same color pixel group where the pixel to be processed is located, the non-same color pixel group can be divided into the second pixel group, the third pixel group and the fourth pixel group according to color. The second pixel group includes all the pixels of color R in the Bayer pixel matrix, and the second pixel group includes pixel points P12, P14, P32, P34, P52 and P54. The third pixel group includes all the pixels of color B in the Bayer pixel matrix, and the second pixel group includes pixel points P21, P23, P25, P41, P43 and P45. The fourth pixel group includes all the pixels of color Gb in the Bayer pixel matrix, and the fourth pixel group includes pixel points P22, P24, P42 and P44.
[0078] See also Figure 1 and Figure 4 As shown, in one embodiment of the present invention, after constructing the Bayer pixel matrix, the pixel to be processed is pre-judged based on the pixel value of the pixel in the same color pixel group where the pixel to be processed is located and the number of preset bad pixels. In this embodiment, step S30 includes steps S301 to S308.
[0079] Step S301, obtaining two median pixels from the pixels other than the pixel to be processed in the same color pixel group, and obtaining a first median absolute difference of the pixel values of the two median pixels and a first mean of the pixel values.
[0080] Specific, combined Figure 1 As shown, the other pixels in the same color pixel group except the pixel to be processed are arranged according to the size of the pixel value, and the two pixel points with pixel values in the middle are the median pixels. That is, the pixel values of the pixels P11, P13, P15, P31, P35, P51, P53 and P55 in the same color pixel group are arranged in order from small to large or from large to small. The pixel values of the other pixels in the same color pixel group except the pixel to be processed are P1, P2, P3, P4, P5, P6, P7 and P8 from small to large or from large to small, the first median absolute difference of the pixel values of the two median pixels Diff11=|P4-P5|, and the first average of the pixel values of the two median pixels Avg1=(P4+P5) / 2.
[0081] Step S302, determine whether the first median absolute difference between the pixel values of the two median pixels is less than the edge threshold. If the first median absolute difference between the pixel values of the two median pixels is less than the edge threshold, execute step S303. If the first median absolute difference between the pixel values of the two median pixels is greater than or equal to the edge threshold, execute step S308 and determine that the pixel to be processed is an edge pixel.
[0082] Among them, the range of the edge threshold TH_edge is set according to specific requirements, and this application does not limit the specific value of the edge threshold.
[0083] In step S302, when the first median absolute difference of the pixel values of two median pixels in the same color pixel group except the pixel to be processed is equal to or greater than the edge threshold, it means that there are four static bright spots and four static dark spots respectively, and the pixel to be processed is determined to be an edge pixel at this time, that is, step S308 is executed to determine that the pixel to be processed is an edge pixel. At this time, the pixel to be processed does not need to be corrected, and the pixel value of the pixel to be processed can be directly obtained.
[0084] Step S303: Subtract the pixel value of the pixel point to be processed from the first average of the pixel values of the two median pixels to obtain a first average absolute difference.
[0085] Specifically, the first mean absolute difference Diff12 = |P 33 - Avg1|, where P 33 is the pixel value of the pixel to be processed.
[0086] Step S304: Determine whether the pixel to be processed is a preset bad pixel according to the relationship between the first mean absolute difference and the bright bad pixel threshold and the dark bad pixel threshold, and the relationship between the pixel value of the pixel to be processed and the first mean value of the pixel values of the two median pixels. When the pixel to be processed is a preset bad pixel, step S305 is executed; when the pixel to be processed is not a preset bad pixel, step S308 is executed to determine that the pixel to be processed is an edge pixel.
[0087] Specifically, if the pixel value of the pixel to be processed is greater than the first mean value of the pixel values of the two median pixels, i.e., P 33 > Avg1, and the first mean absolute difference is greater than the bright bad pixel threshold, i.e., Diff12 > TH_bright, at this time, it is determined that the pixel to be processed is a bright bad pixel, which is a preset bad pixel.
[0088] If the pixel value of the pixel to be processed is less than the first mean value of the pixel values of the two median pixels, i.e., P 33 < Avg1, and the first mean absolute difference is greater than the dark bad pixel threshold, i.e., Diff12 > TH_dark, at this time, it is determined that the pixel to be processed is a dark bad pixel, which is a preset bad pixel.
[0089] In addition, if the pixel value of the pixel to be processed is less than the first mean value of the pixel values of the two median pixels and the first mean absolute difference is greater than the bright bad pixel threshold, the pixel value of the pixel to be processed is greater than the first mean value of the pixel values of the two median pixels and the first mean absolute difference is less than the bright bad pixel threshold, or the pixel value of the pixel to be processed is less than the first mean value of the pixel values of the two median pixels and the first mean absolute difference is less than the bright bad pixel threshold, i.e., P 33 < Avg1 and Diff12 > TH_bright, P 33 > Avg1 and Diff12 < TH_bright, or P 33 < Avg1 and Diff12 < TH_bright, step S308 is executed to determine that the pixel to be processed is an edge pixel.
[0090] In addition, if the pixel value of the pixel to be processed is greater than the first mean of the pixel values of the two median pixels and the first average absolute difference is greater than the dark pixel threshold, the pixel value of the pixel to be processed is greater than the first mean of the pixel values of the two median pixels and the first average absolute difference is less than the dark pixel threshold, or the pixel value of the pixel to be processed is less than the first mean of the pixel values of the two median pixels and the first average absolute difference is less than the dark pixel threshold, that is, P 33 >Avg1 and Diff12 > TH_dark, P 33 >Avg1 and Diff12 <TH_bright, or P 33 <Avg1 and Diff12<TH_bright, execute step S308 to determine that the pixel to be processed is an edge pixel.
[0091] Step S305: determine whether other pixels in the same-color pixel group are preset bad pixels, and obtain the number of preset bad pixels in the same-color pixel group.
[0092] In one embodiment of the present invention, the method of step S303 and step S304 is used to determine whether other pixels in the same color pixel group are preset bad pixels. That is, first, the other pixels in the same color pixel group are subtracted from the first average of the pixel values of the two median pixels to obtain an absolute difference. Then, based on the relationship between the absolute difference corresponding to each pixel and the bright bad pixel threshold and the dark bad pixel threshold, and the relationship between the pixel value of each pixel and the first average of the pixel values of the two median pixels, it is determined whether each pixel is a preset bad pixel.
[0093] After determining whether each pixel in the same-color pixel group is a preset bad pixel, the number of the preset bad pixels in the same-color pixel group can be counted.
[0094] Step 306: determine whether the number of preset bad pixels in the same color pixel group is less than the first preset threshold value. If the number of preset bad pixels in the same color pixel group is less than or equal to the first preset threshold value, execute step S307. If the number of preset bad pixels in the same color pixel group is greater than the first preset threshold value, execute step S308: determine that the pixel to be processed is an edge pixel.
[0095] Step S307: perform secondary edge judgment on the pixel to be processed.
[0096] In an embodiment of the present invention, the first preset threshold is, for example, 2, that is, when the number of preset bad pixels in the same-color pixel group is less than or equal to 2, in the subsequent process, a secondary edge judgment is performed on the pixel to be processed.
[0097] When the number of preset bad pixels in the same color pixel group is greater than 2, that is, the number of preset bad pixels in the same color pixel group is large, at this time, the pixel to be processed is determined to be an edge pixel, and the pixel to be processed does not need to be corrected, and the pixel value of the pixel to be processed can be directly obtained.
[0098] It should be noted that the preset number of bad pixels in the same-color pixel group in step S306 does not include the pixels to be processed.
[0099] See also Figure 1 , Figure 4 and Figure 5 As shown, in one embodiment of the present invention, after the determination of steps S301 to S308 in step S30, if it is necessary to perform secondary edge determination on the pixel to be processed, step S40 is executed to determine whether the pixel to be processed is an edge pixel according to the number of preset bad pixels in the non-same color pixel group or the number and position of preset bad pixels in the same color pixel group. Specifically, step S40 includes steps S401 to S410.
[0100] Step S401: determining whether each pixel in each non-same-color pixel group is an edge pixel according to an edge threshold.
[0101] In one embodiment of the present invention, when determining whether a pixel point in another non-same-color pixel group is an edge pixel point according to the edge threshold, the steps S301 to S302 can be performed. Specifically, Figure 6 As shown, step S401 includes step S4011 to step S4012.
[0102] Step S4011: in each other non-same-color pixel group, obtain two median pixel points of the plurality of pixel points, and obtain the median absolute difference of the pixel values of the two median pixel points and the mean pixel value.
[0103] Specifically, in the second pixel group, the pixel points P12, P14, P32, P34, P52 and P54 are arranged according to the size of the pixel values, the two pixel points with pixel values in the middle are the median pixels, the second median absolute difference Diff21 of the pixel values of the two median pixels is equal to the absolute difference of the pixel values of the two median pixels, and the second mean Avg2 of the pixel values of the two median pixels is equal to the average of the pixel values of the two median pixels.
[0104] In the third pixel group, the pixels P21, P23, P25, P41, P43 and P45 are arranged according to the size of the pixel values. The two pixels with pixel values in the middle are the median pixels. The third median absolute difference Diff31 of the pixel values of the two median pixels is equal to the absolute difference of the pixel values of the two median pixels. The third mean Avg3 of the pixel values of the two median pixels is equal to the average of the pixel values of the two median pixels.
[0105] In the fourth pixel group, the pixel points P22, P24, P42 and P44 are arranged according to the size of the pixel values. The two pixel points with pixel values in the middle are the median pixels. The fourth median absolute difference Diff41 of the pixel values of the two median pixels is equal to the absolute difference of the pixel values of the two median pixels. The fourth mean Avg4 of the pixel values of the two median pixels is equal to the average of the pixel values of the two median pixels.
[0106] Step S4012: determine whether the median absolute difference between the pixel values of the two median pixels in each non-same color pixel group is less than the edge threshold. If the median absolute difference between the pixel values of the two median pixels is greater than or equal to the edge threshold, the pixel in the corresponding non-same color pixel group is determined to be an edge pixel. If the median absolute difference between the pixel values of the two median pixels is less than the edge threshold, enter the re-determination process, that is, continue to execute step S402.
[0107] Specifically, it is determined in sequence whether the second median absolute difference Diff21 is less than the edge threshold TH_edge, whether the third median absolute difference Diff31 is less than the edge threshold TH_edge, and whether the fourth median absolute difference Diff41 is less than the edge threshold TH_edge, and then it is determined whether the pixel points in each pixel group are edge pixel points. That is, if Diff21≥TH_edge, the pixel points in the second pixel group are edge pixel points; if Diff31≥TH_edge, the pixel points in the third pixel group are edge pixel points; if Diff41≥TH_edge, the pixel points in the fourth pixel group are edge pixel points.
[0108] Step S402: determine whether there are any edge pixels in other non-same color pixel groups. If there are any edge pixels in other non-same color pixel groups, execute step S409: determine whether the pixel to be processed is an edge pixel. If there are no edge pixels in other non-same color pixel groups, execute step S403.
[0109] Specifically, if any one of the relationships Diff21≥TH_edge, Diff31≥TH_edge or Diff41≥TH_edge holds, it indicates that there are pixel points in other non-same-color pixel groups that are edge pixels, and the pixel point to be processed is determined to be an edge pixel point. The pixel point to be processed does not need to be corrected, and the pixel value of the pixel point to be processed can be directly obtained.
[0110] Step S403, obtaining the number and position of the preset bad pixels in each other non-same-color pixel group, and obtaining the total number and position of all the preset bad pixels in other non-same-color pixel groups.
[0111] Specifically, if Diff21<TH_edge, Diff31<TH_edge and Diff41<TH_edge, it is impossible to determine whether there are edge pixels in other non-same color pixel groups using the edge threshold, and it is initially determined that there are no edge pixels in other non-same color pixel groups. Continue to execute step S403 and subsequent steps, and determine whether the pixel to be processed is a preset bad pixel according to the total number and position of all preset bad pixels in other non-same color pixel groups. In this embodiment, when obtaining the number and position of preset bad pixels in each other non-same color pixel group, steps S303 to S304 can be referred to. Specifically, combined with Figure 7 As shown, when obtaining the number and position of the preset bad pixels in each other non-same-color pixel group, it includes steps S4031 and S4032.
[0112] Step S4031: In each non-same-color pixel group, the pixel value of each pixel point is subtracted from the average of the pixel values of the two median pixels to obtain the average absolute difference.
[0113] Specifically, in the second pixel group, each time a pixel is verified, a second average absolute difference Diff22 is obtained, and the second average absolute difference Diff22 is the absolute difference between the pixel value of the pixel to be verified in the second pixel group and the second average value Avg2.
[0114] In the third pixel group, each time a pixel is verified, a third average absolute difference Diff32 is obtained, and the third average absolute difference Diff32 is the absolute difference between the pixel value of the pixel to be verified in the third pixel group and the third average value Avg3.
[0115] In the fourth pixel group, each time a pixel is verified, a fourth average absolute difference Diff42 is obtained, and the fourth average absolute difference Diff42 is the absolute difference between the pixel value of the pixel to be verified in the fourth pixel group and the fourth average value Avg4.
[0116] Step S4032: determine whether each pixel to be verified is a preset bad pixel based on the relationship between the average absolute difference of each pixel to be verified in each non-same color pixel group and the bright bad pixel threshold and the dark bad pixel threshold, and the relationship between the pixel value of each pixel and the average of the pixel values of the two median pixels.
[0117] Specifically, in the second pixel group, if the pixel value of the pixel to be verified is greater than the second mean of the pixel values of the two median pixels, that is, P 20 > Avg2, and the second average absolute difference is greater than the bright bad pixel threshold, that is, Diff22>TH_bright, at this time, the pixel to be verified is determined to be a bright bad pixel, that is, a preset bad pixel. If the pixel value of the pixel to be verified is less than the second mean of the pixel values of the two median pixels, that is, P20 <Avg2, and the second average absolute difference is greater than the dark pixel threshold value, that is, Diff22>TH_dark, at this time, the pixel to be verified is determined to be a dark pixel, that is, a preset pixel. 20 is the pixel value of the pixel to be verified in the second pixel group.
[0118] In the third pixel group, if the pixel value of the pixel to be verified is greater than the third mean of the pixel values of the two median pixels, that is, P 30 > Avg3, and the third average absolute difference is greater than the bright bad pixel threshold, that is, Diff32 > TH_bright, at this time, the pixel to be verified is determined to be a bright bad pixel, that is, a preset bad pixel. If the pixel value of the pixel to be verified is less than the third mean of the pixel values of the two median pixels, that is, P 30 <Avg3, and the third average absolute difference is greater than the dark bad pixel threshold, that is, Diff32>TH_dark, at this time, the pixel to be verified is determined to be a dark bad pixel, that is, a preset bad pixel. 30 is the pixel value of the pixel to be verified in the third pixel group.
[0119] In the fourth pixel group, if the pixel value of the pixel to be verified is greater than the fourth mean of the pixel values of the two median pixels, that is, P 40 > Avg4, and the fourth average absolute difference is greater than the bright bad pixel threshold, that is, Diff42>TH_bright, at this time, the pixel to be verified is determined to be a bright bad pixel, that is, a preset bad pixel. If the pixel value of the pixel to be verified is less than the fourth mean of the pixel values of the two median pixels, that is, P 40 <Avg4, and the fourth average absolute difference is greater than the dark pixel threshold value, that is, Diff42>TH_dark, at this time, the pixel to be verified is determined to be a dark pixel, that is, a preset pixel. 40 is the pixel value of the pixel to be verified in the fourth pixel group.
[0120] Through step S4031 and step S4032, it is possible to obtain and verify whether each pixel in each non-same color pixel group is a preset bad pixel. If a pixel to be verified is a preset bad pixel, the position and number of the preset bad pixels can be recorded, and the total number and position of all preset bad pixels in the second pixel group, the third pixel group and the fourth pixel group can be obtained.
[0121] Step S404: determine whether the total number of all preset bad pixels in other non-same-color pixel groups is less than a second preset threshold value. If the total number of all preset bad pixels in other non-same-color pixel groups is less than the second preset threshold value, execute step S405 and the subsequent steps of step S405 to determine whether the pixel to be processed is an edge pixel based on the number of preset bad pixels in the same-color pixel groups; if the total number of all preset bad pixels in other non-same-color pixel groups is greater than or equal to the second preset threshold value, execute step S409 to determine whether the pixel to be processed is an edge pixel.
[0122] Specifically, the second preset threshold is, for example, 5. When the total number of all preset bad pixels in other non-same-color pixel groups is equal to or greater than 5, the pixel point P33 to be processed is determined to be an edge pixel point.
[0123] When the total number of all preset bad pixels in other non-same-color pixel groups is less than 5, it is next determined whether the pixel to be processed is an edge pixel and is divided into three categories. When there is no preset bad pixel in the same-color pixel group except the pixel to be processed, step S405 is executed; when there is one preset bad pixel in the same-color pixel group except the pixel to be processed, step S406 is executed; when there are two preset bad pixels in the same-color pixel group except the pixel to be processed, step S407 is executed.
[0124] Step S405, determine whether two preset bad pixels appear in the same direction among the adjacent pixels of the pixel to be processed. If two preset bad pixels appear in the same direction among the adjacent pixels of the pixel to be processed, execute step S409, determine that the pixel to be processed is an edge pixel. If two preset bad pixels do not appear in the same direction among the adjacent pixels of the pixel to be processed, execute step S408, determine that the pixel to be processed is a bad pixel.
[0125] Specifically, when there is no preset bad pixel in the same color pixel group except the pixel to be processed, and the number of preset bad pixels in other non-same color pixel groups is less than 5, it is sufficient to determine whether two preset bad pixels appear in the same direction among the adjacent pixels of the pixel to be processed. Because the adjacent pixels of the pixel to be processed are non-same color pixels, there may be preset bad pixels among the adjacent pixels of the pixel to be processed. When two preset bad pixels appear in the same direction among the adjacent pixels of the pixel to be processed, combined with Fig. 9 As shown, at this time, two preset bad pixels may appear in the horizontal direction, vertical direction and diagonal direction (45 degree direction and 135 degree direction in the figure) except the pixel to be processed. When any group of pixel points P22 and pixel point P44, pixel point P23 and pixel point P43, pixel point P24 and pixel point P42, or pixel point P32 and pixel point P34 are all preset bad pixels, step S409 is executed to determine that the pixel to be processed is an edge pixel. Otherwise, step S408 is executed to determine that the pixel to be processed is a bad pixel.
[0126] Step S406, determine whether the preset bad pixels appear in the same direction between the pixel to be processed and the adjacent pixel points of the same color preset bad pixels. If the preset bad pixels appear in the same direction between the pixel to be processed and the adjacent pixel points of the same color preset bad pixels, execute step S409, determine that the pixel to be processed is an edge pixel. If the preset bad pixels do not appear in the same direction between the pixel to be processed and the adjacent pixel points of the same color preset bad pixels, execute step S408, determine that the pixel to be processed is a bad pixel.
[0127] For details, please combine Fig.10 As shown, if there is a preset bad pixel of the same color in addition to the pixel to be processed in the same color pixel group, and the preset bad pixel of the same color is, for example, pixel P11, it is sufficient to determine whether the preset bad pixel appears in the same direction between the adjacent pixels of the pixel to be processed P33 and pixel P11. That is, if any group of pixel points among pixel points P21 and pixel point P43, pixel point P12 and pixel point P34, or pixel point P22 and pixel point P44 are all preset bad pixels, step S409 is executed to determine that the pixel to be processed is an edge pixel. Otherwise, step S408 is executed to determine that the pixel to be processed is a bad pixel.
[0128] Step S407, determine whether the two preset bad pixels of the same color of the pixel to be processed are located in the same direction, or whether the two preset bad pixels of the same color are located in the same half area. If the two preset bad pixels of the same color of the pixel to be processed are located in the same direction, or the two preset bad pixels of the same color are located in the same half area, execute step S409, determine that the pixel to be processed is an edge pixel. If the two preset bad pixels of the same color of the pixel to be processed are located in different directions, or the two preset bad pixels of the same color are located in different half areas, execute step S408, determine that the pixel to be processed is a bad pixel.
[0129] Specific, combined Fig.11 As shown, if the three pixels of the same color, pixel point P11, pixel point P33 and pixel point P55, are all preset bad pixels, then step S409 is executed to determine that the pixel point to be processed is an edge pixel point. In addition, if any group of pixel points, pixel point P13, pixel point P33 and pixel point P53, pixel point P15, pixel point P33 and pixel point P51, or pixel point P31, pixel point P33 and pixel point P35, are all preset bad pixels, then step S409 is executed to determine that the pixel point to be processed is an edge pixel point.
[0130] Specific, combined Fig.12As shown, the half area described in the present application includes the upper half area, the lower half area, the left half area and the right half area of the Bayer pixel matrix, and the edges of the pixels in each half area overlap. Then the upper half area includes the first row of pixels P1j, the second row of pixels P2j and the third row of pixels P3j, the lower half area includes the third row of pixels P3j, the fourth row of pixels P4j and the fifth row of pixels P5j, the left half area includes the first column of pixels Pi1, the second column of pixels Pi2 and the third column of pixels Pi3, and the right half area includes the third column of pixels Pi3, the fourth column of pixels Pi4 and the fifth column of pixels Pi5. Among them, if the two preset bad pixels in the same color pixel group are located in the same half area, step S409 is executed to determine that the pixel to be processed is an edge pixel. For example, pixel P11 and pixel P31 are both located in the upper half area, and pixel P11 and pixel P31 are both preset bad pixels, then the pixel to be processed is an edge pixel.
[0131] Except that the two same-color preset bad pixels of the processed pixel in the same-color pixel group are in the same direction, or the two same-color preset bad pixels are located in the same half area, if the two same-color preset bad pixels of the pixel to be processed are located in different directions, or the two same-color preset bad pixels are located in different half areas, step S408 is executed to determine that the pixel to be processed is a bad pixel.
[0132] It should be noted that in the present application, when the pixel to be processed is determined to be a bad pixel, the preset bad pixels in the determination process are also determined to be bad pixels, and the preset bad pixels in the same color pixel group are the same color bad pixels, and the preset bad pixels in the non-same color pixel group are non-same color bad pixels.
[0133] See also Figure 1 As shown, in one embodiment of the present invention, after the judgment process of step S30 and step S40, it can be determined whether the pixel to be processed is a bad pixel. When the pixel to be processed is a bad pixel, step S50 is executed. When the pixel to be processed is an edge pixel, the pixel value is obtained based on the pixel to be processed. If the pixel to be processed is a bad pixel, the pixel to be processed is corrected.
[0134] For details, please combine Figure 8 As shown, in this embodiment, when the pixel to be processed is a bad pixel, correcting the pixel to be processed includes steps S501 to S502.
[0135] Step S501: Correct the same-color bad pixels in the same-color pixel group except the pixels to be processed.
[0136] In one embodiment of the present invention, when there are other same-color bad pixels in addition to the pixels to be processed in the same-color pixel group, the other same-color bad pixels are corrected first. In the present application, if the number and position of the same-color bad pixels in the same-color pixel group are different, the correction method of the same-color bad pixels is different, and the correction value of the same-color bad pixels can be obtained according to the pixel value of the same-color pixel in the same-color bad pixel level and / or numerical gradient direction.
[0137] In one embodiment of the present invention, if there is a same-color bad pixel in a same-color pixel group, and the same-color bad pixel is located at a vertex of the Bayer pixel matrix, two target values of the same-color bad pixel in the horizontal and vertical directions are obtained according to the horizontal and vertical gradient directions, and then the average value of the two target values is obtained as the correction value of the same-color bad pixel.
[0138] Specifically, if a same-color bad pixel in the same-color pixel group is a pixel point P11 located at the vertex of the Bayer pixel matrix, the first target value of the pixel point P11 in the horizontal direction is obtained according to the horizontal gradient direction:
[0139] P_target1=P 13 +(P 13 -P 15 ),
[0140] Among them, P_target1 is the first target value, P 13 is the pixel value of pixel point P13, P 15 is the pixel value of pixel point P15.
[0141] The second target value of the pixel point P11 in the vertical direction is obtained according to the vertical gradient direction:
[0142] P_target2=P 31 +(P 31 -P 51 ),
[0143] Among them, P_target2 is the second target value, P 31 is the pixel value of pixel point P31, P 51 is the pixel value of pixel point P51.
[0144] The pixel value P of pixel point P11 11 =(P_target1+P_target2) / 2.
[0145] In one embodiment of the present invention, if there is a same-color bad pixel in the same-color pixel group, and the same-color bad pixel is located at the middle point of the edge of the Bayer pixel matrix, the correction value of the same-color bad pixel is obtained according to the value of the edge vertex where the same-color bad pixel is located.
[0146] Specifically, if a same-color bad pixel in the same-color pixel group is located at the middle point of the edge of the Bayer pixel matrix, for example, pixel point P13, then the pixel value P of pixel point P13 is 13 =(P 11 +P 15 ) / 2.
[0147] In one embodiment of the present invention, if there are two same-color bad pixels in the same-color pixel group, and the two same-color bad pixels are located at the middle point of the edge of the Bayer pixel matrix, the correction value of the same-color bad pixel is obtained according to the value of the edge vertex where the same-color bad pixel is located. For details, refer to the pixel point P 13 The calculation method of .
[0148] In one embodiment of the present invention, if there are two same-color bad pixels in the same-color pixel group, and the two same-color bad pixels are located at the vertices of the Bayer pixel matrix, correction values of the same-color bad pixels in the horizontal or vertical direction are obtained according to the horizontal or vertical gradient direction.
[0149] Specifically, if two same-color bad pixels in the same-color pixel group are located at the vertices of the Bayer pixel matrix, and one of the same-color bad pixels is, for example, pixel point P11, then the pixel value P of pixel point P11 is 11 =P 31 +(P 31 -P 51 ) / 2. Among them, P 31 is the pixel value of pixel point P31, P 51 is the pixel value of pixel point P51. Or the pixel value P of pixel point P11 11 =P 13 +(P 13 -P 15 ) / 2, where P 13 is the pixel value of pixel point P13, P 15 is the pixel value of pixel point P15.
[0150] In one embodiment of the present invention, if there are two same-color bad pixels in a same-color pixel group, one of the same-color bad pixels is located at the vertex of the Bayer pixel matrix, and the other of the same-color bad pixels is located at the middle point of the edge of the Bayer pixel matrix, and the two same-color bad pixels are located in the same row or the same column, then the correction value of the same-color bad pixel located at the vertex of the Bayer pixel matrix is first obtained according to the horizontal or vertical gradient direction, and then the correction value of the same-color bad pixel is obtained according to the value of the edge vertex where the same-color bad pixel is located.
[0151] Specifically, if the two same-color bad pixels are pixel point P11 and pixel point P31, the pixel value of pixel point P11 is obtained first, and then the pixel value of pixel point P31 is obtained. 11 =P 13 +(P 13 -P 15 ) / 2,P 31=(P 11 +P 51 ) / 2. Among them, P 31 is the pixel value of pixel point P31, P 51 is the pixel value of pixel point P51.
[0152] In one embodiment of the present invention, if there are two same-color bad pixels in a same-color pixel group, one of the same-color bad pixels is located at the vertex of the Bayer pixel matrix, and the other of the same-color bad pixels is located at the middle point of the edge of the Bayer pixel matrix, and the two same-color bad pixels are located in different rows or columns, then the correction value of the same-color bad pixel located at the vertex of the Bayer pixel matrix is first obtained according to the horizontal and vertical gradient directions, and then the correction value of the same-color bad pixel is obtained according to the value of the edge vertex where the same-color bad pixel is located.
[0153] Specifically, if the two same-color bad pixels are pixel point P11 and pixel point P35, the pixel value of pixel point P11 is obtained first, and then the pixel value of pixel point P35 is obtained.
[0154] The first target value of pixel P11 is:
[0155] P_target1=P 13 +(P 13 -P 15 ),
[0156] Among them, P_target1 is the first target value, P 13 is the pixel value of pixel point P13, P 15 is the pixel value of pixel point P15.
[0157] The second target value of the pixel point P11 in the vertical direction is obtained according to the vertical gradient direction:
[0158] P_target2=P 31 +(P 31 -P 51 ),
[0159] Among them, P_target2 is the second target value, P 31 is the pixel value of pixel point P31, P 51 is the pixel value of pixel point P51.
[0160] The pixel value P of pixel point P11 11 =(P_target1+P_target2) / 2.
[0161] The pixel value P of pixel point P35 35 =(P 51 +P 55 ) / 2, where P 51 is the pixel value of pixel point P51, P55 is the pixel value of pixel P55.
[0162] Step S502: calibrate the pixels to be processed.
[0163] When obtaining the pixel value of the pixel to be processed, the horizontal gradient and the vertical gradient are first obtained according to the pixel value of each pixel in the same color pixel group, and then the gradient direction is obtained according to the horizontal gradient and the vertical gradient.
[0164] The horizontal gradient is obtained by the following formula:
[0165]
[0166] The vertical gradient is obtained by the following formula:
[0167]
[0168] Among them, P 11 is the pixel value of pixel point P11, P 31 is the pixel value of pixel point P31;
[0169] The gradient direction is the ratio of the gradient in the horizontal direction to the gradient in the vertical direction, that is, G=Gx / Gy.
[0170] like Fig.13 As shown, in one embodiment of the present invention, after obtaining the gradient direction, the intersection of the gradient direction and the Bayer pixel matrix is obtained as the first intersection point P and the second intersection point Q, and the pixel values of the first intersection point P and the second intersection point Q are obtained, and based on the pixel values of the first intersection point P and the second intersection point Q, the correction value of the pixel to be processed is obtained.
[0171] In one embodiment of the present invention, when the intersection of the gradient direction and the Bayer pixel matrix is the first intersection point P and the second intersection point Q, the spacing between the two pixels is set to 1, then the gradient function is Y=GX. Since the gradient is greater than 1, the ordinate of the first intersection point Q and the abscissa of the second intersection point Q are 1 / G, then the pixel value P of the first intersection point P is P =P 13 ×(1 / G)+P 15 ×(1-1 / G), the pixel value P of the second intersection point Q Q =P 53 ×(1 / G)+P 51 ×(1-1 / G). Correction value P of the pixel to be processed 33 _correct=(P P +P Q ) / 2, which is the average of the pixel value of the first intersection and the pixel value of the second intersection.
[0172] In summary, the pixel value acquisition method and image sensor provided by the present invention first acquire the original image collected by the image sensor, and construct a Bayer pixel matrix with the pixel to be processed as the center. When judging, first pre-judge the pixel to be processed based on the pixel value of the pixel in the same color pixel group where the pixel to be processed is located and the number of preset bad pixels, and then judge whether the pixel to be processed is an edge pixel based on the number of preset bad pixels in the non-same color pixel group or the number and position of preset bad pixels in the same color pixel group. When the pixel to be processed is an edge pixel, the pixel value is obtained based on the pixel to be processed. If the pixel to be processed is a bad pixel, the pixel value of the pixel to be processed is corrected. Double edge judgment is performed on edge pixels with strong correlation. Even if multiple consecutive bad pixels appear, it can detect whether the pixel to be processed is a real bad pixel, not a pixel located at the edge of the image. After determining that the point to be processed is a bad pixel, first interpolate other bad pixels of the same color according to the number and position of the bad pixels in the neighborhood, then obtain the gradient direction of the pixel to be processed, and then interpolate the target pixel value according to the gradient direction. This can effectively retain edge details and ensure the accuracy of the pixel value correction value of the pixel to be processed.
[0173] The embodiments of the present invention disclosed above are only used to help illustrate the present invention. The embodiments do not describe all the details in detail, nor do they limit the invention to the specific embodiments described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A method for obtaining a pixel value, characterized in that: At least the following steps are included: Acquire the original image captured by the image sensor; Construct a Bayer pixel matrix with the pixel to be processed as the center; Pre-judgment of the pixel to be processed is performed based on the pixel values of the pixels in the same color pixel group where the pixel to be processed is located and the number of preset bad pixels; Determining whether the pixel to be processed is an edge pixel according to the number of preset bad pixels in the non-same-color pixel group or the number and position of preset bad pixels in the same-color pixel group; as well as If the pixel point to be processed is an edge pixel point, the pixel value is obtained according to the pixel point to be processed; if the pixel point to be processed is a bad pixel, the pixel value of the pixel point to be processed is corrected.
2. The method for obtaining pixel values according to claim 1, characterized in that: The Bayer pixel matrix includes pixels of multiple colors, the pixels of multiple colors form a 5x5 pixel matrix, and the pixel to be processed is located at the center of the Bayer pixel matrix.
3. The method for obtaining a pixel value according to claim 1, characterized in that: Pre-judging the pixel to be processed includes the following steps: Obtain two median pixels from the other pixels in the same-color pixel group except the pixel to be processed, and obtain a first median absolute difference of pixel values and a first mean value of pixel values of the two median pixels; Determine whether the first median absolute difference between the pixel values of the two median pixels is less than an edge threshold; if the first median absolute difference between the pixel values of the two median pixels is greater than or equal to the edge threshold, determine that the pixel to be processed is an edge pixel.
4. A method for obtaining pixel values according to claim 3, characterized in that: If the first median absolute difference between the pixel values of the two median pixels is less than the edge threshold, subtract the pixel value of the pixel to be processed from the first mean of the pixel values of the two median pixels as a first average absolute difference; Determine whether the pixel to be processed is a preset bad pixel according to the relationship between the first mean absolute difference and the bright bad pixel threshold and the dark bad pixel threshold, and the relationship between the pixel value of the pixel to be processed and the first mean of the pixel values of the two median pixels; If the pixel value of the pixel to be processed is greater than the first mean of the pixel values of the two median pixels and the first mean absolute difference is greater than the bright bad pixel threshold, or the pixel value of the pixel to be processed is less than the first mean of the pixel values of the two median pixels and the first mean absolute difference is greater than the dark bad pixel threshold, then the pixel to be processed is a preset bad pixel; When the pixel to be processed is not the preset bad pixel, it is determined that the pixel to be processed is the edge pixel.
5. A method for obtaining pixel values according to claim 4, characterized in that: When the pixel to be processed is not the preset bad pixel, determining whether other pixels in the same-color pixel group are preset bad pixels, and obtaining the number of the preset bad pixels in the same-color pixel group; Determine whether the number of the preset bad pixels in the same-color pixel group is less than a first preset threshold value. If the number of the preset bad pixels in the same-color pixel group is less than the first preset threshold value, perform secondary edge judgment on the pixel to be processed. If the number of the preset bad pixels in the same-color pixel group is greater than or equal to the first preset threshold value, determine that the pixel to be processed is the edge pixel point.
6. The method for obtaining pixel values according to claim 1, characterized in that: Judging whether the pixel to be processed is an edge pixel according to the number of preset bad pixels in the non-same-color pixel group or the number and position of preset bad pixels in the same-color pixel group comprises the following steps: Determine whether a pixel point in each other non-same-color pixel group is an edge pixel point according to the edge threshold; Determine whether there is a pixel point in each of the other non-same-color pixel groups that is the edge pixel point. If there is a pixel point in the other non-same-color pixel groups that is the edge pixel point, determine that the pixel point to be processed is an edge pixel point; if there is no pixel point in the other non-same-color pixel groups that is the edge pixel point, obtain the number and position of preset bad pixels in each of the other non-same-color pixel groups, and obtain the total number and position of all the preset bad pixels in the other non-same-color pixel groups, and determine whether the pixel point to be processed is a bad pixel based on the total number of all the preset bad pixels in the other non-same-color pixel groups and the number and position of the preset bad pixels in the same-color pixel group.
7. A method for obtaining pixel values according to claim 6, characterized in that: Determining whether a pixel point in each other non-same-color pixel group is an edge pixel point according to the edge threshold comprises the following steps: In each other non-same-color pixel group, two median pixel points of the plurality of pixel points are obtained, and the median absolute difference of the pixel values of the two median pixel points and the mean pixel value are obtained; It is determined whether the median absolute difference of the pixel values of the two median pixels in each other non-same-color pixel group is less than the edge threshold. If the median absolute difference of the pixel values of the two median pixels is greater than or equal to the edge threshold, the pixel in the corresponding non-same-color pixel group is determined to be an edge pixel. If the median absolute difference of the pixel values of the two median pixels is less than the edge threshold, the re-determination process is entered.
8. The method for obtaining pixel values according to claim 6, characterized in that: Obtaining the number and position of the preset bad pixels in each other non-same-color pixel group includes the following steps: In each of the non-same-color pixel groups, the pixel value of each pixel point is subtracted from the average of the pixel values of the two median pixels to obtain the average absolute difference; and According to the relationship between the average absolute difference of each pixel to be verified in each of the non-same-color pixel groups and the bright bad pixel threshold and the dark bad pixel threshold, and the relationship between the pixel value of each pixel and the average of the pixel values of the two median pixels, it is determined whether each pixel is a preset bad pixel.
9. The method for obtaining pixel values according to claim 6, characterized in that: According to the total number of all the preset bad pixels in other non-same-color pixel groups and the number and position of the preset bad pixels in the same-color pixel group, judging whether the pixel to be processed is a bad pixel includes the following steps: Determine whether the total number of all preset bad pixels in the other pixel groups is less than a second preset threshold value, and if the total number of all preset bad pixels in the other pixel groups is greater than or equal to the second preset threshold value, determine that the pixel to be processed is the edge pixel point; If the total number of all preset bad pixels in the other pixel groups is less than the second preset threshold, then it is determined whether the pixel to be processed is the preset bad pixel based on the number and position of the preset bad pixels in the same-color pixel group.
10. A method for obtaining pixel values according to claim 9, characterized in that: When there is no preset bad pixel in the same-color pixel group, it is determined whether two preset bad pixels appear in the same direction between the adjacent pixels of the pixel to be processed; if two preset bad pixels appear in the same direction between the adjacent pixels of the pixel to be processed, the pixel to be processed is determined to be the edge pixel; if two preset bad pixels do not appear in the same direction between the adjacent pixels of the pixel to be processed, the pixel to be processed is determined to be a bad pixel; When there is a preset bad pixel in the same-color pixel group, determine whether the preset bad pixels appear in the same direction between the pixel to be processed and the adjacent pixel points of the preset bad pixel of the same color; if the preset bad pixels appear in the same direction between the pixel to be processed and the adjacent pixel points of the preset bad pixel of the same color, determine that the pixel to be processed is the edge pixel; if the preset bad pixels do not appear in the same direction between the pixel to be processed and the adjacent pixel points of the preset bad pixel of the same color, determine that the pixel to be processed is a bad pixel; When there are two preset bad pixels in the same-color pixel group, determine whether the two preset bad pixels of the same color of the pixel to be processed are located in the same direction, or whether the two preset bad pixels of the same color are located in the same half area. When the two preset bad pixels of the same color of the pixel to be processed are located in the same direction, or the two preset bad pixels of the same color are located in the same half area, the pixel to be processed is determined to be the edge pixel. If the two preset bad pixels of the same color of the pixel to be processed are located in different directions, or the two preset bad pixels of the same color are located in different half areas, the pixel to be processed is determined to be a bad pixel.
11. The method for obtaining pixel values according to claim 1, characterized in that: Correcting the pixel value of the pixel to be processed includes the following steps: Correcting the same-color bad pixels in the same-color pixel group except the pixel to be processed; and Correct the pixel to be processed.
12. A method for obtaining pixel values according to claim 11, characterized in that: When correcting the same-color bad pixels in the same-color pixel group except the pixel to be processed, the correction value of the same-color bad pixel is obtained according to the pixel value of the same-color pixel in the horizontal direction and / or the numerical gradient direction of the same-color bad pixel.
13. A method for obtaining pixel values according to claim 11, characterized in that: Correcting the pixel to be processed includes the following steps: First, the correction direction of the pixel to be processed is obtained, and the correction direction is obtained by the following formula: G = Gx / Gy, and Among them, Gx is the horizontal gradient, Gy is the vertical gradient, and P 11 is the pixel value of pixel point P11, P 13 is the pixel value of pixel point P13, P 15 is the pixel value of pixel point P15, P 31 is the pixel value of pixel point P31, P 33 is the pixel value of pixel point P33, P 35 is the pixel value of pixel point P35, P 51 is the pixel value of pixel point P51, P 53 is the pixel value of pixel point P53, P 55 is the pixel value of pixel P55.
14. A method for obtaining pixel values according to claim 12, characterized in that: Correcting the pixel to be processed also includes the following steps: A first intersection point and a second intersection point of the gradient direction and the Bayer pixel matrix are obtained to obtain a correction value of the pixel to be processed according to the pixel values of the first intersection point and the second intersection point, and the correction value of the pixel to be processed is: P 33 _correct=(P P +P Q ) / 2; and P P =P 13 ×(1 / G)+P 15 ×(1-1 / G); P Q =P 53 ×(1 / G)+P 51 ×(1-1 / G); Among them, P P is the pixel value of the first intersection, P Q is the pixel value of the second intersection, 1 / G is the ordinate of the first intersection and the abscissa of the second intersection.
15. An image sensor, characterized in that: Use the pixel value acquisition method according to any one of claims 1 to 14 to correct the pixel points in the image sensor.