CN111587573A - Image processing method and device - Google Patents

Image processing method and device Download PDF

Info

Publication number
CN111587573A
CN111587573A CN201880086363.8A CN201880086363A CN111587573A CN 111587573 A CN111587573 A CN 111587573A CN 201880086363 A CN201880086363 A CN 201880086363A CN 111587573 A CN111587573 A CN 111587573A
Authority
CN
China
Prior art keywords
light source
color temperature
high color
temperature light
region
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201880086363.8A
Other languages
Chinese (zh)
Other versions
CN111587573B (en
Inventor
林威丞
刘国祥
那柏林
杨琪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Publication of CN111587573A publication Critical patent/CN111587573A/en
Application granted granted Critical
Publication of CN111587573B publication Critical patent/CN111587573B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof
    • H04N23/84Camera processing pipelines; Components thereof for processing colour signals
    • H04N23/88Camera processing pipelines; Components thereof for processing colour signals for colour balance, e.g. white-balance circuits or colour temperature control

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Processing Of Color Television Signals (AREA)
  • Color Television Image Signal Generators (AREA)
  • Image Processing (AREA)

Abstract

An image processing method and device, wherein the image processing method comprises the following steps: acquiring an environment brightness value of the image, and if the environment brightness value of the image is greater than a first brightness threshold value, adjusting the number of pixel blocks in a region within the influence range of at least one high color temperature light source to obtain target color statistical information of the image; furthermore, AWB correction is performed on the image according to the target color statistical information. Therefore, in the embodiment of the application, the environmental brightness value is used as an important influence factor of the AWB correction, and the environmental brightness value is fused into the initial color statistical information of the image to obtain the target color statistical information of the image, and then the AWB correction is performed, so that the problem that the accuracy of the AWB correction is reduced due to the fact that the AWB correction is easily influenced by the color of the object in the image can be effectively solved.

Description

Image processing method and device Technical Field
The present application relates to the field of image technologies, and in particular, to an image processing method and apparatus.
Background
At present, there are three electronic coupling elements inside a color camera for sensing red, green and blue light respectively, and the amplification ratio of the light sensing circuit signals of the three colors is 1:1:1 by default. In an ideal shooting environment, pure white (R, G, B) components are amplified according to a ratio of 1:1:1, and white without color cast is obtained, but under non-ideal ambient light conditions, the effect of white imaging is biased towards the color of ambient light rather than pure white. Therefore, when taking a picture using a camera, the raw image without processing has a problem of overall color shift, such as overall blue shift, overall yellow shift, or overall green shift. To eliminate the integral color cast, an Automatic White Balance (AWB) correction is required to restore the white color affected by the ambient light to a pure white color, so as to ensure that the imaging color is consistent with the real color of the object under various light conditions.
A simple implementation of AWB correction is: for an image with rich colors, gain values of three channels (R, G, B) are obtained according to the average value of three components (R, G, B) of each pixel in the image and are respectively R-gain, G-gain and B-gain, and then the gain values of the three channels are multiplied by the gain values of each pixel in the image (R, G, B), so that the deviation of the image color caused by the light source color is corrected, and the AWB correction is completed.
However, since the color of the light source with a high color temperature in the image is biased to light blue, the color of the light source with a low color temperature in the image is biased to light yellow, and if a light blue object exists in the image content, the light source is easily determined to be a light source with a high color temperature by mistake, and similarly, if a light yellow object exists in the image, the light source is easily determined to be a light source with a low color temperature by mistake, performing the AWB correction by using the above-mentioned three components (R, G, B) according to each pixel in the image causes the AWB correction to be easily affected by the color of the object in the image, thereby reducing the accuracy of the AWB correction.
Invention of the inventionContent providing method and apparatus
The embodiment of the application provides an image processing method and device, which are used for solving the technical problem that the accuracy of AWB correction is reduced because the AWB correction is easily influenced by the color of an object in an image.
In a first aspect, an embodiment of the present application provides an image processing method, including: acquiring initial color statistical information of an image, wherein the image comprises a plurality of pixel blocks, the pixel blocks comprise one or more pixels, and the initial color statistical information comprises the number of the pixel blocks in each of a plurality of regions; acquiring an environment brightness value of the image, and if the environment brightness value of the image is greater than a first brightness threshold, adjusting the number of pixel blocks in at least one of the plurality of regions to obtain target color statistical information of the image, wherein the target color statistical information comprises the adjusted number of pixel blocks in each of the plurality of regions; the number of pixel blocks of a first region in the target color statistical information is greater than that of the pixel blocks of the first region in the initial color statistical information, the first region is any one of the at least one region, and the at least one region is a region within an influence range of at least one high color temperature light source; and then, according to the target color statistical information, carrying out white balance correction on the image.
Considering that sunlight is a natural light source and belongs to a high color temperature light source, light sources for outdoor daytime photographing are all high color temperature light sources, and the brightness value of the environment during outdoor daytime photographing is much larger than that of the environment during indoor photographing, so that the higher the brightness value of the environment during outdoor daytime photographing, the more likely the sunlight is to be a high color temperature light source. Based on this, in the embodiment of the present application, if the ambient brightness value of the image is greater than the first brightness threshold, it is described that the image is an image obtained under the scene of the high color temperature light source, so the number of pixel blocks in the region within the influence range of the high color temperature light source can be increased, that is, the proportion of the number of pixel blocks in the region within the influence range of the high color temperature light source is increased, and then the AWB correction is performed according to the target color statistical information obtained by the adjustment.
In a possible design, the radius of the influence range of the high color temperature light source can be obtained according to the environment brightness value; and further determining the influence range of each high color temperature light source in the at least one high color temperature light source according to the radius of the influence range of the high color temperature light source.
In this way, since the influence range of the high color temperature light source is obtained according to the ambient brightness value, the factor of the ambient brightness value is fully considered when determining the region to be adjusted, which is beneficial to improving the accuracy of the AWB correction.
In one possible design, obtaining the radius of the influence range of the high color temperature light source according to the ambient brightness value includes:
if the environmental brightness value is larger than a second brightness threshold value, the radius of the influence range of the high color temperature light source is the preset radius of the maximum influence range of the high color temperature light source;
if the environmental brightness value is less than or equal to the second brightness threshold, the radius P of the influence range of the high color temperature light source meets the following formula requirement:
P=Pmin+(Pmax-Pmin)×BV-W1/W2-W1
wherein, PminIs a preset radius, P, of the minimum influence range of the high color temperature light sourcemaxIs the preset radius of the maximum influence range of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W2The second brightness threshold is larger than the first brightness threshold.
In one possible design, the at least one high color temperature light source includes a D75 light source, a D65 light source, a D55 light source, and a D50 light source; the radius of the preset maximum influence range of the D75 light source is smaller than that of the preset maximum influence range of the D65 light source; the radius of the maximum influence range of the preset D50 light source is smaller than that of the preset D55 light source.
As such, since the color of the D75 light source partially overlaps with the blue color range of the sky, if the radius of the preset maximum influence range of the D75 light source is too large, the accuracy of the AWB correction may be reduced, and therefore, the radius of the preset maximum influence range of the D75 light source may be smaller than the radius of the preset maximum influence range of the D65 light source, so as to avoid the radius of the preset maximum influence range of the D75 light source being too large.
Since the D50 light source is closer to other medium color temperature light sources (TL84 light sources), if the radius of the maximum influence range of the preset D50 light source is too large, the number of pixel blocks in the region closer to the medium color temperature light source may also be adjusted, so that the accuracy of AWB is reduced, and therefore, the radius of the maximum influence range of the preset D50 light source may be smaller than the radius of the maximum influence range of the preset D55 light source, so as to avoid the radius of the maximum influence range of the preset D50 light source being too large.
In one possible design, adjusting the number of pixel blocks in the at least one region may include: obtaining the distance between the first region and the high color temperature light source to which the first region belongs according to the three primary color characteristics of each pixel block in the first region and the three primary color characteristics of the high color temperature light source to which the first region belongs; then calculating to obtain a gain value of the first region according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs and the gain value of the high color temperature light source to which the first region belongs; wherein the gain value of the high color temperature light source to which the first region belongs is determined according to the ambient brightness value; and finally, multiplying the number of the pixel blocks in the first area by the gain value of the first area to obtain the adjusted number of the pixel blocks in the first area. It should be noted that, since the first area is any one of the at least one area, the adjustment manner is described specifically only by taking the first area as an example, and each of the at least one area is executed with reference to the first area.
In one possible design, the gain value of the high color temperature light source to which the first region belongs is determined according to the ambient brightness value, and includes:
if the environmental brightness value is greater than a third brightness threshold, the gain value of the high color temperature light source to which the first region belongs is a preset maximum gain value of the high color temperature light source to which the first region belongs, and the third brightness threshold is greater than the first brightness threshold;
if the environmental brightness value is less than or equal to a third brightness threshold, the gain value G of the high color temperature light source to which the first region belongs1Meets the following formula requirements:
G1=G1min+(G1max-G1min)×BV-W1/W3-W1
wherein G is1minIs a preset minimum gain value, G, of the high color temperature light source1maxIs the preset maximum gain value of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W3Is the third brightness threshold.
In the embodiment of the application, the gain value of the high color temperature light source to which the first region belongs is related to the ambient brightness value, that is, the gain value of the high color temperature light source to which the first region belongs is determined on the basis of fully considering the ambient brightness value, so that the gain value of the high color temperature light source to which the first region belongs is more reasonable, and a foundation is laid for ensuring the accuracy of the AWB correction.
In a possible design, if the first region is only located in an influence range of a first high color temperature light source, the high color temperature light source to which the first region belongs is the first high color temperature light source; the first high color temperature light source is any one of the at least one high color temperature light source;
if the first region is located in the influence range of the plurality of high color temperature light sources, the high color temperature light source to which the first region belongs is the high color temperature light source with the minimum distance from the first region in the plurality of high color temperature light sources.
In one possible design, the three primary color characteristics include R/G values and B/G values.
Obtaining a distance between the first region and the high color temperature light source to which the first region belongs according to three primary color characteristics of each pixel block in the first region and three primary color characteristics of the high color temperature light source to which the first region belongs, including:
D2=(M1,rg-M2,rg)2+(N1,bg-N2,bg)2
wherein D is the distance between the first region and the high color temperature light source to which the first region belongs, and M is1,rgIs the R/G value, M, of the high color temperature light source to which the first region belongs2,rgIs the average value of R/G values of pixel blocks in the first region, N1,bgIs the B/G value, N, of the high color temperature light source2,bgIs the average of the B/G values of the pixel blocks in the first region.
In one possible design, obtaining the gain value of the first region according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs, and the gain value of the high color temperature light source to which the first region belongs includes:
G=1+(G1-1)×Rn
R=P2-D2/P2
wherein G is a gain value of the first region, G1The gain value of the high color temperature light source to which the first region belongs is obtained, P is the radius of the influence range of the high color temperature light source to which the first region belongs, D is the distance between the first region and the high color temperature light source to which the first region belongs, R is a numerical value which is greater than or equal to 0 and less than or equal to 1, and n is a numerical value which is greater than 0.
In one possible design, determining an ambient brightness value for an image from the camera parameters includes:
BV=K×N2/(t×S)
wherein BV is an environment brightness value of the image, N is an aperture size, t is an exposure time, S is a photosensitive value, and K is a constant.
In one possible design, performing white balance correction on the image according to the adjusted target color statistical information includes: inputting the target color statistical information into a preset model, and performing white balance correction on the image; the preset model is obtained by training initial color statistical information of a plurality of first historical images and target color statistical information of a plurality of second historical images, wherein the environment brightness value of the first historical images is smaller than or equal to a first brightness threshold value, and the environment brightness value of the second historical images is larger than the first brightness threshold value.
In the embodiment of the application, the training data set includes the target color statistical information of the plurality of second history images, that is, the environmental brightness value is also fully considered during deep learning, so that the result of the deep learning is more consistent with the representation of a real scene.
In a second aspect, an embodiment of the present application provides an image processing method, including: acquiring initial color statistical information of an image, wherein the image comprises a plurality of pixel blocks, the pixel blocks comprise one or more pixels, and the initial color statistical information comprises the number of the pixel blocks in each of a plurality of regions; acquiring an environment brightness value of the image, and if the environment brightness value of the image is greater than a first brightness threshold, adjusting the number of pixel blocks in at least one of the plurality of regions to obtain target color statistical information of the image, wherein the target color statistical information comprises the adjusted number of pixel blocks in each of the plurality of regions; the number of pixel blocks of a first region in the target color statistical information is smaller than that of the pixel blocks of the first region in the initial color statistical information, the first region is any one of the at least one region, the at least one region is a region within an influence range of at least one first-type light source, and the first-type light source comprises a medium color temperature light source and a low color temperature light source; and then, according to the target color statistical information, carrying out white balance correction on the image.
It should be noted that, the image processing method provided in the first aspect and the image processing method provided in the second aspect are technical solutions obtained based on the same inventive concept, in the first aspect, the adjustment is implemented by increasing the number of pixel blocks in a region within an influence range of a high color temperature light source, and in the second aspect, the adjustment is implemented by decreasing the number of pixel blocks in a region within an influence range of a medium color temperature light source and a low color temperature light source, which are two corresponding approaches.
In a third aspect, an embodiment of the present application provides an image processing apparatus, including:
the processing module is used for acquiring initial color statistical information of an image, wherein the image comprises a plurality of pixel blocks, the pixel blocks comprise one or more pixels, and the initial color statistical information comprises the number of the pixel blocks in each of a plurality of regions; and acquiring an ambient brightness value of the image;
the processing module is further configured to adjust the number of pixel blocks in at least one of the plurality of regions if the ambient brightness value of the image is greater than a first brightness threshold, so as to obtain target color statistical information of the image, where the target color statistical information includes the adjusted number of pixel blocks in each of the plurality of regions; the number of pixel blocks of a first region in the target color statistical information is greater than that of the pixel blocks of the first region in the initial color statistical information, the first region is any one of the at least one region, and the at least one region is a region within an influence range of at least one high color temperature light source;
and the correction module is used for carrying out white balance correction on the image according to the target color statistical information.
In one possible design, the processing module is further configured to calculate the range of influence of the high color temperature light source by:
obtaining the radius of the influence range of the high color temperature light source according to the environment brightness value;
and determining the influence range of the high color temperature light source according to the radius of the influence range of the high color temperature light source.
In a possible design, the processing module obtains, according to the ambient brightness value, a radius of an influence range of the high color temperature light source, specifically:
if the environmental brightness value is greater than a second brightness threshold, the radius of the influence range of the high color temperature light source is the preset radius of the maximum influence range of the high color temperature light source, and the second brightness threshold is greater than the first brightness threshold;
if the environmental brightness value is less than or equal to the second brightness threshold, the radius P of the influence range of the high color temperature light source meets the following formula requirement:
P=Pmin+(Pmax-Pmin)×BV-W1/W2-W1
wherein, PminIs a preset radius, P, of the minimum influence range of the high color temperature light sourcemaxIs the preset radius of the maximum influence range of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W2Is the second brightness threshold.
In one possible design, the at least one high color temperature light source includes a D75 light source, a D65 light source, a D55 light source, and a D50 light source;
the radius of the preset maximum influence range of the D75 light source is smaller than that of the preset maximum influence range of the D65 light source;
the radius of the maximum influence range of the preset D50 light source is smaller than that of the preset D55 light source.
In one possible design, the processing module is specifically configured to adjust the number of pixel blocks in at least one of the plurality of regions by:
obtaining the distance between the first region and the high color temperature light source to which the first region belongs according to the three primary color characteristics of each pixel block in the first region and the three primary color characteristics of the high color temperature light source to which the first region belongs;
obtaining a gain value of the first region according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs and the gain value of the high color temperature light source to which the first region belongs; the gain value of the high color temperature light source to which the first region belongs is determined according to the environment brightness value;
and multiplying the number of the pixel blocks in the first area by the gain value of the first area to obtain the number of the pixel blocks in the first area after adjustment.
In one possible design, the processing module is further configured to determine a gain value of a high color temperature light source to which the first region belongs by:
if the environmental brightness value is greater than a third brightness threshold, the gain value of the high color temperature light source to which the first region belongs is a preset maximum gain value of the high color temperature light source to which the first region belongs, and the third brightness threshold is greater than the first brightness threshold;
if the environmental brightness value is less than or equal to a third brightness threshold, the gain value G of the high color temperature light source to which the first region belongs1Meets the following formula requirements:
G1=G1min+(G1max-G1min)×BV-W1/W3-W1
wherein G is1minIs a preset minimum gain value, G, of the high color temperature light source1maxIs the preset maximum gain value of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W3Is the third brightness threshold.
In a possible design, if the first region is only located in an influence range of a first high color temperature light source, the high color temperature light source to which the first region belongs is the first high color temperature light source; the first high color temperature light source is any one of the at least one high color temperature light source;
if the first region is located in the influence range of the plurality of high color temperature light sources, the high color temperature light source to which the first region belongs is the high color temperature light source with the minimum distance from the first region in the plurality of high color temperature light sources.
In one possible design, the trichromatic characteristics include R/G values and B/G values;
the processing module is specifically configured to obtain a distance between the first region and a high color temperature light source to which the first region belongs by:
D2=(M1,rg-M2,rg)2+(N1,bg-N2,bg)2
wherein D is the distance between the first region and the high color temperature light source to which the first region belongs, and M is1,rgIs the R/G value, M, of the high color temperature light source to which the first region belongs2,rgIs the average value of R/G values of pixel blocks in the first region, N1,bgIs the B/G value, N, of the high color temperature light source2,bgIs the average of the B/G values of the pixel blocks in the first region.
In one possible design, the processing module is specifically configured to obtain the gain value of the first region by:
G=1+(G1-1)×Rn
R=P2-D2/P2
wherein G is a gain value of the first region, G1The gain value of the high color temperature light source to which the first region belongs is obtained, P is the radius of the influence range of the high color temperature light source to which the first region belongs, D is the distance between the first region and the high color temperature light source to which the first region belongs, R is a numerical value which is greater than or equal to 0 and less than or equal to 1, and n is a numerical value which is greater than 0.
In one possible design, the processing module is specifically configured to determine an ambient brightness value of the image by:
BV=K×N2/(t×S)
wherein BV is an environment brightness value of the image, N is an aperture size, t is an exposure time, S is a photosensitive value, and K is a constant.
In one possible design, the correction module is specifically configured to:
inputting the target color statistical information into a preset model, and performing white balance correction on the image; the preset model is obtained by training initial color statistical information of a plurality of first historical images and target color statistical information of a plurality of second historical images, wherein the environment brightness value of the first historical images is smaller than or equal to a first brightness threshold value, and the environment brightness value of the second historical images is larger than the first brightness threshold value.
Yet another aspect of an embodiment of the present application provides an image processing apparatus, including: a memory for storing a software program; a processor for reading the software program in the memory and executing the image processing method as described in the various possible designs of the first and second aspects above.
A further aspect of embodiments of the present application provides a computer storage medium having stored therein a software program which, when read and executed by one or more processors, implements the image processing method described in the various possible designs of the first and second aspects described above.
It is a further aspect of embodiments of the present application to provide a computer program product comprising instructions which, when run on a computer, cause the computer to perform the image processing method as set out in the various possible designs of the first and second aspects above.
It is a further aspect of embodiments of the present application to provide a computer program which, when run on a computer, causes the computer to perform the image processing method described in the various possible designs of the first and second aspects described above.
Drawings
FIG. 1a is a schematic diagram of three primary color features of each pixel block in an image marked on a color coordinate plane;
FIG. 1b is a two-dimensional color information histogram of an image;
fig. 1c is a schematic view of an overall image processing flow provided in an embodiment of the present application;
fig. 1d is a schematic structural diagram of an image processing apparatus according to an embodiment of the present disclosure;
fig. 1e is a schematic structural diagram of another image processing apparatus according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart corresponding to an image processing method according to an embodiment of the present application;
fig. 3 is a schematic flowchart illustrating a process of adjusting the number of pixel blocks in the first region according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of another image processing apparatus according to an embodiment of the present application.
Detailed Description
Embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
An image is composed of a plurality of pixels, the pixels can be represented by (R, G, B), the three primary color characteristics of the pixels are used for describing the color information of the pixels, and for example, the three primary color characteristics of the pixels can comprise R/G values and B/G values.
Due to the large number of pixels in an image, for analysis, the image may be generally divided into n × m pixel blocks (blocks), each of which includes one or more pixels. Further, (R, G, B) of the pixel block can be obtained by adding the values of the three components of (R, G, B) of all the pixels in the pixel block and then averaging the values, and further, the three primary color characteristics of the pixel block, namely, the R/G value and the B/G value can be obtained according to the (R, G, B) of the pixel block.
In addition, nine standard light sources are currently defined, and the color temperatures of the nine standard light sources from high to low are: d75, color temperature of 7500 DEG K; d65, color temperature of 6500 DEG K; d55, the color temperature is 5500K; d50, color temperature of 5000 degrees K; CWF, color temperature 4100 DEG K; TL84, color temperature 4000 ° K; u30, color temperature of 3000 ° K; a, the color temperature is 2850 degrees K; h, the color temperature is 2300 degrees K. Among them, D75, D65, D55 and D50 are summarized as high color temperatures, CWF, TL84 and U30 are summarized as medium color temperatures, and A and H are summarized as low color temperatures. The light source with high color temperature has a color biased to light blue in the image, the light source with low color temperature has a color biased to light yellow in the image, and the three primary color characteristics of each light source can be obtained based on the color of each light source.
In conjunction with the above description, as shown in fig. 1a, it is a schematic diagram obtained by marking the three primary color features of each pixel block in the image on the color coordinate plane. The positions of the dots represent the three primary color characteristics of each pixel block, and the positions of the nine circles represent the three primary color characteristics of the nine standard light sources.
It should be noted that the above description is only given by taking the three primary color feature as an example, and the three primary color feature includes an R/G value and a B/G value, in other possible implementations, taking a pixel as an example, the (R, G, B) of the pixel may also be converted into other color spaces, such as a (Y, Cb, Cr) or (Y, U, V) color space, and accordingly, the three primary color feature of the pixel may include (Cb, Cr) or (U, V). Where Y refers to the luminance component, Cb refers to the blue chrominance component, Cr refers to the red chrominance component, and U and V both refer to chrominance.
Furthermore, according to the three primary color characteristics of each pixel block of the image, the pixel block of the image can be divided into a plurality of regions, so as to obtain the initial color statistical information of the image, wherein the initial color statistical information comprises the number of the pixel blocks in each region of the plurality of regions. As shown in fig. 1B, the histogram is a two-dimensional color information histogram of an image, each square represents a region, pixel blocks of R/G values and B/G values within the coverage of the square are pixel blocks of the region, and numbers in the squares represent the number of the pixel blocks of the region.
In order to improve accuracy of AWB correction, an AWB correction method is: deep learning (deep learning) is performed on the two-dimensional color information histogram using a Convolutional Neural Network (CNN) to realize AWB correction. Specifically, the two-dimensional color information histogram of a plurality of images can be used as a training data set, when deep learning is performed, the two-dimensional color information histogram of each image in the training data set provides a corresponding actual reference (ground route) as a training reference, and the actual reference is one of the coordinates of the two-dimensional color information histogram, which represents the optimal AWB position (i.e. optimal R-gain, G-gain, B-gain) of the two-dimensional color information histogram; after the training is completed, a CNN model can be obtained. When a new image is obtained subsequently, the two-dimensional color information histogram of the new image is input into the CNN model, and R-gain, G-gain and B-gain corresponding to the new image can be generated to correct the color cast of the image.
Since the CNN model is obtained by training a large number of images, the accuracy is higher than the method of obtaining the gain values of the (R, G, B) three channels based on the average value of the (R, G, B) three components on the image. However, the CNN model performs convolution operation on the two-dimensional color information histogram of the image, and the processed data of the CNN model can only be the color information of the image, so that when the CNN model is used for performing deep learning by using the two-dimensional color information histogram of the image as input to implement AWB correction, no other information can be added, and the CNN model generated by training is still easily affected by the color of an object in the image, so that the accuracy of AWB correction is reduced.
Based on this, the embodiments of the present application provide an image processing method for solving the technical problem that the accuracy of the AWB correction is easily affected by the color of the object in the image, thereby reducing the accuracy of the AWB correction.
Specifically, the method comprises: acquiring initial color statistical information of an image, wherein the image comprises a plurality of pixel blocks, the pixel blocks comprise one or more pixels, and the initial color statistical information comprises the number of the pixel blocks in each of a plurality of regions; acquiring an environment brightness value of the image, and if the environment brightness value of the image is greater than a first brightness threshold, adjusting the number of pixel blocks in at least one of the plurality of regions to obtain target color statistical information of the image, wherein the target color statistical information comprises the adjusted number of pixel blocks in each of the plurality of regions; the number of pixel blocks of a first region in the target color statistical information is greater than that of the pixel blocks of the first region in the initial color statistical information, the first region is any one of the at least one region, and the at least one region is a region within an influence range of at least one high color temperature light source; and then, according to the target color statistical information, carrying out white balance correction on the image. Therefore, in the embodiment of the application, the environmental brightness value is used as an important influence factor of the AWB correction, and the environmental brightness value is fused into the initial color statistical information of the image to obtain the target color statistical information of the image, and then the AWB correction is performed, so that the problem that the accuracy of the AWB correction is reduced due to the fact that the AWB correction is easily influenced by the color of the object in the image can be effectively solved.
One possible overall flow of image processing is described below in conjunction with FIG. 1 c. As shown in fig. 1c, after an image is generated by the photosensitive element, the image is input to the two-dimensional color information histogram generation module to generate an initial two-dimensional color information histogram of the image; the environment brightness value generation module can acquire camera parameters from the photosensitive element, further obtain an environment brightness value according to the camera parameters and input the environment brightness value to the two-dimensional color information histogram generation module; the two-dimensional color information histogram generation module can judge the size of an environment brightness value, if the environment brightness value is larger than a first brightness threshold value, the initial two-dimensional color information histogram of the image can be adjusted, a target two-dimensional color information histogram of the image is obtained and input into the correction module, the correction module can process the target two-dimensional color information histogram through a preset model, and white balance correction is achieved, wherein the preset model can be generated by external equipment training and input into an image processing device executing an image processing flow, or can be directly stored in the device in a firmware mode, and is not limited specifically. Further, after white balance correction is performed on the image by the AWB module, the corrected image may be input to another Image Signal Processing (ISP) module (for example, a noise reduction module, which is not specifically limited herein), so as to obtain an output image.
The image processing method in the embodiment of the present application may be performed by an image processing apparatus. The image processing device can be a semiconductor chip, and the semiconductor chip can be arranged in a camera, a video monitoring device and a terminal device with a photographing function; alternatively, the image processing apparatus may also be a camera, a video monitoring device, and a terminal device having a photographing function. As shown in fig. 1d and 1e, an image processing apparatus 100 provided in the embodiment of the present application includes a processor 11 and a memory 12.
The processor 11 may be a general purpose Central Processing Unit (CPU), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of programs in accordance with the teachings of the present application.
The Memory 12 may be a Read-Only Memory (ROM) or other type of static storage device that can store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that can store information and instructions, an Electrically Erasable Programmable Read-Only Memory (EEPROM), a Compact Disc Read-Only Memory (CD-ROM) or other optical Disc storage, optical Disc storage (including Compact Disc, laser Disc, optical Disc, digital versatile Disc, blu-ray Disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by the apparatus, but is not limited to such. The memory may be self-contained and connected to the processor via a bus (as shown in figure 1 d). The memory may also be integrated with the processor (as shown in fig. 1 e).
The memory 12 may be configured to store an application program code for executing the scheme of the present application, and the processor 11 controls the execution, that is, the processor 11 is configured to execute the application program code stored in the memory 12 to implement the image processing method in the embodiment of the present application.
It should be noted that the terminal device described above may be a mobile phone (mobile phone), a tablet computer (pad), and the like, and is not limited specifically.
Fig. 2 is a schematic flowchart corresponding to an image processing method provided in an embodiment of the present application, and as shown in fig. 2, the method includes:
step 201, obtaining initial color statistical information of an image, where the image includes a plurality of pixel blocks, the pixel blocks include one or more pixels, and the initial color statistical information includes the number of pixel blocks in each of a plurality of regions.
Here, the initial color statistical information may be obtained by generating a two-dimensional color information histogram of the image, and specifically, refer to the content of the description of fig. 1 b.
Step 202, obtaining an environment brightness value of the image.
One possible implementation manner is to obtain a camera parameter when the image is captured, and determine an environment brightness value of the image according to the camera parameter. Here, the camera parameter may include at least one of an aperture size, an exposure time, and a photosensitive value, and may also include other parameters, which are not limited specifically.
In one example, the determined ambient brightness value of the image may comply with the requirement of the following equation 1:
BV=K×N2/(t × S) … … formula 1
Wherein BV is an environment brightness value of the image, N is an aperture size, t is an exposure time, S is a photosensitive value, and K is a constant.
In the embodiment of the present application, K may be a constant greater than 0, and is used to correct the ambient brightness value, for example, in a fixed known brightness scene, K may be used to set BV to a desired value, so as to facilitate subsequent use of BV. In one example, K may be set to 1 first, a fixed scene under 1000Lux light source is photographed, BV is 20, if BV of the scene is desired to be 100, K may be set to 5, and thereafter K is fixed, and BV increases from 100 when light source of the fixed scene increases from 1000 Lux.
Step 203, if the ambient brightness value of the image is greater than the first brightness threshold, adjusting the number of pixel blocks in at least one of the plurality of regions to obtain target color statistical information of the image, where the target color statistical information includes the adjusted number of pixel blocks in each of the plurality of regions; the number of pixel blocks of a first region in the target color statistical information is greater than that of the pixel blocks of the first region in the initial color statistical information, and the at least one region is a region within an influence range of at least one high color temperature light source.
It should be noted that the first area is any one of the at least one area, that is, each of the at least one area conforms to the description of the first area. For example, if the at least one region includes region 1, region 2, and region 3, then: the number of pixel blocks of the area 1 in the target color statistical information is larger than that of the pixel blocks of the area 1 in the initial color statistical information, the number of pixel blocks of the area 2 in the target color statistical information is larger than that of the pixel blocks of the area 2 in the initial color statistical information, and the number of pixel blocks of the area 3 in the target color statistical information is larger than that of the pixel blocks of the area 3 in the initial color statistical information.
Here, since sunlight is a natural light source and belongs to a high color temperature light source, and light sources for outdoor daytime photographing are all high color temperature light sources (a D75 light source, a D65 light source, a D55 light source, and a D50 light source), and an ambient brightness value in outdoor daytime photographing is much larger than an ambient brightness value in indoor photographing, the higher the ambient brightness value in outdoor daytime photographing is, the more likely it is to be a high color temperature light source. Based on this, in the embodiment of the present application, if the ambient brightness value of the image is greater than the first brightness threshold, the number of pixel blocks in the region within the influence range of the at least one high color temperature light source may be adjusted, so as to improve the accuracy of the AWB correction. The at least one high color temperature light source may include a D75 light source, a D65 light source, a D55 light source, and a D50 light source. If the ambient brightness value of the image is less than or equal to the first brightness threshold, since it cannot be determined whether the ambient brightness value is a low color temperature light source, the AWB correction can be performed by using the method in the prior art. The first brightness threshold value can be set according to actual needs; further, since the correction constant K is introduced when the environment brightness value is calculated, the value of K needs to be considered when the first brightness threshold is set, and if the value of K is large, the calculated environment brightness value is large, so that the first brightness threshold needs to be set accordingly.
In the embodiment of the application, the radius of the influence range of the high color temperature light source can be obtained according to the environmental brightness value, and further, the influence range of each high color temperature light source in the at least one high color temperature light source can be determined according to the radius of the influence range of the high color temperature light source. For example, taking the D75 light source illustrated in fig. 1b as an example, after the radius of the influence range of the D75 light source is determined, a circle is obtained according to the radius by taking the position of the D75 light source as the center of the circle, and the range covered by the circle is the influence range of the D75 light source.
There are various ways to obtain the radius of the influence range of the high color temperature light source according to the ambient brightness value. In one possible implementation, a corresponding relationship between the ambient brightness value and the radius of the influence range of the high color temperature light source may be preset, and the corresponding relationship may have various forms, and may exemplarily be: when the environment intensity value is in the range of (a, b), the radius of the influence range of the corresponding high-color temperature light source is d, and when the environment intensity value is in the range of (b, c), the radius of the influence range of the corresponding high-color temperature light source is e.
In another possible implementation manner, if the ambient brightness value is greater than the second brightness threshold, the radius of the influence range of the high color temperature light source may be a preset radius of a maximum influence range of the high color temperature light source; if the ambient brightness value is less than or equal to the second brightness threshold, the radius P of the influence range of the high color temperature light source meets the following formula requirement:
P=Pmin+(Pmax-Pmin)×BV-W1/W2-W1… … equation 2
Wherein, PminIs a preset radius, P, of the minimum influence range of the high color temperature light sourcemaxIs the preset radius of the maximum influence range of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W2Is the second brightness threshold value for the first brightness threshold value,the second brightness threshold is greater than the first brightness threshold, and the second brightness threshold can be set according to actual needs.
In the embodiment of the present application, since the color of the D75 light source overlaps with a part of the blue range of the sky, if the radius of the preset maximum influence range of the D75 light source is too large, the accuracy of AWB correction may be reduced, and therefore, the radius of the preset maximum influence range of the D75 light source may be smaller than the radius of the preset maximum influence range of the D65 light source, so as to avoid the radius of the preset maximum influence range of the D75 light source being too large.
Since the D50 light source is closer to other medium color temperature light sources (TL84 light sources), if the radius of the maximum influence range of the preset D50 light source is too large, the number of pixel blocks in the region closer to the medium color temperature light source may also be adjusted, so that the accuracy of AWB is reduced, and therefore, the radius of the maximum influence range of the preset D50 light source may be smaller than the radius of the maximum influence range of the preset D55 light source, so as to avoid the radius of the maximum influence range of the preset D50 light source being too large.
Further, in the embodiment of the present application, the preset radius of the maximum influence range of the D75 light source (D75_ radius _ max), the preset radius of the maximum influence range of the D65 light source (D65_ radius _ max), the preset radius of the maximum influence range of the D55 light source (D55_ radius _ max), and the preset radius of the maximum influence range of the D50 light source (D50_ radius _ max) may satisfy the following relationships:
D75_radius_max/D65_radius_max=0.85
D50_radius_max/D65_radius_max=0.60
D55_radius_max/D65_radius_max=1.0
it should be noted that the above relationship is only an example, and the embodiment of the present application is not limited thereto.
As can be seen from the above, in the embodiment of the present application, since the influence range of the high color temperature light source is obtained according to the ambient brightness value, when determining the region to be adjusted, the factor of the ambient brightness value is fully considered, which is beneficial to improving the accuracy of the AWB correction.
In the embodiment of the present application, there may be a plurality of ways to adjust the number of pixel blocks in at least one of the plurality of regions. In a possible implementation manner, a gain value larger than 0 may be preset, and the number of pixel blocks in at least one region is multiplied by the gain value, so as to adjust the number of pixel blocks in at least one region. For example, the gain value is 1.2, and before adjustment: the number of pixel blocks in the region 1 is 25, the number of pixel blocks in the region 2 is 35, and the number of pixel blocks in the region 3 is 45; then after the adjustment: the number of pixel blocks in region 1 is 30(25 × 1.2), the number of pixel blocks in region 2 is 42(35 × 1.2), and the number of pixel blocks in region 3 is 54(45 × 1.2).
In another possible implementation manner, for a certain high color temperature light source (such as a D75 light source), the influence range of the D75 light source has multiple regions, and the distances between different regions and the D75 light source may be different, so that in the embodiment of the present application, it is considered that different regions have different Gain values (Gain), thereby achieving more accurate and reasonable adjustment. For example, if the distance between region 1 and the light source of D75 is less than the distance between region 2 and the light source of D75, the gain value of region 1 may be greater than the gain value of region 2.
Specifically, there may be various implementations in which different regions are set to have different gain values, and only the first region is taken as an example, and one possible implementation is described below with reference to fig. 3, and all other regions may be implemented with reference to the first region. As shown in fig. 3, includes:
step 301, obtaining the distance between the first region and the high color temperature light source to which the first region belongs according to the three primary color characteristics of each pixel block in the first region and the three primary color characteristics of the high color temperature light source to which the first region belongs.
Here, if the first region is only within the influence range of the first high color temperature light source, the high color temperature light source to which the first region belongs is the first high color temperature light source, for example, the first high color temperature light source may be any one of a D75 light source, a D65 light source, a D55 light source, and a D50 light source. If the first region is located within the influence range of the plurality of high color temperature light sources, the high color temperature light source to which the first region belongs is the high color temperature light source with the smallest distance from the first region among the plurality of high color temperature light sources, for example, the influence ranges of the D75 light source and the D65 light source have an overlapping region, and the first region is located in the overlapping region, and if the distance between the first region and the D75 light source is smaller than the distance between the first region and the D65 light source, the high color temperature light source to which the first region belongs is the D75 light source.
In one example, the distance between the first region and the high color temperature light source to which the first region belongs may be obtained by:
D2=(M1,rg-M2,rg)2+(N1,bg-N2,bg)2… … equation 3
Wherein D is the distance between the first region and the high color temperature light source to which the first region belongs, and M is1,rgIs the R/G value, M, of the high color temperature light source to which the first region belongs2,rgIs the average value of R/G values of pixel blocks in the first region, N1,bgIs the B/G value, N, of the high color temperature light source to which the first region belongs2,bgIs the average of the B/G values of the pixel blocks in the first region.
In other possible implementations, M in the above formula1,rg、M2,rg、N1,bg、N2,bgIt may also have other meanings, taking the high color temperature light source to which the first region belongs as the light source D75 as an example, such as: m1,rgCan be the R/G value, M, of the center position of the square block where the D75 light source is located as illustrated in FIG. 1b2,rgMay be the R/G value, N, of the center position of the first region1,bgMay be the B/G value, N, of the center position of the square where the D75 light source is located2,bgMay be the B/G value of the central position in the first region. Thus, the distance between the first region and the high color temperature light source to which the first region belongs can be obtained based on the above formula.
Step 302, obtaining a gain value of the first region according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs, and the gain value of the high color temperature light source to which the first region belongs.
Here, the gain value of the high color temperature light source to which the first region belongs may be determined according to the ambient brightness value, and specific implementation manners may be various. In a possible implementation manner, a corresponding relationship between the environmental brightness value and the gain value of the high color temperature light source to which the first region belongs may be preset, so that the gain value of the high color temperature light source to which the first region belongs may be obtained according to the environmental brightness value and the corresponding relationship.
In another possible implementation manner, if the ambient brightness value is greater than a third brightness threshold, the gain value of the high color temperature light source to which the first region belongs is a preset maximum gain value of the high color temperature light source to which the first region belongs. If the environmental brightness value is less than or equal to a third brightness threshold, the gain value G of the high color temperature light source to which the first region belongs1Meets the following formula requirements:
G1=G1min+(G1max-G1min)×BV-W1/W3-W1… … equation 4
Wherein G is1minIs a preset minimum gain value, G, of the high color temperature light source1maxIs the preset maximum gain value of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W3Is the third brightness threshold. The third brightness threshold is greater than the first brightness threshold, and the third brightness threshold can be set according to actual needs.
It should be noted that the third luminance threshold may be the same as or different from the second luminance threshold, and is not limited specifically.
In the embodiment of the application, the gain value of the high color temperature light source to which the first region belongs is related to the ambient brightness value, that is, the gain value of the high color temperature light source to which the first region belongs is determined on the basis of fully considering the ambient brightness value, so that the gain value of the high color temperature light source to which the first region belongs is more reasonable, and a foundation is laid for ensuring the accuracy of the AWB correction.
When the gain value of the first region is determined according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs, and the gain value of the high color temperature light source to which the first region belongs, the specific implementation calculation method may have various forms, and one possible calculation method provided by the embodiment of the present application is:
Figure PCTCN2018089089-APPB-000001
wherein G is a gain value of the first region, G1The gain value of the high color temperature light source to which the first region belongs is obtained, P is the radius of the influence range of the high color temperature light source to which the first region belongs, D is the distance between the first region and the high color temperature light source to which the first region belongs, R is a numerical value which is greater than or equal to 0 and less than or equal to 1, and n is a numerical value which is greater than 0.
As can be seen from the above formula, the gain value of the first region is smaller as the distance between the first region and the high color temperature light source to which the first region belongs is larger. Taking the region within the influence range of the D75 light source as an example, the gain value gradually decreases from the center of the D75 light source to the surrounding region, and n can be used to control the characteristic of the decrease in the gain value from the center of the D75 light source to the surrounding region. Specifically, n may be a number greater than 0 and equal to or less than 10.
It should be noted that the above formula is only an exemplary representation, and in other possible embodiments, a person skilled in the art may also make modifications, and the details are not limited.
Step 303, multiplying the number of pixel blocks in the first region by the gain value of the first region to obtain the adjusted number of pixel blocks in the first region. For example, if the number of pixel blocks in the first region is 25 and the gain value of the first region obtained in step 302 is 1.2, the number of pixel blocks in the first region obtained after adjustment is 30.
As can be seen from the above, in the embodiment of the present application, when the number of pixel blocks in the first region is adjusted, the distance between the first region and the high color temperature light source to which the first region belongs is fully considered, so that the targeted adjustment is realized.
And 204, performing white balance correction on the image according to the target color statistical information.
Therefore, in the embodiment of the application, the environmental brightness value is used as an important influence factor of the AWB correction, and the environmental brightness value is fused into the initial color statistical information of the image to obtain the target color statistical information of the image, and then the AWB correction is performed, so that the problem that the accuracy of the AWB correction is reduced due to the fact that the AWB correction is easily influenced by the color of the object in the image can be effectively solved.
Here, in order to further improve the accuracy of white balance correction, the target color statistical information may be input into a preset model, and then the image is corrected. The preset model may be obtained by training initial color statistical information of a plurality of first historical images and target color statistical information of a plurality of second historical images in advance, wherein an ambient brightness value of the first historical image is less than or equal to a first brightness threshold, and an ambient brightness value of the second historical image is greater than the first brightness threshold. In a specific implementation, a convolutional neural network may be used to perform deep learning on the initial color statistical information of the plurality of first historical images and the target color statistical information of the plurality of second historical images, or may also be used to perform training by using other possible algorithms, which is not limited in this embodiment of the present application. In the embodiment of the application, the training data set includes the target color statistical information of the plurality of second history images, that is, the environmental brightness value is also fully considered during deep learning, so that the result of the deep learning is more consistent with the representation of a real scene.
It should be noted that the step numbers referred in fig. 2 and fig. 3 are only one possible example of the execution flow, and the sequence of each step in the specific implementation is not limited, for example, step 201 and step 202 may be executed simultaneously, or step 202 is executed before step 201.
For the above method flow, the embodiment of the present application further provides an image processing apparatus, and for specific implementation of the image processing apparatus, reference may be made to the above method flow. Based on the same inventive concept, fig. 4 is a schematic structural diagram of an image processing apparatus provided in an embodiment of the present application, the image processing apparatus may be a semiconductor chip, and the image processing apparatus may be configured to execute the method flows illustrated in fig. 2 and fig. 3, as shown in fig. 4, the image processing apparatus 400 includes:
a processing module 401 configured to obtain initial color statistics of an image, the image comprising a plurality of pixel blocks, the pixel blocks comprising one or more pixels, the initial color statistics comprising the number of pixel blocks in each of a plurality of regions (corresponding to step 201 illustrated in fig. 2); and, obtaining an ambient brightness value of the image (corresponding to step 202);
the processing module 401 is further configured to, if the ambient brightness value of the image is greater than the first brightness threshold, adjust the number of pixel blocks in at least one of the multiple regions to obtain target color statistical information of the image, where the target color statistical information includes the adjusted number of pixel blocks in each of the multiple regions; wherein the number of pixel blocks of a first region in the target color statistical information is greater than the number of pixel blocks of the first region in the initial color statistical information, the first region is any one of the at least one region, and the at least one region is a region within an influence range of at least one high color temperature light source (corresponding to step 203);
a correcting module 402, configured to perform white balance correction on the image according to the target color statistical information (corresponding to step 204).
In a possible design, the processing module 401 may obtain a radius of an influence range of the high color temperature light source according to the ambient brightness value; and determining the influence range of each high color temperature light source in the at least one high color temperature light source according to the radius of the influence range of the high color temperature light source.
In a possible design, when the processing module 401 obtains the radius of the influence range of the high color temperature light source according to the environment brightness value, specifically, the radius of the influence range of the high color temperature light source may be:
if the environment brightness value is determined to be larger than a second brightness threshold value, the radius of the influence range of the high color temperature light source is the preset radius of the maximum influence range of the high color temperature light source, and the second brightness threshold value is larger than the first brightness threshold value; if the ambient brightness value is less than or equal to the second brightness threshold, the radius P of the influence range of the high color temperature light source may meet the requirement of the above formula 2.
In one possible design, the at least one high color temperature light source includes a D75 light source, a D65 light source, a D55 light source, and a D50 light source; the radius of the maximum influence range of the preset D75 light source is smaller than the radius of the maximum influence range of the preset D65 light source; the radius of the maximum influence range of the preset D50 light source is smaller than that of the preset D55 light source.
In a possible design, the processing module 401 is specifically configured to adjust the number of pixel blocks in the at least one region through steps 301 to 303 illustrated in fig. 3.
In a possible design, the processing module 401 may specifically determine the gain value of the high color temperature light source to which the first region belongs by:
if the environment brightness value is determined to be greater than a third brightness threshold, the gain value of the high color temperature light source to which the first region belongs is a preset maximum gain value of the high color temperature light source to which the first region belongs, and the third brightness threshold is greater than the first brightness threshold;
if the environmental brightness value is determined to be less than or equal to a third brightness threshold value, the gain value G of the high color temperature light source to which the first region belongs1The requirements of equation 4 above may be met.
In a possible design, if the first region is only located in an influence range of a first high color temperature light source, the high color temperature light source to which the first region belongs is the first high color temperature light source; the first high color temperature light source is any one of the at least one high color temperature light source; if the first region is located in the influence range of the plurality of high color temperature light sources, the high color temperature light source to which the first region belongs is the high color temperature light source with the minimum distance from the first region in the plurality of high color temperature light sources.
In one possible design, the three primary color characteristics include R/G values and B/G values.
The processing module 401 can obtain the distance between the first region and the high color temperature light source to which the first region belongs through the above formula 3.
In one possible design, the processing module 401 may obtain the gain value of the first region through the above equation 5.
In one possible design, the processing module 401 may determine the ambient brightness value of the image by equation 1 above.
In a possible design, the correction module 402 may be specifically configured to input the target color statistical information into a preset model, and perform white balance correction on the image; the preset model is obtained by training initial color statistical information of a plurality of first historical images and target color statistical information of a plurality of second historical images, the environment brightness value of the first historical images is smaller than or equal to a first brightness threshold value, and the environment brightness value of the second historical images is larger than the first brightness threshold value.
It should be noted that the division of the unit in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation. The functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (24)

  1. An image processing method, characterized in that the method comprises:
    acquiring initial color statistical information of an image, wherein the image comprises a plurality of pixel blocks, the pixel blocks comprise one or more pixels, and the initial color statistical information comprises the number of the pixel blocks in each of a plurality of regions;
    acquiring an environment brightness value of the image;
    if the environmental brightness value of the image is larger than a first brightness threshold value, adjusting the number of pixel blocks in at least one of the plurality of regions to obtain target color statistical information of the image, wherein the target color statistical information comprises the adjusted number of pixel blocks in each of the plurality of regions; the number of pixel blocks of a first region in the target color statistical information is greater than that of the pixel blocks of the first region in the initial color statistical information, the first region is any one of the at least one region, and the at least one region is a region within an influence range of at least one high color temperature light source;
    and performing white balance correction on the image according to the target color statistical information.
  2. The method of claim 1, wherein the method of calculating the range of influence of the high color temperature light source comprises:
    obtaining the radius of the influence range of the high color temperature light source according to the environment brightness value;
    and determining the influence range of the high color temperature light source according to the radius of the influence range of the high color temperature light source.
  3. The method of claim 2, wherein obtaining the radius of the range of influence of the high color temperature light source from the ambient brightness value comprises:
    if the environmental brightness value is greater than a second brightness threshold, the radius of the influence range of the high color temperature light source is the preset radius of the maximum influence range of the high color temperature light source, and the second brightness threshold is greater than the first brightness threshold;
    if the environmental brightness value is less than or equal to the second brightness threshold, the radius P of the influence range of the high color temperature light source meets the following formula requirement:
    P=Pmin+(Pmax-Pmin)×BV-W1/W2-W1
    wherein, PminIs a preset radius, P, of the minimum influence range of the high color temperature light sourcemaxIs the preset radius of the maximum influence range of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W2Is the second brightness threshold.
  4. The method of claim 3, wherein the at least one high color temperature light source comprises a D75 light source, a D65 light source, a D55 light source, and a D50 light source, wherein:
    the radius of the preset maximum influence range of the D75 light source is smaller than that of the preset maximum influence range of the D65 light source;
    the radius of the maximum influence range of the preset D50 light source is smaller than that of the preset D55 light source.
  5. The method of any of claims 1 to 4, wherein adjusting the number of pixel blocks in at least one of the plurality of regions comprises:
    obtaining the distance between the first region and the high color temperature light source to which the first region belongs according to the three primary color characteristics of each pixel block in the first region and the three primary color characteristics of the high color temperature light source to which the first region belongs;
    obtaining a gain value of the first region according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs and the gain value of the high color temperature light source to which the first region belongs; the gain value of the high color temperature light source to which the first region belongs is determined according to the environment brightness value;
    and multiplying the number of the pixel blocks in the first area by the gain value of the first area to obtain the number of the pixel blocks in the first area after adjustment.
  6. The method of claim 5, wherein the gain value of the high color temperature light source to which the first region belongs is determined according to the ambient brightness value, and comprises:
    if the environmental brightness value is greater than a third brightness threshold, the gain value of the high color temperature light source to which the first region belongs is a preset maximum gain value of the high color temperature light source to which the first region belongs, and the third brightness threshold is greater than the first brightness threshold;
    if the environmental brightness value is less than or equal to a third brightness threshold, the gain value G of the high color temperature light source to which the first region belongs1Meets the following formula requirements:
    G1=G1min+(G1max-G1min)×BV-W1/W3-W1
    wherein G is1minIs a preset minimum gain value, G, of the high color temperature light source1maxIs the preset maximum gain value of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W3Is the third brightness threshold.
  7. The method of claim 5, wherein:
    if the first region is only located in the influence range of a first high color temperature light source, the high color temperature light source to which the first region belongs is the first high color temperature light source; the first high color temperature light source is any one of the at least one high color temperature light source;
    if the first region is located in the influence range of the plurality of high color temperature light sources, the high color temperature light source to which the first region belongs is the high color temperature light source with the minimum distance from the first region in the plurality of high color temperature light sources.
  8. The method according to claim 5, wherein the trichromatic characteristics comprise R/G values and B/G values;
    obtaining a distance between the first region and the high color temperature light source to which the first region belongs according to three primary color characteristics of each pixel block in the first region and three primary color characteristics of the high color temperature light source to which the first region belongs, including:
    D2=(M1,rg-M2,rg)2+(N1,bg-N2,bg)2
    wherein D is the distance between the first region and the high color temperature light source to which the first region belongs, and M is1,rgIs the R/G value, M, of the high color temperature light source to which the first region belongs2,rgIs the average value of R/G values of pixel blocks in the first region, N1,bgIs the B/G value, N, of the high color temperature light source2,bgIs the average of the B/G values of the pixel blocks in the first region.
  9. The method of claim 5, wherein obtaining the gain value of the first region according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs, and the gain value of the high color temperature light source to which the first region belongs comprises:
    G=1+(G1-1)×Rn
    R=P2-D2/P2
    wherein G is a gain value of the first region,G1the gain value of the high color temperature light source to which the first region belongs is obtained, P is the radius of the influence range of the high color temperature light source to which the first region belongs, D is the distance between the first region and the high color temperature light source to which the first region belongs, R is a numerical value which is larger than or equal to 0 and smaller than or equal to 1, and n is a numerical value which is larger than 0.
  10. The method according to any one of claims 1 to 9, wherein obtaining an ambient brightness value of the image comprises:
    BV=K×N2/(t×S)
    wherein BV is an environment brightness value of the image, N is an aperture size, t is an exposure time, S is a photosensitive value, and K is a constant.
  11. The method according to any one of claims 1 to 10, wherein performing white balance correction on the image according to the adjusted target color statistical information comprises:
    inputting the target color statistical information into a preset model, and performing white balance correction on the image; the preset model is obtained by training initial color statistical information of a plurality of first historical images and target color statistical information of a plurality of second historical images, wherein the environment brightness value of the first historical images is smaller than or equal to a first brightness threshold value, and the environment brightness value of the second historical images is larger than the first brightness threshold value.
  12. An image processing apparatus, characterized in that the apparatus comprises:
    the processing module is used for acquiring initial color statistical information of an image, wherein the image comprises a plurality of pixel blocks, the pixel blocks comprise one or more pixels, and the initial color statistical information comprises the number of the pixel blocks in each of a plurality of regions; and acquiring an ambient brightness value of the image;
    the processing module is further configured to adjust the number of pixel blocks in at least one of the plurality of regions if the ambient brightness value of the image is greater than a first brightness threshold, so as to obtain target color statistical information of the image, where the target color statistical information includes the adjusted number of pixel blocks in each of the plurality of regions; the number of pixel blocks of a first region in the target color statistical information is greater than that of the pixel blocks of the first region in the initial color statistical information, the first region is any one of the at least one region, and the at least one region is a region within an influence range of at least one high color temperature light source;
    and the correction module is used for carrying out white balance correction on the image according to the target color statistical information.
  13. The apparatus of claim 12, wherein the processing module is further configured to calculate the range of influence of the high color temperature light source by:
    obtaining the radius of the influence range of the high color temperature light source according to the environment brightness value;
    and determining the influence range of the high color temperature light source according to the radius of the influence range of the high color temperature light source.
  14. The apparatus according to claim 13, wherein the processing module obtains a radius of an influence range of the high color temperature light source according to the ambient brightness value, specifically:
    if the environmental brightness value is greater than a second brightness threshold, the radius of the influence range of the high color temperature light source is the preset radius of the maximum influence range of the high color temperature light source, and the second brightness threshold is greater than the first brightness threshold;
    if the environmental brightness value is less than or equal to the second brightness threshold, the radius P of the influence range of the high color temperature light source meets the following formula requirement:
    P=Pmin+(Pmax-Pmin)×BV-W1/W2-W1
    wherein, PminIs a preset radius, P, of the minimum influence range of the high color temperature light sourcemaxIs the preset radius of the maximum influence range of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W2Is the second brightness threshold.
  15. The apparatus of claim 14, wherein the at least one high color temperature light source comprises a D75 light source, a D65 light source, a D55 light source, and a D50 light source;
    the radius of the preset maximum influence range of the D75 light source is smaller than that of the preset maximum influence range of the D65 light source;
    the radius of the maximum influence range of the preset D50 light source is smaller than that of the preset D55 light source.
  16. The apparatus according to any of the claims 12 to 15, wherein the processing module is specifically configured to adjust the number of pixel blocks in at least one of the plurality of regions by:
    obtaining the distance between the first region and the high color temperature light source to which the first region belongs according to the three primary color characteristics of each pixel block in the first region and the three primary color characteristics of the high color temperature light source to which the first region belongs;
    obtaining a gain value of the first region according to the distance, the radius of the influence range of the high color temperature light source to which the first region belongs and the gain value of the high color temperature light source to which the first region belongs; the gain value of the high color temperature light source to which the first region belongs is determined according to the environment brightness value;
    and multiplying the number of the pixel blocks in the first area by the gain value of the first area to obtain the number of the pixel blocks in the first area after adjustment.
  17. The apparatus of claim 16, wherein the processing module is further configured to determine the gain value of the high color temperature light source to which the first region belongs by:
    if the environmental brightness value is greater than a third brightness threshold, the gain value of the high color temperature light source to which the first region belongs is a preset maximum gain value of the high color temperature light source to which the first region belongs, and the third brightness threshold is greater than the first brightness threshold;
    if the environmental brightness value is less than or equal to a third brightness threshold, the gain value G of the high color temperature light source to which the first region belongs1Meets the following formula requirements:
    G1=G1min+(G1max-G1min)×BV-W1/W3-W1
    wherein G is1minIs a preset minimum gain value, G, of the high color temperature light source1maxIs the preset maximum gain value of the high color temperature light source, BV is the environment brightness value, W1Is the first brightness threshold, W3Is the third brightness threshold.
  18. The apparatus of claim 16, wherein:
    if the first region is only located in the influence range of a first high color temperature light source, the high color temperature light source to which the first region belongs is the first high color temperature light source; the first high color temperature light source is any one of the at least one high color temperature light source;
    if the first region is located in the influence range of the plurality of high color temperature light sources, the high color temperature light source to which the first region belongs is the high color temperature light source with the minimum distance from the first region in the plurality of high color temperature light sources.
  19. The apparatus of claim 16, wherein the trichromatic characteristics comprise R/G values and B/G values;
    the processing module is specifically configured to obtain a distance between the first region and a high color temperature light source to which the first region belongs by:
    D2=(M1,rg-M2,rg)2+(N1,bg-N2,bg)2
    wherein D is the first regionDistance, M, of domain from high color temperature light source to which the first region belongs1,rgIs the R/G value, M, of the high color temperature light source to which the first region belongs2,rgIs the average value of R/G values of pixel blocks in the first region, N1,bgIs the B/G value, N, of the high color temperature light source2,bgIs the average of the B/G values of the pixel blocks in the first region.
  20. The apparatus of claim 16, wherein the processing module is specifically configured to obtain the gain value of the first region by:
    G=1+(G1-1)×Rn
    R=P2-D2/P2
    wherein G is a gain value of the first region, G1The gain value of the high color temperature light source to which the first region belongs is obtained, P is the radius of the influence range of the high color temperature light source to which the first region belongs, D is the distance between the first region and the high color temperature light source to which the first region belongs, R is a numerical value which is greater than or equal to 0 and less than or equal to 1, and n is a numerical value which is greater than 0.
  21. The apparatus according to any of claims 12 to 20, wherein the processing module is specifically configured to determine an ambient brightness value of an image by:
    BV=K×N2/(t×S)
    wherein BV is an environment brightness value of the image, N is an aperture size, t is an exposure time, S is a photosensitive value, and K is a constant.
  22. The apparatus according to any one of claims 12 to 21, wherein the correction module is specifically configured to:
    inputting the target color statistical information into a preset model, and performing white balance correction on the image; the preset model is obtained by training initial color statistical information of a plurality of first historical images and target color statistical information of a plurality of second historical images, wherein the environment brightness value of the first historical images is smaller than or equal to a first brightness threshold value, and the environment brightness value of the second historical images is larger than the first brightness threshold value.
  23. An image processing apparatus, characterized in that the apparatus comprises:
    a memory for storing a software program;
    a processor for reading the software program in the memory and executing the image processing method of any one of claims 1 to 11.
  24. A computer storage medium, characterized in that the storage medium stores therein a software program that, when read and executed by one or more processors, implements the image processing method of any one of claims 1 to 11.
CN201880086363.8A 2018-05-30 2018-05-30 Image processing method and device and computer storage medium Active CN111587573B (en)

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/089089 WO2019227355A1 (en) 2018-05-30 2018-05-30 Image processing method and apparatus

Publications (2)

Publication Number Publication Date
CN111587573A true CN111587573A (en) 2020-08-25
CN111587573B CN111587573B (en) 2021-06-15

Family

ID=68696786

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201880086363.8A Active CN111587573B (en) 2018-05-30 2018-05-30 Image processing method and device and computer storage medium

Country Status (2)

Country Link
CN (1) CN111587573B (en)
WO (1) WO2019227355A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022257574A1 (en) * 2021-06-07 2022-12-15 荣耀终端有限公司 Fusion algorithm of ai automatic white balance and automatic white balance, and electronic device
CN116761081A (en) * 2021-06-07 2023-09-15 荣耀终端有限公司 Algorithm for automatic white balance of AI (automatic input/output) and electronic equipment

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112150392B (en) * 2020-09-30 2024-03-19 普联技术有限公司 Low-illumination image restoration method and device
CN115002437A (en) * 2021-03-02 2022-09-02 北京小米移动软件有限公司 White balance processing method and device, and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1953561A (en) * 2006-11-27 2007-04-25 北京中星微电子有限公司 A system and method to correct white balance
CN101039439A (en) * 2007-04-23 2007-09-19 北京中星微电子有限公司 Method and apparatus for realizing correction of white balance
US20110279703A1 (en) * 2010-05-12 2011-11-17 Samsung Electronics Co., Ltd. Apparatus and method for processing image by using characteristic of light source
CN102395035A (en) * 2011-11-22 2012-03-28 北京英泰智软件技术发展有限公司 Processing method for white balance of intelligent camera
CN105227945A (en) * 2015-10-21 2016-01-06 维沃移动通信有限公司 A kind of control method of Automatic white balance and mobile terminal
CN105611184A (en) * 2015-12-18 2016-05-25 珠海全志科技股份有限公司 White balance debugging method and debugging system of digital video device
CN105959662A (en) * 2016-05-24 2016-09-21 深圳英飞拓科技股份有限公司 Self-adaptive white balance adjusting method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4941370B2 (en) * 2008-03-18 2012-05-30 富士通株式会社 Image correction program, image correction apparatus, and image correction method
CN104954772B (en) * 2015-06-26 2017-05-10 济南中维世纪科技有限公司 Image adjacent-grey pixel selection algorithm applied to automatic white balance algorithm
CN107690065A (en) * 2017-07-31 2018-02-13 努比亚技术有限公司 A kind of white balance correcting, device and computer-readable recording medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1953561A (en) * 2006-11-27 2007-04-25 北京中星微电子有限公司 A system and method to correct white balance
CN101039439A (en) * 2007-04-23 2007-09-19 北京中星微电子有限公司 Method and apparatus for realizing correction of white balance
US20110279703A1 (en) * 2010-05-12 2011-11-17 Samsung Electronics Co., Ltd. Apparatus and method for processing image by using characteristic of light source
CN102395035A (en) * 2011-11-22 2012-03-28 北京英泰智软件技术发展有限公司 Processing method for white balance of intelligent camera
CN105227945A (en) * 2015-10-21 2016-01-06 维沃移动通信有限公司 A kind of control method of Automatic white balance and mobile terminal
CN105611184A (en) * 2015-12-18 2016-05-25 珠海全志科技股份有限公司 White balance debugging method and debugging system of digital video device
CN105959662A (en) * 2016-05-24 2016-09-21 深圳英飞拓科技股份有限公司 Self-adaptive white balance adjusting method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022257574A1 (en) * 2021-06-07 2022-12-15 荣耀终端有限公司 Fusion algorithm of ai automatic white balance and automatic white balance, and electronic device
CN116761081A (en) * 2021-06-07 2023-09-15 荣耀终端有限公司 Algorithm for automatic white balance of AI (automatic input/output) and electronic equipment

Also Published As

Publication number Publication date
CN111587573B (en) 2021-06-15
WO2019227355A1 (en) 2019-12-05

Similar Documents

Publication Publication Date Title
CN104796683B (en) A kind of method and system of calibration image color
KR100886099B1 (en) Apparatus for automatically computing image correction curve and Method thereof
US10757386B2 (en) White balance calibration method based on skin color data and image processing apparatus using the same
CN111641819B (en) Method, device, system and computer device for white balance gain correction
JP5980294B2 (en) Data processing apparatus, imaging apparatus, and data processing method
CN104618702B (en) A kind of digital camera auto white balance method supposed based on white block
CN105898263B (en) A kind of image white balance method, device and computing device
CN101527860A (en) White balance control apparatus, control method therefor, and image sensing apparatus
CN109672871B (en) White balance information synchronization method, white balance information synchronization device and computer readable medium
CN111587573B (en) Image processing method and device and computer storage medium
WO2019170007A1 (en) Image color adjustment method and device
JP6006543B2 (en) Image processing apparatus and image processing method
CN111861922A (en) Method and device for adjusting color correction matrix and storage medium
US9716880B2 (en) Image calibrating method for stitching images and related camera and image processing system with image calibrating function
WO2017096858A1 (en) Method and device for calibrating white balance of images
CN108063926B (en) Image processing method and device, computer readable storage medium and computer device
WO2020093653A1 (en) Color adjustment method, color adjustment device, electronic device and computer-readable storage medium
US9319653B2 (en) White balance compensation method and electronic apparatus using the same
WO2022036539A1 (en) Color consistency correction method and device for multiple cameras
CN112788322A (en) Adaptive white balance processing method, device, medium, and electronic apparatus
CN103685854A (en) Image processing apparatus, image processing method, and program
US9131200B2 (en) White balance adjusting method with scene detection and device thereof
US20190311464A1 (en) Tuning for deep-learning-based color enhancement systems
CN110033412B (en) Image processing method and device
US20230342977A1 (en) Method for Determining Chromaticity Information and Related Electronic Device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant