CN106791758B - The judgment method and device of natural light mixing colour temperature in a kind of image - Google Patents

The judgment method and device of natural light mixing colour temperature in a kind of image Download PDF

Info

Publication number
CN106791758B
CN106791758B CN201611117128.1A CN201611117128A CN106791758B CN 106791758 B CN106791758 B CN 106791758B CN 201611117128 A CN201611117128 A CN 201611117128A CN 106791758 B CN106791758 B CN 106791758B
Authority
CN
China
Prior art keywords
color temperature
natural light
mixed color
direction vector
image
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.)
Expired - Fee Related
Application number
CN201611117128.1A
Other languages
Chinese (zh)
Other versions
CN106791758A (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.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology 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 Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN201611117128.1A priority Critical patent/CN106791758B/en
Priority to US16/095,979 priority patent/US10805588B2/en
Priority to EP17788723.9A priority patent/EP3449628B1/en
Priority to PCT/CN2017/081617 priority patent/WO2017186071A1/en
Publication of CN106791758A publication Critical patent/CN106791758A/en
Application granted granted Critical
Publication of CN106791758B publication Critical patent/CN106791758B/en
Priority to US17/067,700 priority patent/US11363244B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N9/00Details of colour television systems
    • H04N9/64Circuits for processing colour signals
    • H04N9/73Colour balance circuits, e.g. white balance circuits or colour temperature control

Landscapes

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

Abstract

本发明公开一种图像中自然光混合色温的判断方法及装置,所述方法包括:将图像划分为多个矩形区域,确定每个矩形区域的一对自然光混合色温评价参数的值;根据所述参数确定每个矩形区域对应的每个第一坐标点;将所述第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量;当第一单位方向向量和预先保存的第二单位方向向量的夹角小于第一设定阈值时,确定待校正的图像存在自然光混合色温。由于在本发明实施例中,第一单位方向向量和第二单位方向向量的夹角反映了图像为自然光混合色温的可能性程度,因此,判断待校正的图像是否存在自然光混合色温更加准确。

The invention discloses a method and device for judging the mixed color temperature of natural light in an image. The method includes: dividing the image into a plurality of rectangular areas, and determining the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area; according to the parameters Determining each first coordinate point corresponding to each rectangular area; dividing the first coordinate point into a first cluster and a second cluster, and determining a first unit direction vector according to the center point of each cluster; when When the included angle between the first unit direction vector and the pre-stored second unit direction vector is smaller than the first set threshold, it is determined that the image to be corrected has a mixed color temperature of natural light. In the embodiment of the present invention, the angle between the first unit direction vector and the second unit direction vector reflects the possibility of the image having a mixed color temperature of natural light, so it is more accurate to judge whether the image to be corrected has a mixed color temperature of natural light.

Description

一种图像中自然光混合色温的判断方法及装置A method and device for judging the mixed color temperature of natural light in an image

技术领域technical field

本发明涉及图像处理技术领域,尤其涉及一种图像中自然光混合色温的判断方法及装置。The present invention relates to the technical field of image processing, in particular to a method and a device for judging the mixed color temperature of natural light in an image.

背景技术Background technique

随着图像处理技术的不断发展,白平衡校正方法也在日益完善,在现有技术中,在对待校正图像进行白平衡校正时,多采用自动白平衡校正方法,图1为现有技术中的自动白平衡校正方法,具体过程包括:With the continuous development of image processing technology, the white balance correction method is also becoming more and more perfect. In the existing technology, when performing white balance correction on the image to be corrected, the automatic white balance correction method is often used. Figure 1 shows the white balance correction method in the prior art Automatic white balance correction method, the specific process includes:

S101:采集待校正图像的参考白点,并确定出基准白点绘制参考白区。S101: Collect a reference white point of the image to be corrected, and determine the reference white point to draw a reference white area.

S102:计算待校正图像当前落入参考白区的参考白点数量,若所述参考白点数量小于或等于第一预设阈值,进行S105,否则,进行S103。S102: Calculate the number of reference white points that currently fall into the reference white area of the image to be corrected. If the number of reference white points is less than or equal to a first preset threshold, go to S105; otherwise, go to S103.

S103:判断待校正图像是否存在自然光混合色温,若是进行S105,否则,进行S104。S103: Determine whether the image to be corrected has a mixed color temperature of natural light, if so, go to S105, otherwise, go to S104.

S104:根据落入参考白区的白点数量计算白平衡增益,并使用所述白平衡增益对所述待校正图像进行补色校正。S104: Calculate a white balance gain according to the number of white points falling into the reference white area, and use the white balance gain to perform color correction on the image to be corrected.

S105:使用预设算法策略计算出白平衡增益,并使用所述白平衡增益对所述待校正图像进行补色校正。S105: Calculate a white balance gain using a preset algorithm strategy, and use the white balance gain to perform color correction on the image to be corrected.

该方法将待校正的图像落入参考白区的白点进行动态类聚,将白点划分到两个簇类中,当两个簇类中的白点个数满足预设条件时,则判断待校正图像存在自然光混合色温,但在进行判断时并未考虑自然光混合色温的规律。例如,当图像中有白色马路和绿色植物时,经过动态类聚将白色和绿色划分到两个簇类,经判断,白色和绿色簇类中的白点个数满足预设条件,则该方法认为图像存在自然光混合色温,并对白色和绿色分别计算白平衡增益,而实际情况该图像并非存在自然光混合色温。这样就使得对图像是否存在自然光混合色温判断失误,进而降低了白平衡校正的准确性。This method dynamically clusters the white points of the image to be corrected that fall into the reference white area, and divides the white points into two clusters. When the number of white points in the two clusters satisfies the preset condition, then judge The image to be corrected has a mixed color temperature of natural light, but the law of mixed color temperature of natural light is not considered when making judgments. For example, when there are white roads and green plants in the image, the white and green are divided into two clusters through dynamic clustering. After judging that the number of white points in the white and green clusters meets the preset conditions, the method It is considered that the image has a mixed color temperature of natural light, and the white balance gain is calculated separately for white and green, but in reality, the image does not have a mixed color temperature of natural light. This makes it wrong to judge whether there is natural light mixed color temperature in the image, thereby reducing the accuracy of white balance correction.

发明内容Contents of the invention

本发明实施例提供一种图像中自然光混合色温的判断方法及装置,用以解决现有技术图像中自然光混合色温的判断不准确的问题。Embodiments of the present invention provide a method and device for judging the mixed color temperature of natural light in an image to solve the problem of inaccurate judgment of the mixed color temperature of natural light in an image in the prior art.

本发明方法包括一种图像中自然光混合色温的判断方法,该方法包括:The method of the present invention includes a method for judging the mixed color temperature of natural light in an image, the method comprising:

针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;For the image to be corrected, divide the image into multiple rectangular areas according to the set rules, and determine a pair of natural light mixed color temperature evaluations for each rectangular area according to the mean values of red R, green G, and blue B in each rectangular area the value of the parameter;

根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴;Each first coordinate point corresponding to each rectangular area is determined in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system uses the pair of natural light mixed color temperature evaluation parameters as the abscissa axis and vertical axis;

将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向;Divide the first coordinate point in the coordinate system into a first cluster and a second cluster, and determine a first unit direction vector according to the center point of each cluster, wherein the direction of the first unit direction vector is From low color temperature to high color temperature;

判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的;judging whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, wherein the second unit direction vector is predetermined and saved according to the target image with mixed color temperature of natural light ;

如果是,确定待校正的图像存在自然光混合色温,否则,确定待校正的图像不存在自然光混合色温。If yes, it is determined that the image to be corrected has a mixed color temperature of natural light; otherwise, it is determined that the image to be corrected does not have a mixed color temperature of natural light.

进一步地,确定所述第二单位方向向量的过程包括:Further, the process of determining the second unit direction vector includes:

针对预先采集的自然光混合色温的目标图像,按照设定的规则将所述目标图像划分为多个矩形区域,根据每个矩形区域的R、G、B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;For the pre-collected target image of mixed color temperature of natural light, the target image is divided into multiple rectangular areas according to the set rules, and a pair of natural light in each rectangular area is determined according to the R, G, and B mean values of each rectangular area. The value of the mixed color temperature evaluation parameter;

根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第二坐标点,其中坐标系的以所述一对自然光混合色温评价参数作为横轴和纵轴;According to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, each second coordinate point corresponding to each rectangular area is determined in the constructed coordinate system, wherein the coordinate system uses the pair of natural light mixed color temperature evaluation parameters as horizontal and vertical axes;

根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。According to the coordinates of each second coordinate point in the coordinate system, a second unit direction vector is determined, wherein the direction of the second unit direction vector is a direction from low color temperature to high color temperature.

进一步地,所述根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量包括:Further, the determining the second unit direction vector according to the coordinates of each second coordinate point in the coordinate system includes:

获取用户输入的两个坐标点的坐标信息,确定所述两个坐标点的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量;或Acquire coordinate information of two coordinate points input by the user, determine direction vectors of the two coordinate points, and use the unit vector corresponding to the direction vector as the second unit direction vector; or

根据最小二乘法,确定所述坐标系中第二坐标点对应的直线方程,根据所述直线方程,确定所述直线方程对应的第二单位方向向量;或According to the method of least squares, determine the equation of a line corresponding to the second coordinate point in the coordinate system, and determine the second unit direction vector corresponding to the equation of the line according to the equation of the line; or

根据主成分分析的方法,确定所述第二坐标点组成的点集的协方差矩阵,根据所述协方差矩阵的特征向量确定第二单位方向向量。According to the principal component analysis method, the covariance matrix of the point set composed of the second coordinate points is determined, and the second unit direction vector is determined according to the eigenvectors of the covariance matrix.

进一步地,所述确定待校正的图像存在自然光混合色温之后,所述方法还包括:Further, after it is determined that the image to be corrected has a mixed color temperature of natural light, the method further includes:

根据自然光混合色温白平衡算法确定白平衡增益并对所述图像进行校正。The white balance gain is determined according to the natural light mixed color temperature white balance algorithm and the image is corrected.

进一步地,所述根据自然光混合色温白平衡算法确定白平衡增益包括:Further, the determining the white balance gain according to the natural light mixed color temperature white balance algorithm includes:

根据所述第一单位方向向量和第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值;According to the angle between the first unit direction vector and the second unit direction vector and the setting parameters, using a preset algorithm to determine the natural light mixing color temperature parameter value corresponding to the angle and the setting parameters;

根据所述自然光混合色温参数值确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重,根据所述单色温白平衡算法和自然光混合色温白平衡算法及对应的第一权重和第二权重,确定白平衡增益。Determine the first weight and the second weight corresponding to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm according to the natural light mixed color temperature parameter value, according to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm and the corresponding The first weight and the second weight determine the white balance gain.

进一步地,所述根据所述自然光混合色温参数值,确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重包括:Further, according to the natural light mixed color temperature parameter value, determining the first weight and the second weight corresponding to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm includes:

将所述自然光混合色温参数值作为第二权重,将1与所述第二权重的差作为第一权重。The value of the natural light mixed color temperature parameter is used as a second weight, and the difference between 1 and the second weight is used as a first weight.

进一步地,所述根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值包括:Further, according to the angle between the first unit direction vector and the pre-saved second unit direction vector and the setting parameters, a preset algorithm is used to determine the natural light corresponding to the angle and the setting parameters. Mixed color temperature parameter values include:

根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角,计算所述夹角与预设参数的乘积;将所述乘积的余弦值确定为所述自然光混合色温参数值。According to the included angle between the first unit direction vector and the pre-stored second unit direction vector, calculate the product of the included angle and a preset parameter; determine the cosine value of the product as the natural light mixing color temperature parameter value.

进一步地,所述确定待校正的图像不存在自然光混合色温之后,所述方法还包括:Further, after it is determined that the image to be corrected does not have a mixed color temperature of natural light, the method further includes:

根据单色温白平衡算法确定白平衡增益并对所述图像进行校正。The white balance gain is determined according to the monochromatic temperature white balance algorithm and the image is corrected.

进一步地,所述判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值之前,所述方法还包括:Further, before the judging whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, the method further includes:

根据保存的相机拍摄快门时间、增益参数、光圈确定图像的环境照度,当所述环境照度大于第二设定阈值时,继续后续步骤;或Determine the ambient illuminance of the image according to the stored camera shutter time, gain parameters, and aperture, and when the ambient illuminance is greater than the second set threshold, continue to the subsequent steps; or

判断第一聚类和第二聚类的中心点之间的距离大于第三设定阈值时,继续后续步骤;或When it is judged that the distance between the center points of the first cluster and the second cluster is greater than the third set threshold, continue to the subsequent steps; or

判断第一聚类和第二聚类的中心点的横坐标均位于自然光的色温对应的横坐标范围内,且第一聚类和第二聚类的中心点的纵坐标均位于自然光的色温对应的纵坐标范围内时,继续后续步骤。Judging that the abscissas of the center points of the first cluster and the second cluster are both within the range of abscissas corresponding to the color temperature of natural light, and the ordinates of the center points of the first cluster and the second cluster are both within the range corresponding to the color temperature of natural light If it is within the range of the ordinate, continue to the next step.

进一步地,所述每个矩形区域的一对自然光混合色温评价参数的值包括:Further, the values of a pair of natural light mixed color temperature evaluation parameters for each rectangular area include:

每个矩形区域的G/R值和G/B值;或G/R value and G/B value for each rectangular area; or

每个矩形区域的G/R的对数值和G/B的对数值;或the logarithmic values of G/R and the logarithmic values of G/B for each rectangular area; or

每个矩形区域的R/G的对数值和B/G的对数值。The logarithmic value of R/G and the logarithmic value of B/G of each rectangular area.

另一方面,本发明实施例提供了一种图像中自然光混合色温的判断装置,所述装置包括:On the other hand, an embodiment of the present invention provides a device for judging the mixed color temperature of natural light in an image, the device comprising:

第一确定模块,用于针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;The first determination module is used to divide the image to be corrected into a plurality of rectangular areas according to the set rules, and determine each rectangular area according to the mean value of red R, green G, and blue B of each rectangular area. The value of a pair of natural light mixed color temperature evaluation parameters;

第二确定模块,用于根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴;The second determination module is used to determine each first coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system is based on the pair The natural light mixed color temperature evaluation parameters are used as the horizontal axis and the vertical axis;

第三确定模块,用于将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向;The third determination module is used to divide the first coordinate points in the coordinate system into the first cluster and the second cluster, and determine the first unit direction vector according to the center point of each cluster, wherein the first unit direction vector The direction of a unit direction vector is the direction from low color temperature to high color temperature;

第一判断模块,用于判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的;The first judging module is used to judge whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, wherein the second unit direction vector is based on the mixed color temperature of natural light The target image is predetermined and saved;

第四确定模块,用于如果第一判断模块的判断结果为是,确定待校正的图像存在自然光混合色温,如果第一判断模块的判断结果为否,确定待校正的图像不存在自然光混合色温。The fourth determination module is configured to determine that the image to be corrected has a natural light mixed color temperature if the judgment result of the first judgment module is Yes, and determine that the image to be corrected does not have a natural light mixed color temperature if the judgment result of the first judgment module is No.

进一步地,所述第一确定模块,还用于针对预先采集的自然光混合色温的目标图像,按照设定的规则将所述目标图像划分为多个矩形区域,根据每个矩形区域的R、G、B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;Further, the first determination module is also used for dividing the target image into a plurality of rectangular areas according to the set rules for the pre-collected target image of mixed color temperature of natural light, and according to the R, G , B mean value, determine the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area;

所述第二确定模块,还用于根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第二坐标点,其中坐标系的以所述一对自然光混合色温评价参数作为横轴和纵轴;The second determination module is further configured to determine each second coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system is represented by The pair of natural light mixed color temperature evaluation parameters are used as the horizontal axis and the vertical axis;

所述第三确定模块,还用于根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。The third determining module is further configured to determine a second unit direction vector according to the coordinates of each second coordinate point in the coordinate system, wherein the direction of the second unit direction vector is the direction from low color temperature to high color temperature .

进一步地,所述第三确定模块,具体用于获取用户输入的两个坐标点的坐标信息,确定所述两个坐标点的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量;或,根据最小二乘法,确定所述坐标系中第二坐标点对应的直线方程,根据所述直线方程,确定所述直线方程对应的第二单位方向向量;或,根据主成分分析的方法,确定所述第二坐标点组成的点集的协方差矩阵,根据所述协方差矩阵的特征向量确定第二单位方向向量。Further, the third determining module is specifically configured to obtain coordinate information of two coordinate points input by the user, determine direction vectors of the two coordinate points, and use the unit vector corresponding to the direction vector as the first Two unit direction vectors; or, according to the least square method, determine the straight line equation corresponding to the second coordinate point in the coordinate system, and determine the second unit direction vector corresponding to the straight line equation according to the straight line equation; or, according to the main The component analysis method is to determine the covariance matrix of the point set composed of the second coordinate points, and determine the second unit direction vector according to the eigenvectors of the covariance matrix.

进一步地,所述装置还包括:Further, the device also includes:

第五确定模块,用于确定待校正的图像存在自然光混合色温之后,根据自然光混合色温白平衡算法确定白平衡增益并对所述图像进行校正。The fifth determination module is configured to determine the white balance gain according to the natural light mixed color temperature white balance algorithm and correct the image after it is determined that the image to be corrected has the mixed color temperature of natural light.

进一步地,所述第五确定模块,具体用于根据所述第一单位方向向量和第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值;根据所述自然光混合色温参数值确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重,根据所述单色温白平衡算法和自然光混合色温白平衡算法及对应的第一权重和第二权重,确定白平衡增益。Further, the fifth determining module is specifically configured to determine the included angle and the set parameter by using a preset algorithm according to the included angle between the first unit direction vector and the second unit direction vector and setting parameters. The natural light mixed color temperature parameter value corresponding to the given parameter; the first weight and the second weight corresponding to the monochromatic temperature white balance algorithm and the natural light mixed color temperature white balance algorithm are determined according to the natural light mixed color temperature parameter value, according to the monochromatic temperature white balance Algorithm and natural light mixed color temperature white balance algorithm and corresponding first weight and second weight to determine white balance gain.

进一步地,所述第五确定模块,具体用于将所述自然光混合色温参数值作为第二权重,将1与所述第二权重的差作为第一权重。Further, the fifth determining module is specifically configured to use the natural light mixing color temperature parameter value as the second weight, and use the difference between 1 and the second weight as the first weight.

进一步地,所述第五确定模块,具体用于根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角,计算所述夹角与预设参数的乘积;将所述乘积的余弦值确定为所述自然光混合色温参数值。Further, the fifth determination module is specifically configured to calculate the product of the included angle and a preset parameter according to the included angle between the first unit direction vector and the pre-saved second unit direction vector; The cosine value of is determined as the natural light mixing color temperature parameter value.

进一步地,所述装置还包括:Further, the device also includes:

第五确定模块,用于确定待校正的图像不存在自然光混合色温之后,根据单色温白平衡算法确定白平衡增益并对所述图像进行校正。The fifth determination module is configured to determine the white balance gain according to the single color temperature white balance algorithm and correct the image after determining that there is no natural light mixed color temperature in the image to be corrected.

进一步地,所述装置还包括:Further, the device also includes:

第二判断模块,用于根据保存的相机拍摄快门时间、增益参数、光圈确定图像的环境照度,当所述环境照度大于第二设定阈值时,继续后续步骤;或判断第一聚类和第二聚类的中心点之间的距离大于第三设定阈值时,继续后续步骤;或判断第一聚类和第二聚类的中心点的横坐标均位于自然光的色温对应的横坐标范围内,且第一聚类和第二聚类的中心点的纵坐标均位于自然光的色温对应的纵坐标范围内时,触发第一判断模块。The second judging module is used to determine the ambient illuminance of the image according to the saved camera shutter time, gain parameters, and aperture, and when the ambient illuminance is greater than the second set threshold, continue to the subsequent steps; or judge the first cluster and the second When the distance between the center points of the two clusters is greater than the third set threshold, continue to the subsequent steps; or judge that the abscissas of the center points of the first cluster and the second cluster are both within the range of abscissas corresponding to the color temperature of natural light , and when the ordinates of the center points of the first cluster and the second cluster are both within the range of ordinates corresponding to the color temperature of natural light, the first judging module is triggered.

进一步地,所述第一确定模块,具体用于确定每个矩形区域的每个矩形区域的G/R值和G/B值;或,确定每个矩形区域的G/R的对数值和G/B的对数值;或,确定每个矩形区域的每个矩形区域的R/G的对数值和B/G的对数值。Further, the first determination module is specifically used to determine the G/R value and G/B value of each rectangular area in each rectangular area; or, determine the logarithmic value of G/R and the G/B value of each rectangular area / logarithmic value of B; or, determine the logarithmic value of R/G and the logarithmic value of B/G of each rectangular area of each rectangular area.

本发明实施例提供一种图像中自然光混合色温的判断方法及装置,所述方法包括:针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴;将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向;判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的;如果是,确定待校正的图像存在自然光混合色温,否则,确定待校正的图像不存在自然光混合色温。由于第二单位方向向量是针对于存在自然光混合色温的目标图像确定的,因此,当第一单位方向向量与第二单位方向向量的夹角小于设定的第一阈值,说明该待校正的图像与该存在自然光混合色温的目标图像类似,也存在自然光混合色温,从而可以保证图像自然光混合色温判断的准确性,并且进一步保证了后续白平衡校正的准确性。Embodiments of the present invention provide a method and device for judging the mixed color temperature of natural light in an image. The method includes: for the image to be corrected, divide the image into a plurality of rectangular areas according to set rules, and divide the image into a plurality of rectangular areas according to each rectangular area. Determine the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area; according to the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area, determine each in the constructed coordinate system. Each first coordinate point corresponding to a rectangular area, wherein the coordinate system uses the pair of natural light mixed color temperature evaluation parameters as the horizontal axis and the vertical axis; the first coordinate point in the coordinate system is divided into the first cluster and For the second clustering, determine the first unit direction vector according to the center point of each cluster, wherein the direction of the first unit direction vector is the direction from low color temperature to high color temperature; judge the first unit direction vector and the pre-saved first unit direction vector Whether the included angle between the two unit direction vectors is smaller than the set first threshold, wherein the second unit direction vector is predetermined and saved according to the target image with mixed color temperature of natural light; if yes, it is determined that the image to be corrected has natural light Mixed color temperature, otherwise, make sure there is no natural light mixed color temperature in the image to be corrected. Since the second unit direction vector is determined for the target image with mixed color temperature of natural light, when the angle between the first unit direction vector and the second unit direction vector is smaller than the set first threshold, it indicates that the image to be corrected Similar to the target image with the mixed color temperature of natural light, the mixed color temperature of natural light also exists, so that the accuracy of judging the color temperature of the mixed natural light of the image can be ensured, and the accuracy of subsequent white balance correction can be further ensured.

附图说明Description of drawings

为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For Those of ordinary skill in the art can also obtain other drawings based on these drawings without making creative efforts.

图1为现有技术提供的一种自动白平衡校正过程示意图;FIG. 1 is a schematic diagram of an automatic white balance correction process provided by the prior art;

图2为本发明实施例1提供的一种图像中自然光混合色温的判断过程示意图;FIG. 2 is a schematic diagram of a judging process of the mixed color temperature of natural light in an image provided by Embodiment 1 of the present invention;

图3为本发明实施例1提供的图像划分矩形区域示意图;FIG. 3 is a schematic diagram of an image divided into rectangular regions provided by Embodiment 1 of the present invention;

图4为本发明实施例2提供的目标图像对应的坐标系示意图;FIG. 4 is a schematic diagram of a coordinate system corresponding to a target image provided in Embodiment 2 of the present invention;

图5为本发明实施例4提供的一种图像中自然光混合色温的判断过程示意图;Fig. 5 is a schematic diagram of a judging process of the mixed color temperature of natural light in an image provided by Embodiment 4 of the present invention;

图6为本发明实施例提供的一种图像中自然光混合色温的判断装置结构示意图。FIG. 6 is a schematic structural diagram of an apparatus for judging the mixed color temperature of natural light in an image provided by an embodiment of the present invention.

具体实施方式Detailed ways

为了使图像自然光混合色温判断更加准确,并且进一步使后续白平衡校正的准确性提高,本发明实施例提供了一种图像中自然光混合色温的判断方法及装置。In order to make the judgment of the mixed color temperature of natural light in an image more accurate, and further improve the accuracy of subsequent white balance corrections, embodiments of the present invention provide a method and device for judging the mixed color temperature of natural light in an image.

下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。The present invention will be further described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.

实施例1:Example 1:

图2为本发明实施例提供的一种图像中自然光混合色温的判断过程示意图,该过程包括以下步骤:Fig. 2 is a schematic diagram of a process of judging the mixed color temperature of natural light in an image provided by an embodiment of the present invention, and the process includes the following steps:

S201:针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值。S201: For the image to be corrected, divide the image into multiple rectangular areas according to the set rules, and determine a pair of natural light mixtures for each rectangular area according to the mean values of red R, green G, and blue B in each rectangular area The value of the color temperature evaluation parameter.

本发明实施例提供的一种图像中自然光混合色温的判断方法应用于电子设备。所述电子设备包括PC、智能电视、相机及手机等。A method for judging the mixed color temperature of natural light in an image provided by an embodiment of the present invention is applied to an electronic device. The electronic devices include PCs, smart TVs, cameras, and mobile phones.

所述电子设备按照设定的规则将待校正的图像划分为多个矩形区域,在对待校正的图像进行划分时,可以将图像的长进行n等分,对图像的宽进行m等分,其中所述m和n相同或不同,划分后得到多个矩形区域。如图3所示,对图像的长宽分别进行6等分,即将图像划分为36个矩形区域。根据每个矩形区域内的每个像素点的红R、绿G、蓝B值,确定每个矩形区域的R、G、B均值,进而确定每个矩形区域的一对自然光混合色温评价参数的值,所述一对自然光混合色温评价参数的值可以为每个矩形区域的G/R、G/B值,也可以是每个矩形区域的G/R的对数值、G/B的对数值,还可以是每个矩形区域的R/G的对数值、B/G的对数值。The electronic device divides the image to be corrected into multiple rectangular areas according to the set rules, and when dividing the image to be corrected, the length of the image can be divided into n equal parts, and the width of the image can be divided into m equal parts, wherein The m and n are the same or different, and multiple rectangular areas are obtained after division. As shown in Figure 3, the length and width of the image are divided into 6 equal parts, that is, the image is divided into 36 rectangular areas. According to the red R, green G, and blue B values of each pixel in each rectangular area, determine the R, G, and B mean values of each rectangular area, and then determine the pair of natural light mixed color temperature evaluation parameters for each rectangular area value, the value of the pair of natural light mixed color temperature evaluation parameters can be the G/R and G/B values of each rectangular area, or the logarithmic value of G/R and the logarithmic value of G/B of each rectangular area , can also be the logarithmic value of R/G and the logarithmic value of B/G of each rectangular area.

S202:根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴。S202: Determine each first coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system is based on the pair of natural light mixed color temperature evaluation parameters as horizontal and vertical axes.

所述一对自然光混合色温评价参数的值可以为每个矩形区域的G/R、G/B值,也可以是每个矩形区域的G/R的对数值、G/B的对数值,还可以是每个矩形区域的R/G的对数值、B/G的对数值,将该一对自然光混合色温评价参数作为横轴和纵轴,构建坐标系,确定每个矩形区域对应的每个第一坐标点。The value of the pair of natural light mixed color temperature evaluation parameters can be the G/R and G/B values of each rectangular area, or the logarithmic value of G/R and the logarithmic value of G/B of each rectangular area, or It can be the logarithmic value of R/G and the logarithmic value of B/G of each rectangular area, and use the pair of natural light mixed color temperature evaluation parameters as the horizontal axis and the vertical axis to construct a coordinate system and determine each rectangular area corresponding to each first coordinate point.

例如该一对自然光混合色温评价参数的值为每个矩形区域的G/R、G/B值,构建的坐标系以G/R作为坐标系的横轴,以G/B作为坐标系的纵轴。因此对于每个矩形区域,该矩形区域的G/R、G/B值,可以认为是该矩形区域的横坐标和纵坐标,因此该矩形区域标识到该坐标系中,可以认为是横坐标是其G/R值,纵坐标是其G/B值的坐标点。For example, the pair of natural light mixed color temperature evaluation parameters are the G/R and G/B values of each rectangular area, and the coordinate system is constructed with G/R as the horizontal axis of the coordinate system and G/B as the vertical axis of the coordinate system axis. Therefore, for each rectangular area, the G/R and G/B values of the rectangular area can be considered as the abscissa and ordinate of the rectangular area, so the rectangular area is marked in the coordinate system, which can be considered as the abscissa is Its G/R value, the ordinate is the coordinate point of its G/B value.

例如该一对自然光混合色温评价参数的值还可以为每个矩形区域的G/R的对数值、G/B的对数值,构建的坐标系以G/R的对数值作为坐标系的横轴,以G/B的对数值作为坐标系的纵轴。该一对自然光混合色温评价参数的值还可以为每个矩形区域的R/G的对数值、B/G的对数值,构建的坐标系以R/G的对数值作为坐标系的横轴,以B/G的对数值作为坐标系的纵轴。For example, the value of the pair of natural light mixed color temperature evaluation parameters can also be the logarithmic value of G/R and the logarithmic value of G/B in each rectangular area, and the constructed coordinate system takes the logarithmic value of G/R as the horizontal axis of the coordinate system , taking the logarithmic value of G/B as the vertical axis of the coordinate system. The value of the pair of natural light mixed color temperature evaluation parameters can also be the logarithmic value of R/G and the logarithmic value of B/G of each rectangular area, and the constructed coordinate system takes the logarithmic value of R/G as the horizontal axis of the coordinate system, Take the logarithmic value of B/G as the vertical axis of the coordinate system.

S203:将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向。S203: Divide the first coordinate point in the coordinate system into a first cluster and a second cluster, and determine a first unit direction vector according to the center point of each cluster, wherein the first unit direction vector The direction is from low color temperature to high color temperature.

根据每个矩形区域的一对自然光混合色温评价参数的值,确定了坐标系中每个矩形区域对应的第一坐标点后,可以采用聚类算法,将坐标系中的第一坐标点进行聚类,具体在聚类时,将所述坐标系中的第一坐标点划分为第一聚类和第二聚类。其中在对坐标系中的第一坐标点进行聚类时,可以采用通用的聚类方法,例如kmeans算法、K均值算法等。According to the value of a pair of natural light mixed color temperature evaluation parameters in each rectangular area, after determining the first coordinate point corresponding to each rectangular area in the coordinate system, a clustering algorithm can be used to cluster the first coordinate points in the coordinate system Classes, specifically during clustering, the first coordinate point in the coordinate system is divided into a first cluster and a second cluster. Wherein, when clustering the first coordinate points in the coordinate system, general clustering methods, such as kmeans algorithm, K-means algorithm, etc., can be used.

在本发明实施例中可以通过K均值算法,将所述坐标系中的第一坐标点划分为第一聚类和第二聚类。划分为两个聚类后可以采用均值漂移方法分别确定第一聚类和第二聚类的中心点。In the embodiment of the present invention, the first coordinate points in the coordinate system may be divided into a first cluster and a second cluster by using a K-means algorithm. After being divided into two clusters, the center point of the first cluster and the second cluster can be respectively determined by using the mean shift method.

色温越高,越偏蓝色调,B值越大;色温越低,越偏红色调,R值越大。具体的确定低色温到高色温方向的过程属于现有技术,在本发明实施例中对该过程不进行赘述。The higher the color temperature, the bluer the tone, the greater the B value; the lower the color temperature, the redder the tone, the greater the R value. The specific process of determining the direction from low color temperature to high color temperature belongs to the prior art, and will not be described in detail in the embodiment of the present invention.

具体的采用聚类算法,将坐标系中的第一坐标点划分为第一聚类和第二聚类以及采用均值漂移方法确定第一聚类和第二聚类的中心点的过程属于现有技术,在本发明实施例中对该过程不进行赘述。Specifically, the clustering algorithm is used to divide the first coordinate points in the coordinate system into the first cluster and the second cluster, and the process of using the mean shift method to determine the center points of the first cluster and the second cluster belongs to the existing technology, and this process will not be described in detail in this embodiment of the present invention.

S204:判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的,如果是,则进行S205,否则,进行S206。S204: Determine whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, wherein the second unit direction vector is determined in advance according to the target image with mixed color temperature of natural light and saved, if yes, go to S205, otherwise, go to S206.

在本发明实施例中根据存在自然光混合色温的目标图像,生成第二单位方向向量。因为对于存在自然光混合色温的目标图像,当将其按照设定的规则划分为多个矩形区域时,其每个矩形区域的一对自然光混合色温评价参数的值在坐标系中分布近似一条直线,因此根据该特征可以确定这条直线对应的低色温到高色温方向的单位向量,将该单位向量作为第二单位方向向量。In the embodiment of the present invention, the second unit direction vector is generated according to the target image with mixed color temperature of natural light. Because for the target image with natural light mixed color temperature, when it is divided into multiple rectangular areas according to the set rules, the value of a pair of natural light mixed color temperature evaluation parameters in each rectangular area is distributed approximately on a straight line in the coordinate system, Therefore, according to this feature, the unit vector corresponding to the straight line in the direction from low color temperature to high color temperature can be determined, and this unit vector can be used as the second unit direction vector.

S205:确定待校正的图像存在自然光混合色温。S205: Determine that the image to be corrected has a mixed color temperature of natural light.

S206:确定待校正的图像不存在自然光混合色温。S206: Determine that the image to be corrected does not have a mixed color temperature of natural light.

当确定了第一单位方向向量后,根据第一单位方向向量与第二单位方向向量的夹角,即可判断待校正的图像是否存在自然光混合色温,当所述夹角小于第一设定阈值时,说明该图像划分后的矩形区域的一对自然光混合色温评价参数的值也符合自然光混合色温图像的分布特征,因此确定待校正的图像存在自然光混合色温,当所述夹角不小于第一设定阈值时,确定待校正的图像不存在自然光混合色温。其中该第一设定阈值可以是3度、5度等较小的数值。After the first unit direction vector is determined, according to the angle between the first unit direction vector and the second unit direction vector, it can be judged whether the image to be corrected has a mixed color temperature of natural light. When the angle is smaller than the first set threshold , it shows that the value of a pair of natural light mixed color temperature evaluation parameters in the divided rectangular area of the image also conforms to the distribution characteristics of the natural light mixed color temperature image, so it is determined that the image to be corrected has natural light mixed color temperature, when the included angle is not less than the first When setting the threshold, it is determined that there is no natural light mixed color temperature in the image to be corrected. Wherein the first set threshold may be a smaller value such as 3 degrees, 5 degrees, or the like.

由于在本发明实施例中,根据第一单位方向向量与第二单位方向向量的夹角判断待校正的图像是否存在自然光混合色温,第二单位方向向量是针对于存在自然光混合色温的目标图像预先确定并保存的,因此,当第一单位方向向量与第二单位方向向量的夹角小于设定的第一阈值,说明该待校正的图像与该存在自然光混合色温的目标图像类似,也存在自然光混合色温,从而可以保证图像自然光混合色温判断的准确性,并且进一步保证了后续白平衡校正的准确性。Since in the embodiment of the present invention, it is judged whether the image to be corrected has a mixed color temperature of natural light according to the angle between the first unit direction vector and the second unit direction vector, the second unit direction vector is for the target image with a mixed color temperature of natural light. Determined and saved, therefore, when the angle between the first unit direction vector and the second unit direction vector is smaller than the set first threshold, it means that the image to be corrected is similar to the target image with natural light mixed color temperature, and there is also natural light Mixing color temperature, so as to ensure the accuracy of judging the mixed color temperature of natural light in the image, and further ensure the accuracy of subsequent white balance correction.

实施例2:Example 2:

在上述实施例的基础上,为了根据预先采集的自然光混合色温的目标图像,准确的确定第二单位方向向量,提高后续判断的准确性,在本发明实施例中,确定所述第二单位方向向量的过程包括:On the basis of the above-mentioned embodiments, in order to accurately determine the second unit direction vector according to the pre-collected target image of the mixed color temperature of natural light and improve the accuracy of subsequent judgments, in the embodiment of the present invention, the second unit direction is determined The vector process includes:

针对预先采集的自然光混合色温的目标图像,按照设定的规则将所述目标图像划分为多个矩形区域,根据每个矩形区域的R、G、B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;For the pre-collected target image of mixed color temperature of natural light, the target image is divided into multiple rectangular areas according to the set rules, and a pair of natural light in each rectangular area is determined according to the R, G, and B mean values of each rectangular area. The value of the mixed color temperature evaluation parameter;

根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第二坐标点,其中坐标系的以所述一对自然光混合色温评价参数作为横轴和纵轴;According to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, each second coordinate point corresponding to each rectangular area is determined in the constructed coordinate system, wherein the coordinate system uses the pair of natural light mixed color temperature evaluation parameters as horizontal and vertical axes;

根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。According to the coordinates of each second coordinate point in the coordinate system, a second unit direction vector is determined, wherein the direction of the second unit direction vector is a direction from low color temperature to high color temperature.

电子设备预先采集一幅自然光混合色温的目标图像,所述目标图像中有蓝天、阳光、阴影等信息,按照设定的规则将目标图像划分为多个矩形区域。在将目标图像划分为多个矩形区域时,可以采用多种方式,只要和上述实施例中该图像的矩形区域的划分方式相同即可。例如在对目标图像进行划分时,可以将图像的长进行n等分,对图像的宽进行m等分,其中所述m和n相同或不同,划分后得到多个矩形区域,具体的划分方式参照图3。根据每个矩形区域内的每个像素点的红R、绿G、蓝B值确定每个矩形区域的R、G、B均值,进而确定每个矩形区域的一对自然光混合色温评价参数的值。The electronic device pre-collects a target image with mixed color temperature of natural light. The target image contains information such as blue sky, sunlight, shadows, etc., and divides the target image into multiple rectangular areas according to the set rules. When dividing the target image into a plurality of rectangular regions, various methods can be adopted, as long as the method of dividing the rectangular region of the image in the above-mentioned embodiment is the same. For example, when dividing the target image, the length of the image can be divided into n equal parts, and the width of the image can be divided into m equal parts, wherein the m and n are the same or different, and multiple rectangular areas can be obtained after division. The specific division method Refer to Figure 3. According to the red R, green G, and blue B values of each pixel in each rectangular area, determine the R, G, and B mean values of each rectangular area, and then determine the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area .

所述一对自然光混合色温评价参数的值可以为每个矩形区域的G/R、G/B值,也可以是每个矩形区域的G/R的对数值、G/B的对数值,还可以是每个矩形区域的R/G的对数值、B/G的对数值。The value of the pair of natural light mixed color temperature evaluation parameters can be the G/R and G/B values of each rectangular area, or the logarithmic value of G/R and the logarithmic value of G/B of each rectangular area, or It can be the logarithmic value of R/G and the logarithmic value of B/G of each rectangular area.

以所述一对自然光混合色温评价参数的值为每个矩形区域的G/R、G/B值为例,确定了每个矩形区域的G/R、G/B值后,在构建坐标系中确定每个矩形区域的G/R、G/B值对应的每个第二坐标点,具体的在坐标系中针对存在自然光混合色温的目标图像确定的每个第二坐标点参见图4。Taking the pair of natural light mixed color temperature evaluation parameters as the G/R and G/B values of each rectangular area as an example, after determining the G/R and G/B values of each rectangular area, construct the coordinate system Each second coordinate point corresponding to the G/R and G/B values of each rectangular area is determined in , for each second coordinate point determined in the coordinate system for a target image with mixed color temperature of natural light, refer to FIG. 4 .

根据图4可知,存在自然光混合色温的目标图像,将其划分为多个矩形区域后,根据每个矩形区域的G/R、G/B值,在构建的坐标系中确定了每个矩形区域对应的第二坐标点后,该坐标系中第二坐标点的分布是近似一条直线的,因此可以根据该直线确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。According to Figure 4, there is a target image with mixed color temperature of natural light. After dividing it into multiple rectangular areas, each rectangular area is determined in the constructed coordinate system according to the G/R and G/B values of each rectangular area. After the corresponding second coordinate point, the distribution of the second coordinate point in the coordinate system is approximately a straight line, so the second unit direction vector can be determined according to the straight line, wherein the direction of the second unit direction vector is from low color temperature to High color temperature direction.

具体的确定每个矩形区域的一对混合色温评价参数的值及构建坐标系的方法与本发明实施例1中的方法相同,在本发明实施例中不再进行赘述。The specific method of determining a pair of mixed color temperature evaluation parameters for each rectangular area and constructing a coordinate system is the same as the method in Embodiment 1 of the present invention, and will not be repeated in this embodiment of the present invention.

在本发明实施例中,可以通过不同的方法确定第二单位方向向量,根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量包括:In the embodiment of the present invention, the second unit direction vector can be determined by different methods, and according to the coordinates of each second coordinate point in the coordinate system, determining the second unit direction vector includes:

获取用户输入的两个坐标点的坐标信息,确定所述两个坐标点的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量;或Acquire coordinate information of two coordinate points input by the user, determine direction vectors of the two coordinate points, and use the unit vector corresponding to the direction vector as the second unit direction vector; or

根据最小二乘法,确定所述坐标系中第二坐标点对应的直线方程,根据所述直线方程,确定所述直线方程对应的第二单位方向向量;或According to the method of least squares, determine the equation of a line corresponding to the second coordinate point in the coordinate system, and determine the second unit direction vector corresponding to the equation of the line according to the equation of the line; or

根据主成分分析的方法,确定所述第二坐标点组成的点集的协方差矩阵,根据所述协方差矩阵的特征向量确定第二单位方向向量。According to the principal component analysis method, the covariance matrix of the point set composed of the second coordinate points is determined, and the second unit direction vector is determined according to the eigenvectors of the covariance matrix.

在坐标系中的第二坐标点近似于一条直线,用户可以选取所述直线上的两个坐标点,或者用户输入两个坐标点的坐标,当电子设备确定两个坐标点的坐标后,进而可以确定所述两个坐标点的低色温到高色温方向的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量。The second coordinate point in the coordinate system is similar to a straight line, the user can select two coordinate points on the straight line, or the user inputs the coordinates of the two coordinate points, after the electronic device determines the coordinates of the two coordinate points, and then A direction vector from a low color temperature to a high color temperature direction of the two coordinate points may be determined, and a unit vector corresponding to the direction vector is used as the second unit direction vector.

例如电子设备确定的该两个坐标点为A(gr1,gb1)和B(gr2,gb2),则可以确定A、B两个坐标点对应的方向向量为C=B-A,其中方向为低色温到高色温方向,接着求出第二单位方向向量e=C/|C|For example, if the two coordinate points determined by the electronic device are A(gr1, gb1) and B(gr2, gb2), then it can be determined that the direction vectors corresponding to the two coordinate points A and B are C=B-A, where the direction is from low color temperature to High color temperature direction, then find the second unit direction vector e=C/|C|

也可以是电子设备根据每个第二坐标点在所述坐标系中的坐标,通过最小二乘法,确定所述坐标系中第二坐标点对应的直线方程gb=k*gr+b,其中,通过最小二乘法拟合直线方程的过程属于现有技术,在本发明实施例中对该实现过程不进行赘述。当确定了直线方程后,确定满足该直线方程的任意两个坐标点,进而可以确定所述两个坐标点的低色温到高色温方向的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量。It may also be that the electronic device determines the linear equation gb=k*gr+b corresponding to the second coordinate point in the coordinate system through the least square method according to the coordinates of each second coordinate point in the coordinate system, wherein, The process of fitting the linear equation by the least square method belongs to the prior art, and the implementation process will not be described in detail in the embodiment of the present invention. After the straight line equation is determined, determine any two coordinate points that satisfy the straight line equation, and then determine the direction vector from the low color temperature to the high color temperature direction of the two coordinate points, and use the unit vector corresponding to the direction vector as the second unit direction vector.

还可以根据该坐标系中的每个第二坐标点,通过主成分分析的方法,确定所述第二坐标点组成的点集的协方差矩阵,并求取所述协方差矩阵的特征向量,根据所述特征向量,进而确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。其中通过主成分分析的方法确定协方差矩阵的过程属于现有技术,在本发明实施例中对该过程不进行赘述。It is also possible to determine the covariance matrix of the point set composed of the second coordinate points according to each second coordinate point in the coordinate system through the method of principal component analysis, and obtain the eigenvector of the covariance matrix, According to the feature vector, a second unit direction vector is further determined, wherein the direction of the second unit direction vector is from a low color temperature to a high color temperature. The process of determining the covariance matrix through the method of principal component analysis belongs to the prior art, and this process will not be described in detail in the embodiment of the present invention.

实施例3:Example 3:

为了实现的对图像的白平衡校正,在上述各实施例的基础上,在本发明实施例中,确定待校正的图像存在自然光混合色温之后,所述方法还包括:In order to realize the white balance correction of the image, on the basis of the above-mentioned embodiments, in the embodiment of the present invention, after determining that the image to be corrected has a mixed color temperature of natural light, the method further includes:

根据自然光混合色温白平衡算法确定白平衡增益并对所述图像进行校正。The white balance gain is determined according to the natural light mixed color temperature white balance algorithm and the image is corrected.

所述自然光混合色温白平衡算法可以为灰度世界算法,具体的,采用灰度世界算法,确定白平衡增益的过程属于现有技术,根据白平衡增益对图像进行校正的过程也是现有技术,在本发明实施例中对该过程不进行赘述。The natural light mixed color temperature white balance algorithm may be a grayscale world algorithm. Specifically, the process of determining the white balance gain by using the grayscale world algorithm belongs to the prior art, and the process of correcting the image according to the white balance gain is also the prior art. This process is not described in detail in this embodiment of the present invention.

为了使白平衡校正更加准确,在本发明实施例中所述根据自然光混合色温白平衡算法确定白平衡增益包括:In order to make the white balance correction more accurate, the determination of the white balance gain according to the natural light mixed color temperature white balance algorithm in the embodiment of the present invention includes:

根据所述第一单位方向向量和第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值;According to the angle between the first unit direction vector and the second unit direction vector and the setting parameters, using a preset algorithm to determine the natural light mixing color temperature parameter value corresponding to the angle and the setting parameters;

根据所述自然光混合色温参数值确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重,根据所述单色温白平衡算法和自然光混合色温白平衡算法及对应的第一权重和第二权重,确定白平衡增益。Determine the first weight and the second weight corresponding to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm according to the natural light mixed color temperature parameter value, according to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm and the corresponding The first weight and the second weight determine the white balance gain.

所述第一单位方向向量和第二单位方向向量的方向都是由低色温到高色温方向,根据第一单位方向向量和第二单位方向向量的夹角以及电子设备设定的参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值。其中,预设的算法可以为根据所述第一单位方向向量和第二单位方向向量的夹角,计算所述夹角与预设参数的乘积;将所述乘积的余弦值确定为所述自然光混合色温参数值。The directions of the first unit direction vector and the second unit direction vector are from low color temperature to high color temperature. According to the angle between the first unit direction vector and the second unit direction vector and the parameters set by the electronic device, the preset The established algorithm determines the included angle and the natural light mixed color temperature parameter value corresponding to the set parameter. Wherein, the preset algorithm can be to calculate the product of the angle and the preset parameter according to the angle between the first unit direction vector and the second unit direction vector; determine the cosine value of the product as the natural light Mixed color temperature parameter value.

具体的,第一单位方向向量和第二单位方向向量的夹角为α,设定参数为k,根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角α,及预设参数k的乘积;将所述乘积的余弦值确定为所述自然光混合色温参数值,即所述自然光混合色温参数值为cos(kα)。Specifically, the angle between the first unit direction vector and the second unit direction vector is α, and the parameter is set as k. According to the angle α between the first unit direction vector and the pre-saved second unit direction vector, and the preset Assume the product of the parameter k; determine the cosine value of the product as the natural light mixed color temperature parameter value, that is, the natural light mixed color temperature parameter value is cos(kα).

在本实施例中,单色温白平衡算法可以为动态阈值算法,自然光混合色温白平衡算法可以为灰度世界算法。In this embodiment, the single color temperature white balance algorithm may be a dynamic threshold algorithm, and the natural light mixed color temperature white balance algorithm may be a grayscale world algorithm.

当确定了自然光混合色温参数值后,可以根据该自然光混合色温参数值确定单色温白平衡算法的第一权重,和自然光混合色温白平衡算法的第二权重,将所述自然光混合色温参数值作为第二权重,将1与所述第二权重的差作为第一权重,即动态阈值算法对应的第一权重为1-cos(kα),灰度世界算法对应的第二权重为cos(kα)。当然在确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重时,也可以采用其他方法,只要能够保证第二权重与所述第一权重和第二权重的和的比值等于所述自然光混合色温参数值即可。After the natural light mixed color temperature parameter value is determined, the first weight of the single color temperature white balance algorithm and the second weight of the natural light mixed color temperature white balance algorithm can be determined according to the natural light mixed color temperature parameter value, and the natural light mixed color temperature parameter value can be determined. As the second weight, the difference between 1 and the second weight is used as the first weight, that is, the first weight corresponding to the dynamic threshold algorithm is 1-cos(kα), and the second weight corresponding to the grayscale world algorithm is cos(kα ). Of course, when determining the first weight and the second weight corresponding to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm, other methods can also be used, as long as the second weight can be guaranteed to be equal to the first weight and the second weight The ratio of the sum to the sum may be equal to the natural light mixed color temperature parameter value.

当确定了第一权重和第二权重后,通过单色温白平衡算法和自然光混合色温白平衡算法,及其对应的第一权重和第二权重计算出待校正的图像的最终白平衡增益,其算法如下公式所示:After the first weight and the second weight are determined, the final white balance gain of the image to be corrected is calculated through the monochromatic temperature white balance algorithm and the natural light mixed color temperature white balance algorithm, and the corresponding first weight and second weight, Its algorithm is shown in the following formula:

RGain=(1-cos(kα))*RGain1+cos(kα)*RGain2;RGain=(1-cos(kα))*RGain1+cos(kα)*RGain2;

BGain=(1-cos(kα))*BGain1+cos(kα)*BGain2;BGain=(1-cos(kα))*BGain1+cos(kα)*BGain2;

其中,RGain1,BGain1为根据单色温白平衡算法计算出的R,B的白平衡增益,RGain2,BGain2为根据自然光混合色温白平衡算法计算出的R,B的白平衡增益,RGain,BGain为计算出的待校正的图像的最终白平衡增益。Among them, RGain1 and BGain1 are the white balance gains of R and B calculated according to the single color temperature white balance algorithm, RGain2 and BGain2 are the white balance gains of R and B calculated according to the natural light mixed color temperature white balance algorithm, and RGain and BGain are Computed final white balance gain for the image to be corrected.

根据计算出的待校正的图像的最终白平衡增益对图像进行校正,具体的,根据白平衡增益对图像进行校正的过程属于现有技术,在本发明实施例中对该过程不进行赘述。The image is corrected according to the calculated final white balance gain of the image to be corrected. Specifically, the process of correcting the image according to the white balance gain belongs to the prior art, and will not be described in detail in this embodiment of the present invention.

在本发明实施例中,在对待校正的图像进行白平衡校正时,只对图像中的R,B分量进行校正,保持G分量不变,从而可以使得待校正的图像进行白平衡校正后的亮度保持不变。In the embodiment of the present invention, when performing white balance correction on the image to be corrected, only the R and B components in the image are corrected, and the G component is kept unchanged, so that the brightness of the image to be corrected can be adjusted by white balance constant.

由于根据单色温白平衡算法和混合色温白平衡算法及其对应的第一权重和第二权重计算出最终的白平衡增益,使得对存在自然光混合色温的待校正的图像进行白平衡校正时,能够根据待校正的图像的自然光混合色温程度,对该图像进行校正,从而可以保证白平衡校正的准确性。Since the final white balance gain is calculated according to the single color temperature white balance algorithm and the mixed color temperature white balance algorithm and their corresponding first weights and second weights, when performing white balance correction on an image to be corrected with mixed color temperatures of natural light, The image to be corrected can be corrected according to the mixed color temperature degree of natural light of the image to be corrected, so that the accuracy of white balance correction can be ensured.

为了实现的对图像的白平衡校正,在上述各实施例的基础上,在本发明实施例中,确定待校正的图像不存在自然光混合色温之后,所述方法还包括:In order to realize the white balance correction of the image, on the basis of the above-mentioned embodiments, in the embodiment of the present invention, after determining that the image to be corrected does not have a mixed color temperature of natural light, the method further includes:

根据单色温白平衡算法确定白平衡增益并对所述图像进行校正。The white balance gain is determined according to the monochromatic temperature white balance algorithm and the image is corrected.

所述单色温白平衡算法可以为动态阈值算法,具体的,采用动态阈值算法,确定白平衡增益的过程属于现有技术,根据白平衡增益对图像进行校正的过程也是现有技术,在本发明实施例中对该过程不进行赘述。The monochromatic temperature white balance algorithm may be a dynamic threshold algorithm. Specifically, the process of using the dynamic threshold algorithm to determine the white balance gain belongs to the prior art, and the process of correcting the image according to the white balance gain is also the prior art. In this paper This process is not described in detail in the embodiment of the invention.

实施例4:Example 4:

在实施例1的基础上,为了进一步提高判断图像中是否存在自然光混合色温的准确性,判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的之前,所述方法还包括:On the basis of Embodiment 1, in order to further improve the accuracy of judging whether there is natural light mixed color temperature in the image, it is judged whether the angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, Wherein, before the second unit direction vector is pre-determined and saved according to the target image with mixed color temperature of natural light, the method further includes:

根据保存的相机拍摄快门时间、增益参数、光圈判断图像的环境照度,当环境照度大于第二设定阈值时,继续后续步骤;或Judging the ambient illuminance of the image according to the saved camera shooting shutter time, gain parameters, and aperture, when the ambient illuminance is greater than the second set threshold, continue to the subsequent steps; or

判断第一聚类和第二聚类的中心点之间的距离大于第三设定阈值时,继续后续步骤;或When it is judged that the distance between the center points of the first cluster and the second cluster is greater than the third set threshold, continue to the subsequent steps; or

判断第一聚类和第二聚类的中心点的横坐标均位于自然光的色温对应的横坐标范围内,且第一聚类和第二聚类的中心点的纵坐标均位于自然光的色温对应的纵坐标范围内时,继续后续步骤。Judging that the abscissas of the center points of the first cluster and the second cluster are both within the range of abscissas corresponding to the color temperature of natural light, and the ordinates of the center points of the first cluster and the second cluster are both within the range corresponding to the color temperature of natural light If it is within the range of the ordinate, continue to the next step.

在本发明实施例中,由于自然光混合色温场景所在的照度都比较大,电子设备根据保存的相机拍摄快门时间、增益参数、光圈判断图像的环境照度,当环境照度大于第二设定阈值时,则认为待校正的图像存在自然光混合色温的可能性大,此时,继续后续步骤,即判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值。In the embodiment of the present invention, since the illuminance of the natural light mixed color temperature scene is relatively large, the electronic device judges the ambient illuminance of the image according to the saved camera shutter time, gain parameter, and aperture. When the ambient illuminance is greater than the second set threshold, Then it is considered that the image to be corrected is likely to have a mixed color temperature of natural light. At this time, continue to the subsequent step, that is, determine whether the angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold.

由于自然光混合色温场景中,色温差异较大,在将坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,若两个中心点较近,很容易因为其中一个中心点的微小移动,使得第一单位方向向量发生很大的变化,因此也就很可能使得第一单位方向向量和预先保存的第二单位方向向量的夹角α发生较大的变化,稳定性较差。因此,在判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值之前,判断两个聚类的中心点的距离是否大于第三设定阈值,如果大于则判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值。Due to the large difference in color temperature in the natural light mixed color temperature scene, the first coordinate point in the coordinate system is divided into the first cluster and the second cluster. According to the center point of each cluster, if the two center points are close , it is easy to cause a large change in the first unit direction vector due to a small movement of one of the central points, so it is also likely to cause a relatively large change in the angle α between the first unit direction vector and the pre-saved second unit direction vector. Large changes, poor stability. Therefore, before judging whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the first set threshold, it is judged whether the distance between the center points of the two clusters is greater than the third set threshold, if If it is greater than, it is judged whether the included angle between the first unit direction vector and the pre-stored second unit direction vector is smaller than the set first threshold.

为了避免将图像中的某一色彩误认为是一种色温的自然光,电子设备中保存了自然光的色温范围,根据确定矩形区域的一对自然光混合色温评价参数的值及构建坐标系的方法,确定自然光的色温范围对应的横坐标范围,和纵坐标范围,如果判断第一聚类和第二聚类的中心点的横坐标均处于自然光的色温对应的横坐标范围内,第一聚类和第二聚类的中心点的纵坐标均处于自然光的色温对应的纵坐标范围内时,则认为待校正的图像存在自然光混合色温的可能性大,此时,继续后续判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值的步骤。In order to avoid mistaking a certain color in the image as natural light with a color temperature, the color temperature range of natural light is saved in the electronic device, and the color temperature range of natural light mixed with a pair of determined rectangular areas and the method of constructing a coordinate system are determined. The abscissa range corresponding to the color temperature range of natural light, and the ordinate range, if it is judged that the abscissa of the center points of the first cluster and the second cluster are both within the abscissa range corresponding to the color temperature of natural light, the first cluster and the second cluster When the ordinates of the central points of the two clusters are all within the range of ordinates corresponding to the color temperature of natural light, it is considered that the image to be corrected is likely to have a mixed color temperature of natural light. A step of whether the saved included angle of the second unit direction vector is smaller than the set first threshold.

在判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值之前可以采用上述任一方法进行判断,或者还可以采用上述两种或三种的结合来进行判断,采用上述三种方法结合来进行判断的过程如图5所示。Before judging whether the angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, any of the above methods can be used to judge, or a combination of two or three of the above can be used to determine To make a judgment, the process of using the combination of the above three methods to make a judgment is shown in FIG. 5 .

图5为本发明实施例提供的一种图像中自然光混合色温的判断过程示意图,该过程包括以下步骤:Fig. 5 is a schematic diagram of a process of judging the mixed color temperature of natural light in an image provided by an embodiment of the present invention, and the process includes the following steps:

S501:针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值。S501: For the image to be corrected, divide the image into multiple rectangular areas according to the set rules, and determine a pair of natural light mixtures for each rectangular area according to the mean values of red R, green G, and blue B in each rectangular area The value of the color temperature evaluation parameter.

S502:根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴。S502: Determine each first coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system is based on the pair of natural light mixed color temperature evaluation parameters as horizontal and vertical axes.

S503:将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的密度中心,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向。S503: Divide the first coordinate point in the coordinate system into a first cluster and a second cluster, and determine a first unit direction vector according to the density center of each cluster, wherein the first unit direction vector The direction is from low color temperature to high color temperature.

S504:根据保存的相机拍摄快门时间、增益参数、光圈判断图像的环境照度,当环境照度大于第二设定阈值时,进行步骤S505,否则,进行步骤S509。S504: Determine the ambient illuminance of the image according to the saved camera shutter time, gain parameter, and aperture. When the ambient illuminance is greater than the second set threshold, go to step S505; otherwise, go to step S509.

S505:判断第一聚类和第二聚类的中心之间的距离大于第三设定阈值时,进行步骤S506,否则,进行步骤S509。S505: When it is judged that the distance between the center of the first cluster and the center of the second cluster is greater than the third set threshold, go to step S506; otherwise, go to step S509.

S506:判断第一聚类和第二聚类的中心点的横坐标处于自然光的色温对应的横坐标范围内,判断第一聚类和第二聚类的中心点的纵坐标处于自然光的色温对应的纵坐标范围内时,进行步骤S507,否则,,进行步骤S509。S506: Judging that the abscissas of the center points of the first cluster and the second cluster are within the range of abscissas corresponding to the color temperature of natural light, and judging that the ordinates of the center points of the first cluster and the second cluster are corresponding to the color temperature of natural light If it is within the range of the ordinate, go to step S507; otherwise, go to step S509.

S507:判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的,如果是,则进行S508,否则,进行S509。S507: Determine whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, wherein the second unit direction vector is determined in advance according to the target image with mixed color temperature of natural light and saved, if yes, go to S508; otherwise, go to S509.

S508:确定待校正的图像存在自然光混合色温。S508: Determine that the image to be corrected has a mixed color temperature of natural light.

S509:确定待校正的图像不存在自然光混合色温。S509: Determine that the image to be corrected does not have a mixed color temperature of natural light.

图6为本发明实施例提供的一种图像中自然光混合色温的判断装置结构示意图,应用于电子设备,该装置包括:Fig. 6 is a schematic structural diagram of an apparatus for judging the mixed color temperature of natural light in an image provided by an embodiment of the present invention, which is applied to electronic equipment, and the apparatus includes:

第一确定模块61,用于针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;The first determination module 61 is used for dividing the image into a plurality of rectangular areas according to the set rules for the image to be corrected, and determining each rectangular area according to the mean value of red R, green G, and blue B of each rectangular area. The value of a pair of natural light mixed color temperature evaluation parameters in the area;

第二确定模块62,用于根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴;The second determination module 62 is configured to determine each first coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system is based on the one The evaluation parameters of the mixed color temperature of natural light are used as the horizontal axis and the vertical axis;

第三确定模块63,用于将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向;The third determining module 63 is configured to divide the first coordinate points in the coordinate system into first clusters and second clusters, and determine a first unit direction vector according to the center point of each cluster, wherein the The direction of the first unit direction vector is the direction from low color temperature to high color temperature;

第一判断模块64,用于判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的;The first judging module 64 is used to judge whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, wherein the second unit direction vector is based on the mixed color temperature of natural light The target image is pre-determined and saved;

第四确定模块65,用于用于如果第一判断模块的判断结果为是,确定待校正的图像存在自然光混合色温,如果第一判断模块的判断结果为否,确定待校正的图像不存在自然光混合色温。The fourth determination module 65 is used to determine that the image to be corrected has natural light mixed color temperature if the judgment result of the first judgment module is yes, and determine that the image to be corrected does not have natural light if the judgment result of the first judgment module is no Mix color temperature.

所述第一确定模块61,还用于针对预先采集的自然光混合色温的目标图像,按照设定的规则将所述目标图像划分为多个矩形区域,根据每个矩形区域的R、G、B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;The first determination module 61 is also used to divide the target image into a plurality of rectangular areas according to the pre-collected target image of mixed color temperature of natural light according to the set rules, and according to the R, G, B of each rectangular area Mean value, to determine the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area;

所述第二确定模块62,还用于根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第二坐标点,其中坐标系的以所述一对自然光混合色温评价参数作为横轴和纵轴;The second determination module 62 is further configured to determine each second coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system Taking the pair of natural light mixed color temperature evaluation parameters as the horizontal axis and the vertical axis;

所述第三确定模块63,还用于根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。The third determination module 63 is further configured to determine a second unit direction vector according to the coordinates of each second coordinate point in the coordinate system, wherein the direction of the second unit direction vector is from low color temperature to high color temperature direction.

所述第三确定模块63,具体用于获取用户输入的两个坐标点的坐标信息,确定所述两个坐标点的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量;或根据最小二乘法,确定所述坐标系中第二坐标点对应的直线方程,根据所述直线方程,确定所述直线方程对应的第二单位方向向量;或根据主成分分析的方法,确定所述第二坐标点组成的点集的协方差矩阵,根据所述协方差矩阵的特征向量确定第二单位方向向量。The third determining module 63 is specifically configured to obtain coordinate information of two coordinate points input by the user, determine direction vectors of the two coordinate points, and use the unit vector corresponding to the direction vector as the second unit direction vector; or according to the least squares method, determine the line equation corresponding to the second coordinate point in the coordinate system, and determine the second unit direction vector corresponding to the line equation according to the line equation; or according to the method of principal component analysis , determine the covariance matrix of the point set composed of the second coordinate points, and determine the second unit direction vector according to the eigenvectors of the covariance matrix.

所述装置还包括:The device also includes:

第五确定模块66,用于确定待校正的图像存在自然光混合色温之后,根据自然光混合色温白平衡算法确定白平衡增益并对所述图像进行校正。The fifth determination module 66 is configured to determine the white balance gain according to the natural light mixed color temperature white balance algorithm and correct the image after it is determined that the image to be corrected has the mixed color temperature of natural light.

所述第五确定模块66,具体用于根据所述第一单位方向向量和第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值;根据所述自然光混合色温参数值确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重,根据所述单色温白平衡算法和自然光混合色温白平衡算法及对应的第一权重和第二权重,确定白平衡增益。The fifth determining module 66 is specifically used to determine the angle and the setting parameters according to the angle between the first unit direction vector and the second unit direction vector and the setting parameters, using a preset algorithm The corresponding natural light mixed color temperature parameter value; determine the first weight and the second weight corresponding to the monochromatic temperature white balance algorithm and the natural light mixed color temperature white balance algorithm according to the natural light mixed color temperature parameter value, according to the monochromatic temperature white balance algorithm and The natural light mixed color temperature white balance algorithm and the corresponding first weight and second weight determine the white balance gain.

所述第五确定模块66,具体用于将所述自然光混合色温参数值作为第二权重,将1与所述第二权重的差作为第一权重。The fifth determination module 66 is specifically configured to use the natural light mixing color temperature parameter value as the second weight, and use the difference between 1 and the second weight as the first weight.

所述第五确定模块66,具体用于根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角,计算所述夹角与预设参数的乘积;将所述乘积的余弦值确定为所述自然光混合色温参数值。The fifth determining module 66 is specifically configured to calculate the product of the included angle and a preset parameter according to the included angle between the first unit direction vector and the pre-saved second unit direction vector; The value is determined as the natural light mixing color temperature parameter value.

所述装置还包括:The device also includes:

第五确定模块66,用于确定待校正的图像不存在自然光混合色温之后,根据单色温白平衡算法确定白平衡增益并对所述图像进行校正。The fifth determining module 66 is configured to determine a white balance gain according to a single color temperature white balance algorithm and correct the image after determining that the image to be corrected does not have a mixed color temperature of natural light.

所述装置还包括:The device also includes:

第二判断模块67,用于根据保存的相机拍摄快门时间、增益参数、光圈确定图像的环境照度,当所述环境照度大于第二设定阈值时,继续后续步骤;或判断第一聚类和第二聚类的中心点之间的距离大于第三设定阈值时,继续后续步骤;或判断第一聚类和第二聚类的中心点的横坐标均位于自然光的色温对应的横坐标范围内,且第一聚类和第二聚类的中心点的纵坐标均位于自然光的色温对应的纵坐标范围内时,触发第一判断模块64。The second judging module 67 is used to determine the ambient illuminance of the image according to the saved camera shutter time, gain parameters, and aperture, and when the ambient illuminance is greater than the second set threshold, continue the subsequent steps; or judge the first clustering and When the distance between the center points of the second cluster is greater than the third set threshold, continue to the subsequent steps; or determine that the abscissas of the center points of the first cluster and the second cluster are both within the abscissa range corresponding to the color temperature of natural light , and the ordinates of the central points of the first cluster and the second cluster are both within the range of ordinates corresponding to the color temperature of natural light, the first judging module 64 is triggered.

所述第一确定模块61,具体用于确定每个矩形区域的每个矩形区域的G/R值和G/B值;或,确定每个矩形区域的G/R的对数值和G/B的对数值;或,确定每个矩形区域的每个矩形区域的R/G的对数值和B/G的对数值。The first determining module 61 is specifically used to determine the G/R value and G/B value of each rectangular area in each rectangular area; or, determine the logarithmic value of G/R and G/B of each rectangular area or, determine the logarithm value of R/G and the logarithm value of B/G of each rectangular area of each rectangular area.

本发明实施例提供一种图像中自然光混合色温的判断方法及装置,所述方法包括:针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴;将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向;判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的;如果是,确定待校正的图像存在自然光混合色温,否则,确定待校正的图像不存在自然光混合色温。由于第二单位方向向量是针对于存在自然光混合色温的目标图像预先确定并保存的,因此,当第一单位方向向量与第二单位方向向量的夹角小于设定的第一阈值,说明该待校正的图像与该存在自然光混合色温的目标图像类似,也存在自然光混合色温,从而可以保证图像自然光混合色温判断的准确性,并且进一步保证了后续白平衡校正的准确性。Embodiments of the present invention provide a method and device for judging the mixed color temperature of natural light in an image. The method includes: for the image to be corrected, divide the image into a plurality of rectangular areas according to set rules, and divide the image into a plurality of rectangular areas according to each rectangular area. Determine the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area; according to the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area, determine each in the constructed coordinate system. Each first coordinate point corresponding to a rectangular area, wherein the coordinate system uses the pair of natural light mixed color temperature evaluation parameters as the horizontal axis and the vertical axis; the first coordinate point in the coordinate system is divided into the first cluster and For the second clustering, determine the first unit direction vector according to the center point of each cluster, wherein the direction of the first unit direction vector is the direction from low color temperature to high color temperature; judge the first unit direction vector and the pre-saved first unit direction vector Whether the included angle between the two unit direction vectors is smaller than the set first threshold, wherein the second unit direction vector is predetermined and saved according to the target image with mixed color temperature of natural light; if yes, it is determined that the image to be corrected has natural light Mixed color temperature, otherwise, make sure there is no natural light mixed color temperature in the image to be corrected. Since the second unit direction vector is predetermined and saved for the target image with the mixed color temperature of natural light, when the angle between the first unit direction vector and the second unit direction vector is smaller than the set first threshold, it indicates that the pending The corrected image is similar to the target image that has the mixed color temperature of natural light, and also has the mixed color temperature of natural light, thereby ensuring the accuracy of judging the mixed color temperature of natural light in the image, and further ensuring the accuracy of subsequent white balance correction.

本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each procedure and/or block in the flowchart and/or block diagram, and a combination of procedures and/or blocks in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions may be provided to a general purpose computer, special purpose computer, embedded processor, or processor of other programmable data processing equipment to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing equipment produce a An apparatus for realizing the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions The device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby The instructions provide steps for implementing the functions specified in the flow chart or blocks of the flowchart and/or the block or blocks of the block diagrams.

尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。While preferred embodiments of the invention have been described, additional changes and modifications to these embodiments can be made by those skilled in the art once the basic inventive concept is appreciated. Therefore, it is intended that the appended claims be construed to cover the preferred embodiment as well as all changes and modifications which fall within the scope of the invention.

显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention also intends to include these modifications and variations.

Claims (18)

1.一种图像中自然光混合色温的判断方法,其特征在于,所述方法包括:1. A method for judging the mixed color temperature of natural light in an image, characterized in that the method comprises: 针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;For the image to be corrected, divide the image into multiple rectangular areas according to the set rules, and determine a pair of natural light mixed color temperature evaluations for each rectangular area according to the mean values of red R, green G, and blue B in each rectangular area the value of the parameter; 根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴;Each first coordinate point corresponding to each rectangular area is determined in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system uses the pair of natural light mixed color temperature evaluation parameters as the abscissa axis and vertical axis; 将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向;Divide the first coordinate point in the coordinate system into a first cluster and a second cluster, and determine a first unit direction vector according to the center point of each cluster, wherein the direction of the first unit direction vector is From low color temperature to high color temperature; 判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的;judging whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, wherein the second unit direction vector is predetermined and saved according to the target image with mixed color temperature of natural light ; 如果是,确定待校正的图像存在自然光混合色温,否则,确定待校正的图像不存在自然光混合色温;If so, determine that the image to be corrected has a natural light mixed color temperature, otherwise, determine that the image to be corrected does not have a natural light mixed color temperature; 确定所述第二单位方向向量的过程包括:The process of determining the second unit direction vector includes: 针对预先采集的自然光混合色温的目标图像,按照设定的规则将所述目标图像划分为多个矩形区域,根据每个矩形区域的R、G、B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;For the pre-collected target image of mixed color temperature of natural light, the target image is divided into multiple rectangular areas according to the set rules, and a pair of natural light in each rectangular area is determined according to the R, G, and B mean values of each rectangular area. The value of the mixed color temperature evaluation parameter; 根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第二坐标点,其中坐标系的以所述一对自然光混合色温评价参数作为横轴和纵轴;According to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, each second coordinate point corresponding to each rectangular area is determined in the constructed coordinate system, wherein the coordinate system uses the pair of natural light mixed color temperature evaluation parameters as horizontal and vertical axes; 根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。According to the coordinates of each second coordinate point in the coordinate system, a second unit direction vector is determined, wherein the direction of the second unit direction vector is a direction from low color temperature to high color temperature. 2.根据权利要求1所述的方法,其特征在于,所述根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量包括:2. The method according to claim 1, wherein said determining the second unit direction vector according to the coordinates of each second coordinate point in the coordinate system comprises: 获取用户输入的两个坐标点的坐标信息,确定所述两个坐标点的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量;或Acquire coordinate information of two coordinate points input by the user, determine direction vectors of the two coordinate points, and use the unit vector corresponding to the direction vector as the second unit direction vector; or 根据最小二乘法,确定所述坐标系中第二坐标点对应的直线方程,根据所述直线方程,确定所述直线方程对应的第二单位方向向量;或According to the method of least squares, determine the equation of a line corresponding to the second coordinate point in the coordinate system, and determine the second unit direction vector corresponding to the equation of the line according to the equation of the line; or 根据主成分分析的方法,确定所述第二坐标点组成的点集的协方差矩阵,根据所述协方差矩阵的特征向量确定第二单位方向向量。According to the principal component analysis method, the covariance matrix of the point set composed of the second coordinate points is determined, and the second unit direction vector is determined according to the eigenvectors of the covariance matrix. 3.根据权利要求1所述的方法,其特征在于,所述确定待校正的图像存在自然光混合色温之后,所述方法还包括:3. The method according to claim 1, characterized in that, after determining that the image to be corrected has a mixed color temperature of natural light, the method further comprises: 根据自然光混合色温白平衡算法确定白平衡增益并对所述图像进行校正。The white balance gain is determined according to the natural light mixed color temperature white balance algorithm and the image is corrected. 4.根据权利要求3所述的方法,其特征在于,所述根据自然光混合色温白平衡算法确定白平衡增益包括:4. The method according to claim 3, wherein the determining the white balance gain according to the natural light mixed color temperature white balance algorithm comprises: 根据所述第一单位方向向量和第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值;According to the angle between the first unit direction vector and the second unit direction vector and the setting parameters, using a preset algorithm to determine the natural light mixing color temperature parameter value corresponding to the angle and the setting parameters; 根据所述自然光混合色温参数值,确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重,根据所述单色温白平衡算法和自然光混合色温白平衡算法及对应的第一权重和第二权重,确定白平衡增益。According to the natural light mixed color temperature parameter value, determine the first weight and the second weight corresponding to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm, according to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm and The white balance gain is determined corresponding to the first weight and the second weight. 5.根据权利要求4所述的方法,其特征在于,所述根据所述自然光混合色温参数值,确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重包括:5. The method according to claim 4, wherein, according to the natural light mixed color temperature parameter value, determining the first weight and the second weight corresponding to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm include : 将所述自然光混合色温参数值作为第二权重,将1与所述第二权重的差作为第一权重。The value of the natural light mixed color temperature parameter is used as a second weight, and the difference between 1 and the second weight is used as a first weight. 6.根据权利要求4所述的方法,其特征在于,所述根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值包括:6. The method according to claim 4, characterized in that, according to the included angle between the first unit direction vector and the pre-saved second unit direction vector and setting parameters, a preset algorithm is used to determine the The above-mentioned included angle and the corresponding natural light mixing color temperature parameter value of the above-mentioned setting parameters include: 根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角,计算所述夹角与预设参数的乘积;将所述乘积的余弦值确定为所述自然光混合色温参数值。According to the included angle between the first unit direction vector and the pre-stored second unit direction vector, calculate the product of the included angle and a preset parameter; determine the cosine value of the product as the natural light mixing color temperature parameter value. 7.根据权利要求1所述的方法,其特征在于,所述确定待校正的图像不存在自然光混合色温之后,所述方法还包括:7. The method according to claim 1, wherein after determining that the image to be corrected does not have a mixed color temperature of natural light, the method further comprises: 根据单色温白平衡算法确定白平衡增益并对所述图像进行校正。The white balance gain is determined according to the monochromatic temperature white balance algorithm and the image is corrected. 8.根据权利要求1所述的方法,其特征在于,所述判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值之前,所述方法还包括:8. The method according to claim 1, wherein before the judgment of whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, the method further comprises : 根据保存的相机拍摄快门时间、增益参数、光圈确定图像的环境照度,当所述环境照度大于第二设定阈值时,继续后续步骤;或Determine the ambient illuminance of the image according to the stored camera shutter time, gain parameters, and aperture, and when the ambient illuminance is greater than the second set threshold, continue to the subsequent steps; or 判断第一聚类和第二聚类的中心点之间的距离大于第三设定阈值时,继续后续步骤;或When it is judged that the distance between the center points of the first cluster and the second cluster is greater than the third set threshold, continue to the subsequent steps; or 判断第一聚类和第二聚类的中心点的横坐标均位于自然光的色温对应的横坐标范围内,且第一聚类和第二聚类的中心点的纵坐标均位于自然光的色温对应的纵坐标范围内时,继续后续步骤。Judging that the abscissas of the center points of the first cluster and the second cluster are both within the range of abscissas corresponding to the color temperature of natural light, and the ordinates of the center points of the first cluster and the second cluster are both within the range corresponding to the color temperature of natural light If it is within the range of the ordinate, continue to the next step. 9.根据权利要求1所述的方法,其特征在于,所述每个矩形区域的一对自然光混合色温评价参数的值包括:9. The method according to claim 1, wherein the values of a pair of natural light mixed color temperature evaluation parameters for each rectangular area include: 每个矩形区域的G/R值和G/B值;或G/R value and G/B value for each rectangular area; or 每个矩形区域的G/R的对数值和G/B的对数值;或the logarithmic values of G/R and the logarithmic values of G/B for each rectangular area; or 每个矩形区域的R/G的对数值和B/G的对数值。The logarithmic value of R/G and the logarithmic value of B/G of each rectangular area. 10.一种图像中自然光混合色温的判断装置,其特征在于,所述装置包括:10. A device for judging the mixed color temperature of natural light in an image, characterized in that the device comprises: 第一确定模块,用于针对待校正的图像,按照设定的规则将所述图像划分为多个矩形区域,根据每个矩形区域的红R、绿G、蓝B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;The first determination module is used to divide the image to be corrected into a plurality of rectangular areas according to the set rules, and determine each rectangular area according to the mean value of red R, green G, and blue B of each rectangular area. The value of a pair of natural light mixed color temperature evaluation parameters; 第二确定模块,用于根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第一坐标点,其中坐标系以所述一对自然光混合色温评价参数作为横轴和纵轴;The second determination module is used to determine each first coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system is based on the pair The natural light mixed color temperature evaluation parameters are used as the horizontal axis and the vertical axis; 第三确定模块,用于将所述坐标系中的第一坐标点划分为第一聚类和第二聚类,根据每个聚类的中心点,确定第一单位方向向量,其中所述第一单位方向向量的方向为低色温到高色温方向;The third determination module is used to divide the first coordinate points in the coordinate system into the first cluster and the second cluster, and determine the first unit direction vector according to the center point of each cluster, wherein the first unit direction vector The direction of a unit direction vector is the direction from low color temperature to high color temperature; 第一判断模块,用于判断第一单位方向向量与预先保存的第二单位方向向量的夹角是否小于设定的第一阈值,其中,所述第二单位方向向量为根据存在自然光混合色温的目标图像预先确定并保存的;The first judging module is used to judge whether the included angle between the first unit direction vector and the pre-saved second unit direction vector is smaller than the set first threshold, wherein the second unit direction vector is based on the mixed color temperature of natural light The target image is predetermined and saved; 第四确定模块,用于如果第一判断模块的判断结果为是,确定待校正的图像存在自然光混合色温,如果第一判断模块的判断结果为否,确定待校正的图像不存在自然光混合色温;The fourth determination module is used to determine that the image to be corrected has a natural light mixed color temperature if the judgment result of the first judgment module is Yes, and if the judgment result of the first judgment module is No, determine that the image to be corrected does not have a natural light mixed color temperature; 所述第一确定模块,还用于针对预先采集的自然光混合色温的目标图像,按照设定的规则将所述目标图像划分为多个矩形区域,根据每个矩形区域的R、G、B均值,确定每个矩形区域的一对自然光混合色温评价参数的值;The first determining module is also used to divide the target image into a plurality of rectangular areas according to the pre-collected target image of mixed color temperature of natural light according to the set rules, and according to the R, G, and B mean values of each rectangular area , to determine the value of a pair of natural light mixed color temperature evaluation parameters for each rectangular area; 所述第二确定模块,还用于根据每个矩形区域的一对自然光混合色温评价参数的值在构建的坐标系中确定每个矩形区域对应的每个第二坐标点,其中坐标系的以所述一对自然光混合色温评价参数作为横轴和纵轴;The second determination module is further configured to determine each second coordinate point corresponding to each rectangular area in the constructed coordinate system according to the value of a pair of natural light mixed color temperature evaluation parameters of each rectangular area, wherein the coordinate system is represented by The pair of natural light mixed color temperature evaluation parameters are used as the horizontal axis and the vertical axis; 所述第三确定模块,还用于根据每个第二坐标点在所述坐标系中的坐标,确定第二单位方向向量,其中所述第二单位方向向量的方向为低色温到高色温方向。The third determining module is further configured to determine a second unit direction vector according to the coordinates of each second coordinate point in the coordinate system, wherein the direction of the second unit direction vector is the direction from low color temperature to high color temperature . 11.根据权利要求10所述的装置,其特征在于,所述第三确定模块,具体用于获取用户输入的两个坐标点的坐标信息,确定所述两个坐标点的方向向量,并将所述方向向量对应的单位向量作为所述第二单位方向向量;或,根据最小二乘法,确定所述坐标系中第二坐标点对应的直线方程,根据所述直线方程,确定所述直线方程对应的第二单位方向向量;或,根据主成分分析的方法,确定所述第二坐标点组成的点集的协方差矩阵,根据所述协方差矩阵的特征向量确定第二单位方向向量。11. The device according to claim 10, wherein the third determining module is specifically configured to obtain coordinate information of two coordinate points input by the user, determine the direction vectors of the two coordinate points, and set The unit vector corresponding to the direction vector is used as the second unit direction vector; or, according to the least squares method, determine the straight line equation corresponding to the second coordinate point in the coordinate system, and determine the straight line equation according to the straight line equation The corresponding second unit direction vector; or, according to the principal component analysis method, determine the covariance matrix of the point set composed of the second coordinate points, and determine the second unit direction vector according to the eigenvectors of the covariance matrix. 12.根据权利要求10所述的装置,其特征在于,所述装置还包括:12. The device according to claim 10, further comprising: 第五确定模块,用于确定待校正的图像存在自然光混合色温之后,根据自然光混合色温白平衡算法确定白平衡增益并对所述图像进行校正。The fifth determination module is configured to determine the white balance gain according to the natural light mixed color temperature white balance algorithm and correct the image after it is determined that the image to be corrected has the mixed color temperature of natural light. 13.根据权利要求12所述的装置,其特征在于,所述第五确定模块,具体用于根据所述第一单位方向向量和第二单位方向向量的夹角及设定参数,采用预设的算法,确定所述夹角及所述设定参数对应的自然光混合色温参数值;根据所述自然光混合色温参数值确定单色温白平衡算法和自然光混合色温白平衡算法对应的第一权重和第二权重,根据所述单色温白平衡算法和自然光混合色温白平衡算法及对应的第一权重和第二权重,确定白平衡增益。13. The device according to claim 12, wherein the fifth determining module is specifically configured to adopt a preset According to the algorithm, determine the angle and the natural light mixed color temperature parameter value corresponding to the set parameter; determine the first weight sum corresponding to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm according to the natural light mixed color temperature parameter value The second weight is to determine the white balance gain according to the single color temperature white balance algorithm and the natural light mixed color temperature white balance algorithm and the corresponding first weight and second weight. 14.根据权利要求13所述的装置,其特征在于,所述第五确定模块,具体用于将所述自然光混合色温参数值作为第二权重,将1与所述第二权重的差作为第一权重。14. The device according to claim 13, wherein the fifth determination module is specifically configured to use the natural light mixed color temperature parameter value as the second weight, and use the difference between 1 and the second weight as the second weight. a weight. 15.根据权利要求13所述的装置,其特征在于,所述第五确定模块,具体用于根据所述第一单位方向向量和预先保存的第二单位方向向量的夹角,计算所述夹角与预设参数的乘积;将所述乘积的余弦值确定为所述自然光混合色温参数值。15. The device according to claim 13, wherein the fifth determination module is specifically configured to calculate the included angle according to the included angle between the first unit direction vector and the pre-saved second unit direction vector. The product of the angle and the preset parameter; the cosine value of the product is determined as the parameter value of the natural light mixing color temperature. 16.根据权利要求10所述的装置,其特征在于,所述装置还包括:16. The device according to claim 10, further comprising: 第五确定模块,用于确定待校正的图像不存在自然光混合色温之后,根据单色温白平衡算法确定白平衡增益并对所述图像进行校正。The fifth determination module is configured to determine the white balance gain according to the single color temperature white balance algorithm and correct the image after determining that there is no natural light mixed color temperature in the image to be corrected. 17.根据权利要求10所述的装置,其特征在于,所述装置还包括:17. The device according to claim 10, further comprising: 第二判断模块,用于根据保存的相机拍摄快门时间、增益参数、光圈确定图像的环境照度,当所述环境照度大于第二设定阈值时,继续后续步骤;或判断第一聚类和第二聚类的中心点之间的距离大于第三设定阈值时,继续后续步骤;或判断第一聚类和第二聚类的中心点的横坐标均位于自然光的色温对应的横坐标范围内,且第一聚类和第二聚类的中心点的纵坐标均位于自然光的色温对应的纵坐标范围内时,触发第一判断模块。The second judging module is used to determine the ambient illuminance of the image according to the saved camera shutter time, gain parameters, and aperture, and when the ambient illuminance is greater than the second set threshold, continue to the subsequent steps; or judge the first cluster and the second When the distance between the center points of the two clusters is greater than the third set threshold, continue to the subsequent steps; or judge that the abscissas of the center points of the first cluster and the second cluster are both within the range of abscissas corresponding to the color temperature of natural light , and when the ordinates of the center points of the first cluster and the second cluster are both within the range of ordinates corresponding to the color temperature of natural light, the first judging module is triggered. 18.根据权利要求10所述的装置,其特征在于,所述第一确定模块,具体用于确定每个矩形区域的每个矩形区域的G/R值和G/B值;或,确定每个矩形区域的G/R的对数值和G/B的对数值;或,确定每个矩形区域的每个矩形区域的R/G的对数值和B/G的对数值。18. The device according to claim 10, wherein the first determination module is specifically configured to determine the G/R value and the G/B value of each rectangular area of each rectangular area; or, determine each The logarithmic value of G/R and the logarithmic value of G/B of each rectangular area; or, determine the logarithmic value of R/G and the logarithmic value of B/G of each rectangular area of each rectangular area.
CN201611117128.1A 2016-04-25 2016-12-07 The judgment method and device of natural light mixing colour temperature in a kind of image Expired - Fee Related CN106791758B (en)

Priority Applications (5)

Application Number Priority Date Filing Date Title
CN201611117128.1A CN106791758B (en) 2016-12-07 2016-12-07 The judgment method and device of natural light mixing colour temperature in a kind of image
US16/095,979 US10805588B2 (en) 2016-04-25 2017-04-24 Methods, systems, and media for image white balance adjustment
EP17788723.9A EP3449628B1 (en) 2016-04-25 2017-04-24 Methods, systems, and media for image white balance adjustment
PCT/CN2017/081617 WO2017186071A1 (en) 2016-04-25 2017-04-24 Methods, systems, and media for image white balance adjustment
US17/067,700 US11363244B2 (en) 2016-04-25 2020-10-11 Methods, systems, and media for image white balance adjustment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611117128.1A CN106791758B (en) 2016-12-07 2016-12-07 The judgment method and device of natural light mixing colour temperature in a kind of image

Publications (2)

Publication Number Publication Date
CN106791758A CN106791758A (en) 2017-05-31
CN106791758B true CN106791758B (en) 2018-07-06

Family

ID=58877054

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611117128.1A Expired - Fee Related CN106791758B (en) 2016-04-25 2016-12-07 The judgment method and device of natural light mixing colour temperature in a kind of image

Country Status (1)

Country Link
CN (1) CN106791758B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108063891B (en) * 2017-12-07 2020-04-24 Oppo广东移动通信有限公司 Image processing method, image processing device, computer-readable storage medium and computer equipment
CN108063934B (en) * 2017-12-25 2020-01-10 Oppo广东移动通信有限公司 Image processing method and device, computer readable storage medium and computer device
WO2020000262A1 (en) * 2018-06-27 2020-01-02 华为技术有限公司 Light source estimating method, image processing method and related products
CN109361910B (en) * 2018-10-23 2020-09-01 浙江宇视科技有限公司 Self-adaptive white balance correction method and device
CN109600606B (en) * 2018-11-30 2019-12-27 深圳市华星光电半导体显示技术有限公司 Method for identifying single tone image
CN109685348A (en) * 2018-12-14 2019-04-26 广东电网有限责任公司 A kind of power equipment typical mode of operation determines method
CN113068016B (en) * 2021-04-02 2023-03-24 杭州涂鸦信息技术有限公司 White balance correction method and device and computer equipment
TWI759188B (en) * 2021-04-27 2022-03-21 凌巨科技股份有限公司 Image processing device and method for adjusting white balance
CN114399477A (en) * 2021-12-30 2022-04-26 中国舰船研究院 Method and system for positioning detection of ship signal flag
CN114745532B (en) * 2022-04-01 2024-04-09 北京紫光展锐通信技术有限公司 Mixed color temperature scene white balance processing method and device, storage medium and terminal

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101193317A (en) * 2006-11-30 2008-06-04 北京思比科微电子技术有限公司 Method and device for automatic white balance processing of the image
CN101911715A (en) * 2008-02-13 2010-12-08 高通股份有限公司 The white balance calibration that is used for digital camera device
CN103929632A (en) * 2014-04-15 2014-07-16 浙江宇视科技有限公司 Automatic white balance correcting method and device
CN104144333A (en) * 2013-05-08 2014-11-12 全视科技有限公司 Automatic white balance based on dynamic mapping

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4740602B2 (en) * 2005-01-19 2011-08-03 イーストマン コダック カンパニー Auto white balance device and white balance adjustment method
US8064110B2 (en) * 2005-12-08 2011-11-22 Qualcomm Incorporated Adaptive auto white balance
JP5744431B2 (en) * 2010-07-16 2015-07-08 キヤノン株式会社 Image processing apparatus, image processing method, and program

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101193317A (en) * 2006-11-30 2008-06-04 北京思比科微电子技术有限公司 Method and device for automatic white balance processing of the image
CN101911715A (en) * 2008-02-13 2010-12-08 高通股份有限公司 The white balance calibration that is used for digital camera device
CN104144333A (en) * 2013-05-08 2014-11-12 全视科技有限公司 Automatic white balance based on dynamic mapping
CN103929632A (en) * 2014-04-15 2014-07-16 浙江宇视科技有限公司 Automatic white balance correcting method and device

Also Published As

Publication number Publication date
CN106791758A (en) 2017-05-31

Similar Documents

Publication Publication Date Title
CN106791758B (en) The judgment method and device of natural light mixing colour temperature in a kind of image
CN106686319B (en) A kind of control method and its device of image exposure
CN105338262B (en) A kind of graphic images processing method and processing device
CN109361910B (en) Self-adaptive white balance correction method and device
CN110830778B (en) Imaging device color correction method, imaging device color correction device, electronic device and storage medium
US20180342224A1 (en) Electronic device, and display panel device correction method and system thereof
CN104796683B (en) A kind of method and system of calibration image color
CN108234971B (en) White balance parameter determines method, white balance adjustment method and device, storage medium, terminal
CN109688396B (en) Image white balance processing method and device and terminal equipment
US8854709B1 (en) Automatic white balance based on dynamic mapping
CN107221306A (en) Method, device and the display device of brightness of image in correction splicing device screen
CN108259877B (en) A kind of white balancing treatment method and device
CN108009997B (en) Method and device for adjusting image contrast
CN106060491A (en) Projected image color correction method and apparatus
CN111587573B (en) Image processing method and device and computer storage medium
WO2020093653A1 (en) Color adjustment method, color adjustment device, electronic device and computer-readable storage medium
CN106954051A (en) A kind of image processing method and mobile terminal
CN104346817A (en) Video image color cast detection method and device
CN111105365A (en) Color correction method, medium, terminal and device for texture image
CN110033412A (en) A kind of image processing method and device
CN114222101B (en) White balance adjusting method and device and electronic equipment
US20190304352A1 (en) Color temperature adjusting system and method
CN112492191B (en) Image acquisition method, device, equipment and medium
US9131200B2 (en) White balance adjusting method with scene detection and device thereof
CN106971375B (en) Image amplification processing method and 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
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20180706