Summary of the invention
Carry out the deficiency of compensating bad point at above-mentioned at the RGB data, main purpose of the present invention is to provide a kind of dead pixel compensation method more fast and effectively.
Consider that human eye is more responsive to brightness, and yuv format data characteristics that luminance signal is separated from picture signal, the present invention proposes a kind ofly to realize the method for compensating bad point at yuv data that concrete steps are as follows:
A) obtain the YUV component of image current pixel, and the YUV component of at least four pixels in the adjacent domain;
B) utilize described current pixel and the difference of being close to each pixel YUV value, judge whether current pixel is bad point, if bad point enters step c) and carries out compensating bad point, otherwise, finish the processing of current pixel;
C) the YUV value of utilizing the adjacent domain pixel is carried out compensating bad point to the pixel value of current pixel.
When obtaining the YUV component of current pixel, the Y component of each pixel all being handled, then is that every interval plurality of pixels is handled a U, V component on level or vertical direction to U, V component.
U of the processes pixel in every interval, V component, and choose and be separated by in the horizontal and vertical directions four pixels of a pixel of handled pixel carry out compensating bad point to U, the V component of this pixel and handle.
Can choose and be separated by in the horizontal and vertical directions four pixels of a pixel of current pixel, come Y component to current pixel to carry out compensating bad point and handle.
Also can choose four pixels nearest in the horizontal and vertical directions, come the Y component of current pixel is carried out the compensating bad point processing with current pixel.
Describedly judge that whether current pixel is that the method for bad point is specially:
Calculate the YUV component Grad in the horizontal and vertical directions of described pixel;
Described two Grad are compared with predefined bad some decision threshold,, enter step c), otherwise finish the processing of current pixel, enter processing next pixel if two Grad think then that all greater than bad some decision threshold current pixel is a bad point.
Described bad some decision threshold comprises three: the bad some decision threshold of bad some decision threshold, chromatic component U and the V of luminance component Y, and the bad some decision threshold of luminance component Y is less than the bad some decision threshold of chromatic component U and V.
The bad some decision threshold of described U, V component equates.
The described method that current pixel is carried out compensating bad point is specially: two Grad relatively, get two pixels of the less direction of Grad, and calculate its YUV component average, with this average replacement current pixel value.
The present invention is directed to the deficiency of original method, by carrying out compensating bad point at rgb signal originally, change at yuv data and carry out compensating bad point, effective like this human eye characteristics more responsive to the Y component of having utilized have strengthened the effect of compensating bad point; Further, not that U, V component to each pixel all carries out the compensating bad point computing, but dot interlace is chosen U, the V data are carried out the compensating bad point computing, be equivalent to reduce the data volume of U, V component, therefore this method can significantly reduce amount of calculation, also can effectively compensate simultaneously, improve picture quality bad point.Method disclosed by the invention can be widely used in the image data processing module of digital image-forming equipment such as camera, digital camera.
Embodiment
Core concept of the present invention is: utilize human eye more responsive to brightness, in conjunction with the characteristics that the yuv format data are represented brightness and colourity respectively, carry out compensating bad point at yuv data.Further, can also carry out dot interlace to U, V component and handle, therefore significantly reduce amount of calculation, improve picture quality.
As shown in Figure 3, the step that the yuv format data are carried out compensating bad point comprises:
Step 1 is obtained the YUV component of current pixel, and the YUV component of at least four pixels in the adjacent domain;
Step 2 is utilized the difference of the YUV value of current pixel and adjacent domain pixel, judges whether current pixel is bad point, if then enter step 3 it is carried out compensating bad point, otherwise finish processing to current pixel;
Step 3, the YUV value of utilizing the adjacent domain pixel is carried out compensating bad point to the pixel value of current pixel, finishes the processing to current pixel.
Concrete steps below in conjunction with a preferable compensating bad point embodiment of accompanying drawing 4 explanations.
Step 401 is obtained the YUV component of four pixels in current pixel and the adjacent domain thereof.
Illustrate that in technical background yuv data has multiple form, but no matter be which kind of compressed format, U, the V component through overcompression can be assigned in each pixel that reduction becomes the view data that each pixel all contains Y, U, V component.Therefore in following compensating bad point embodiment, do not consider the data format that each is concrete, but the data that each pixel all included each component of YUV are carried out the explanation of the inventive method as pending initial data.
The original data structure schematic diagram of yuv data is shown in Fig. 2 a, and wherein each pixel all contains Y, U, V component.
We pixel value to be processed can represent with the data structure diagram of brightness and two passages of colourity.Shown in Fig. 2 b,, all the Y component is handled when handling each pixel the data of Y passage.And for U, V component, because human eye to the chromatic component relative insensitivity, so the method for taking dot interlace to handle promptly is not that U, the V component to each pixel all handled, but is handled a U, V component every some pixels.Shown in Fig. 2 c, in the present embodiment, take to handle a U, V component every a bit, promptly when handling the n-1 row,, select the V component is handled, and when handling the n row, then select the U component is handled for U, V component.Therefore, to the pixel of n-1 row, only handle Y, V component in its pixel value; And the pixel of n row, the Y in the processed pixels value, U component, the pixel value that other row pixel selection is handled is in like manner as can be known.The difference of the YUV value of the following stated pixel selected component because of to each processes pixel the time is different, if select Y, U component in the processed pixels value, then actual Y, the U value of referring to of YUV value; If select Y, V component in the processed pixels value, then actual Y, the V value of referring to of YUV value.
Carry out choosing of adjacent domain pixel on this basis again.
Shown in Fig. 2 b and 2c, current pixel P
M, nIn the pixel value that needs to handle be Y, U component, present embodiment is all selected and be separated by in the horizontal and vertical directions four pixel P that contain Y and U component of a pixel of this pixel Y and U component when choosing the adjacent domain pixel
M-2, n, P
M+2, n, P
M, n-2, P
M, n+2Come current pixel P
M, nCarry out the processing of compensating bad point.
Choosing also of adjacent domain pixel can be taked alternate manner, as to the Y component in the current pixel, the Y component that can be chosen in four nearest with it on level and vertical direction pixels carries out the compensating bad point processing to it, but at this moment the pixel of Y component adjacent domain is different with the pixel of U component adjacent domain, with regard to adopting different computing formula that Y and U are carried out compensating bad point, can cause the complicated of computational methods like this; For the U component, if four nearest pixels of selected distance current pixel then do not make full use of the human eye characteristics more responsive to the brightness chrominance, data volume is bigger.Therefore seldom adopt aforesaid way to select neighborhood pixels, but select identical neighborhood pixels when handling Y with the U component, can make computational methods simpler like this, the Grad of the both direction that calculates more has comparativity.
Step 402, the second order gradient D of the YUV value on calculated level and the vertical direction
H (m, n)And D
V (m, n), be specially: the Y component:
Horizontal direction, D
Y-H (m, n)=| (P
M, n-P
M, n-2)+(P
M, n-P
M, n+2) |=|-P
M, n-2+ 2P
M, n-P
M, n+2|,
Vertical direction, D
Y-V (m, n)=| (P
M, n-P
M-2, n)+(P
M, n-P
M+2, n) |=|-P
M-2, n+ 2P
M, n-P
M+2, n|;
The second order Grad D of U, V component
U-H (m, n), D
U-V (m, n), D
V-H (m, n)D
V-V (m, n)Can obtain with reference to the calculating formula of above-mentioned Y component second order gradient.
Current pixel in the present embodiment only need be handled Y, U component, and the second order gradient of therefore only calculating Y, U component gets final product.
Step 403, D
H (m, n)And D
V (m, n)Whether all put a decision threshold greater than going bad?
Described bad some decision threshold is three, and wherein the bad some decision threshold of luminance component Y is T
Y, the bad some decision threshold of chromatic component U and V is T
UAnd T
V, T
Y<T
UAnd T
Y<T
VIn actual use, the user can adjust the size of each threshold value voluntarily according to the different requirements to picture quality.
The second order Grad of described Y, U, each component of V is compared with bad some decision threshold separately, and comparison procedure is specially:
D
Y-H (m, n)And D
Y-V (m, n)Whether all greater than T
Y
If judged result is for being then to need the Y component is carried out compensating bad point;
D
U-H (m, n), D
U-V (m, n)Whether all greater than T
U
If judged result is for being then to need the U component is carried out compensating bad point;
D
V-H (m, n)And D
V-V (m, n)Whether all greater than T
V
If judged result is for being then to need the V component is carried out compensating bad point.
If its corresponding bad some decision threshold of the second order gradient of above-mentioned Y, U, each component of V is compared, go bad a little and judge have in its judged result to be, then enter step 404; If the result is not, finish processing to current pixel.
In the present embodiment, make T
V=T
U, can simplify computational process.Only need make its corresponding bad some decision threshold of second order Grad of Y, U compare in the present embodiment respectively.Suppose and need carry out compensating bad point to the Y component, then the processing to the Y component enters step 404, finishes the processing to the U component simultaneously.
Step 404, D
H (m, n)〉=D
V (m, n)
The degree of suddenling change is bigger if judged result, promptly illustrates the pixel value of horizontal direction for being, need come the pixel value of current pixel is revised with the pixel value of two pixels of vertical direction.
Be specially:, judge D for the Y component
Y-H (m, n)Whether more than or equal to D
Y-V (m, n), if the result is for being then to enter step 405; Otherwise enter step 406.
For the processing of U, V component, identical with above-mentioned processing method to the Y component.
Present embodiment supposes that in above-mentioned steps 403 the Y component needs compensating bad point, so need to judge the second order gradient D of Y component
Y-H (m, n)Whether more than or equal to D
Y-V (m, n), if the result is for being then to enter step 405; Otherwise enter step 406.
Suppose the second order gradient D of Y component horizontal direction
Y-H (m, n)Greater than D
Y-V (m, n), enter step 405.
Step 405 is with the pixel average replacement current pixel value of two pixels on the vertical direction.
That is: use P respectively
M-2, n, P
M+2, nAverage (the Y of the YUV value in two pixels
M-2, n+ Y
M+2, n)/2, (U
M-2, n+ U
M+2, n)/2 or (V
M-2, n+ V
M+2, n)/2 replace current pixel P
M, nIn Y
M, n, U
M, nOr V
M, n, finish the processing of current pixel.
In the present embodiment, need use P
M-2, n, P
M+2, nAverage (the Y of Y value in two pixels
M-2, n+ Y
M+2, n)/2 replace current pixel P
M, nIn Y
M, n
Step 406, water square upwards the pixel average of two pixels replace current pixel value.
That is: use P
M, n-2, P
M, n+2Average (the Y of the YUV value in two pixels
M, n-2+ Y
M, n+2)/2, (U
M, n-2+ U
M, n+2)/2 or (V
M, n-2+ V
M, n+2)/2 replace current pixel P
M, nIn Y
M, n, U
M, nOr V
M, n, finish the processing of current pixel.
In addition, when the Y component is carried out compensating bad point, but also the nearest level of selected distance current pixel and four pixels on the vertical direction are carried out compensating bad point to the Y component of current pixel and are handled.And U, V component are except the situation of U described in the foregoing description and the adjacent appearance of V, also can select U and V component to appear in the same pixel, in this case, the U and the V component that need obtain at least four pixels of adjacent domain carries out compensating bad point to U in the current pixel and V component.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being done, is equal to replacement, improvement etc., all should be included within protection scope of the present invention.