Color-shift calibration method and device
10848726 ยท 2020-11-24
Assignee
Inventors
Cpc classification
H04N9/646
ELECTRICITY
International classification
Abstract
A color-shift calibration method is provided to process an image including pixels, in which an arrangement of the pixels corresponds to a Bayer color filter array and the pixels include first green pixels, second green pixels, red pixels and blue pixels. The color-shift calibration method includes the steps outlined below. A regional gradient change of the first and the second green pixels within a neighboring region corresponding to a target green pixel is calculated. An intensity difference between the first and the second green pixels is calculated. When the regional gradient change is smaller than a gradient threshold and the intensity difference exceeds an intensity threshold range, a pixel calibration is performed on the target green pixel based on the first and the second green pixels.
Claims
1. A color-shift calibration method to process an image comprising pixels, in which an arrangement of the pixels corresponds to a Bayer color filter array and the pixels include a plurality of red pixels, a plurality of blue pixels, a plurality of first green pixels related to the red pixels and a plurality of second green pixels related to the blue pixels, wherein the color-shift calibration method comprises: calculating a regional gradient change of the first and the second green pixels within a neighboring region corresponding to a target green pixel of the image; calculating an intensity difference between the first and the second green pixels within the neighboring region; and performing a pixel calibration on the target green pixel based on the first and the second green pixels to generate a calibrated target green pixel when the regional gradient change is smaller than a gradient threshold and the intensity difference exceeds an intensity threshold range.
2. The color-shift calibration method of claim 1, wherein the step of calculating the regional gradient change further comprises: calculating a first weighted average according to the first green pixels within the neighboring region; calculating a second weighted average according to the second green pixels within the neighboring region; and calculating the regional gradient change according to a difference of the first weighted average and the second weighted average.
3. The color-shift calibration method of claim 1, wherein the step of calculating the intensity difference further comprises: comparing the intensities of each pair of the first green pixels and the second green pixels closest to the first green pixels within the neighboring region to accumulate a first number of times that the intensity of the first green pixels is larger than the intensity of the second green pixels and a second number of times that the intensity of the second green pixels is larger than the intensity of the first green pixels; and generating the intensity difference by adding the first number and the second number of times; wherein when the intensity difference is larger than a first threshold value or the intensity difference is smaller than a second threshold value, the intensity difference is determined to exceed the intensity threshold range.
4. The color-shift calibration method of claim 1, wherein the first green pixels and the red pixels are disposed in an interlaced manner at the m-th row of the pixels, the second green pixels and the blue pixels are disposed in the interlaced manner at the m1-th row and/or the m+1-th row, the first green pixels are disposed at the n-th column of the pixels and the second green pixels are disposed at the n1-th column and/or the n+1-th column of the pixels, wherein m and n are respectively an even number or an odd number.
5. The color-shift calibration method of claim 1, further comprising: outputting the calibrated target green pixel as one of the pixels of an output image when the regional gradient change is smaller than the gradient threshold and the intensity difference exceeds the intensity threshold range; and outputting the target green pixel as one of the pixels of the output image when the regional gradient change is not smaller than the gradient threshold or the intensity difference does not exceed the intensity threshold range.
6. The color-shift calibration method of claim 1, wherein the step of performing the pixel calibration further comprises: performing a low pass filtering on the target green pixel according to the first green pixels and the second green pixels within the neighboring region to generate the calibrated target green pixel.
7. A color-shift calibration device to process an image comprising pixels, in which an arrangement of the pixels corresponds to a Bayer color filter array and the pixels comprise a plurality of red pixels, a plurality of blue pixels, a plurality of first green pixels related to the red pixels and a plurality of second green pixels related to the blue pixels, wherein the color-shift calibration device comprises: a calculating circuit configured to calculate a regional gradient change of the first and the second green pixels within a neighboring region corresponding to a target green pixel of the image; a comparing circuit configured to calculate an intensity difference between the first and the second green pixels within the neighboring region; and a color-shift calibration circuit configured to perform a pixel calibration on the target green pixel based on the first and the second green pixels to generate a calibrated target green pixel when the regional gradient change is smaller than a gradient threshold and the intensity difference exceeds an intensity threshold range.
8. The color-shift calibration device of claim 7, wherein the calculating circuit is further configured to calculate a first weighted average according to the first green pixels within the neighboring region, calculate a second weighted average according to the second green pixels within the neighboring region and calculate the regional gradient change according to a difference of the first weighted average and the second weighted average.
9. The color-shift calibration device of claim 7, wherein the comparing circuit is further configured to compare the intensities of each pair of the first green pixels and the second green pixels closest to the first green pixels within the neighboring region to accumulate a first number of times that the intensity of the first green pixels is larger than the intensity of the second green pixels and a second number of times that the intensity of the second green pixels is larger than the intensity of the first green pixels and generate the intensity difference by adding the first number and the second number of times; wherein when the intensity difference is larger than a first threshold value or the intensity difference is smaller than a second threshold value, the intensity difference is determined to exceed the intensity threshold range.
10. The color-shift calibration device of claim 7, wherein the pixel calibration circuit is further configured to average the target green pixels, the first green pixels and/or the second green pixels within the neighboring region.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) The invention can be more fully understood by reading the following detailed description of the embodiment, with reference made to the accompanying drawings as follows:
(2)
(3)
(4)
(5)
(6)
DETAILED DESCRIPTION
(7) Reference is made to
(8) Reference is now made to
(9) In the present embodiment, the arrangement of the pixels of the image 101 corresponds to a Bayer color filter array and the pixels include a plurality of red pixels R, a plurality of blue pixels B, a plurality of first green pixels GR related to the red pixels and a plurality of second green pixels GB related to the blue pixels.
(10) In an embodiment, the first green pixels GR and the red pixels R are disposed in an interlaced manner at the m-th row of the pixels. The second green pixels GB and the blue pixels B are disposed in the interlaced manner at the m1-th row and/or the m+1-th row. The first green pixels are disposed at the n-th column of the pixels and the second green pixels are disposed at the n1-th column and/or the n+1-th column of the pixels, wherein m and n are respectively an even number or an odd number.
(11) For example, when both m and n are odd numbers, the first green pixels GR and the red pixels R can be disposed in the interlaced manner at the first row, the third row, the fifth row, etc. The second green pixels GB and the blue pixels B can be disposed in the interlaced manner at the second row, the fourth row, the sixth row, etc. At the same time, the first green pixels GR can be disposed at the first column, the third column, the fifth column, etc. The second green pixels GB are disposed at the second column, the fourth column, the sixth column, etc.
(12) It is appreciated that in an embodiment, m and n can also be both even numbers. In another embodiment, one of m and n is an even number and the other one is an odd number. The present invention is not limited thereto.
(13) Reference is now made to
(14) The central pixel of the window is a first green pixel GR and corresponds to the i-th row and the j-th column (denoted by G.sub.R(i, j)). The first green pixels GR and the red pixels R are disposed in the interlaced manner at the i-th row, the i2-th row and the i+2-th row. The second green pixels GB and the blue pixels B are disposed in the interlaced manner at the i1-th row and the i+1-th row. The first green pixels GR are disposed at the j2-th column, the j-th column and the j+2-th column. The second green pixels GB are disposed at the j1-th column and the j+1-th column.
(15) Each of the components of the color-shift calibration device 1 is described in detail in accompany with
(16) The calculating circuit 100 is configured to calculate a regional gradient change of the first green pixels GR and the second green pixels GB within a neighboring region corresponding to a target green pixel of the image 101.
(17) In an embodiment, the target green pixel can be the central pixel G.sub.R(i, j) corresponding to the i-th row and the j-th column, as illustrated in
(18) Take
(19) In an actual implementation, the calculating circuit 100 can be implemented by a combination of various operation units, such as, but not limited to a combination of an adder, a subtractor, a multiplier, a divider and a bit shifter to perform arithmetic operation.
(20) In an embodiment, the calculating circuit 100 calculates a first weighted average G.sub.Ravg according to the first green pixels G.sub.R within the neighboring region and calculates a second weighted average G.sub.Bavg according to the second green pixels G.sub.B within the neighboring region. Further, the calculating circuit 100 calculates the regional gradient change G.sub.grad(i,j) according to a difference of the first weighted average G.sub.Ravg and the second weighted average G.sub.Bavg.
(21) For example, when the calculating circuit 100 calculates the first weighted average G.sub.Ravg of the first green pixels G.sub.R(i2,j), G.sub.R(i+2,j), G.sub.R(i,j), G.sub.R(i,j2) and G.sub.R(i,j+2), the following equation is used:
G.sub.Ravg=(4G.sub.R(i,j)+1G.sub.R(i2,j)+1G.sub.R(i+2,j)+1G.sub.R(i,j2)+1G.sub.R(i,j+2))/8
(22) When the calculating circuit 100 calculates the second weighted average G.sub.Bavg of the second green pixels G.sub.B(i1,j1), G.sub.B(i1,j+1), G.sub.B(i+1,j1), and G.sub.R(i+1,j+1), the following equation is used:
G.sub.Ravg=(1G.sub.R(i1,j1)+1G.sub.B(i1,j+1)+1G.sub.B(i+1,j1)+1G.sub.B(i+1,j+1))/4
(23) Each of the numbers in front of the first green pixels G.sub.R and the second green pixels G.sub.B is the weighting number. In the present example, since a weighting numbers is four and the sums of equation are divided by 8 and 4 respectively, the bit shifter can be used in the implementation instead of the divider that is area-consuming and highly complex. However, in different embodiments, the amounts of the weighting values can be adjusted. The present invention is not limited thereto.
(24) As a result, the regional gradient change G.sub.grad(i,j) can be expressed by the following equation:
G.sub.grad(i,j)=|G.sub.RavgG.sub.Bavg|
(25) When the regional gradient change G.sub.grad(i,j) is smaller than a gradient threshold, the neighboring region of the target green pixel G.sub.R(i,j) is a flat region. When the regional gradient change G.sub.grad(i,j) is not smaller than a gradient threshold, the neighboring region of the target green pixel G.sub.R(i,j) is not a flat region and includes edges or textures that the intensity changes dramatically.
(26) The comparing circuit 102 is configured to calculate an intensity difference between the first green pixels G.sub.R and the second green pixels G.sub.B within the neighboring region.
(27) In a practical condition, the comparing circuit 102 can be implemented by such as, but not limited to a plurality of comparators to perform comparison on two values respectively.
(28) In an embodiment, the comparing circuit 102 compares the intensities of each pair of at least part of the first green pixels G.sub.R and the second green pixels G.sub.B closest to the first green pixels G.sub.R in the neighboring region to accumulate a first number of times that the intensity of the first green pixels G.sub.R is larger than the intensity of the second green pixels GB and a second number of times that the intensity of the second green pixels G.sub.B is larger than the intensity of the first green pixels G.sub.R.
(29) For example, the comparing circuit 102 compares the first green pixel G.sub.R(i,j) with the second green pixels G.sub.B(i1,j1), G.sub.B(i1,j+1), G.sub.B(i+1,j1) and G.sub.B(i+1,j+1) closest to the first green pixel G.sub.R(i,j) respectively, compares the first green pixel G.sub.R(i2,j) with the second green pixels G.sub.B(i1,j1) and G.sub.B(i1,j+1) closest to the first green pixel G.sub.R(i2,j) respectively and compares the first green pixel G.sub.R(i,j2) with the second green pixels G.sub.B(i1,j1) and G.sub.B(i+1,j1) closest to the first green pixel G.sub.R(i,j2) respectively.
(30) Further, the comparing circuit 102 compares the first green pixel G.sub.R(i,j+2) with the second green pixels G.sub.B(i1,j+1) and G.sub.B(j+1,j+1) closest to the first green pixel G.sub.R(i,j+2) respectively and compares the first green pixel G.sub.R(i+2,j) with the second green pixels G.sub.B(j+1,j1) and G.sub.B(i+1,j+1) closest to the first green pixel G.sub.R(i+2,j) respectively.
(31) Accordingly, the comparing circuit 102 performs comparisons for twelve times and further generates the accumulation result as the intensity difference BD between the first green pixels G.sub.R and the second green pixels G.sub.B.
(32) In an embodiment, when one of the first green pixels G.sub.R is larger than one of the second green pixels G.sub.B, the value of 1 is accumulated. When one of the first green pixels G.sub.R is not larger than one of the second green pixels G.sub.B, the value of 0 is accumulated. In other embodiments, other values can be selectively used to perform accumulation.
(33) The accumulation result of the comparison includes a first number of times that the intensity of the first green pixels G.sub.R is larger than the intensity of the second green pixels G.sub.B (accumulated as 1 for each time) and a second number of times that the intensity of the second green pixels G.sub.B is larger than the intensity of the first green pixels G.sub.R (accumulated as 0 for each time). The accumulation result can be used as the intensity difference BD.
(34) When the accumulation result of the comparison is closer to 12, the intensity of the first green pixels G.sub.R tends to be larger than the intensity of the second green pixels G.sub.B. When the accumulation result of the comparison is closer to 0, the intensity of the second green pixels G.sub.B tends to be larger than the intensity of the first green pixels G.sub.R.
(35) As a result, when the intensity difference BD is larger than a first threshold value or the intensity difference BD is smaller than a second threshold value, the intensity difference BD is determined to exceed the intensity threshold range. More specifically, the color-shift condition occurs between the first green pixels G.sub.R and the second green pixels G.sub.B.
(36) Take the accumulation method described above as an example, the first threshold value can be such as, but not limited to 10. The second threshold value can be such as, but not limited to 2. When the intensity difference BD is above 10, the intensity of the first green pixels G.sub.R is larger and the green color tends to include more red color. When the intensity difference BD is below 2, the intensity of the second green pixels G.sub.B is larger and the green color tends to include more blue color.
(37) The color-shift calibration circuit 104 is configured to perform a pixel calibration on the first green pixels G.sub.R and the second green pixels G.sub.B when the regional gradient change G.sub.grad(i,j) is smaller than the gradient threshold and the intensity difference BD exceeds the intensity threshold range.
(38) The color-shift calibration circuit 104 may include such as, but not limited to an adder, a subtractor, a multiplier, a divider and a bit shifter to perform arithmetic operation.
(39) In an embodiment, the color-shift calibration circuit 104 averages the target green pixel G.sub.R(i,j) and the first green pixels G.sub.R and/or the second green pixels G.sub.B within the neighboring region to perform a low pass filter to accomplish object of the color-shift calibration.
(40) For example, for the target green pixel G.sub.R(i,j) that is a first green pixel G.sub.R, the color-shift calibration circuit 104 averages the second green pixels G.sub.B first:
G.sub.Bavg=(G.sub.B(i1,j1)+G.sub.B(i1,j+1)+G.sub.B(i+1,j1)+G.sub.B(i+1,j+1))/4
(41) Subsequently, the color-shift calibration circuit 104 further averages the average of the second green pixels G.sub.B and the target green pixel G.sub.R(i,j) to generate the calibrated target green pixel G.sub.R(i,j):
G.sub.R(i,j)=(G.sub.Bavg+G.sub.R(i,j))/2
(42) The output circuit 106 is further configured to generate the output image 103. When the regional gradient change G.sub.grad(i,j) is smaller than the gradient threshold and the intensity difference BD exceeds the intensity threshold range, the output circuit 106 outputs the calibrated target green pixel G.sub.R(i,j) as the pixel at the position of (i, j) of the output image 103. When the regional gradient change G.sub.grad(i,j) is not smaller than the gradient threshold or the intensity difference BD does not exceed the intensity threshold range, the output circuit 106 outputs the target green pixel G.sub.R(i,j) as the pixel at the position of (i, j) of the output image 103.
(43) In an embodiment, the comparing circuit 102 can selectively cease to perform the comparison operation when the regional gradient change G.sub.grad(i,j) is not smaller than the gradient threshold such that the output circuit 106 directly outputs the target green pixel G.sub.R(i,j).
(44) As a result, the color-shift calibration device 1 of the present invention can determine the color-shift condition in the flat region of the image 101 and perform calibration on the target green pixel. Such a design prevents the edges or the textures in the image 101 from being blurred. The color-shift of the green pixels can be calibrated efficiently while the sharpness of the textures and the edges can be preserved.
(45) It is appreciated that configuration and the calculating method of the calculating circuit 100, the comparing circuit 102 and the color-shift calibration circuit 104 described above is merely an example. In other embodiments, other methods can be used to calculate the regional gradient change and the intensity difference and process the low pass filtering. The present invention is not limited thereto.
(46) Reference is now made to
(47) In step 301, the calculating circuit 100 calculates the regional gradient change G.sub.grad(i,j) of the first green pixels G.sub.R and the second green pixels G.sub.B within the neighboring region corresponding to the target green pixel G.sub.R(i,j) of the image 101.
(48) In step 302, the comparing circuit 102 calculates the intensity difference BD between the first green pixels G.sub.R and the second green pixels G.sub.B within the neighboring region.
(49) In step 303, whether the regional gradient change G.sub.grad(i,j) is smaller than the gradient threshold and whether the intensity difference BD exceeds the intensity threshold range are determined.
(50) In step 304, when the regional gradient change G.sub.grad(i,j) is smaller than the gradient threshold and the intensity difference BD exceeds the intensity threshold range, the color-shift calibration circuit 104 performs the pixel calibration on the target green pixel G.sub.R(i,j) based on the first green pixels G.sub.R and the second green pixels G.sub.B to generate the calibrated target green pixel G.sub.R(i,j) such that the output circuit 106 outputs the calibrated target green pixel G.sub.R(i,j).
(51) In step 305, when the regional gradient change G.sub.grad(i,j) is not smaller than the gradient threshold or the intensity difference BD exceeds the intensity threshold range, the output circuit 106 directly outputs the target green pixel G.sub.R(i,j).
(52) Reference is now made to
(53) In step 401, the calculating circuit 100 calculates the regional gradient change G.sub.grad(i,j) of the first green pixels G.sub.R and the second green pixels G.sub.B within the neighboring region corresponding to the target green pixel G.sub.R(i,j) of the image 101.
(54) In step 402, whether the regional gradient change G.sub.grad(i,j) is smaller than the gradient threshold determined.
(55) When the regional gradient change G.sub.grad(i,j) is determined to be smaller than the gradient threshold, the flow goes to step 403, wherein the comparing circuit 102 calculates the intensity difference BD between the first green pixels G.sub.R and the second green pixels G.sub.B within the neighboring region.
(56) In step 404, whether the intensity difference BD exceeds the intensity threshold range is determined.
(57) In step 405, when the intensity difference BD is determined to exceed the intensity threshold range, the color-shift calibration circuit 104 performs the pixel calibration on the target green pixel G.sub.R(1,j) based on the first green pixels G.sub.R and the second green pixels G.sub.B to generate the calibrated target green pixel G.sub.R(i,j) such that the output circuit 106 outputs the calibrated target green pixel G.sub.R(i,j).
(58) When the regional gradient change G.sub.grad(i,j) is determined to be not smaller than the gradient threshold in step 402 or when the intensity difference BD is determined to not exceed the intensity threshold range, the flow goes to step 406 such that the output circuit 106 directly outputs the target green pixel G.sub.R(i,j).
(59) Although the present invention has been described in considerable detail with reference to certain embodiments thereof, other embodiments are possible. Therefore, the spirit and scope of the appended claims should not be limited to the description of the embodiments contained herein.
(60) It will be apparent to those skilled in the art that various modifications and variations can be made to the structure of the present invention without departing from the scope or spirit of the invention. In view of the foregoing, it is intended that the present invention cover modifications and variations of this invention provided they fall within the scope of the following claims.