Color shading correction method and device
By obtaining the compensation table combination of different color temperature light sources and calculating the error value of the interpolation coefficient, determining the target compensation table suitable for the current light source, solving the problem that the compensation table in the prior art cannot accurately adapt to the current light source, and achieving better color shadow correction effect.
Patent Information
- Application Number
- CN202111677580.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2041-12-31
AI Technical Summary
The existing color shadow correction technology has the problem that the compensation table cannot accurately adapt to the current light source, resulting in the unsatisfactory color shadow correction effect.
By obtaining multiple compensation table combinations, each combination contains a compensation table corresponding to light sources of different color temperatures, calculate the error value of each combination using different interpolation coefficients, and determine the target compensation table combination and target interpolation coefficient corresponding to the minimum error value, thereby obtaining a target compensation table suitable for the current light source for color shading correction.
It realizes accurate compensation for the color shadow of the current light source, improving the effect of color shadow correction.
Smart Images

Figure CN114331907B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image signal processing, and in particular to a color shading correction method and device. Background Art
[0002] Color shading is a common lens shading, which is manifested as inconsistent colors between the center and the surrounding areas of the image. Since the lens refracts light of different spectra to different degrees, light of different wavelengths falls on different positions of the image sensor. Under different light source color temperatures, the attenuation trends of the R, G, and B channels are different, resulting in color deviations around and in the center of the image. The color uniformity of the image is poor, which seriously affects the image quality.
[0003] A common solution to the above problem is to perform image processing on the original image through an image signal processor (ISP) after capturing the original image, specifically to correct the lens shading of the original image through a lens shading correction (LSC) module included in the ISP.
[0004] However, the existing color shading correction technology has the problem that the compensation table cannot accurately adapt to the current light source, resulting in an unsatisfactory color shading correction effect.
[0005] The above information disclosed in the background section is only for enhancing understanding of the background of the present application and therefore it may contain information that does not form the prior art known to a person of ordinary skill in the art. Summary of the invention
[0006] The present application provides a color shading correction method and device to solve the problems existing in the prior art.
[0007] In a first aspect, the present application provides a color shading correction method, comprising:
[0008] Acquire at least two compensation table combinations, each compensation table combination includes a first compensation table and a second compensation table, the first compensation table and the second compensation table respectively including color shading compensation data corresponding to light sources of different color temperatures;
[0009] Determine the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determine the target compensation table combination and the target interpolation coefficient corresponding to the minimum error value;
[0010] A target compensation table is determined according to the first compensation table and the second compensation table in the target compensation table combination and the target interpolation coefficient, and a color shading correction process is performed using the target compensation table.
[0011] In some embodiments, respectively determining the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determining the target compensation table combination and the target interpolation coefficient corresponding to the minimum error value, includes:
[0012] determining a first selectable interpolation coefficient;
[0013] Calculate the first error value of each compensation table combination for color shading correction under the first optional interpolation coefficient, determine the second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value in the first error values, and use the second optional interpolation coefficient as the new first optional interpolation coefficient, and repeat this step until the iteration stop condition is met;
[0014] The compensation table combination corresponding to the last obtained minimum error value is determined as the target compensation table combination, and the interpolation coefficient corresponding to the last obtained minimum error value is determined as the target interpolation coefficient.
[0015] In some embodiments, determining the first selectable interpolation coefficient includes:
[0016] A first optional interpolation coefficient is determined according to the first value range and the first step length, wherein the first step length is smaller than a difference between a maximum value and a minimum value in the first value range.
[0017] In some embodiments, calculating a first error value for color shading correction for each compensation table combination under a first optional interpolation coefficient includes:
[0018] According to the first compensation table and the second compensation table in each compensation table combination, and the first optional interpolation coefficient, the following processing is performed:
[0019] Performing color shading correction on the original image according to the first compensation table, the second compensation table and the first optional interpolation coefficient to obtain a corrected statistical value image;
[0020] Determining error values of at least two sub-image blocks in the corrected statistical value image;
[0021] According to the error value of each sub-image block, a first error value of the corrected statistical value image is determined.
[0022] In some embodiments, color shading correction is performed by the following formula:
[0023] lscm_apply_table=LSCM*table0*ratio+LSCM*table1*(1-ratio)
[0024] Among them, lscm_apply_table represents the corrected statistical value image, LSCM represents the downsampled original image, table0 represents the first compensation table, table1 represents the second compensation table, and ratio represents the first optional interpolation coefficient.
[0025] In some embodiments, determining the error values of at least two sub-image blocks in the corrected statistical value image includes:
[0026] Converting the ratio of the r channel to the g channel of the sub-image block to a logarithmic domain to obtain a first sub-error value;
[0027] Converting the ratio of the b channel to the g channel of the sub-image block to a logarithmic domain to obtain a second sub-error value;
[0028] The sum of the variances of the first sub-error value and the second sub-error value is determined as the error value of the sub-image block.
[0029] In some embodiments, determining the first error value of the corrected statistical value image according to the error value of each sub-image block includes:
[0030] Determine the weight of each sub-image block according to the magnitude relationship between the error value of each sub-image block and the average error value, wherein the average error value is the average value of the error values of all sub-image blocks;
[0031] A weighted summation process is performed according to the error values and weights of all sub-image blocks to obtain a first error value of the corrected statistical value image.
[0032] In some embodiments, determining the second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value among the first error values includes:
[0033] Determine a second value range according to the interpolation coefficient corresponding to the minimum error value among the first error values;
[0034] A second optional interpolation coefficient is determined according to the second value range and the second step length, wherein the second step length is smaller than a difference between a maximum value and a minimum value in the second value range.
[0035] In some embodiments, determining a target compensation table according to a first compensation table and a second compensation table in a target compensation table combination and a target interpolation coefficient includes:
[0036] The target compensation table is determined by the following formula:
[0037] table_tar=table0_tar*ratio_tar+table1_tar*(1-ratio_tar)
[0038] Among them, table_tar represents the target compensation table, table0_tar represents the first compensation table in the target compensation table combination, table1_tar represents the second compensation table in the target compensation table combination, and ratio_tar represents the target interpolation coefficient.
[0039] In a second aspect, the present application provides a color shading correction device, comprising:
[0040] An acquisition module, used to acquire at least two compensation table combinations, each compensation table combination includes a first compensation table and a second compensation table, the first compensation table and the second compensation table respectively contain color shading compensation data corresponding to light sources of different color temperatures;
[0041] A determination module, used to respectively determine the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determine a target compensation table combination and a target interpolation coefficient corresponding to a minimum error value;
[0042] A processing module is used to determine a target compensation table according to the first compensation table and the second compensation table in the target compensation table combination and the target interpolation coefficient, and perform color shading correction processing through the target compensation table.
[0043] The color shading correction method and device provided in the present application first obtain a plurality of compensation table combinations, each compensation table combination including compensation tables corresponding to two light sources with different color temperatures, and then calculate the error value of color shading correction for each compensation table combination through different interpolation coefficients, so as to determine the optimal target compensation table suitable for the current light source, and then perform color shading correction through the target compensation table, which can accurately compensate for the color shading of the current light source, thereby effectively improving the color shading correction effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0045] Figure 1 A schematic diagram of an electronic device capturing image data through a camera module;
[0046] Figure 2 A schematic diagram of a color shading correction method provided in an embodiment of the present application;
[0047] Figure 3 A schematic diagram of a color shading correction device provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0049] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0050] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "an" and "the" used in the embodiments of the present application are also intended to include plural forms, unless the context clearly indicates other meanings.
[0052] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a product or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such a product or system. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the product or system including the elements.
[0053] Color shading is a common lens shading, which is manifested as inconsistent colors between the center and the surrounding areas of the image. Since the lens refracts light of different spectra to different degrees, light of different wavelengths falls on different positions of the image sensor. Under different light source color temperatures, the attenuation trends of the R, G, and B channels are different, resulting in color deviations around and in the center of the image. The color uniformity of the image is poor, which seriously affects the image quality.
[0054] A common solution to the above problem is to perform image processing on the original image through an image signal processor (ISP) after capturing the original image, specifically to correct the lens shading of the original image through a lens shading correction (LSC) module included in the ISP.
[0055] In the prior art, when color shading correction is performed, first, multiple original images are taken by a mobile phone camera or other imaging system under multiple standard light sources, such as TL84 light source (color temperature: 4000K), CWF light source (color temperature: 4150K), D65 light source (color temperature: 6500K), etc., and lens shading compensation tables under each light source are obtained based on the original image calibration and stored in a medium. When an image is taken in an actual scene, the stored compensation table is called according to the current scene light source to perform color shading compensation on the current scene light source image.
[0056] However, the existing technology has the following problems: First, the number of light sources that can be used for calibration is limited. The actual ambient color temperature changes linearly, and it is impossible to calibrate light sources of all color temperatures. Second, the actual ambient light source is more complex than the calibrated light source, and may be a mixed light source, such as the light source near the window in the room. Directly calling the pre-calibrated compensation table cannot adapt well to complex light source scenes, resulting in unsatisfactory color shading correction effect.
[0057] The color shading correction method and device provided in this application are intended to solve the above technical problems in the prior art.
[0058] The main concept of the scheme of the present application is: the present application proposes a method and device for adaptive color shading correction of a light source, firstly, a plurality of compensation table combinations are obtained, each compensation table combination contains compensation tables corresponding to two light sources with different color temperatures, and then the error value of color shading correction for each compensation table combination is calculated by different interpolation coefficients, so as to determine the optimal target compensation table suitable for the current light source, and then the color shading correction is performed by the target compensation table, which can accurately compensate for the color shading of the current light source, thereby effectively improving the color shading correction effect.
[0059] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0060] It can be understood that the processing steps of the color shading correction method in the present application can be implemented by an image signal processor ISP, and specifically can be implemented by a lens shading correction LSC module in the ISP.
[0061] It can be understood that the technical solution of the present application can be specifically applied to electronic devices that are integrated with camera modules, have shooting functions and require color shading correction, such as mobile phones, industrial cameras, network cameras, tablet computer cameras, game console cameras, video-capable smart watches, security cameras, camera modules, etc.
[0062] In the above electronic devices, the camera module generally includes a lens, a filter (such as an infrared cutoff filter) and an image sensor, wherein the lens is generally composed of one or more lenses, and the image sensor can generally be a CCD image sensor or a CMOS image sensor.
[0063] Figure 1 A schematic diagram of an electronic device capturing image data through a camera module, such as Figure 1 As shown, after the light passes through the lens 101 and the filter 102 in sequence, it reaches the image sensor 103, and the image sensor 103 converts the optical signal into an electrical signal to collect image data. In this process, the angle of the light changes after being refracted by the lens 101. The light transmittance of the filter changes with the change of the incident angle, that is, the light of the same wavelength has different transmittances at different incident angles, which causes the problem of color shadows in the captured image.
[0064] Figure 2 A schematic diagram of a color shading correction method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method mainly includes the following steps:
[0065] S100, obtaining at least two compensation table combinations, each compensation table combination including a first compensation table and a second compensation table, the first compensation table and the second compensation table respectively including color shading compensation data corresponding to light sources of different color temperatures, that is, the first compensation table and the second compensation table are color shading compensation tables corresponding to light sources of different color temperatures;
[0066] Specifically, the compensation table combination refers to a combination of color shading compensation tables corresponding to two light sources of different color temperatures, and each compensation table contains color shading compensation data corresponding to a light source of a certain color temperature.
[0067] For example, the number of compensation table combinations may be 3, specifically a first compensation table combination, a second compensation table combination, and a third compensation table combination. Among them, the first compensation table in the first compensation table combination corresponds to a light source with a color temperature of x1, and the second compensation table in the first compensation table combination corresponds to a light source with a color temperature of x2; the first compensation table in the second compensation table combination corresponds to a light source with a color temperature of x3, and the second compensation table in the second compensation table combination corresponds to a light source with a color temperature of x4; the first compensation table in the third compensation table combination corresponds to a light source with a color temperature of x5, and the second compensation table in the third compensation table combination corresponds to a light source with a color temperature of x6.
[0068] Optionally, the light sources corresponding to the compensation tables in all compensation table combinations include multiple light sources ranging from low color temperature to high color temperature. For example, in combination with the above example, x1 and x2 may be low color temperature, x3 and x4 may be medium color temperature, and x5 and x6 may be high color temperature, thereby ensuring that the target compensation table obtained by interpolation can be suitable for light sources with different color temperatures.
[0069] Optionally, in each compensation table combination, the color temperature difference between the light sources corresponding to the first compensation table and the second compensation table is less than a preset threshold, that is, the first compensation table and the second compensation table are compensation tables corresponding to light sources with relatively close color temperatures. Thus, by interpolating two compensation tables with relatively close color temperatures, a target compensation table suitable for the current color temperature can be better determined.
[0070] Optionally, the process of obtaining at least two compensation table combinations may be to first obtain a plurality of original images for calibration (i.e., color shading correction) under light sources of different color temperatures through a photographing device; then, perform color shading correction on the plurality of original images for calibration, thereby obtaining color shading compensation tables corresponding to a plurality of light sources of different color temperatures; finally, combine the color shading compensation tables corresponding to the plurality of light sources of different color temperatures, thereby obtaining at least two compensation table combinations.
[0071] For example, assuming that light sources with different color temperatures specifically include light sources with color temperatures of x1, x2, x3, x4, x5, and x6 (the color temperature data are sorted from small to large, where x1 is a low color temperature and x6 is a high color temperature), six compensation tables are obtained through calibration, namely table_x1, table_x2, table_x3, table_x4, table_x5, and table_x6. Then, three compensation table combinations can be obtained through combination, namely {table_x1, table_x2}, {table_x3, table_x4}, and {table_x5, table_x6}.
[0072] In addition, depending on the value of the preset threshold, other combinations can also be used to obtain other numbers of compensation table combinations, such as {table_x1, table_x2}, {table_x2, table_x3}, {table_x3, table_x4}, {table_x4, table_x5}, {table_x5, table_x6}, etc.
[0073] In addition, the same compensation table can be combined with multiple other compensation tables to obtain multiple compensation table combinations. For example, taking table_x1 as an example, the compensation table combination obtained by combination can also be {table_x1, table_x2}, {table_x1, table_x3}, {table_x1, table_x4}, etc. Similarly, for table_x2, the compensation table combination obtained by combination can also be {table_x2, table_x3}, {table_x2, table_x4}, {table_x1, table_x5}, etc. The same applies to other compensation tables.
[0074] S200, respectively determining the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determining a target compensation table combination and a target interpolation coefficient corresponding to a minimum error value;
[0075] After obtaining at least two compensation table combinations, for each compensation table combination, different interpolation coefficients are used to perform color shading correction on the original image, and error values of color shading correction for each compensation table combination under different interpolation coefficients are obtained, wherein the smaller the error value, the better the color shading correction effect. Therefore, after obtaining all error values, the minimum error value is screened out from all error values, and the target compensation table combination and the target interpolation coefficient corresponding to the minimum error value are determined.
[0076] S300, determining a target compensation table according to the first compensation table and the second compensation table in the target compensation table combination and the target interpolation coefficient, and performing color shading correction processing through the target compensation table.
[0077] After determining the target compensation table combination and the target interpolation coefficient corresponding to the minimum error value, the target compensation table is determined according to the first compensation table and the second compensation table in the target compensation table combination, and the target interpolation coefficient, that is, the first compensation table and the second compensation table in the target compensation table combination are merged through the target interpolation coefficient to obtain a single target compensation table suitable for the current light source. The color shading correction processing of the image of the current light source is performed through the target compensation table, which can ensure the best color shading correction effect.
[0078] The present embodiment proposes a light source adaptive color shading correction method, firstly, a plurality of compensation table combinations are obtained, each compensation table combination includes compensation tables corresponding to two light sources with different color temperatures, and then the error value of color shading correction for each compensation table combination is calculated by different interpolation coefficients, so as to determine the optimal target compensation table suitable for the current light source, and then the color shading correction is performed by the target compensation table, which can accurately compensate for the color shading of the current light source, thereby effectively improving the color shading correction effect.
[0079] In some embodiments, respectively determining the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determining the target compensation table combination and the target interpolation coefficient corresponding to the minimum error value, includes:
[0080] S210, determining a first optional interpolation coefficient;
[0081] S220, calculating the first error value of each compensation table combination for color shading correction under the first optional interpolation coefficient, determining the second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value in the first error values, and using the second optional interpolation coefficient as a new first optional interpolation coefficient, and repeating this step until the iteration stop condition is met;
[0082] S230, determining the compensation table combination corresponding to the last minimum error value obtained as the target compensation table combination, and determining the interpolation coefficient corresponding to the last minimum error value obtained as the target interpolation coefficient.
[0083] In this embodiment, after obtaining at least two compensation table combinations, a similar one-N search method (such as a one-quarter search method) can be used for the two compensation tables in each compensation table combination, that is, iterative processing is performed through interpolation coefficients in different ranges to find the interpolation coefficients that minimize the compensation effect error.
[0084] Optionally, determining a first optional interpolation coefficient includes: determining the first optional interpolation coefficient according to a first value range and a first step length, wherein the first step length is smaller than a difference between a maximum value and a minimum value in the first value range.
[0085] Among them, error represents the error value, ratio represents the interpolation coefficient, the first value range can be specifically [0, 1], the first step length is 1 / s, and the first optional interpolation coefficient specifically includes {0*1 / s, 1*1 / s, 2*1 / s,…, (s-1)*1 / s, s*1 / s}.
[0086] Optionally, calculating a first error value for color shading correction for each compensation table combination under a first optional interpolation coefficient includes:
[0087] According to the first compensation table and the second compensation table in each compensation table combination, and the first optional interpolation coefficient, the following processing is performed:
[0088] S221, performing color shading correction on the original image according to the first compensation table, the second compensation table and the first optional interpolation coefficient to obtain a corrected statistical value image;
[0089] The statistical value image is the downsampled image, and the corrected statistical value image is the downsampled image after color shading correction.
[0090] Optionally, for the three channels of R, G, and B, color shading correction is performed using the following formula:
[0091] lscm_apply_table=LSCM*table0*ratio+LSCM*table1*(1-ratio)
[0092] Among them, lscm_apply_table represents the corrected statistical value image, LSCM represents the downsampled original image, table0 represents the first compensation table, table1 represents the second compensation table, and ratio represents the first optional interpolation coefficient.
[0093] S222, determining error values of at least two sub-image blocks in the corrected statistical value image;
[0094] After obtaining the corrected statistical value image lscm_apply_table, the corrected statistical value image lscm_apply_table is divided, for example, into m*n sub-image blocks, and then the error value of each sub-image block is calculated respectively.
[0095] Optionally, determining the error values of at least two sub-image blocks in the corrected statistical value image includes:
[0096] S222a, converting the r / g and b / g values of the sub-image block into a logarithmic domain to obtain a first sub-error value and a second sub-error value;
[0097] S222b: Determine the sum of the variances of the first sub-error value and the second sub-error value as the error value of the sub-image block.
[0098] Specifically, for the i-th (i=1, 2, 3, ..., m*n) sub-image block, the r / g and b / g values are converted to the logarithmic domain respectively to obtain the first sub-error value and the second sub-error value, which are respectively recorded as error_r and error_b. Then, the sum of the variances of error_r and error_b is calculated, that is, the variance of the i-th sub-image block, to obtain the error value of the sub-image block, which is recorded as error_value.
[0099] Repeat the above steps until the error_value of m*n sub-image blocks is calculated.
[0100] S223: Determine a first error value of the corrected statistical value image according to the error value of each sub-image block.
[0101] After the error values error_value of m*n sub-image blocks are obtained, the first error value of the corrected statistical value image can be determined according to the error values of all sub-image blocks.
[0102] Optionally, determining a first error value of the corrected statistical value image according to the error value of each sub-image block includes:
[0103] S223a, determining the weight of each sub-image block according to the magnitude relationship between the error value of each sub-image block and the average error value, wherein the average error value is the average value of the error values of all sub-image blocks;
[0104] S223b, performing weighted summation processing according to the error values and weights of all sub-image blocks to obtain a first error value of the corrected statistical value image.
[0105] Specifically, firstly, the average error value of the error values error_value of the m*n sub-image blocks is calculated, recorded as avg_error_value, and then the weight of each sub-image block is determined according to the average error value avg_error_value.
[0106] Optionally, the weight of each sub-image block is determined by the following formula:
[0107]
[0108] Among them, error weight(i) represents the weight of the i-th sub-image block, and error_value(i) represents the error value of the i-th sub-image block.
[0109] After obtaining the weights of each sub-image block, the first error value error of the corrected statistical value image can be obtained by performing weighted summation, which is specifically:
[0110]
[0111] In this embodiment, the error evaluation method adopts weighted summation, assigning different weights to different variance values, fully considering the importance of different variance values to the error, making the error calculation more accurate, thereby ensuring that the optimal interpolation coefficient of the compensation table is calculated more accurately, so that the target compensation table obtained by the final interpolation is the compensation table most suitable for the current light source color temperature.
[0112] In some embodiments, after the first error value is calculated by a set of optional interpolation coefficients, when performing the next iterative process of calculating the error value, determining the second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value in the first error values includes:
[0113] Determine a second value range according to the interpolation coefficient corresponding to the minimum error value in the first error value; determine a second optional interpolation coefficient according to the second value range and the second step size, wherein the second step size is smaller than the difference between the maximum value and the minimum value in the second value range.
[0114] Specifically, the first value range is [0, 1], the first step length is 1 / s, and the first optional interpolation coefficients include {0*1 / s, 1*1 / s, 2*1 / s, ..., (s-1)*1 / s, s*1 / s} as an example for explanation:
[0115] (1) In the first error value obtained by the first calculation, if the interpolation coefficient corresponding to the minimum error value is close to 0, that is, in the range of [0*1 / s, 1*1 / s], then the range of the interpolation coefficient corresponding to the minimum error value can be used as the second value range, that is, the second value range is [0*1 / s, 1*1 / s], and the second step size is less than the difference between 1*1 / s and 0*1 / s, for example, it can be 1 / s 2 , then the second optional interpolation coefficient can be {0*1 / s 2 , 1*1 / s 2 , 2*1 / s 2 ,…,(s-1)*1 / s 2 , s*1 / s 2}.
[0116] (2) If the interpolation coefficient corresponding to the minimum error value is close to 1, that is, in the range of [(s-1)*1 / s, s*1 / s] (that is, [1-1 / s, 1]), then the range of the interpolation coefficient corresponding to the minimum error value can be used as the second value range, that is, the second value range is [1-1 / s, 1], and the second step size is less than the difference between 1 and 1-1 / s, for example, it can be 1 / s 2 , then the second optional interpolation coefficient can be {1-s*1 / s 2 , 1-(s-1)*1 / s 2 , ..., 1-3*1 / s 2 , 1-2*1 / s 2 , 1-1*1 / s 2 , 1}.
[0117] (3) If the interpolation coefficient corresponding to the minimum error value is near an intermediate point such as 1*1 / s, 2*1 / s, 3*1 / s, such as 1*1 / s, then the second value range can be, for example, [1 / s-1 / s, 1 / s+1 / s], the second step length is 1 / 2s, and the second optional interpolation coefficient can be {0*1 / 2s, 1*1 / 2s, 2*1 / 2s, 3*1 / 2s, …, s*1 / 2s}, and the same applies to other intermediate points.
[0118] After determining the second optional interpolation coefficient, the second optional interpolation coefficient is used as a new first optional interpolation coefficient, and then the corresponding first error value is calculated through steps S221-S223, so as to obtain the first error value of each compensation table combination for color shading correction under the first optional interpolation coefficient.
[0119] It can be understood that in this embodiment, the process of determining a new first optional interpolation coefficient based on the minimum error value among the first error values determined last time, and calculating the corresponding first error value based on the new first optional interpolation coefficient can be considered as an iterative calculation process, and the iterative calculation process can be repeated until the iteration stop condition is met.
[0120] Optionally, the iteration stopping condition may be, for example, that the number of iterations reaches a preset number (e.g., 8 times), or that the duration of other iterative calculations reaches a preset duration, which may be determined based on the calculation accuracy requirements and calculation time requirements of the actual scenario.
[0121] In some embodiments, determining a target compensation table according to a first compensation table and a second compensation table in a target compensation table combination and a target interpolation coefficient includes:
[0122] The target compensation table is determined by the following formula:
[0123] table_tar=table0_tar*ratio_tar+table1_tar*(1-ratio_tar)
[0124] Among them, table_tar represents the target compensation table, table0_tar represents the first compensation table in the target compensation table combination, table1_tar represents the second compensation table in the target compensation table combination, and ratio_tar represents the target interpolation coefficient.
[0125] It should be understood that, although the various steps in the flowcharts in the above-described embodiments are sequentially displayed according to the indications of the arrows, these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and they can be executed in other orders. Moreover, at least a portion of the steps in the figure may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily to be carried out sequentially, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0126] In some embodiments, a color shading correction apparatus is provided.
[0127] Figure 3 A schematic diagram of a color shading correction device provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the device comprises:
[0128] An acquisition module 100 is used to acquire at least two compensation table combinations, each compensation table combination includes a first compensation table and a second compensation table, the first compensation table and the second compensation table respectively contain color shading compensation data corresponding to light sources of different color temperatures;
[0129] A determination module 200, for respectively determining the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determining a target compensation table combination and a target interpolation coefficient corresponding to a minimum error value;
[0130] The processing module 300 is used to determine a target compensation table according to the first compensation table and the second compensation table in the target compensation table combination and the target interpolation coefficient, and perform color shading correction processing through the target compensation table.
[0131] In some embodiments, respectively determining the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determining the target compensation table combination and the target interpolation coefficient corresponding to the minimum error value, includes:
[0132] determining a first selectable interpolation coefficient;
[0133] Calculate the first error value of each compensation table combination for color shading correction under the first optional interpolation coefficient, determine the second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value in the first error values, and use the second optional interpolation coefficient as the new first optional interpolation coefficient, and repeat this step until the iteration stop condition is met;
[0134] The compensation table combination corresponding to the last obtained minimum error value is determined as the target compensation table combination, and the interpolation coefficient corresponding to the last obtained minimum error value is determined as the target interpolation coefficient.
[0135] In some embodiments, determining the first selectable interpolation coefficient includes:
[0136] A first optional interpolation coefficient is determined according to the first value range and the first step length, wherein the first step length is smaller than a difference between a maximum value and a minimum value in the first value range.
[0137] In some embodiments, calculating a first error value for color shading correction for each compensation table combination under a first optional interpolation coefficient includes:
[0138] According to the first compensation table and the second compensation table in each compensation table combination, and the first optional interpolation coefficient, the following processing is performed:
[0139] Performing color shading correction on the original image according to the first compensation table, the second compensation table and the first optional interpolation coefficient to obtain a corrected statistical value image;
[0140] Determining error values of at least two sub-image blocks in the corrected statistical value image;
[0141] According to the error value of each sub-image block, a first error value of the corrected statistical value image is determined.
[0142] In some embodiments, color shading correction is performed by the following formula:
[0143] lscm_apply_table=LSCM*table0*ratio+LSCM*table1*(1-ratio)
[0144] Among them, lscm_apply_table represents the corrected statistical value image, LSCM represents the downsampled original image, table0 represents the first compensation table, table1 represents the second compensation table, and ratio represents the first optional interpolation coefficient.
[0145] In some embodiments, determining the error values of at least two sub-image blocks in the corrected statistical value image includes:
[0146] Convert the r / g and b / g values of the sub-image block to the logarithmic domain to obtain a first sub-error value and a second sub-error value;
[0147] The sum of the variances of the first sub-error value and the second sub-error value is determined as the error value of the sub-image block.
[0148] In some embodiments, determining the first error value of the corrected statistical value image according to the error value of each sub-image block includes:
[0149] Determine the weight of each sub-image block according to the magnitude relationship between the error value of each sub-image block and the average error value, wherein the average error value is the average value of the error values of all sub-image blocks;
[0150] A weighted summation process is performed according to the error values and weights of all sub-image blocks to obtain a first error value of the corrected statistical value image.
[0151] In some embodiments, determining the second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value among the first error values includes:
[0152] Determine a second value range according to the interpolation coefficient corresponding to the minimum error value among the first error values;
[0153] A second optional interpolation coefficient is determined according to the second value range and the second step length, wherein the second step length is smaller than a difference between a maximum value and a minimum value in the second value range.
[0154] In some embodiments, determining a target compensation table according to a first compensation table and a second compensation table in a target compensation table combination and a target interpolation coefficient includes:
[0155] The target compensation table is determined by the following formula:
[0156] table_tar=table0_tar*ratio_tar+table1_tar*(1-ratio_tar)
[0157] Among them, table_tar represents the target compensation table, table0_tar represents the first compensation table in the target compensation table combination, table1_tar represents the second compensation table in the target compensation table combination, and ratio_tar represents the target interpolation coefficient.
[0158] The specific definition of the color shading correction device can be found in the definition of the color shading correction method above, which will not be repeated here. Each module in the above-mentioned color shading correction device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0159] The present application provides a color shading correction device, which first obtains multiple compensation table combinations, each compensation table combination includes compensation tables corresponding to two light sources with different color temperatures, and then calculates the error value of color shading correction for each compensation table combination through different interpolation coefficients, so as to determine the optimal target compensation table suitable for the current light source, and then performs color shading correction through the target compensation table, which can accurately compensate for the color shading of the current light source, thereby effectively improving the color shading correction effect.
[0160] In some embodiments, an electronic device is provided, which can adaptively perform color shading correction processing according to the color temperature of a current light source.
[0161] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 4 As shown, the electronic device includes: an image capturing module 10 , an image signal processing module 20 and an output module 30 .
[0162] The image capture module 10 includes an image sensor 11 for capturing images, which may be a camera phone, a video camera, a digital camera or other forms of camera devices;
[0163] The image signal processing module 20 includes a black level correction module 21, a lens shading correction module 22, an automatic white balance module 23, a demosaicing module 24 and other image processing modules (not shown in the figure);
[0164] The output module 30 includes a display device 31 and a memory 32 . The display device may include an LCD or LED screen, and the memory may include a flash memory, RAM, ROM, EEPROM, etc.
[0165] refer to Figure 4 The original image data output by the image sensor is input into the image signal processing module, processed by the black level correction, lens shading correction, automatic white balance and other modules, and then output to the display device for display. The original image data output by the image sensor is downsampled to obtain statistical value data, which is combined with multiple fixed compensation tables and input into the lens shading correction module to calculate the target compensation table combination and target interpolation coefficient that best suits the current light source, thereby obtaining the target compensation table corresponding to the color temperature of the current light source, and then accurately compensating the color shading of the current light source, effectively improving the color shading correction effect.
[0166] In some embodiments, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method embodiments of the present application when executing the program.
[0167] In the above electronic device, the memory and the processor are electrically connected directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines, such as through a bus connection. The memory stores computer-executable instructions for implementing the data access control method, including at least one software function module that can be stored in the memory in the form of software or firmware. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory.
[0168] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory is used to store programs, and the processor executes the programs after receiving the execution instructions. Furthermore, the software programs and modules in the above-mentioned memory may also include an operating system, which may include various software components and / or drivers for managing system tasks (such as memory management, storage device control, power management, etc.), and may communicate with various hardware or software components to provide an operating environment for other software components.
[0169] The processor may be an integrated circuit chip having the ability to process signals. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc. The disclosed methods, steps and logic block diagrams in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0170] In some embodiments, a computer-readable storage medium is provided, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the steps of various method embodiments of the present application.
[0171] In some embodiments, a computer program product is provided, including a computer program, which implements the steps of various method embodiments of the present application when executed by a processor.
[0172] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0173] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the application disclosed herein. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0174] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A color shading correction method, characterized in that: include: Acquire at least two compensation table combinations, each compensation table combination includes a first compensation table and a second compensation table, the first compensation table and the second compensation table respectively including color shading compensation data corresponding to light sources of different color temperatures; Determine the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determine the target compensation table combination and the target interpolation coefficient corresponding to the minimum error value; Determine a target compensation table according to the first compensation table and the second compensation table in the target compensation table combination and the target interpolation coefficient, and perform color shading correction processing through the target compensation table; The step of respectively determining the error value of each compensation table combination for color shading correction under different interpolation coefficients includes: performing the following processing according to the first compensation table and the second compensation table in each compensation table combination and the first optional interpolation coefficient: Performing color shading correction on the original image according to the first compensation table, the second compensation table, and the first optional interpolation coefficient to obtain a corrected statistical value image; Determining error values of at least two sub-image blocks in the corrected statistical value image; A first error value of the corrected statistical value image is determined according to the error value of each of the sub-image blocks.
2. The method according to claim 1, characterized in that The method further comprises: determining the first optional interpolation coefficient; Determine a second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value among the first error values, and use the second optional interpolation coefficient as a new first optional interpolation coefficient, and repeat this step until an iteration stop condition is met; The step of determining a target compensation table combination and a target interpolation coefficient corresponding to the minimum error value includes: The compensation table combination corresponding to the last obtained minimum error value is determined as the target compensation table combination, and the interpolation coefficient corresponding to the last obtained minimum error value is determined as the target interpolation coefficient.
3. The method according to claim 2, characterized in that The determining of the first optional interpolation coefficient comprises: The first optional interpolation coefficient is determined according to a first value range and a first step length, wherein the first step length is smaller than a difference between a maximum value and a minimum value in the first value range.
4. The method according to claim 1, characterized in that Color shading correction is performed by the following formula: lscm_apply_table = LSCM table0 ratio + LSCM table1 (1 - ratio) Among them, lscm_apply_table represents the corrected statistical value image, LSCM represents the downsampled original image, table0 represents the first compensation table, table1 represents the second compensation table, and ratio represents the first optional interpolation coefficient.
5. The method according to claim 1, characterized in that The step of determining the error values of at least two sub-image blocks in the corrected statistical value image comprises: Converting the ratio of the r channel to the g channel of the sub-image block to a logarithmic domain to obtain a first sub-error value; Converting the ratio of the b channel to the g channel of the sub-image block to a logarithmic domain to obtain a second sub-error value; The sum of the variances of the first sub-error value and the second sub-error value is determined as the error value of the sub-image block.
6. The method according to claim 4, characterized in that The step of determining the first error value of the corrected statistical value image according to the error value of each of the sub-image blocks comprises: Determine the weight of each sub-image block according to the magnitude relationship between the error value of each sub-image block and the average error value, wherein the average error value is the average value of the error values of all sub-image blocks; A weighted summation process is performed according to the error values and weights of all sub-image blocks to obtain the first error value of the corrected statistical value image.
7. The method according to claim 2, characterized in that Determining a second optional interpolation coefficient according to the interpolation coefficient corresponding to the minimum error value among the first error values includes: Determine a second value range according to the interpolation coefficient corresponding to the minimum error value among the first error values; The second optional interpolation coefficient is determined according to the second value range and the second step length, wherein the second step length is smaller than the difference between the maximum value and the minimum value in the second value range.
8. The method according to claim 1, characterized in that: The determining of the target compensation table according to the first compensation table and the second compensation table in the target compensation table combination and the target interpolation coefficient comprises: The target compensation table is determined by the following formula: table_tar = table0_tar ratio_tar + table1_tar (1 - ratio_tar) Among them, table_tar represents the target compensation table, table0_tar represents the first compensation table in the target compensation table combination, table1_tar represents the second compensation table in the target compensation table combination, and ratio_tar represents the target interpolation coefficient.
9. A color shading correction device, characterized in that: include: An acquisition module, used for acquiring at least two compensation table combinations, each compensation table combination including a first compensation table and a second compensation table; A determination module, used to respectively determine the error value of each compensation table combination for color shading correction under different interpolation coefficients, and determine a target compensation table combination and a target interpolation coefficient corresponding to a minimum error value; A processing module, configured to determine a target compensation table according to the first compensation table and the second compensation table in the target compensation table combination and the target interpolation coefficient, and perform color shading correction processing through the target compensation table; The processing module is specifically configured to perform the following processing according to the first compensation table and the second compensation table in each compensation table combination, and the first optional interpolation coefficient: Performing color shading correction on the original image according to the first compensation table, the second compensation table, and the first optional interpolation coefficient to obtain a corrected statistical value image; Determining error values of at least two sub-image blocks in the corrected statistical value image; A first error value of the corrected statistical value image is determined according to the error value of each of the sub-image blocks.
Citation Information
Patent Citations
Lens shadow correction method and device, medium and terminal
CN113284062A
Image processing device
JP2013198041A