[go: up one dir, main page]

CN107580205A - Method and device for adjusting white balance - Google Patents

Method and device for adjusting white balance Download PDF

Info

Publication number
CN107580205A
CN107580205A CN201710775995.2A CN201710775995A CN107580205A CN 107580205 A CN107580205 A CN 107580205A CN 201710775995 A CN201710775995 A CN 201710775995A CN 107580205 A CN107580205 A CN 107580205A
Authority
CN
China
Prior art keywords
white balance
value
balance gains
image
gain value
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
CN201710775995.2A
Other languages
Chinese (zh)
Other versions
CN107580205B (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.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp 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 Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201710775995.2A priority Critical patent/CN107580205B/en
Priority to PCT/CN2017/107333 priority patent/WO2019041493A1/en
Publication of CN107580205A publication Critical patent/CN107580205A/en
Application granted granted Critical
Publication of CN107580205B publication Critical patent/CN107580205B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Color Television Image Signal Generators (AREA)
  • Processing Of Color Television Signals (AREA)

Abstract

The invention provides a white balance adjusting method and a white balance adjusting device, wherein the method comprises the following steps: calculating to obtain a first white balance gain value of the image by adopting a face white balance algorithm; calculating a plurality of second white balance gain values corresponding to the image if the image is obtained by imaging under a plurality of light sources respectively; selecting a target white balance gain value close to the first white balance gain value from the plurality of second white balance gain values according to the first white balance gain value; calculating to obtain a third white balance gain value of the image by adopting a simple gray world algorithm; and performing white balance adjustment on the image according to the target white balance gain value and the third white balance gain value. The technical problem that in the prior art, under the same scene, when a face exists in an image or the face does not exist in the image, the white balance gain value changes suddenly is solved.

Description

白平衡调整方法和装置Method and device for adjusting white balance

技术领域technical field

本发明涉及成像技术领域,尤其涉及一种白平衡调整方法和装置。The invention relates to the field of imaging technology, in particular to a white balance adjustment method and device.

背景技术Background technique

相关技术中,在使用终端设备的拍摄设备进行拍照时,在实际的彩色图像采集得到的色彩值和物体的真实色彩会产生偏差,造成该偏差的原因主要有两个,一个是光源环境的色温变化,不同色温情况下,同一个物体的反射的光谱不一样,从而导致物体在不同色温的光源照射下呈现的颜色不同,例如白色物体在高色温环境下呈现蓝色,而在低色温的环境中呈现红色。另一个是由于拍摄设备本身所固有的色彩通道的增益的偏差,比如对于GC0307的B通道的manual gain值是0x98,而R,G通道的manual gain值为0x80。In related technologies, when using the shooting device of the terminal device to take pictures, there will be a deviation between the color value obtained by the actual color image collection and the real color of the object. There are two main reasons for this deviation. One is the color temperature of the light source environment Change, under different color temperature conditions, the reflected spectrum of the same object is different, resulting in different colors of the object under the light source of different color temperature, for example, a white object appears blue in a high color temperature environment, but in a low color temperature environment in red. The other is due to the deviation of the inherent color channel gain of the shooting device itself, for example, the manual gain value of the B channel of GC0307 is 0x98, while the manual gain value of the R and G channels is 0x80.

因而,相关技术中,为了补偿这种色彩的偏差,通过相关的白平衡算法改变拍摄设备的色彩增益通道的白平衡增益值,对色温环境所造成的颜色偏差和拍摄设备本身所固有的色彩通道增益的偏差进行统一补偿,从而让获取的图像能正确的反应物体的真实色彩。Therefore, in the related art, in order to compensate for this color deviation, the white balance gain value of the color gain channel of the shooting device is changed through the relevant white balance algorithm, and the color deviation caused by the color temperature environment and the inherent color channel of the shooting device itself Gain deviation is uniformly compensated, so that the acquired image can correctly reflect the true color of the object.

其中,白平衡算法有多种,均可用于计算出白平衡增益值,在人像拍摄现场进行下,为了起到较好的处理效果,基于有人脸和没有人脸采用不同的白平衡算法进行白平衡处理,导致当在进行拍照时,在相同场景下,有人脸和没有人脸时,得到的白平衡增益值变化明显,从而导致图像色彩突变。Among them, there are many kinds of white balance algorithms, all of which can be used to calculate the white balance gain value. In the portrait shooting scene, in order to achieve a better processing effect, different white balance algorithms are used for white balance based on whether there are faces or no faces. Balance processing, when taking pictures, in the same scene, when there is a face and no face, the obtained white balance gain value changes significantly, resulting in a sudden change in image color.

发明内容Contents of the invention

本发明提供一种白平衡调整方法和装置,以解决现有技术中,在相同的场景下,图像中有人脸和没人脸时,白平衡增益值突变的,从而导致色彩突变的技术问题。The present invention provides a white balance adjustment method and device to solve the technical problem in the prior art that, in the same scene, when there is a face and no face in the image, the white balance gain value changes suddenly, resulting in a color change.

本发明实施例提供一种白平衡调整方法,包括以下步骤:采用人脸白平衡算法,计算得到图像的第一白平衡增益值;计算若分别在多种光源下成像得到所述图像时,所述图像所对应的多个第二白平衡增益值;根据所述第一白平衡增益值,从所述多个第二白平衡增益值中选取得到与所述第一白平衡增益值接近的目标白平衡增益值;采用简单灰度世界算法,计算得到所述图像的第三白平衡增益值;根据所述目标平衡增益值目标白平衡增益值和所述第三白平衡增益值,对所述图像进行白平衡调整。An embodiment of the present invention provides a white balance adjustment method, which includes the following steps: using the face white balance algorithm to calculate the first white balance gain value of the image; A plurality of second white balance gain values corresponding to the image; according to the first white balance gain value, select from the plurality of second white balance gain values to obtain a target close to the first white balance gain value White balance gain value; a third white balance gain value of the image is calculated by using a simple grayscale world algorithm; according to the target white balance gain value of the target balance gain value and the third white balance gain value, the The image is white balance adjusted.

本发明另一实施例提供一种白平衡调整装置,包括:第一计算模块,用于采用人脸白平衡算法,计算得到图像的第一白平衡增益值;第二计算模块,用于计算若分别在多种光源下成像得到所述图像时,所述图像所对应的多个第二白平衡增益值;选取模块,用于根据所述第一白平衡增益值,从所述多个第二白平衡增益值中选取得到与所述第一白平衡增益值接近的目标白平衡增益值;第三计算模块,用于采用简单灰度世界算法,计算得到所述图像的第三白平衡增益值;调整模块,用于根据所述目标白平衡增益值和所述第三白平衡增益值,对所述图像进行白平衡调整。Another embodiment of the present invention provides a white balance adjustment device, including: a first calculation module, used to calculate the first white balance gain value of an image by using a face white balance algorithm; a second calculation module, used to calculate if When the image is obtained by imaging under a variety of light sources, a plurality of second white balance gain values corresponding to the image; a selection module, configured to select from the plurality of second white balance gain values according to the first white balance gain value A target white balance gain value close to the first white balance gain value is selected from the white balance gain value; the third calculation module is used to calculate the third white balance gain value of the image by using a simple grayscale world algorithm ; An adjustment module, configured to adjust the white balance of the image according to the target white balance gain value and the third white balance gain value.

本发明又一实施例提供一种计算机设备,包括存储器及处理器,所述存储器中储存有计算机可读指令,所述指令被所述处理器执行时,使得所述处理器执行本发明上述实施例所述的白平衡调整方法。Yet another embodiment of the present invention provides a computer device, including a memory and a processor. Computer-readable instructions are stored in the memory. When the instructions are executed by the processor, the processor executes the above-mentioned embodiment of the present invention. The white balance adjustment method described in the example.

本发明还一实施例提供一种非临时性计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如本发明上述实施例所述的白平衡调整方法。Another embodiment of the present invention provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the white balance adjustment method as described in the above-mentioned embodiments of the present invention is implemented.

本发明实施例提供的技术方案可以包括以下有益效果:The technical solutions provided by the embodiments of the present invention may include the following beneficial effects:

采用人脸白平衡算法,计算得到图像的第一白平衡增益值,计算若分别在多种光源下成像得到图像时,图像所对应的多个第二白平衡增益值,根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值,采用简单灰度世界算法,计算得到图像的第三白平衡增益值,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。由此,抑制了在同样的场景下,有人脸和没有人脸时,白平衡增益值突变从而导致屏幕闪烁的问题,避免了对人眼的伤害。Use the face white balance algorithm to calculate the first white balance gain value of the image, and calculate the multiple second white balance gain values corresponding to the image when the image is imaged under multiple light sources, according to the first white balance gain Value, select the target white balance gain value close to the first white balance gain value from multiple second white balance gain values, and use the simple grayscale world algorithm to calculate the third white balance gain value of the image, according to the target white balance gain value The balance gain value and the third white balance gain value are used to adjust the white balance of the image. As a result, the problem of flickering of the screen caused by sudden changes in the white balance gain value when there is a human face or no human face in the same scene is suppressed, and damage to human eyes is avoided.

附图说明Description of drawings

本发明上述的和/或附加的方面和优点从下面结合附图对实施例的描述中将变得明显和容易理解,其中:The above and/or additional aspects and advantages of the present invention will become apparent and easy to understand from the following description of the embodiments in conjunction with the accompanying drawings, wherein:

图1是根据本发明一个实施例的白平衡调整方法的流程图;FIG. 1 is a flowchart of a white balance adjustment method according to an embodiment of the present invention;

图2是根据本发明另一个实施例的白平衡调整方法的流程图;FIG. 2 is a flowchart of a white balance adjustment method according to another embodiment of the present invention;

图3是根据本发明一个实施例的白平衡调整装置的结构示意图;以及FIG. 3 is a schematic structural diagram of a white balance adjustment device according to an embodiment of the present invention; and

图4是本发明一实施例提出的计算机设备中的图像处理电路的结构示意图。FIG. 4 is a schematic structural diagram of an image processing circuit in a computer device according to an embodiment of the present invention.

具体实施方式Detailed ways

下面详细描述本发明的实施例,所述实施例的示例在附图中示出,其中自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。下面通过参考附图描述的实施例是示例性的,旨在用于解释本发明,而不能理解为对本发明的限制。Embodiments of the present invention are described in detail below, examples of which are shown in the drawings, wherein the same or similar reference numerals designate the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the figures are exemplary and are intended to explain the present invention and should not be construed as limiting the present invention.

可以理解,在实际应用中的很多应用场景下,用户使用智能手机等终端设备中的应用程序进行拍照,其中,在终端设备的前置拍照模式或人像拍照模式等拍人像的模式下拍照,和,在使用后置拍照模式等非人像拍照模式下进行拍照时,所采用的白平衡算法是不同的,这是因为在人脸拍照模式下和非人脸模式下图像的色彩组成是不同的。具体而言,在人像拍照模式下采用人脸白平衡(Face Automatic White Balance,FaceAWB)算法,当图像中存在人物时,由于一类人种的肤色变化很小,在一个可估算的范围内。因此,可以根据人脸肤色的特征,确定对应的校正算子,进而得到更准确的白平衡计算结果。尤其在大面积纯色背景和/或混光条件下,能有效改善图像的白平衡效果。It can be understood that in many application scenarios in practical applications, the user uses an application program in a terminal device such as a smart phone to take pictures, wherein, taking pictures in a portrait mode such as a front camera mode or a portrait camera mode of the terminal device, and , when taking photos in non-portrait shooting modes such as the rear camera mode, the white balance algorithm used is different, because the color composition of the image in the face shooting mode and the non-face shooting mode is different. Specifically, in the portrait mode, the Face Automatic White Balance (FaceAWB) algorithm is adopted. When there are people in the image, the skin color of a class of people changes very little, within an estimable range. Therefore, the corresponding correction operator can be determined according to the characteristics of the skin color of the human face, so as to obtain a more accurate white balance calculation result. It can effectively improve the white balance effect of the image, especially under the condition of large-area solid color background and/or mixed light.

在非人像拍照模式下采用灰度世界(Simple Gray World)算法,灰度世界(SimpleGray World)算法是以灰度世界假设为基础,该假设认为:对于一幅有着大量色彩变化的图像,红色(Red,R)、绿色(Green,G)和蓝色(Blue,B)三个分量的饱和度的平均值趋于同一灰度值。即灰度世界算法假设自然界景物对于光线的平均反射的均值在总体上是个定值,这个定值中R、G、B三个分量的饱和度趋于一致。当图像中存在丰富的色彩时,通过该灰度世界算法对图像进行处理,可以更好地消除环境光的影响。In the non-portrait mode, the Simple Gray World algorithm is used. The Simple Gray World algorithm is based on the gray world assumption. The average value of the saturation of the three components of Red, R), green (Green, G) and blue (Blue, B) tends to the same gray value. That is, the grayscale world algorithm assumes that the mean value of the average reflection of light by natural scenes is generally a fixed value, and the saturation of the three components of R, G, and B in this fixed value tends to be consistent. When there are rich colors in the image, the effect of ambient light can be better eliminated by processing the image through the grayscale world algorithm.

然而,采用不同的白平衡算法所获取的白平衡增益值差距较大,在同样的应用场景下,当终端设备从有人脸的场景移动到没有人脸的场景下时,所获得的白平衡增益值差距较大,从而导致色彩发生突变,对人眼具有伤害,视觉效果不好。However, the white balance gain values obtained by using different white balance algorithms vary greatly. In the same application scenario, when the terminal device moves from a scene with a face to a scene without a face, the obtained white balance gain If there is a big difference in the value, it will lead to a sudden change in the color, which is harmful to the human eye and the visual effect is not good.

为了解决上述技术问题,本发明提出了一种白平衡调整方法和装置,可以抑制白平衡增益值突变的问题。In order to solve the above technical problems, the present invention proposes a white balance adjustment method and device, which can suppress the sudden change of the white balance gain value.

下面参考附图描述本发明实施例的白平衡调整方法和装置。The method and device for adjusting white balance according to the embodiments of the present invention will be described below with reference to the accompanying drawings.

图1是根据本发明一个实施例的白平衡调整方法的流程图,如图1所示,该方法包括以下步骤:Fig. 1 is a flowchart of a method for adjusting white balance according to an embodiment of the present invention. As shown in Fig. 1, the method includes the following steps:

步骤101,采用人脸白平衡算法,计算得到图像的第一白平衡增益值。Step 101, using a face white balance algorithm to calculate a first white balance gain value of the image.

具体地,为了为人脸图像选用合适的增益值对图像进行白平衡处理,使得图像处理结果中,人脸的颜色和肤色比较吻合,可以先根据该人脸白平衡算法,对图像计算得到第一增益值以作备用。Specifically, in order to select an appropriate gain value for the face image to perform white balance processing on the image, so that in the image processing result, the color of the face is more consistent with the skin color, the image can be calculated according to the face white balance algorithm to obtain the first Gain value for backup.

步骤102,计算若分别在多种光源下成像得到图像时,图像所对应的多个第二白平衡增益值。Step 102, calculating a plurality of second white balance gain values corresponding to the image if the image is obtained by imaging under various light sources.

其中,光源包括:日光光源、荧光光源、钨丝灯光源和F-A-H光源中的一个或多个组合,其中,F-A-H光源是A光和H光之间的光源,A光色温为2850K,H光色温为2350K。Among them, the light source includes: one or more combinations of daylight light source, fluorescent light source, tungsten light source and F-A-H light source, wherein, the F-A-H light source is a light source between A light and H light, the color temperature of A light is 2850K, and the color temperature of H light is 2850K. for 2350K.

具体地,为了为非人脸图像选用合适的增益值对图像进行白平衡处理,使得图像处理结果中,非人脸区域的颜色和自然色比较吻合,计算若分别在多种光源下成像得到图像时,图像所分别对应的多个第二白平衡增益值以作备用,该第二白平衡增益值与灰度世界的算法结果较为接近。Specifically, in order to select an appropriate gain value for the non-face image to perform white balance processing on the image, so that the color of the non-face area in the image processing result is more consistent with the natural color, calculate if the image obtained by imaging under various light sources In this case, multiple second white balance gain values respectively corresponding to the images are used for backup, and the second white balance gain values are relatively close to the algorithm results of the grayscale world.

步骤103,根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值。Step 103, according to the first white balance gain value, select a target white balance gain value close to the first white balance gain value from multiple second white balance gain values.

具体地,为了避免在人脸拍照模式和非人脸拍照模式下的白平衡增益值差异较大,根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值,从而,根据该目标白平衡增益值一方面考量了人脸肤色,另一方面考量了自然界丰富的色彩(灰度世界),不仅可以提高图像处理的视觉效果,而且基于目标白平衡增益值与灰度世界的白平衡增益值较为接近,避免了白平衡增益值突变从而导致屏幕闪烁的问题。Specifically, in order to avoid large differences in white balance gain values in the face-photographing mode and non-face-photographing mode, according to the first white balance gain value, a plurality of second white balance gain values are selected to obtain the same white balance gain value as the first white balance gain value. The target white balance gain value is close to the balance gain value. Therefore, according to the target white balance gain value, on the one hand, the skin color of the human face is considered, and on the other hand, the rich colors in nature (gray world) are considered, which can not only improve the visual effect of image processing Effect, and based on the target white balance gain value is relatively close to the white balance gain value in the grayscale world, it avoids the problem of screen flicker caused by sudden changes in the white balance gain value.

需要说明的是,根据应用场景的不同,可采用不同的实现方式,根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值,举例说明如下:It should be noted that, according to different application scenarios, different implementation methods can be adopted. According to the first white balance gain value, a target white balance close to the first white balance gain value can be obtained by selecting from multiple second white balance gain values. The gain value is illustrated as follows:

第一种示例,确定第一白平衡增益值中,各颜色分量的第一增益值,针对每一个第二白平衡增益值,确定各颜色分量的第二增益值,对每一个第二白平衡增益值与第一白平衡增益值之间的差异值进行计算,差异值是对同颜色分量中第一增益值与第二增益值之绝对差值计算后,对各颜色分量的绝对差值求和得到的,从多个第二白平衡增益值中,选取与第一增益值之间的差异值最小的目标白平衡增益值。The first example, determine the first gain value of each color component in the first white balance gain value, determine the second gain value of each color component for each second white balance gain value, and determine the second gain value of each color component for each second white balance gain value The difference between the gain value and the first white balance gain value is calculated. The difference value is calculated for the absolute difference of each color component after calculating the absolute difference between the first gain value and the second gain value in the same color component. and obtained, from the multiple second white balance gain values, select the target white balance gain value with the smallest difference from the first gain value.

第二种示例,根据第一白平衡增益值在各颜色分量上的第一增益值,生成第一向量,根据每一个第二白平衡增益值在各颜色分量上的第二增益值,生成对应的多个第二向量,计算第一向量和每一个第二向量之间的向量距离,向量距离包括欧几里得距离,根据向量距离,从多个第二白平衡增益值中,选取得到向量距离最小的目标白平衡增益值。In the second example, the first vector is generated according to the first gain value of the first white balance gain value on each color component, and the corresponding vector is generated according to the second gain value of each second white balance gain value on each color component. multiple second vectors, calculate the vector distance between the first vector and each second vector, the vector distance includes the Euclidean distance, according to the vector distance, select the vector from multiple second white balance gain values The target white balance gain value with the smallest distance.

步骤104,采用简单灰度世界算法,计算得到图像的第三白平衡增益值。In step 104, a third white balance gain value of the image is calculated by using a simple grayscale world algorithm.

应当理解的是,灰度世界算法所基于的假设为:对于一幅有着大量色彩变化的图像,R、G、B三个分量的饱和度的平均值趋于同一灰度值G。在实际应用中,通常有两种方法确定该灰度值G。It should be understood that the grayscale world algorithm is based on the assumption that for an image with a large number of color changes, the average value of the saturation of the three components R, G, and B tends to the same grayscale value G. In practical applications, there are usually two methods to determine the gray value G.

作为一种可能的实现方式,可以取固定值。例如,可以取最亮灰度值的一半,即当最亮灰度值为255时,该灰度值G可以为128。As a possible implementation manner, a fixed value can be taken. For example, half of the brightest grayscale value can be taken, that is, when the brightest grayscale value is 255, the grayscale value G can be 128.

作为另一种可能的实现方式,可以通过计算图像中R、G、B三种颜色各自的平均值,取这三个平均值的均值作为该灰度值G。在确定该灰度值G后,可以通过将该灰度值G与R、G、B三种颜色各自的平均值分别进行比较,从而计算出该图像的第二增益值。As another possible implementation manner, the average value of the three colors R, G, and B in the image may be calculated, and the average value of these three average values may be taken as the gray value G. After the grayscale value G is determined, the second gain value of the image can be calculated by comparing the grayscale value G with the average values of the three colors R, G, and B respectively.

步骤105,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。Step 105, adjust the white balance of the image according to the target white balance gain value and the third white balance gain value.

具体地,由于目标白平衡值为与第一增益值差异较小的增益值,可能较大程度的考虑了对人脸的处理效果,在由包含人脸到不包含人脸场景进行切换时,可能认为由于色彩的组成变化较大,而导致出现色彩突变,因此,在本发明的实施例中,进一步,综合考量目标白平衡增益值和基于灰度世界运算的第三白平衡增益值,对图像进行白平衡调整,使得在包含人脸场景到不包含人脸场景进行切换时,由于白平衡增益值与灰度世界的白平衡增益值更为接近,有效避免了白平衡增益值突变而导致色彩突变的问题。Specifically, since the target white balance value is a gain value with a smaller difference from the first gain value, the processing effect on the face may be considered to a greater extent. When switching from a scene containing a face to a scene not containing a face, It may be considered that a sudden change in color occurs due to a large change in color composition. Therefore, in the embodiment of the present invention, further considering the target white balance gain value and the third white balance gain value based on the grayscale world calculation, the The white balance of the image is adjusted so that when switching from a scene containing a human face to a scene not containing a human face, the white balance gain value is closer to the white balance gain value of the grayscale world, effectively avoiding the sudden change of the white balance gain value. The color change problem.

需要说明的是,根据应用场景的不同,可采用不同的实现方式,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整,举例说明如下:It should be noted that, according to different application scenarios, different implementation methods can be used to adjust the white balance of the image according to the target white balance gain value and the third white balance gain value. Examples are as follows:

第一种示例:First example:

计算目标白平衡增益值和第三白平衡增益值的加权平均值,根据加权平均值,对图像进行白平衡调整。Calculate the weighted average value of the target white balance gain value and the third white balance gain value, and adjust the white balance of the image according to the weighted average value.

第二种示例:Second example:

根据图像中人脸区域的面积占比,确定目标白平衡增益值的权重和第三白平衡增益值的权重,其中,由于人脸区域占比越大,目标白平衡增益值与灰度世界的第三白平衡增益值的差异越大,因此,为了保证拍摄人脸区域原色与肤色符合,设置目标白平衡增益值的权重与面积占比之间为正向关系,根据目标白平衡增益值的权重和第三白平衡增益值的权重,计算得到加权平均值。According to the area proportion of the face area in the image, determine the weight of the target white balance gain value and the weight of the third white balance gain value, wherein, because the proportion of the face area is larger, the target white balance gain value and the grayscale world The greater the difference in the third white balance gain value, therefore, in order to ensure that the primary color of the captured face area matches the skin color, the weight of the target white balance gain value and the area ratio are set to have a positive relationship. The weight and the weight of the third white balance gain value are calculated to obtain the weighted average.

综上所述,本发明实施例的白平衡调整方法,采用人脸白平衡算法,计算得到图像的第一白平衡增益值,计算若分别在多种光源下成像得到图像时,图像所对应的多个第二白平衡增益值,根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值,采用简单灰度世界算法,计算得到图像的第三白平衡增益值,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。由此,抑制了在同样的场景下,有人脸和没有人脸时,白平衡增益值突变从而导致屏幕闪烁的问题,避免了对人眼的伤害。To sum up, the white balance adjustment method of the embodiment of the present invention uses the face white balance algorithm to calculate the first white balance gain value of the image, and calculates the corresponding gain value of the image if the image is obtained by imaging under various light sources. Multiple second white balance gain values, according to the first white balance gain value, select from multiple second white balance gain values to obtain a target white balance gain value close to the first white balance gain value, using a simple grayscale world algorithm , calculate the third white balance gain value of the image, and adjust the white balance of the image according to the target white balance gain value and the third white balance gain value. As a result, the problem of flickering of the screen caused by sudden changes in the white balance gain value when there is a human face or no human face in the same scene is suppressed, and damage to human eyes is avoided.

基于以上实施例,为了进一步详细的描述,如何根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值,下面结合上述第二种示例示出的基于增益值的向量确定目标白平衡增益值为例,进行说明。Based on the above embodiments, in order to further describe in detail, how to select a target white balance gain value close to the first white balance gain value from multiple second white balance gain values according to the first white balance gain value, the following combines the above The determination of the target white balance gain value based on the vector of gain values shown in the second example is taken as an example for description.

图2是根据本发明另一个实施例的白平衡调整方法的流程图,如图2所示,该方法包括:Fig. 2 is a flowchart of a method for adjusting white balance according to another embodiment of the present invention. As shown in Fig. 2, the method includes:

步骤201,采用人脸白平衡算法,计算得到图像的第一白平衡增益值。Step 201, using a face white balance algorithm to calculate a first white balance gain value of the image.

具体地,可以通过人脸识别技术,对图像进行人脸识别,以确定图像中包含人脸区域,比如,可以先通过人脸识别技术,对图像中的人脸进行识别,得到人脸区域的坐标区间,其中,人脸识别算法,现有技术中有很多种实现方式,例如,采用Adaboost模型算法来进行人脸识别,还可以采用其他能快递识别人脸区域的算法,进行人脸区域的识别。对应人脸识别的实现方式,本实施例中不做限定。Specifically, face recognition can be performed on the image through face recognition technology to determine that the image contains a face area. Coordinate interval, wherein, the face recognition algorithm, there are many ways of implementation in the prior art, for example, adopt Adaboost model algorithm to carry out face recognition, can also adopt other algorithm that can identify face area quickly, carry out face area identify. The implementation manner of corresponding face recognition is not limited in this embodiment.

在得到人脸区域后,由于一类人种的肤色变化很小。例如,据统计,肤色RGB色彩空间转换到YCbCr空间后,人脸的Cb、Cr范围分别为[133,173],[77,127]。即只要能确定出人的肤色范围,就可以根据该肤色范围校正图像。因此,可以通过对比该图像中人脸区域的颜色与预设的肤色范围,计算出该图像的第一增益值。After getting the face area, the skin color of a class of people changes very little. For example, according to statistics, after the skin color RGB color space is converted to the YCbCr space, the Cb and Cr ranges of the face are [133, 173], [77, 127] respectively. That is, as long as the skin color range of a person can be determined, the image can be corrected according to the skin color range. Therefore, the first gain value of the image can be calculated by comparing the color of the face area in the image with the preset range of skin color.

当然,上述实施例进行人脸识别确定第一增益值的目的,是为了获取在人脸拍照模式下基于肤色进行白平衡处理时的第一增益值,事实上,在前置摄像头拍照模式或者在后置摄像头的拍照模式下,都是基于人脸白平衡算法进行白平衡处理,因此,还可以确定图像采用前置摄像头成像时,采用人脸白平衡算法,计算得到图像的第一白平衡增益值,或者,确定图像采用后置摄像头的人像模式成像时,采用人脸白平衡算法,计算得到图像的第一白平衡增益值等。Of course, the purpose of face recognition to determine the first gain value in the above embodiment is to obtain the first gain value when performing white balance processing based on skin color in the face photographing mode. In fact, in the front camera photographing mode or in the In the camera mode of the rear camera, the white balance processing is performed based on the face white balance algorithm. Therefore, it can also be determined that when the image is imaged by the front camera, the face white balance algorithm is used to calculate the first white balance gain of the image. value, or, when the image is determined to be imaged in the portrait mode of the rear camera, the face white balance algorithm is used to calculate the first white balance gain value of the image, etc.

步骤202,计算若分别在多种光源下成像得到图像时,图像所对应的多个第二白平衡增益值。Step 202 , calculating a plurality of second white balance gain values corresponding to the image if the image is obtained by imaging under various light sources.

步骤203,根据第一白平衡增益值在各颜色分量上的第一增益值,生成第一向量。Step 203: Generate a first vector according to the first gain value of the first white balance gain value on each color component.

步骤204,根据每一个第二白平衡增益值在各颜色分量上的第二增益值,生成对应的多个第二向量。Step 204: Generate a plurality of corresponding second vectors according to the second gain value of each second white balance gain value on each color component.

在实际应用中,可以利用色彩空间中的向量精确地表征该第一增益值和该第二增益值。色彩空间可以由多种,例如:RGB(red,green,blue)颜色空间,即基于设备三基色的颜色空间。另外,还可以是HSI色彩空间,该HSI色彩空间是从人的视觉系统出发,用色调(Hue)、色饱和度(Saturation或Chroma)和亮度(Intensity或Brightness)来描述色彩。HSI色彩空间可以用一个圆锥空间模型来描述。当然,还可以采用其他色彩空间进行描述,本实施例中对此不再赘述。作为一种可能的实现方式,可以采用色彩空间中的RGB模型表征第一增益值和第二增益值。In practical applications, the first gain value and the second gain value can be accurately represented by vectors in a color space. There are many kinds of color spaces, for example: RGB (red, green, blue) color space, that is, a color space based on three primary colors of a device. In addition, it may also be an HSI color space, which starts from the human visual system and uses hue (Hue), color saturation (Saturation or Chroma) and brightness (Intensity or Brightness) to describe colors. The HSI color space can be described by a cone space model. Of course, other color spaces may also be used for description, which will not be repeated in this embodiment. As a possible implementation manner, an RGB model in a color space may be used to characterize the first gain value and the second gain value.

具体地,在RGB模型中,每种颜色出现在R、G、B三个颜色分量中,这个模型基于笛卡尔坐标系统,所考虑的彩色空间是一个立方体。立方体的一个顶点可以作为原点,黑色位于该原点处,白色位于该立方体中离原点最远的顶点处。在该模型中,不同的颜色处在立方体上或者处在立方体内部,并可用从原点分布的向量来表征。Specifically, in the RGB model, each color appears in three color components of R, G, and B. This model is based on a Cartesian coordinate system, and the considered color space is a cube. One vertex of the cube could be the origin, with black at that origin and white at the vertex in the cube that is farthest from the origin. In this model, the different colors are on or inside the cube and can be represented by vectors distributed from the origin.

作为一种可能的实现方式,假定所有的颜色都归一化了,则该立方体为一个单位立方体,即所有R、G、B的值都在[0,1]的范围内取值。因此,该第一增益值和第二增益值在R、G、B中每一颜色分量上的取值也可以都在[0,1]的范围内取值。将第一增益值在每一颜色分量上的取值组合在一起,便可以生成第一向量,将第二增益值在每一颜色分量上的取值组合在一起,便可以生成第二向量。例如,若第一增益值在R分量上的取值为0.1,在G分量上的取值为0.2,在B分量上的取值为0.3,则可以根据第一增益值在每一颜色分量上的取值,生成第一向量[0.1,0.2,0.3]。若第二增益值在R分量上的取值为0.2,在G分量上的取值为0.2,在B分量上的取值为0.2,则可以根据第二增益值在每一颜色分量上的取值,生成第一向量[0.2,0.2,0.2]。As a possible implementation, assuming that all colors are normalized, the cube is a unit cube, that is, all values of R, G, and B are within the range of [0, 1]. Therefore, the values of the first gain value and the second gain value on each color component of R, G, and B may also be within the range of [0, 1]. The first vector can be generated by combining the values of the first gain value on each color component, and the second vector can be generated by combining the values of the second gain value on each color component. For example, if the value of the first gain value on the R component is 0.1, the value on the G component is 0.2, and the value on the B component is 0.3, then each color component can be The value of , generate the first vector [0.1, 0.2, 0.3]. If the value of the second gain value on the R component is 0.2, the value on the G component is 0.2, and the value on the B component is 0.2, then according to the value of the second gain value on each color component value, generating the first vector [0.2, 0.2, 0.2].

步骤205,计算第一向量和每一个第二向量之间的向量距离;向量距离包括欧几里得距离。Step 205, calculate the vector distance between the first vector and each second vector; the vector distance includes Euclidean distance.

具体地,在生成第一向量和第二向量后,便实现了对第一增益值和第二增益值的量化表征。在计算第一向量和第二向量之间的向量距离时,可以采用欧几里得距离描述这两个向量之间的向量距离,也可以采用余弦距离、皮尔逊相关系数等方式描述这两个向量之间的向量距离。以采用欧几里得距离描述第一向量和第二向量之间的向量距离为例,可以通过如下欧几里得距离公式:Specifically, after the first vector and the second vector are generated, the quantitative representation of the first gain value and the second gain value is realized. When calculating the vector distance between the first vector and the second vector, the Euclidean distance can be used to describe the vector distance between the two vectors, or the cosine distance, Pearson correlation coefficient, etc. can be used to describe the two Vector distance between vectors. Taking the Euclidean distance to describe the vector distance between the first vector and the second vector as an example, the following Euclidean distance formula can be used:

计算第一向量和第二向量之间的向量距离。其中,d(x,y)为第一向量和第二向量之间的向量距离,xR、xG、xB分别为第一向量中每一颜色分量上的取值,yR、yG、yB分别为第二向量中每一颜色分量上的取值。Computes the vector distance between the first vector and the second vector. Among them, d(x, y) is the vector distance between the first vector and the second vector, x R , x G , x B are the values of each color component in the first vector, y R , y G , y B are the values of each color component in the second vector, respectively.

进而,在计算得到第一向量和第二向量之间的向量距离后,可以判断该第一向量和该第二向量之间的向量距离,第一向量和该第二向量之间的向量距离越大,可以确定第一增益值和第二增益值越不相似。若该第一向量和该第二向量之间的向量距离越接近,则可以确定第一增益值和第二增益值相似。Furthermore, after the vector distance between the first vector and the second vector is calculated, the vector distance between the first vector and the second vector can be judged, the more the vector distance between the first vector and the second vector The larger the value, the more dissimilar the first gain value and the second gain value can be determined. If the vector distance between the first vector and the second vector is closer, it can be determined that the first gain value and the second gain value are similar.

步骤206,根据向量距离,从多个第二白平衡增益值中,选取得到向量距离最小的目标白平衡增益值。Step 206, according to the vector distance, select the target white balance gain value with the smallest vector distance from the plurality of second white balance gain values.

步骤207,采用简单灰度世界算法,计算得到图像的第三白平衡增益值。In step 207, a third white balance gain value of the image is calculated by using a simple grayscale world algorithm.

步骤208,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。Step 208, adjust the white balance of the image according to the target white balance gain value and the third white balance gain value.

具体地,根据向量距离,从多个第二白平衡增益值中,选取得到向量距离最小的目标白平衡增益值,结合灰度世界算法计算得到的第三白平衡增益值和目标白平衡增益值对图像进行准确的白平衡处理,一方面考量了人脸肤色,另一方面考量了自然界丰富的色彩,不仅可以提高图像处理的视觉效果,避免了白平衡增益值突变从而导致屏幕闪烁的问题。Specifically, according to the vector distance, from the multiple second white balance gain values, select the target white balance gain value with the smallest vector distance, and combine the third white balance gain value and the target white balance gain value calculated by the grayscale world algorithm Accurate white balance processing of images, on the one hand, considers the skin color of the face, and on the other hand, considers the rich colors of nature, which can not only improve the visual effect of image processing, but also avoid the problem of screen flicker caused by sudden changes in white balance gain.

综上所述,本发明实施例的白平衡调整方法,在根据用于将图像中的人脸调整至肤色的人脸白平衡算法,对该图像计算第一增益值,以及计算若分别在多种光源下成像得到图像时,图像所分别对应的多个第二白平衡增益值,根据第一白平衡增益值在各颜色分量上的第一增益值,生成第一向量,根据每一个第二白平衡增益值在各颜色分量上的第二增益值,生成对应的多个第二向量,并计算第一向量和每一个第二向量之间的向量距离;向量距离包括欧几里得距离,根据向量距离,从多个第二白平衡增益值中,选取得到向量距离最小的目标白平衡增益值,进而,采用简单灰度世界算法,计算得到图像的第三白平衡增益值,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。由此,配合较慢的白平衡收敛速度,可有效改善采用人脸白平衡算法进行白平衡调整时,有无人脸时闪烁的问题。To sum up, in the white balance adjustment method of the embodiment of the present invention, according to the face white balance algorithm used to adjust the face in the image to the skin color, calculate the first gain value for the image, and calculate if the When an image is obtained by imaging under such a light source, a plurality of second white balance gain values corresponding to the image respectively generate a first vector according to the first gain value of the first white balance gain value on each color component, and according to each second The second gain value of the white balance gain value on each color component generates a plurality of corresponding second vectors, and calculates the vector distance between the first vector and each second vector; the vector distance includes the Euclidean distance, According to the vector distance, select the target white balance gain value with the smallest vector distance from multiple second white balance gain values, and then use the simple grayscale world algorithm to calculate the third white balance gain value of the image. The balance gain value and the third white balance gain value are used to adjust the white balance of the image. Therefore, in conjunction with the slower white balance convergence speed, it can effectively improve the problem of flickering when there is no face when using the face white balance algorithm for white balance adjustment.

为了实现上述实施例,本发明还提出一种白平衡调整装置,图3是根据本发明一个实施例的白平衡调整装置的结构示意图,如图3所示,该白平衡调整装置包括第一计算模块100、第二计算模块200、选取模块300、第三计算模块400和调整模块500。In order to realize the above-mentioned embodiment, the present invention also proposes a white balance adjustment device. FIG. 3 is a schematic structural diagram of a white balance adjustment device according to an embodiment of the present invention. As shown in FIG. 3 , the white balance adjustment device includes a first calculation Module 100 , second calculation module 200 , selection module 300 , third calculation module 400 and adjustment module 500 .

其中,第一计算模块100,用于采用人脸白平衡算法,计算得到图像的第一白平衡增益值。Wherein, the first calculating module 100 is configured to calculate a first white balance gain value of the image by using a face white balance algorithm.

第二计算模块200,用于计算若分别在多种光源下成像得到图像时,图像所对应的多个第二白平衡增益值。The second calculation module 200 is configured to calculate multiple second white balance gain values corresponding to the image if the image is obtained by imaging under multiple light sources.

选取模块300,用于根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值;A selection module 300, configured to select a target white balance gain value close to the first white balance gain value from a plurality of second white balance gain values according to the first white balance gain value;

第三计算模块400,用于采用简单灰度世界算法,计算得到图像的第三白平衡增益值。The third calculation module 400 is configured to calculate a third white balance gain value of the image by using a simple grayscale world algorithm.

调整模块500,用于根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。The adjustment module 500 is configured to adjust the white balance of the image according to the target white balance gain value and the third white balance gain value.

需要说明的是,前述对方法实施例的描述,也适用于本发明实施例的装置,其实现原理类似,在此不再赘述。It should be noted that the foregoing descriptions of the method embodiments are also applicable to the devices of the embodiments of the present invention, and their implementation principles are similar, so details are not repeated here.

上述白平衡调整装置中各个模块的划分仅用于举例说明,在其他实施例中,可将白平衡调整装置按照需要划分为不同的模块,以完成上述白平衡调整装置的全部或部分功能。The division of each module in the above-mentioned white balance adjustment device is only for illustration. In other embodiments, the white balance adjustment device can be divided into different modules as required to complete all or part of the functions of the above-mentioned white balance adjustment device.

综上所述,本发明实施例的白平衡调整装置,采用人脸白平衡算法,计算得到图像的第一白平衡增益值,计算若分别在多种光源下成像得到图像时,图像所对应的多个第二白平衡增益值,根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值,采用简单灰度世界算法,计算得到图像的第三白平衡增益值,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。由此,抑制了在同样的场景下,有人脸和没有人脸时,白平衡增益值突变从而导致屏幕闪烁的问题,避免了对人眼的伤害。To sum up, the white balance adjustment device of the embodiment of the present invention uses the face white balance algorithm to calculate the first white balance gain value of the image, and calculates the corresponding gain value of the image if the image is obtained by imaging under various light sources. Multiple second white balance gain values, according to the first white balance gain value, select from multiple second white balance gain values to obtain a target white balance gain value close to the first white balance gain value, using a simple grayscale world algorithm , calculate the third white balance gain value of the image, and adjust the white balance of the image according to the target white balance gain value and the third white balance gain value. As a result, the problem of flickering of the screen caused by sudden changes in the white balance gain value when there is a human face or no human face in the same scene is suppressed, and damage to human eyes is avoided.

为实现上述目的,本发明实施例还提供一种计算机设备。上述计算机设备中包括图像处理电路,图像处理电路可以利用硬件和/或软件组件实现,可包括定义ISP(ImageSignal Processing,图像信号处理)管线的各种处理单元。图4为一个实施例中图像处理电路的示意图。如图4所示,为便于说明,仅示出与本发明实施例相关的图像处理技术的各个方面。To achieve the above object, an embodiment of the present invention further provides a computer device. The above computer device includes an image processing circuit, which may be implemented by hardware and/or software components, and may include various processing units defining an ISP (Image Signal Processing, image signal processing) pipeline. Fig. 4 is a schematic diagram of an image processing circuit in one embodiment. As shown in FIG. 4 , for ease of description, only various aspects of the image processing technology related to the embodiment of the present invention are shown.

如图4所示,图像处理电路包括ISP处理器1040和控制逻辑器1050。成像设备1010捕捉的图像数据首先由ISP处理器1040处理,ISP处理器1040对图像数据进行分析以捕捉可用于确定和/或成像设备1010的一个或多个控制参数的图像统计信息。成像设备1010可包括具有一个或多个透镜1012和图像传感器1014的照相机。图像传感器1014可包括色彩滤镜阵列(如Bayer滤镜),图像传感器1014可获取用图像传感器1014的每个成像像素捕捉的光强度和波长信息,并提供可由ISP处理器1040处理的一组原始图像数据。传感器1020可基于传感器1020接口类型把原始图像数据提供给ISP处理器1040。传感器1020接口可以利用SMIA(Standard Mobile Imaging Architecture,标准移动成像架构)接口、其它串行或并行照相机接口或上述接口的组合。As shown in FIG. 4 , the image processing circuit includes an ISP processor 1040 and a control logic 1050 . Image data captured by imaging device 1010 is first processed by ISP processor 1040 , which analyzes the image data to capture image statistics that may be used to determine and/or control one or more parameters of imaging device 1010 . Imaging device 1010 may include a camera having one or more lenses 1012 and an image sensor 1014 . Image sensor 1014 may include a color filter array (such as a Bayer filter), and image sensor 1014 may obtain light intensity and wavelength information captured with each imaging pixel of image sensor 1014 and provide a set of raw images that may be processed by ISP processor 1040. image data. The sensor 1020 may provide raw image data to the ISP processor 1040 based on the sensor 1020 interface type. The interface of the sensor 1020 may utilize a SMIA (Standard Mobile Imaging Architecture, Standard Mobile Imaging Architecture) interface, other serial or parallel camera interfaces, or a combination of the above interfaces.

ISP处理器1040按多种格式逐个像素地处理原始图像数据。例如,每个图像像素可具有8、10、12或14比特的位深度,ISP处理器1040可对原始图像数据进行一个或多个图像处理操作、收集关于图像数据的统计信息。其中,图像处理操作可按相同或不同的位深度精度进行。The ISP processor 1040 processes raw image data pixel by pixel in various formats. For example, each image pixel may have a bit depth of 8, 10, 12, or 14 bits, and the ISP processor 1040 may perform one or more image processing operations on raw image data, collect statistical information about the image data. Among other things, image processing operations can be performed with the same or different bit depth precision.

ISP处理器1040还可从图像存储器1030接收像素数据。例如,从传感器1020接口将原始像素数据发送给图像存储器1030,图像存储器1030中的原始像素数据再提供给ISP处理器1040以供处理。图像存储器1030可为存储器装置的一部分、存储设备、或电子设备内的独立的专用存储器,并可包括DMA(Direct Memory Access,直接直接存储器存取)特征。ISP processor 1040 may also receive pixel data from image memory 1030 . For example, the raw pixel data is sent from the sensor 1020 interface to the image memory 1030, and the raw pixel data in the image memory 1030 is provided to the ISP processor 1040 for processing. The image memory 1030 may be a part of a memory device, a storage device, or an independent dedicated memory in an electronic device, and may include a DMA (Direct Memory Access, direct memory access) feature.

当接收到来自传感器1020接口或来自图像存储器1030的原始图像数据时,ISP处理器1040可进行一个或多个图像处理操作,如时域滤波。处理后的图像数据可发送给图像存储器1030,以便在被显示之前进行另外的处理。ISP处理器1040从图像存储器1030接收处理数据,并对所述处理数据进行原始域中以及RGB和YCbCr颜色空间中的图像数据处理。处理后的图像数据可输出给显示器1070,以供用户观看和/或由图形引擎或GPU(GraphicsProcessing Unit,图形处理器)进一步处理。此外,ISP处理器1040的输出还可发送给图像存储器1030,且显示器1070可从图像存储器1030读取图像数据。在一个实施例中,图像存储器1030可被配置为实现一个或多个帧缓冲器。此外,ISP处理器1040的输出可发送给编码器/解码器1060,以便编码/解码图像数据。编码的图像数据可被保存,并在显示于显示器1070设备上之前解压缩。编码器/解码器1060可由CPU或GPU或协处理器实现。Upon receiving raw image data from the sensor 1020 interface or from the image memory 1030, the ISP processor 1040 may perform one or more image processing operations, such as temporal filtering. The processed image data may be sent to image memory 1030 for additional processing before being displayed. The ISP processor 1040 receives the processed data from the image memory 1030 and performs image data processing in the original domain and in the RGB and YCbCr color spaces on the processed data. The processed image data can be output to the display 1070 for viewing by the user and/or further processed by a graphics engine or a GPU (Graphics Processing Unit, graphics processor). In addition, the output of the ISP processor 1040 can also be sent to the image memory 1030 , and the display 1070 can read image data from the image memory 1030 . In one embodiment, image memory 1030 may be configured to implement one or more frame buffers. Also, the output of the ISP processor 1040 may be sent to an encoder/decoder 1060 for encoding/decoding image data. The encoded image data may be saved and decompressed prior to display on the display 1070 device. Encoder/decoder 1060 may be implemented by a CPU or GPU or a coprocessor.

ISP处理器1040确定的统计数据可发送给控制逻辑器1050单元。例如,统计数据可包括自动曝光、自动白平衡、自动聚焦、闪烁检测、黑电平补偿、透镜1012阴影校正等图像传感器1014统计信息。控制逻辑器1050可包括执行一个或多个例程(如固件)的处理器和/或微控制器,一个或多个例程可根据接收的统计数据,确定成像设备1010的控制参数以及的控制参数。例如,控制参数可包括传感器1020控制参数(例如增益、曝光控制的积分时间)、照相机闪光控制参数、透镜1012控制参数(例如聚焦或变焦用焦距)、或这些参数的组合。ISP控制参数可包括用于自动白平衡和颜色调整(例如,在RGB处理期间)的增益水平和色彩校正矩阵,以及透镜1012阴影校正参数。The statistics determined by the ISP processor 1040 may be sent to the control logic 1050 unit. For example, statistical data may include image sensor 1014 statistical information such as auto exposure, auto white balance, auto focus, flicker detection, black level compensation, lens 1012 shading correction, and the like. Control logic 1050 may include a processor and/or a microcontroller that executes one or more routines (e.g., firmware) that determine control parameters of imaging device 1010 and control of imaging device 1010 based on received statistical data. parameter. For example, control parameters may include sensor 1020 control parameters (eg, gain, integration time for exposure control), camera flash control parameters, lens 1012 control parameters (eg, focal length for focus or zoom), or combinations of these parameters. ISP control parameters may include gain levels and color correction matrices for automatic white balance and color adjustment (eg, during RGB processing), as well as lens 1012 shading correction parameters.

以下为运用图4中图像处理技术实现白平衡调整方法的步骤:The following are the steps of implementing the white balance adjustment method using the image processing technology in Fig. 4:

步骤101’,采用人脸白平衡算法,计算得到图像的第一白平衡增益值。Step 101', using the face white balance algorithm to calculate the first white balance gain value of the image.

步骤102’,计算若分别在多种光源下成像得到所述图像时,所述图像所对应的多个第二白平衡增益值。Step 102', calculating multiple second white balance gain values corresponding to the image if the image is obtained by imaging under multiple light sources.

步骤103’,根据所述第一白平衡增益值,从所述多个第二白平衡增益值中选取得到与所述第一白平衡增益值接近的目标白平衡增益值。Step 103', according to the first white balance gain value, select a target white balance gain value close to the first white balance gain value from the plurality of second white balance gain values.

步骤104’,采用简单灰度世界算法,计算得到所述图像的第三白平衡增益值。Step 104', using a simple grayscale world algorithm to calculate the third white balance gain value of the image.

步骤105’,根据所述目标白平衡增益值和所述第三白平衡增益值,对所述图像进行白平衡调整。Step 105', adjust the white balance of the image according to the target white balance gain value and the third white balance gain value.

需要说明的是,前述对方法实施例的解释说明也适用于本实施例的终端设备,其实现原理类似,此处不再赘述。It should be noted that the foregoing explanations of the method embodiments are also applicable to the terminal device of this embodiment, and the implementation principles thereof are similar, and details are not repeated here.

综上所述,本发明实施例的终端设备,采用人脸白平衡算法,计算得到图像的第一白平衡增益值,计算若分别在多种光源下成像得到图像时,图像所对应的多个第二白平衡增益值,根据第一白平衡增益值,从多个第二白平衡增益值中选取得到与第一白平衡增益值接近的目标白平衡增益值,采用简单灰度世界算法,计算得到图像的第三白平衡增益值,根据目标白平衡增益值和第三白平衡增益值,对图像进行白平衡调整。由此,抑制了在同样的场景下,有人脸和没有人脸时,白平衡增益值突变从而导致屏幕闪烁的问题,避免了对人眼的伤害。To sum up, the terminal device of the embodiment of the present invention adopts the face white balance algorithm to calculate the first white balance gain value of the image, and calculates the multiple white balance gain values corresponding to the image when the image is obtained by imaging under multiple light sources. The second white balance gain value, according to the first white balance gain value, is selected from multiple second white balance gain values to obtain a target white balance gain value close to the first white balance gain value, using a simple grayscale world algorithm to calculate A third white balance gain value of the image is obtained, and white balance adjustment is performed on the image according to the target white balance gain value and the third white balance gain value. As a result, the problem of flickering of the screen caused by sudden changes in the white balance gain value when there is a human face or no human face in the same scene is suppressed, and damage to human eyes is avoided.

本发明实施例还提出一种非临时性计算机可读存储介质,其上存储有计算机程序,当该计算机程序被处理器执行时能够实现如前述实施例所述的白平衡调整方法。The embodiment of the present invention also proposes a non-transitory computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the white balance adjustment method as described in the foregoing embodiments can be implemented.

在本说明书的描述中,参考术语“一个实施例”、“一些实施例”、“示例”、“具体示例”、或“一些示例”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本发明的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不必须针对的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任一个或多个实施例或示例中以合适的方式结合。此外,在不相互矛盾的情况下,本领域的技术人员可以将本说明书中描述的不同实施例或示例以及不同实施例或示例的特征进行结合和组合。In the description of this specification, descriptions referring to the terms "one embodiment", "some embodiments", "example", "specific examples", or "some examples" mean that specific features described in connection with the embodiment or example , structure, material or characteristic is included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the described specific features, structures, materials or characteristics may be combined in any suitable manner in any one or more embodiments or examples. In addition, those skilled in the art can combine and combine different embodiments or examples and features of different embodiments or examples described in this specification without conflicting with each other.

此外,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括至少一个该特征。在本发明的描述中,“多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。In addition, the terms "first" and "second" are used for descriptive purposes only, and cannot be interpreted as indicating or implying relative importance or implicitly specifying the quantity of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include at least one of these features. In the description of the present invention, "plurality" means at least two, such as two, three, etc., unless specifically defined otherwise.

流程图中或在此以其他方式描述的任何过程或方法描述可以被理解为,表示包括一个或更多个用于实现定制逻辑功能或过程的步骤的可执行指令的代码的模块、片段或部分,并且本发明的优选实施方式的范围包括另外的实现,其中可以不按所示出或讨论的顺序,包括根据所涉及的功能按基本同时的方式或按相反的顺序,来执行功能,这应被本发明的实施例所属技术领域的技术人员所理解。Any process or method descriptions in flowcharts or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing custom logical functions or steps of a process , and the scope of preferred embodiments of the invention includes alternative implementations in which functions may be performed out of the order shown or discussed, including substantially concurrently or in reverse order depending on the functions involved, which shall It is understood by those skilled in the art to which the embodiments of the present invention pertain.

在流程图中表示或在此以其他方式描述的逻辑和/或步骤,例如,可以被认为是用于实现逻辑功能的可执行指令的定序列表,可以具体实现在任何计算机可读介质中,以供指令执行系统、装置或设备(如基于计算机的系统、包括处理器的系统或其他可以从指令执行系统、装置或设备取指令并执行指令的系统)使用,或结合这些指令执行系统、装置或设备而使用。就本说明书而言,"计算机可读介质"可以是任何可以包含、存储、通信、传播或传输程序以供指令执行系统、装置或设备或结合这些指令执行系统、装置或设备而使用的装置。计算机可读介质的更具体的示例(非穷尽性列表)包括以下:具有一个或多个布线的电连接部(电子装置),便携式计算机盘盒(磁装置),随机存取存储器(RAM),只读存储器(ROM),可擦除可编辑只读存储器(EPROM或闪速存储器),光纤装置,以及便携式光盘只读存储器(CDROM)。另外,计算机可读介质甚至可以是可在其上打印所述程序的纸或其他合适的介质,因为可以例如通过对纸或其他介质进行光学扫描,接着进行编辑、解译或必要时以其他合适方式进行处理来以电子方式获得所述程序,然后将其存储在计算机存储器中。The logic and/or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced listing of executable instructions for implementing logical functions, can be embodied in any computer-readable medium, For use with instruction execution systems, devices, or devices (such as computer-based systems, systems including processors, or other systems that can fetch instructions from instruction execution systems, devices, or devices and execute instructions), or in conjunction with these instruction execution systems, devices or equipment used. For the purposes of this specification, a "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use in or in conjunction with an instruction execution system, device or device. More specific examples (non-exhaustive list) of computer-readable media include the following: electrical connection with one or more wires (electronic device), portable computer disk case (magnetic device), random access memory (RAM), Read Only Memory (ROM), Erasable and Editable Read Only Memory (EPROM or Flash Memory), Fiber Optic Devices, and Portable Compact Disc Read Only Memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program can be printed, since the program can be read, for example, by optically scanning the paper or other medium, followed by editing, interpretation or other suitable processing if necessary. The program is processed electronically and stored in computer memory.

应当理解,本发明的各部分可以用硬件、软件、固件或它们的组合来实现。在上述实施方式中,多个步骤或方法可以用存储在存储器中且由合适的指令执行系统执行的软件或固件来实现。如,如果用硬件来实现和在另一实施方式中一样,可用本领域公知的下列技术中的任一项或他们的组合来实现:具有用于对数据信号实现逻辑功能的逻辑门电路的离散逻辑电路,具有合适的组合逻辑门电路的专用集成电路,可编程门阵列(PGA),现场可编程门阵列(FPGA)等。It should be understood that various parts of the present invention can be realized by hardware, software, firmware or their combination. In the embodiments described above, various steps or methods may be implemented by software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented by any one or a combination of the following techniques known in the art: a discrete Logic circuits, ASICs with suitable combinational logic gates, Programmable Gate Arrays (PGA), Field Programmable Gate Arrays (FPGA), etc.

本技术领域的普通技术人员可以理解实现上述实施例方法携带的全部或部分步骤是可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,该程序在执行时,包括方法实施例的步骤之一或其组合。Those of ordinary skill in the art can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. During execution, one or a combination of the steps of the method embodiments is included.

此外,在本发明各个实施例中的各功能单元可以集成在一个处理模块中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。所述集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。In addition, each functional unit in each embodiment of the present invention may be integrated into one processing module, each unit may exist separately physically, or two or more units may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware or in the form of software function modules. If the integrated modules are realized in the form of software function modules and sold or used as independent products, they can also be stored in a computer-readable storage medium.

上述提到的存储介质可以是只读存储器,磁盘或光盘等。尽管上面已经示出和描述了本发明的实施例,可以理解的是,上述实施例是示例性的,不能理解为对本发明的限制,本领域的普通技术人员在本发明的范围内可以对上述实施例进行变化、修改、替换和变型。The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, and the like. Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present invention, those skilled in the art can make the above-mentioned The embodiments are subject to changes, modifications, substitutions and variations.

Claims (10)

1. a kind of white balance adjustment method, it is characterised in that comprise the following steps:
Using face white balance algorithm, the first white balance gains value of image is calculated;
If calculating respectively, when obtaining described image, multiple second white balances corresponding to described image increase for imaging under various light sources Benefit value;
According to the first white balance gains value, chosen from the multiple second white balance gains value obtain with it is described first white The close target white balance gains value of balancing gain value;
Using simple gray world algorithm, the 3rd white balance gains value of described image is calculated;
According to the target white balance gains value and the 3rd white balance gains value, blank level adjustment is carried out to described image.
2. white balance adjustment method according to claim 1, it is characterised in that described according to first white balance gains Value, chosen from the multiple second white balance gains value and obtain the target white balance close with the first white balance gains value Yield value, including:
Determine in the first white balance gains value, the first yield value of each color component;
For each the second white balance gains value, the second yield value of each color component is determined;
Difference value between each second white balance gains value and the first white balance gains value is calculated, the difference Different value is after calculating the absolute difference of the first yield value described in same color component and second yield value, to each color point The absolute difference of amount sums what is obtained;
From multiple second white balance gains values, the target white balance the difference value minimum between the first yield value is chosen Yield value.
3. white balance adjustment method according to claim 1, it is characterised in that described according to first white balance gains Value, chosen from the multiple second white balance gains value and obtain the target white balance close with the first white balance gains value Yield value, including:
According to first yield value of the first white balance gains value on each color component, primary vector is generated;
According to each second yield value of the second white balance gains value on each color component, corresponding to generation multiple second to Amount;
Calculate the vector distance between the primary vector and each described secondary vector;The vector distance include Europe it is several in Obtain distance;
According to the vector distance, from the multiple second white balance gains value, choose and obtain the vector distance minimum Target white balance gains value.
4. according to the white balance adjustment method described in claim any one of 1-3, it is characterised in that described to use face white balance Algorithm, it is calculated before the first white balance gains value of image, in addition to:
Recognition of face is carried out to described image, to determine to include human face region in described image;
Or, determine that described image is imaged to obtain using front camera;
Or, determine that described image is imaged to obtain using the portrait mode of figure of rear camera.
5. according to the white balance adjustment method described in claim any one of 1-3, it is characterised in that the light source includes:Daylight One or more of light source, fluorescence light source, tungsten filament lamp sources and F-A-H light sources combine.
6. according to the white balance adjustment method described in claim any one of 1-3, it is characterised in that described white according to the target Balancing gain value and the 3rd white balance gains value, blank level adjustment is carried out to described image, including:
Calculate the weighted average of the target white balance gains value and the 3rd white balance gains value;
According to the weighted average, blank level adjustment is carried out to described image.
7. white balance adjustment method according to claim 6, it is characterised in that described to calculate the target white balance gains The weighted average of value and the 3rd white balance gains value, including:
According to the area accounting of human face region in described image, the weight and the described 3rd of the target white balance gains value is determined The weight of white balance gains value;Wherein, it is positive pass between the weight of the target white balance gains value and the area accounting System;
According to the weight of the target white balance gains value and the weight of the 3rd white balance gains value, described add is calculated Weight average value.
A kind of 8. white balance adjustment device, it is characterised in that including:
First computing module, for using face white balance algorithm, the first white balance gains value of image is calculated;
Second computing module, if for when calculating that imaging obtains described image under various light sources respectively, corresponding to described image Multiple second white balance gains values;
Module is chosen, for according to the first white balance gains value, being chosen from the multiple second white balance gains value To the target white balance gains value close with the first white balance gains value;
3rd computing module, for using simple gray world algorithm, the 3rd white balance gains value of described image is calculated;
Adjusting module, for according to the target white balance gains value and the 3rd white balance gains value, entering to described image Row blank level adjustment.
9. a kind of computer equipment, it is characterised in that including memory, processor and storage on a memory and can be in processor The computer program of upper operation, during the computing device described program, realize putting down in vain as described in any in claim 1-7 Weigh method of adjustment.
10. a kind of computer-readable recording medium, is stored thereon with computer program, it is characterised in that the program is by processor The white balance adjustment method as described in any in claim 1-7 is realized during execution.
CN201710775995.2A 2017-08-31 2017-08-31 white balance adjusting method and device Active CN107580205B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201710775995.2A CN107580205B (en) 2017-08-31 2017-08-31 white balance adjusting method and device
PCT/CN2017/107333 WO2019041493A1 (en) 2017-08-31 2017-10-23 White balance adjustment method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710775995.2A CN107580205B (en) 2017-08-31 2017-08-31 white balance adjusting method and device

Publications (2)

Publication Number Publication Date
CN107580205A true CN107580205A (en) 2018-01-12
CN107580205B CN107580205B (en) 2019-06-07

Family

ID=61030995

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710775995.2A Active CN107580205B (en) 2017-08-31 2017-08-31 white balance adjusting method and device

Country Status (1)

Country Link
CN (1) CN107580205B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111127359A (en) * 2019-12-19 2020-05-08 大连海事大学 Underwater image enhancement method based on selective compensation color and three-interval balance
TWI759188B (en) * 2021-04-27 2022-03-21 凌巨科技股份有限公司 Image processing device and method for adjusting white balance
CN114240800A (en) * 2021-12-22 2022-03-25 清华大学 Coding camera image enhancement method and device for scattering scene
CN116485786A (en) * 2023-06-15 2023-07-25 贵州医科大学附属医院 An intelligent analysis method for endocrine test paper

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080211925A1 (en) * 2007-03-02 2008-09-04 Fujifilm Corporation White balance correction apparatus and method
CN101272505A (en) * 2007-03-19 2008-09-24 株式会社理光 Pick-up device and pick-up method
CN101350883A (en) * 2007-07-17 2009-01-21 富士胶片株式会社 Auto white balance correction value calculation device, method, program, and image pickup device
CN103139573A (en) * 2011-11-22 2013-06-05 三星电子株式会社 Apparatus and method for adjusting white balance
US20130278793A1 (en) * 2012-04-24 2013-10-24 Canon Kabushiki Kaisha Image processing apparatus, image processing method, and storage medium
CN105894458A (en) * 2015-12-08 2016-08-24 乐视移动智能信息技术(北京)有限公司 Processing method and device of image with human face
CN106357988A (en) * 2016-11-09 2017-01-25 广东欧珀移动通信有限公司 White balance adjustment method, device and terminal equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080211925A1 (en) * 2007-03-02 2008-09-04 Fujifilm Corporation White balance correction apparatus and method
CN101272505A (en) * 2007-03-19 2008-09-24 株式会社理光 Pick-up device and pick-up method
CN101350883A (en) * 2007-07-17 2009-01-21 富士胶片株式会社 Auto white balance correction value calculation device, method, program, and image pickup device
CN103139573A (en) * 2011-11-22 2013-06-05 三星电子株式会社 Apparatus and method for adjusting white balance
US20130278793A1 (en) * 2012-04-24 2013-10-24 Canon Kabushiki Kaisha Image processing apparatus, image processing method, and storage medium
CN105894458A (en) * 2015-12-08 2016-08-24 乐视移动智能信息技术(北京)有限公司 Processing method and device of image with human face
CN106357988A (en) * 2016-11-09 2017-01-25 广东欧珀移动通信有限公司 White balance adjustment method, device and terminal equipment

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111127359A (en) * 2019-12-19 2020-05-08 大连海事大学 Underwater image enhancement method based on selective compensation color and three-interval balance
CN111127359B (en) * 2019-12-19 2023-05-23 大连海事大学 Underwater image enhancement method based on selective compensation of colors and three-interval equalization
TWI759188B (en) * 2021-04-27 2022-03-21 凌巨科技股份有限公司 Image processing device and method for adjusting white balance
CN114240800A (en) * 2021-12-22 2022-03-25 清华大学 Coding camera image enhancement method and device for scattering scene
CN114240800B (en) * 2021-12-22 2022-11-29 清华大学 Scattering scene-oriented coded camera image enhancement method and device
CN116485786A (en) * 2023-06-15 2023-07-25 贵州医科大学附属医院 An intelligent analysis method for endocrine test paper
CN116485786B (en) * 2023-06-15 2023-09-01 贵州医科大学附属医院 Intelligent analysis method for endocrine test paper

Also Published As

Publication number Publication date
CN107580205B (en) 2019-06-07

Similar Documents

Publication Publication Date Title
US11503219B2 (en) Image processing apparatus, image capture apparatus, and control method for adding an effect of a virtual light source to a subject
US10997696B2 (en) Image processing method, apparatus and device
US10397486B2 (en) Image capture apparatus and method executed by image capture apparatus
CN107451969B (en) Image processing method, image processing device, mobile terminal and computer readable storage medium
CN108024055B (en) White balance processing method and device, mobile terminal and storage medium
US9288392B2 (en) Image capturing device capable of blending images and image processing method for blending images thereof
CN110022469B (en) Image processing method, device, storage medium and electronic device
WO2020034737A1 (en) Imaging control method, apparatus, electronic device, and computer-readable storage medium
CN108683862A (en) Imaging control method, device, electronic device, and computer-readable storage medium
CN108024057B (en) Background blurring processing method, device and equipment
CN107396079A (en) Method and device for adjusting white balance
CN108174172B (en) Photographing method and apparatus, computer-readable storage medium, and computer device
CN108055452A (en) Image processing method, device and equipment
CN108712608A (en) Terminal equipment shooting method and device
WO2020034701A1 (en) Imaging control method and apparatus, electronic device, and readable storage medium
CN108156369B (en) Image processing method and device
WO2019019904A1 (en) White balance processing method and apparatus, and terminal
WO2019011154A1 (en) White balance processing method and apparatus
CN109040607A (en) Imaging control method, imaging control device, electronic device and computer-readable storage medium
CN107580205A (en) Method and device for adjusting white balance
CN107465903A (en) Image white balance method, device and computer-readable storage medium
CN107135384A (en) White balance adjusting method, device, image processing terminal and storage medium
US11115637B2 (en) Image processing apparatus, image capturing apparatus, image processing method, and storage medium
CN107635124A (en) White balance processing method, device and equipment for face shooting
CN109300186A (en) Image processing method and device, storage medium, 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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 523860 No. 18, Wu Sha Beach Road, Changan Town, Dongguan, Guangdong

Applicant after: OPPO Guangdong Mobile Communications Co., Ltd.

Address before: 523860 No. 18, Wu Sha Beach Road, Changan Town, Dongguan, Guangdong

Applicant before: Guangdong OPPO Mobile Communications Co., Ltd.

GR01 Patent grant
GR01 Patent grant