Adaptive shading correction
10044952 ยท 2018-08-07
Assignee
Inventors
- Viacheslav Chesnokov (Loughborough, GB)
- Daniel Larkin (Nottingham, GB)
- Varuna De Silva (Leicester, GB)
- Sutirtha Deb (Leicester, GB)
Cpc classification
H04N9/646
ELECTRICITY
H04N25/61
ELECTRICITY
H04N25/615
ELECTRICITY
International classification
H04N9/77
ELECTRICITY
Abstract
The present disclosure provides an adaptive shading correction method for correcting an image for lens shading, including segmenting the image into a plurality of blocks of pixels and identifying hue-flat blocks with a relatively low hue variance, where the hue-flat blocks are clustered into at least one cluster based on a spatial distribution of the blocks. Selected modification parameters for modifying an average shading mesh are identified by modifying the average shading mesh along a plurality of dimensions using a plurality of modification parameters, and processing the at least one cluster with the average shading mesh as modified so as to identify the selected modification parameters. The average shading mesh is modified using the selected modification parameters to generate a shading correction mesh, which is used to correct the image for lens shading.
Claims
1. An adaptive shading correction method for correcting an image for lens shading, the adaptive shading correction method comprising: segmenting the image into a plurality of blocks of pixels; identifying hue-flat blocks of the plurality of blocks, the hue-flat blocks having a relatively low hue variance; clustering the hue-flat blocks into at least one cluster based on a spatial distribution of the hue-flat blocks; identifying selected modification parameters for modifying an average shading mesh by: modifying the average shading mesh along a plurality of dimensions using a plurality of modification parameters, different ones of the plurality of modification parameters corresponding to a respective different dimension of the plurality of dimensions, and processing the at least one cluster, so as to identify the selected modification parameters; modifying the average shading mesh using the selected modification parameters to generate a shading correction mesh; and correcting the image for the lens shading using the shading correction mesh.
2. The adaptive shading correction method of claim 1, comprising: capturing a respective flatfield image for each of a plurality of different light sensors for each of a plurality of sensors of a same sensor type; and averaging the flatfield images to generate the average shading mesh.
3. The adaptive shading correction method of claim 1, wherein the average shading mesh is a representative profile of a brightness gradient for a predetermined sensor type.
4. The adaptive shading correction method of claim 1, wherein the identifying the hue-flat blocks comprises: calculating, for blocks of the plurality of blocks, a respective hue variance for a first color with respect to a second color; calculating, for blocks of the plurality of blocks, a respective hue variance for a third color with respect to the second color; and identifying blocks of the plurality of blocks with the hue variance for the first color with respect to the second color less than a first threshold and with the hue variance for the third color with respect to the second color less than a second threshold.
5. The adaptive shading correction method of claim 4, wherein: the first color is red, the second color is green and the third color is blue; the hue variance for red with respect to green, H.sub.r/g, for a block of the plurality of blocks is:
6. The adaptive shading correction method of claim 1, wherein: the selected modification parameters are selected to minimize a total hue variance of the at least one cluster upon correction of a first color channel of the image using the average shading mesh modified using the selected modification parameters, and wherein the total hue variance of the at least one cluster, E.sub.x/y, for correcting the first color channel of the image is:
7. The adaptive shading correction method of claim 6, wherein the first color is red or blue and the second color is green.
8. The adaptive shading correction method of claim 1, wherein the plurality of modification parameters comprises: a vertical shift of the average shading mesh; a horizontal shift of the average shading mesh; and a scaling of the average shading mesh.
9. The adaptive shading correction method of claim 8, wherein at least one of: the vertical shift is within a predetermined vertical search range; the horizontal shift is within a predetermined horizontal search range; or the scaling is within a predetermined scaling range.
10. The adaptive shading correction method of claim 1, wherein the modifying the average shading mesh comprises modifying the average shading mesh separately for each of a plurality of color channels.
11. The adaptive shading correction method of claim 1, comprising: correcting a first color channel of the image using the average shading mesh to generate a first partly corrected image; and applying the adaptive shading correction method to the first partly corrected image, the identifying the modification parameters comprising identifying modification parameters for a second color channel of the first partly corrected image; the modifying the average shading mesh comprising modifying the average shading mesh using the modification parameters for the second color channel of the first partly corrected image to generate the shading correction mesh; the correcting the image for the lens shading comprising correcting the first color channel of the first partly corrected image for the lens shading using the shading correction mesh to generate a second partly corrected image, the method further comprising: correcting the first color channel of the second partly corrected image using a further best shading correction mesh generated for a third color channel to generate a third partly corrected image.
12. The adaptive shading correction method of claim 11, wherein the first color channel is green, the second color channel is red and the third color channel is blue.
13. The adaptive shading correction method of claim 1, wherein the correcting the image for the lens shading using the shading correction mesh comprises, for each of a plurality of pixels of the image, multiplying a pixel value of a pixel of the plurality of pixels with a respective value of an inverse of the shading correction mesh.
14. The adaptive shading correction method of claim 1, wherein the clustering comprises, for each hue-flat block of the hue-flat blocks: determining a hue-flatness of other blocks in a spatial neighborhood of the hue-flat block; in response to determining that none of the other blocks are hue-flat, assigning the hue-flat block to a new cluster; in response to determining that solely one of the other blocks is hue-flat, assigning the hue-flat block to a same cluster as the one of the other blocks; and in response to determining that more than one of the other blocks is hue-flat, assigning the hue-flat block to a cluster comprising one of the more than one of the other blocks in dependence on a comparison between an average hue variance of the hue-flat block and an average hue variance of each cluster comprising one of the more than one of the other blocks.
15. The adaptive shading correction method of claim 14, wherein the comparison comprises: comparing an average r/g of the hue-flat block with an average r/g of the respective cluster; and comparing an average b/g of the hue-flat block with an average b/g of the respective cluster, where r is the proportion of red, g is the proportion of green, and b is the proportion of blue.
16. The adaptive shading correction method of claim 1, comprising pre-processing the image before the segmenting the image.
17. The adaptive shading correction method of claim 1, wherein the selected modification parameters are selected to minimize an error function based on a variance and a mean of the at least one cluster and a variance and a mean of regions of the average shading mesh as modified, each region of the regions corresponding with a cluster of the at least one cluster.
18. The adaptive shading correction method of claim 1, wherein the modifying the average shading mesh comprises interpolation of a variance and a mean of zones of the average shading mesh, each zone of the zones corresponding with a block of the plurality of blocks.
19. An image signal processor configured to perform an adaptive shading correction method for correcting an image for lens shading, the adaptive shading correction method comprising: segmenting the image into a plurality of blocks of pixels; identifying hue-flat blocks of the plurality of blocks, the hue-flat blocks having a relatively low hue variance; clustering the hue-flat blocks into at least one cluster based on a spatial distribution of the hue-flat blocks; identifying selected modification parameters for modifying an average shading mesh by: modifying the average shading mesh along a plurality of dimensions using a plurality of modification parameters, different ones of the plurality of modification parameters corresponding to a respective different dimension of the plurality of dimensions, and processing the at least one cluster, so as to identify the selected modification parameters; modifying the average shading mesh using the selected modification parameters to generate a shading correction mesh; and correcting the image for the lens shading using the shading correction mesh.
20. The image signal processor of claim 19, comprising a field programmable gate array.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
(1) Various features of the present disclosure will be apparent from the detailed description taken in conjunction with the accompanying drawings, which together illustrate, by way of example only, features of the present disclosure, and wherein:
(2)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
DETAILED DESCRIPTION OF CERTAIN INVENTIVE EMBODIMENTS
(12) Details of the method according to examples will become apparent from the following description, with reference to the FIGS. In this description, for the purpose of explanation, numerous specific details of certain examples are set forth. Reference in the specification to an example or similar language means that a particular feature, structure, or characteristic described in connection with the example is included in at least that one example, but not necessarily in other examples. It should further be noted that certain examples are described schematically with certain features omitted and/or necessarily simplified for ease of explanation and understanding of the concepts underlying the examples.
(13) Examples described herein provide an adaptive shading correction method for correcting an image for lens shading.
(14) The adaptive shading correction method according to examples can be used to adaptively correct images for lens shading, eliminating the need for per-unit calibration and/or the need for light source or illuminant identification, unlike a current industry standard vignetting correction method. For example, the adaptive shading correction method in examples preserves color saturation, leading to an improved image quality compared with known methods. For example, the adaptive shading correction method can be used to correct images for lens shading without losing naturally occurring shadows in the image and without losing overall saturation. Moreover, the adaptive shading correction method in examples can be implemented in a lightweight manner, so that the method can be realizable for real-time vignetting correction, e.g. using a field programmable gate array (FPGA) architecture. For example, the adaptive shading correction method can be implemented on various image signal processors (ISPs), e.g. mobile image signal processors. Details of the adaptive shading correction method according to various examples are discussed in more detail below.
(15)
(16) The adaptive shading correction module 100 in examples sits after black level correction and noise reduction blocks and, for example, may replace a status mesh shading correction block in an image signal processor.
(17)
(18) In examples such as
(19) Subsequently, the image is processed to identify regions of similar color, or hue, in the image. In examples such as that of
(20) In examples, the first color is red, the second color is green and the third color is blue. In such examples, the hue variance for red with respect to green, H.sub.r/g, for a block of the plurality of blocks may be calculated as:
(21)
where r is the proportion of red in a pixel of the block, g is the proportion of green in the pixel of the block, N is the number of pixels in the block, and
(22)
where b is the proportion of blue in a pixel of the block, g is the proportion of green in the pixel of the block, N is the number of pixels in the block, and
(23) In such cases, a particular block may be considered hue-flat if the hue variance for both red with respect to green (sometimes denoted as rig) and blue with respect to green (sometimes denoted as b/g) are both less than respective thresholds, Th.sub.r and Th.sub.b respectively:
(24)
(25) In an example, the thresholds Th.sub.r and Th.sub.b are calculated as 3 times the maximum hue variance in the average shading mesh, although other thresholds are possible in other examples. The thresholds are typically selected so as to isolate natural variations of hue from hue variations caused by lens shading.
(26) In examples, such as that of
(27) In
(28) Next, a set of candidates for the cluster number for the hue-flat block 126 is derived from the cluster numbers of the neighboring blocks 128. All non-zero cluster numbers of the neighboring blocks 128 will become candidates. If there are no non-zero clusters in the neighborhood, a new cluster number is assigned to the hue-flat block 126. An illustrated example of assigning a cluster number to the hue-flat block 126 is provided in
(29) As shown in the example of
(30) At this stage, if there is just one candidate cluster, the block N will be assigned to the candidate cluster and the mean or average hue variance of the candidate cluster will be adjusted accordingly. If there is more than one candidate cluster with the same cluster number, all the candidate clusters will become one cluster with that cluster number, and the block N will also be assigned to the consolidated cluster. All the blocks that belonged to the candidate clusters will be reassigned to the consolidated cluster number. In this scenario, the block N will act as a bridge to connect two or more disconnected clusters of hue-flat blocks.
(31)
(32) The clustering shown in
(33) Referring back to
(34) An example of identifying the shading correction mesh is illustrated schematically in
(35) In examples, the scaling of the average shading mesh may be performed as follows:
f.sub.scaled=S(f)
where is the maximum of the average shading mesh, S is the scaling factor, f is the average shading mesh and f.sub.scaled is the scaled average shading mesh.
(36) At least one of the vertical shift is within a predetermined vertical search range, the horizontal shift is within a predetermined horizontal search range or the scaling is within a predetermined scaling range in examples. For example, the horizontal and vertical search range may be limited to 77 pixels, i.e. so that a maximum x is 3. The scaling range may be for example between 0.9 and 1.1, in steps of 0.2.
(37) The selected modification parameters, such as the shifting or scaling of the average shading mesh, may be selected. The selection of the modification parameters typically involves processing of the at least one cluster. For example, the average shading mesh as modified may be applied to the at least one cluster and the modification parameters may be chosen based on the hue variance of the at least one cluster of the image as corrected using the average shading mesh. The selected modification parameters in examples are selected to minimize a total hue variance of the at least one cluster, for example upon correction of a first color channel of the image using the average shading mesh modified using the selected modification parameters. In such examples, the total hue variance of the at least one cluster, E.sub.x/y, for correcting the first color channel of the image may be calculated using:
(38)
where c is a cluster of the at least one cluster, C is the total number of clusters in the at least one cluster, N is the number of pixels in blocks of the cluster c, i is a pixel of the blocks of the cluster c, x is the proportion of a first color in the pixel i, y is the proportion of a second color in the pixel i, and
(39) In such cases, the selected modification parameters may be determined by calculating the total hue variance of all the clusters for each modification of the average shading mesh and then identifying the selected modification parameters (which may be denoted as, for example, x.sub.best, y.sub.best and S.sub.best) by the modification that yields the lowest E.sub.x/y:
(40)
(41) In examples, the first color is red or blue and the second color is green. In these examples, the total hue variance may be calculated as E.sub.r/g or E.sub.b/g respectively.
(42) The modifying the average shading mesh in examples, such as the example of
(43) In such cases, the method according to examples may include correcting a first color channel of the image using the average shading mesh to generate a first partly corrected image; and applying the adaptive shading correction method to the first partly corrected image. In these examples, the identifying the modification parameters may include identifying modification parameters for a second color channel of the first partly corrected image, the modifying the average shading mesh may include modifying the average shading mesh using the modification parameters for the second color channel of the first partly corrected image to generate the shading correction mesh, and the correcting the image for lens shading may include correcting the first color channel of the first partly corrected image for lens shading using the shading correction mesh to generate a second partly corrected image. In such examples, the first color channel of the second partly corrected image may be corrected using a further best shading correction mesh generated for a third color channel to generate a third partly corrected image. The first color channel may be green, the second color channel may be red and the third color channel may be blue, although other color channels are possible, as the skilled person will appreciate.
(44) In these cases, the process may for example be considered to be exhaustive across all three color channels. In a particular example, the process involves correcting the green channel of the image with the unmodified green channel of the average shading mesh, finding adaptation or modification parameters, for example best adaptation parameters, for the red channel with use of the partly corrected image, correcting the green channel of the image with the modified red channel of the average scaling mesh and repeating the finding of the modification parameters for the blue channel with use of the partly corrected image after correction with the modified red channel of the average scaling mesh and correction of the blue channel using the selected modification parameters.
(45) The adaptive shading correction method according to examples may be implemented in software, for example using Matlab.
(46) The example implementation of
(47) In
(48) In examples, the method of
(49) After the pre-processing 142, the image undergoes block analysis 144 in the example of
(50) Subsequently, the output of the clustering is used for pixel storage 150, in which a table of pixels 152 is stored with a pixel address in row and column space, an r/g value of the respective pixels, a b/g value of the respective pixel and the cluster the respective pixel is associated with. In an example, this table will contain 5168 entries, although other numbers of entries are possible in other examples. The output of the clustering may also be or include a value to indicate if there are any clusters of hue-flat regions. For example, if this value is 0 (indicating no hue-flat regions), a traditional mesh shading may be applied instead of the adaptive shading correction method according to examples.
(51) In
(52) The output of the search 236 for the shading correction mesh in the example of
(53) The selected modification parameters 156 are used to generate the shading correction mesh, which is used to apply the shading correction 238 to the image. In the example of
Comparative Example
(54) The performance of the adaptive shading correction method according to examples is compared against a known dynamic mesh shading correction algorithm (DMSC). The shading correction experiments were carried out on 160 raw images captured with several camera units manufactured by OmniVision, 4275 Burton Drive, Santa Clara, Calif. 95054, United States of America (Part No: OV8835).
(55) While traditional image quality metrics (such as the structural similarity index, SSIM, or the video quality metric, VQM) cannot be used for this comparison, as they do not take color shading artifacts into consideration, the variance of hue in hue-flat regions may be taken as the color shading metric and the average pixel saturation may be taken as the saturation measure.
(56) The results in Table 1 (below) indicate that the adaptive shading correction method according to examples outperforms the DMSC algorithm in terms of color shading measured using the hue-variance metric, without compromising the overall saturation:
(57) TABLE-US-00001 TABLE 1 Comparison of performance of the adaptive shading correction method according to examples and the DMSC algorithm in terms of color shading and saturation. Hue-variance in Average pixel hue-flat blocks saturation DMSC algorithm 0.072 0.2165 Adaptive shading 0.064 0.2115 correction method
APPENDICES
(58) Appendix 1 illustrates an example Matlab function flow and Appendix 2 illustrates example Matlab function interfaces. Both of these examples may be used with the Matlab implementation described with reference to
(59) The above examples are to be understood as illustrative examples. Further examples are envisaged. For example, although
(60)
(61) As in the example of
(62) The method of the example of
(63)
where c is a cluster of the at least one cluster, C is the total number of clusters in the at least one cluster, N is the number of pixels in blocks of the cluster c, i is a pixel of the blocks of the cluster c, x is the proportion of a first color in the pixel i, y is the proportion of a second color in the pixel i, and
(64) Referring now to the generation of the shading correction mesh, in the example of
(65) After creation of the cluster map 162 as described above, the average shading mesh after modification 158 in the example of
(66) In other examples, the cluster map 164 of the average shading mesh is obtained by overlaying the cluster map from the at least one cluster of the image over the blocks of the average shading mesh before the average shading mesh is modified. In such cases, the average shading mesh may subsequently be modified, for example by shifting in an x and/or y direction and/or by scaling to generate the modified average shading mesh.
(67) Subsequently, in examples such as that of
(68) Various methods may be used to calculate the mean and variance of blocks of a cluster of the image as corrected using the average shading mesh as modified. For example, if the variance of a block of the image as corrected using the average shading mesh as modified is symbolized as , then may be calculated as:
=.sub.image*.sub.mesh+(.sub.image).sup.2*.sub.mesh(.sub.mesh).sup.2*.sub.image
where .sub.image is the variance of the corresponding block of the image and .sub.mesh is the variance of the corresponding block of the average shading mesh as modified.
(69) Similarly, the mean of the block as corrected using the average shading mesh as modified, symbolized as , may be calculated as:
=.sub.image*.sub.mesh
where .sub.image is the mean of the corresponding block of the image and .sub.mesh is the mean of the corresponding block of the average shading mesh as modified.
(70) The calculation of the variance and the mean of blocks of the image and of the average shading mesh as modified is illustrated schematically in step 166 of the example of FIG. 10. The variance and the mean of blocks of the image and of the average shading mesh as modified, for example obtained as set out above, may then be used in an error analysis 168.
(71) The error analysis 168 in examples such as that of
(72)
where i is a block of the blocks in the cluster and N is the total number of blocks in the cluster.
(73) The variance of the cluster .sub.cluster of the shading corrected resultant image may be calculated for example using:
(74)
where the sum is over the blocks of the cluster, N.
(75) The standard deviation, SD, of a cluster may be calculated, for example, as:
(76)
where N.sub.B is the number of blocks in the cluster and N.sub.B.sup.Tot is the total number of blocks in all the clusters.
(77) An error function, EF, may then be calculated based on the standard deviation as:
(78)
where C is the total number of clusters.
(79) This process may be repeated for the average shading mesh as modified using a variety of different modification parameters, for example to identify the selected modification parameters. In examples, the selected modification parameters may be chosen to minimize the error function or such that the error function satisfies a predetermined criterion, such as being below a given threshold error value. Identification of the selected modification parameters allows the shading correction mesh to be obtained 170 by modifying the average shading mesh using the selected modification parameters to generate the shading correction mesh. The image may then be corrected using the shading correction mesh.
(80) This process in examples may therefore be summarized as selecting the selected modification parameters to minimize an error function based on a variance and a mean of the at least one cluster and a variance and a mean of regions of the average shading mesh as modified, each region of the regions corresponding with a cluster of the at least one cluster. Thus, in examples in accordance with
(81) In further examples, rather than modifying the average shading mesh using the modification parameters and then calculating the mean and the variance of blocks and subsequently clusters of the average shading mesh as modified, the average shading mesh may instead be modified by interpolating a variance and a mean of zones or blocks of the average shading mesh, each zone of the zones corresponding with a block of the plurality of blocks. For example, the mean and variance of the average shading mesh may be calculated for each of the zones for various different modification parameters as applied to the average shading mesh by appropriately interpolating the mean and variance of the average shading mesh with given modification parameters (or prior to modification). The calculated mean and variance of the average shading mesh as modified may then be combined with the calculated mean and variance of the hue-flat blocks of the image to calculate the error function, for example as described above with reference to
(82) It is to be understood that any feature described in relation to any one example may be used alone, or in combination with other features described, and may also be used in combination with one or more features of any other of the examples, or any combination of any other of the examples. Furthermore, equivalents and modifications not described above may also be employed without departing from the scope of the accompanying claims.