Compensation method and device of white balance gain, electronic equipment and storage medium
By determining calibration parameters and white balance gain in the shooting device, constructing gain geometry, and selecting target points for white balance adjustment, the problem of white balance deviation in the prior art is solved, achieving more accurate image color representation and reducing hardware costs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-24
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, the white balance processing method of shooting devices relies on the characteristics of the camera module or the relative color temperature, which leads to image color deviation that does not match human eye perception and increases hardware costs.
By determining the gray-area white balance statistics of multiple standard light sources, calculating calibration parameters and white balance gain, constructing gain geometry, selecting target points for white balance adjustment, and using the coordinate values of the target points to compensate the original image.
It achieves more accurate white balance adjustment, reduces hardware costs, does not rely on an additional color temperature sensor, and improves the accuracy of image color performance and subjective preferences.
Smart Images

Figure CN115643388B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of image processing, and in particular, to a white balance gain compensation method and device, electronic equipment and storage medium. BACKGROUND
[0002] In the actual color image acquisition process, there is a certain deviation between the white color captured by the shooting device and the real white color observed by the human eye in the natural daylight environment. The purpose of white balance processing is to uniformly compensate for the color deviation caused by the color temperature environment and the inherent color channel gain deviation of the shooting device by changing the gain of the color channel of the shooting device, so that the image can correctly reflect the real color of the object being shot.
[0003] In related technologies, there are mainly the following two methods for implementing the AWB function in the shooting device: one is to use a camera module calibration white point method, which uses the calibration parameters of the camera module as the first calibration parameters, writes them into the device memory, and then estimates the relative color temperature of the current environment light source and the white balance gain based on the first calibration parameters, to finally realize the gain compensation of the color channel of the shooting device; the other is to add a white balance gain compensation module based on the above method, and the basic principle is to set the white balance gain compensation value of the standard light source point, and the automatic white balance algorithm outputs the relative color temperature estimation value and the current white balance gain. The compensation module inputs the relative color temperature estimation value as a condition, and obtains the white balance gain compensation by linear interpolation of the white balance gain compensation corresponding to the two standard light sources with the smallest color temperature difference.
[0004] The first method described above relies too much on the camera module of the shooting device, and the nonlinearity of the photoelectric and optical device characteristics of the camera module, as well as the deviation in the selection and statistics of the gray area of the original picture by the image signal processor, results in inaccurate white balance of the picture obtained by this method, which is different from the subjective perception of the human eye to the actual scene. The second method described above only uses the relative color temperature as the input of the white balance gain compensation module, but the relative color temperature cannot fully reflect the spectral characteristics of the light source, and light sources with the same relative color temperature can also exhibit different color characteristics. The white color presented by the picture adjusted based on this method is still different from the subjective perception of the human eye. In addition, in other ways of related technologies, if more accurate white balance compensation is to be achieved, a color temperature sensor needs to be added to calibrate the standard light source, which undoubtedly increases the hardware cost of the entire device. SUMMARY
[0005] To solve at least one of the above technical problems, the present disclosure provides a white balance gain compensation method, device, electronic equipment and storage medium.
[0006] According to one aspect of the present disclosure, a method for compensating white balance gain is provided, which can include: determining a plurality of calibration parameters according to white balance statistical information of a gray area in each standard light source; determining a target point satisfying a target condition in a gain coordinate system according to a white balance gain corresponding to the calibration parameters and a white balance gain corresponding to the white balance statistical information; and performing white balance adjustment on an original image to obtain a target image with a target white color by taking coordinate values of the target point as compensation values of original gain.
[0007] In some embodiments, determining a plurality of calibration parameters according to white balance statistical information of a gray area in each standard light source can include: taking the white balance statistical information of the gray area in each standard light source as a first calibration parameter corresponding to each standard light source, wherein the white balance statistical information is used to represent a pixel distribution state of the gray area; calculating a white balance gain of the standard light source by using an inverse of the first calibration parameter; adjusting a sample image by using the white balance gain to obtain a target parameter corresponding to the adjusted sample image; and taking the white balance gain as a second calibration parameter of the standard light source in response to a judgment result that the target parameter satisfies a preset target condition.
[0008] In some embodiments, before taking the white balance gain as the second calibration parameter of the standard light source in response to the judgment result that the target parameter satisfies the preset target condition, the method can further include: adjusting a weight of the white balance gain in response to a judgment result that the target parameter does not satisfy the target condition.
[0009] In some embodiments, before taking the white balance gain as the second calibration parameter of the standard light source in response to the judgment result that the target parameter satisfies the preset target condition, the method can further include: setting a target condition for measuring a state of the target parameter.
[0010] In some embodiments, determining a target point satisfying a target condition in a gain coordinate system according to a white balance gain corresponding to the calibration parameters and a white balance gain corresponding to the white balance statistical information can include: respectively calculating at least two white balance gains when each calibration parameter corresponds to at least two standard light sources; determining a plurality of parameter points for representing the white balance gain corresponding to the calibration parameters and a state point for representing the white balance gain corresponding to the white balance statistical information in the gain coordinate system; constructing at least one gain geometry according to the plurality of parameter points and the state point; and determining the target point satisfying the target condition in the at least one gain geometry based on a positional relationship of the state point relative to the parameter points.
[0011] In some embodiments, constructing the at least one gain geometry according to the plurality of parameter points and the state point can include: determining an adjustment coefficient between a white balance gain corresponding to the first calibration parameter and a white balance gain corresponding to the second calibration parameter under the same standard light source; determining a first adjustment point and a second adjustment point when the state point corresponds to each standard light source respectively based on the adjustment coefficient; determining at least one target parameter point between at least two parameter points corresponding to the second calibration parameter according to a distance between the state point and the at least two parameter points corresponding to the first calibration parameter; and constructing the at least one gain geometry with the first adjustment point, the second adjustment point and the at least one target parameter point as vertices.
[0012] In some embodiments, determining the target point satisfying the target condition in the at least one gain geometry based on the positional relationship of the state point relative to the parameter points can include: when distances between the state point and the at least two parameter points corresponding to the first calibration parameter are different, taking a barycenter of the gain geometry as the target point; and when distances between the state point and the at least two parameter points corresponding to the first calibration parameter are the same, determining barycenters of the respective gain geometries respectively, and taking a midpoint of a line connecting the barycenters as the target point.
[0013] In some embodiments, before determining the target point satisfying the target condition in the gain coordinate system according to the white balance gain corresponding to the calibration parameter and the white balance gain corresponding to the white balance statistical information, can include: constructing a gain coordinate system for describing a relationship between a red channel gain and a blue channel gain.
[0014] In some embodiments, taking the coordinate value of the target point as a compensation value of the original gain to perform white balance adjustment on the original image to obtain a target image with the target white color can include: taking the coordinate value of the target point as a compensation value of the original gain to adjust the original gain using the compensation value to obtain a target white balance gain; and performing multiplication operation on each pixel in the original image with the target white balance gain to obtain a target image with the target white color.
[0015] In some embodiments, before determining the plurality of calibration parameters according to the white balance statistical information of the gray area in each standard light source, can include: obtaining the white balance statistical information of the gray area in each standard light source.
[0016] In some embodiments, obtaining the white balance statistical information of the gray area in each standard light source can include: taking a plurality of original pictures containing the target gray card under each standard light source respectively; taking the position of the target gray card as the gray area of the original picture, and respectively counting the average value of the pixels in the red channel, the blue channel and the green channel in the gray area; and calculating and integrating the ratio of the average value of the pixels in the red channel to the average value of the pixels in the green channel, and the average value of the pixels in the blue channel and the green channel, to obtain the white balance statistical information for representing the pixel distribution state of the gray area.
[0017] According to another aspect of the present disclosure, a compensation device for white balance gain is provided, which can include: a calibration parameter determination module configured to determine a plurality of calibration parameters according to the white balance statistical information of the gray area in each standard light source; a target point determination module configured to determine a target point satisfying a target condition in a gain coordinate system according to the white balance gain corresponding to the calibration parameters and the white balance gain corresponding to the white balance statistical information; and a compensation module configured to take the coordinate value of the target point as a compensation value of the original gain, and perform white balance adjustment on the original image to obtain a target image with a target white color.
[0018] According to still another aspect of the present disclosure, an electronic device is provided, which can include: a memory storing an execution instruction; and a processor executing the execution instruction stored in the memory, so that the processor executes the compensation method for white balance gain of any embodiment of the present disclosure.
[0019] According to still another aspect of the present disclosure, a readable storage medium is provided, which stores an execution instruction, and the execution instruction is used for the compensation method for white balance gain of any embodiment of the present disclosure when executed by a processor. BRIEF DESCRIPTION OF DRAWINGS
[0020] The accompanying drawings illustrate exemplary embodiments of the present disclosure and together with the general description of the disclosure given above, and the detailed description of the embodiments below, serve to explain the principles of the present disclosure.
[0021] Figure 1 A flowchart of the compensation method for white balance gain of the exemplary embodiment of the present disclosure;
[0022] Figure 2 A flowchart of the second calibration parameter calibration of the exemplary embodiment of the present disclosure;
[0023] Figure 3 A gain geometry diagram of the exemplary embodiment of the present disclosure;
[0024] Figure 4 Another gain geometry diagram of the exemplary embodiment of the present disclosure;
[0025] Figure 5 A schematic diagram of a compensation device for white balance gain of an exemplary embodiment of the present disclosure.
[0026] Reference Signs List
[0027] 1000 compensation device for white balance gain
[0028] 1002 calibration parameter determination module
[0029] 1004 target point determination module
[0030] 1006 compensation module
[0031] 1100 bus
[0032] 1200 processor
[0033] 1300 memory
[0034] 1400 other circuitry. DETAILED DESCRIPTION
[0035] The present disclosure will be described in further detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only intended to explain the related content and are not a limitation on the present disclosure. In addition, it should be noted that only parts related to the present disclosure are shown in the drawings for ease of description.
[0036] It should be noted that the embodiments and features in the embodiments in the present disclosure can be combined with each other without conflict. The technical solutions of the present disclosure will be described in detail below with reference to the drawings and in combination with the embodiments.
[0037] Unless otherwise specified, the exemplary embodiments / examples shown will be understood to provide exemplary features of various details that can implement the technical concepts of the present disclosure in practice. Therefore, unless otherwise specified, the features of various embodiments / examples can be additionally combined, separated, interchanged and / or rearranged without departing from the technical concepts of the present disclosure.
[0038] The use of cross-hatching and / or shading in the drawings is generally used to make the boundaries and regions of adjacent components more clearly understood. As such, unless specifically stated otherwise, the presence of cross-hatching or shading in one part of a figure does not necessarily constitute a preference or requirement for a specific material, material property, dimension, ratio, commonality of components between illustrated parts, and / or any other characteristic, attribute, property, etc. of the components. Moreover, the size and relative sizes of components in the drawings can be exaggerated for clarity and / or descriptive purposes. When exemplary embodiments can be practiced differently, a specific sequence of processes can be performed in an order other than described. For example, two consecutively described processes can be performed at substantially the same time or in the reverse order of the described processes. Further, like reference numerals denote like components.
[0039] When a component is referred to as being "on" or "over" another component, "connected to" or "coupled to" another component, it can be directly on, connected or coupled to the other component or intervening components can be present. However, when a component is referred to as being "directly on", "directly connected to" or "directly coupled to" another component, there are no intervening components present. To that end, the term "connected" can refer to physical or electrical connection, with or without intervening components.
[0040] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. Further, when the terms "comprises", "comprising", "includes", "including", "contains", "containing" and / or "has" and / or "having" are used, it is specifically intended that these terms be taken as
[0041] Figure 1 A flowchart of a white balance gain compensation method S100 for an exemplary embodiment of the present disclosure; Figure 2 A flowchart of a second calibration parameter calibration for an exemplary embodiment of the present disclosure; Figure 3 A gain geometry diagram for an exemplary embodiment of the present disclosure; Figure 4 Another gain geometry diagram for an exemplary embodiment of the present disclosure. The following description is made in conjunction with Figures 1 to 4 The white balance gain compensation method of the present disclosure is described in detail.
[0042] In step S102, a plurality of calibration parameters are determined according to the white balance statistical information of the gray area in each standard light source.
[0043] The standard light source is a light source defined by the International Lighting Association, which is used to simulate artificial light sources at various color temperatures, and the main purpose is to provide lighting effects consistent with natural lighting environments for production plants or laboratories and other environments.
[0044] The gray area is the ROI (region of interest) in the original picture, and in this disclosure, the gray card part of the original picture is set as the ROI. The gray card is a kind of picture card that can balance all complex light scenes to 18% neutral gray, and is usually used as a reference for accurate exposure detection. Specifically, by recording the reflected light of the gray card with a light meter, accurate exposure values can be obtained. Therefore, before this step, the camera of the camera device is also needed to shoot the original image containing the 18% gray card under various standard light sources, so as to provide data sources for the white balance statistical information. Of course, this disclosure takes the 18% gray card as the target gray card of the first calibration parameter calibration process, and the user can select the picture card according to the actual needs.
[0045] The white balance statistical information is used to represent the pixel distribution state of the gray area. Specifically, according to the average value of the pixels in different color channels in the gray area (i.e. the ROI of this disclosure), the ratio R / G of the average value of the pixels in the red channel of the gray area under any standard light source to the average value of the pixels in the green channel of the gray area under the standard light source, and the ratio B / G of the average value of the pixels in the blue channel of the gray area under the standard light source to the average value of the pixels in the green channel of the gray area under the standard light source, i.e. R / G and B / G, are obtained. The white balance statistical information of the gray area. It should be noted that the general image sensor is in Bayer format, i.e. there are two green channels, one red channel and one blue channel, so G=(GR+GB) / 2, and each standard light source corresponds to a set of R / G and B / G.
[0046] The calibration parameters include the first calibration parameter and the second calibration parameter. The first calibration parameter can be directly obtained according to the white statistical information, and the second calibration parameter is an improvement based on the first calibration parameter combined with a preset target condition.
[0047] Specifically, the white balance statistical information of the gray area in each standard light source is taken as the first calibration parameter corresponding to each standard light source; the reciprocal of the first calibration parameter is used to calculate the white balance gain of the standard light source; the sample image is adjusted using the white balance gain, and the target parameter corresponding to the adjusted sample image is obtained; and the white balance gain is taken as the second calibration parameter of the standard light source in response to the judgment result that the target parameter satisfies the preset target condition.
[0048] It should be noted that after the white balance gain of the standard light source is calculated by using the inverse of the first calibration parameter, the automatic white balance function of the shooting device needs to be closed to avoid invalid work of the shooting device before the compensation value of the white balance gain is determined, which will also affect the determination of the compensation value of the white balance gain.
[0049] More specifically, the sample image is adjusted by using the white balance gain, and the target parameter corresponding to the adjusted sample image is obtained, including: applying the white balance gain to the white balance gain module of the image signal processor of the shooting device; shooting the sample image by using the shooting device; analyzing the region of interest of the sample image, so that the target parameter corresponding to the adjusted sample image is obtained. The target parameter can be R / G, B / G, or 18% gray card. The region of interest can be a picture gray area, and the 24 card can select 20 to 23 color blocks, and the 18% gray card can select the center area to obtain the target parameter.
[0050] Before the white balance gain is used as the second calibration parameter of the standard light source in response to the judgment result that the target parameter meets the preset target condition, the target condition for measuring the state of the target parameter is set.
[0051] Specifically, the target condition to be met by the target parameter can be set according to requirements, for example:
[0052] deltaC≤limit or R / G∈(Hthd1,Lthd1) AND B / G∈(Hthd2,Lthd2), wherein deltaC is the target parameter; Limit is a limit function of the target parameter deltaC. When the target parameter deltaC is R / G AND B / G, (Hthd1, Lthd1) is the set value range of R / G, and (Hthd2, Lthd2) is the value range of B / G.
[0053] In some embodiments, in response to the judgment result that the target parameter does not meet the target condition, the weight of the white balance gain is adjusted. After adjusting the weight of the white balance gain, the steps of "applying the white balance gain to the white balance gain module of the image signal processor of the shooting device; shooting the sample image by using the shooting device; analyzing the region of interest of the sample image, so that the target parameter corresponding to the adjusted sample image is obtained" are repeatedly executed until the target parameter obtained meets the target condition, at which time the new white balance gain after the weight adjustment is used as the second calibration parameter.
[0054] In some embodiments, after the first calibration parameter is obtained, the first calibration parameter needs to be written into the memory of the shooting device. After the second calibration parameter is obtained, the second calibration parameter also needs to be written into the memory of the shooting device. In some embodiments, after the first calibration parameter is obtained, the first calibration parameter needs to be written into the memory of the shooting device. After the second calibration parameter is obtained, the second calibration parameter also needs to be written into the memory of the shooting device.
[0055] In step S104, a target point satisfying a target condition is determined in a gain coordinate system according to a white balance gain corresponding to the calibration parameter and a white balance gain corresponding to the white balance statistical information.
[0056] The gain coordinate system takes the red channel gain as the horizontal coordinate and the blue channel gain as the vertical coordinate, and is used to describe the relationship between the red channel gain and the blue channel gain.
[0057] The target point is a point that can accurately reflect the white balance gain, and is a point selected in the gain coordinate system to satisfy the target condition in combination of the white balance gain corresponding to the calibration parameter and the white balance gain corresponding to the white balance statistical information.
[0058] Specifically, at least two white balance gains corresponding to each calibration parameter when at least two standard light sources are respectively obtained; a plurality of parameter points for representing the white balance gain corresponding to the calibration parameter and a state point for representing the white balance gain corresponding to the white balance statistical information are determined in the gain coordinate system; at least one gain geometry is constructed according to the plurality of parameter points and the state point; and a target point satisfying a target condition is determined in the at least one gain geometry based on the positional relationship of the state point relative to the parameter point.
[0059] The at least one gain geometry constructed according to the plurality of parameter points and the state point can include: determining an adjustment coefficient between the white balance gain corresponding to the first calibration parameter and the white balance gain corresponding to the second calibration parameter under the same standard light source; determining a first adjustment point and a second adjustment point corresponding to the state point when each standard light source is based on the adjustment coefficient; determining at least one target parameter point between at least two parameter points corresponding to the second calibration parameter according to the distance between the state point and at least two parameter points corresponding to the first calibration parameter; and constructing at least one gain geometry with the first adjustment point, the second adjustment point and the at least one target parameter point as vertices.
[0060] The target point satisfying the target condition in the at least one gain geometry based on the positional relationship of the state point relative to the parameter point can include: when the distances between the state point and at least two parameter points corresponding to the first calibration parameter are different, taking the center of gravity of the gain geometry as the target point; and when the distances between the state point and at least two parameter points corresponding to the first calibration parameter are the same, determining the center of gravity of each gain geometry respectively, and taking the midpoint of the line between the plurality of centers of gravity as the target point.
[0061] In some embodiments, before step S104 is performed, a gain coordinate system is also constructed according to the red channel gain Rgain, the green channel gain Ggain and the blue channel gain Bgain. In the analysis process of automatic white balance, Rgain, Bgain and Ggain are normalized, that is, Ggain is set to 1. Therefore, the horizontal coordinate of the gain coordinate system after normalization is Rgain, and the vertical coordinate is Bgain.
[0062] The specific description of step S104 will be given below in combination with Figure 3 and Figure 4
[0063] For the case that the distance between the state point and the at least two parameter points corresponding to the first calibration parameter is different, reference can be made to Figure 3 .
[0064] The present disclosure is provided with two standard light sources H light and A light. In the gain coordinate system, the white balance gain of the first calibration parameter under H light is embodied as a parameter point L1, and the coordinate value of the parameter point L1 is the inverse of the first calibration parameter under H light; the white balance gain of the first calibration parameter under A light is embodied as a parameter point L2, and the coordinate value of the parameter point L2 is the inverse of the first calibration parameter under A light. Correspondingly, the white balance gain of the second calibration parameter under H light is embodied as a parameter point L1', and the coordinate value of the parameter point L1' is the inverse of the second calibration parameter under H light; the white balance gain of the second calibration parameter under A light is embodied as a parameter point L2', and the coordinate value of the parameter point L2' is the inverse of the second calibration parameter under A light. At this time, the target parameter is the deltaC of the 24th card 20-23 color block, which satisfies deltaC≤1, that is, the parameter point L1' and the parameter point L2' are more accurate white balance gains for H light and A light.
[0065] The line connecting the first calibration parameters of each standard light source (i.e. the line connecting the parameter point L1 and the parameter point L2) is defined as the first calibration parameter curve. The line connecting the second calibration parameters of each standard light source (i.e. the line connecting the parameter point L1' and the parameter point L2') is defined as the second calibration parameter curve.
[0066] The white balance gain obtained after taking the inverse of the white balance statistical information (i.e. R / G, B / G) is embodied as the state point S and the state point Sa in the gain coordinate system. The state point S falls between the parameter point L1 and the parameter point L2, and is close to the parameter point L1, which is used to represent the case that the state point S is more greatly affected by the weight of the parameter point H light; the state point Sa falls between the parameter point L1 and the parameter point L2, and is close to the parameter point L2, which is used to represent the case that the state point Sa is more greatly affected by the weight of the parameter point A light.
[0067] The principle of the new white balance gain compensation is to find a suitable target point based on the known first calibration parameter, second calibration parameter and state point, so that the target point is close to the second calibration parameter curve, thereby achieving the purpose of compensating the white balance gain.
[0068] The parameter point L1' and the parameter point L2' in the second calibration parameter curve are the results after the white balance gain compensation of the parameter point L1 and the parameter point L2, therefore, the target point G and the target point Ga should be closer to the second calibration parameter curve. Compared with the state point S and the state point Sa which are closer to the first calibration parameter curve, the target point G and the target point Ga have more accurate white balance gain.
[0069] After the coordinate values of the state point S and the coordinate values of the state point Sa are processed by the adjustment coefficient, the first adjustment point S1' and the first adjustment point Sa1' are obtained. Because the state point S, the reference point L1, the reference point L1' and the first adjustment point S1' form a parallelogram, and the state point Sa, the reference point L1, the reference point L1' and the first adjustment point Sa1' form a parallelogram, based on the law of parallelogram, the change amount between the coordinate values of the parameter point L1 and the coordinate values of the parameter point L1' is the change amount between the state point S and the first adjustment point S1', and also the change amount between the state point Sa and the first adjustment point Sa1'. Based on this, the change amount between the coordinate values of the parameter point L1 and the coordinate values of the parameter point L1' is taken as the adjustment coefficient for H light, at this time, the coordinate values of the parameter point L1' can meet the target condition of H light. Therefore, the coordinate values of the first adjustment point S1' and the coordinate values of the first adjustment point Sa1' after the adjustment coefficient processing can meet the target condition of H light.
[0070] Of course, the state point is not only related to H light, but also related to A light. Therefore, the second adjustment point S2' and the second adjustment point Sa2' are obtained by the above-mentioned method, and the coordinate values of the two are the results after the coordinate values of the state point S and the coordinate values of the state point Sa are processed by the adjustment coefficient based on A light. The coordinate values of the second adjustment point S2' and the coordinate values of the second adjustment point Sa2' can meet the target condition of A light.
[0071] Based on the above, the coordinate values of the state point S, the coordinate values of the reference point L1 and the coordinate values of the reference point L1' are known.
[0072] At this time, the first adjustment point S1' and the first adjustment point Sa1' are regarded as the gain after the H light part of the reference point S changes, and the second adjustment point S2' and the second adjustment point Sa2' are regarded as the gain after the A light part of the state point S changes. The final target point should also have the weight of the first adjustment point and the second adjustment point, in order to obtain more accurate coordinate values of the target point G and the coordinate values of the Ga point, here the method of the centroid of a triangle is adopted.
[0073] The following analyzes the case that the state point S is close to the reference point L1 to obtain the coordinate value of the target point G.
[0074] The state point S is close to the reference point L1 than the reference point L2, so the weight of the reference point L1' can be increased in the target point G. Therefore, the target point G is the gravity center of L1'S1'S2', and the target point G is composed of the reference point L1', the first adjustment point S1', and the second adjustment point S2' with corresponding weights. If the weights of the three are equal, the target point G is the gravity center of the triangle. The weights of the three can also be adjusted according to the actual test effect. The coordinates of the target point G are calculated as follows:
[0075] The coordinates of the parameter point L1 are (rg1, bg1), the coordinates of the parameter point L2 are (rg2, gb2), the coordinates of the parameter point L1' are (rg1', bg1'), the coordinates of the parameter point L2' are (rg2', gb2'), and the coordinates of the state point S are (rgs, bgs). The coordinates of the first adjustment point S1' are (rgs1', bgs1') and the coordinates of the second adjustment point S2' are (rgs2', bgs2').
[0076] Obviously, rgs1'=rgs+rg1'-rg1;
[0077] bgs1'=bgs+bg1'-bg1;
[0078] rgs2'=rgs+rg2'-rg2;
[0079] bgs2'=bgs+bg2'-bg2.
[0080] Set the weights m1, m2, and m3. The three parameters can be adjusted, but they must satisfy m1+m2+m3=1. Then the coordinates of the target point G are:
[0081] G_rg=m1*rg1'+m2*rgs1'+m3*rgs2';
[0082] G_bg=m1*bg1'+m2*bgs1'+m3*bgs2';
[0083] When m1=m2=m3, G is the gravity center.
[0084] Similarly, when the state point Sa is close to the reference point L2, the coordinates of the target point Ga are calculated in the same way. At this time, the coordinate value of the state point Sa, the coordinate value of the reference point L1 and the coordinate value of the reference point L1' are known. The state point Sa is close to the reference point L2 than the reference point L1, so the weight of the reference point L1' can be increased in the target point Ga. Therefore, the target point Ga is the barycenter of L1'Sa1'Sa2', which is composed of the reference point L1', the first adjustment point Sa1' and the second adjustment point Sa2' with corresponding weights. If the weights of the three are equal, the target point Ga is the barycenter of the triangle. The weights of the three can also be adjusted according to the actual test effect. The coordinates of the target point Ga can be obtained by referring to the above, which will not be described here.
[0085] For the case that the distances between the state point and the at least two parameter points corresponding to the first calibration parameter are the same, the method can be referred to Figure 4 .
[0086] At this time, the distances of the state point S to the reference points L1 and L2 are the same, and the first adjustment point S1' and the second adjustment point S2' can be found by using the parallelogram according to the method described above. However, when the barycenter of the triangle is determined, a single triangle cannot be taken as before. The triangle SL1L2 forms an isosceles triangle, which can be understood as that the weights of the H light and the A light in the state point S are equal. When the barycenter of the triangle is determined, the triangles S2'L1'S1' and S2'S1'L2' can be formed at the same time; the barycenter point G1 of the triangle S2'L1'S1' and the barycenter point G2 of the triangle S2'S1'L2' are determined; finally, the midpoint of the line connecting the barycenter point G1 and the barycenter point G2 is taken as the target point Gc. The coordinates of the target point Gc are taken as the compensated white balance gain.
[0087] In step S106, the coordinates of the target point are taken as the compensation value of the original gain, and the original image is adjusted for white balance to obtain a target image with a target white color.
[0088] Specifically, the coordinates of the target point are taken as the compensation value of the original gain, and the original gain is adjusted by using the compensation value to obtain a target white balance gain; and each pixel in the original image is multiplied by the target white balance gain to obtain a target image with a target white color.
[0089] In some embodiments, after the first calibration parameter is obtained, the relative color temperature of the target environment in which the original picture is located can also be estimated according to the first calibration parameter.
[0090] In some embodiments, before step S102, it further includes: obtaining white balance statistical information of the gray area in each standard light source.
[0091] Specifically, under each standard light source, a plurality of original pictures containing a target gray card are respectively photographed; the position of the target gray card is taken as the gray area of the original picture, and the average values of the pixels in the red channel, the blue channel and the green channel in the gray area are respectively counted; and the ratio of the average values of the pixels in the red channel to the average values of the pixels in the green channel and the average values of the pixels in the blue channel to the average values of the pixels in the green channel are calculated and integrated to obtain white balance statistical information for representing the pixel distribution state of the gray area.
[0092] According to the white balance gain compensation method S100 of the present disclosure, the calibration of the second calibration parameter is introduced, and the target parameter and the satisfaction condition can be customized. According to the setting of the target parameter, the target performance of the white balance has better accuracy or subjective preference performance. The implementation of the present disclosure does not need to increase an additional color temperature sensor, thereby reducing the hardware cost. The present disclosure also utilizes the method of constituting a parallelogram and a triangular gravity center weight, so that the white balance has better accuracy or subjective preference performance. The present disclosure does not need specific platform hardware support, and has good portability.
[0093] Figure 5 The white balance gain compensation device of the exemplary embodiment of the present disclosure is shown in a schematic diagram.
[0094] As Figure 5 shown, another aspect of the present disclosure provides a white balance gain compensation device 1000, which can include: a calibration parameter determination module 1002 configured to determine a plurality of calibration parameters according to the white balance statistical information of the gray area in each standard light source; a target point determination module 1004 configured to determine a target point satisfying a target condition in a gain coordinate system according to the white balance gain corresponding to the calibration parameters and the white balance gain corresponding to the white balance statistical information; and a compensation module 1006 configured to take the coordinate value of the target point as a compensation value of an original gain, to perform white balance adjustment on an original image to obtain a target image with a target white color.
[0095] The device can include corresponding modules for performing each or several steps in the above flowcharts. Therefore, each or several steps in the above flowcharts can be performed by corresponding modules, and the device can include one or more of these modules. The modules can be one or more hardware modules specially configured to perform the corresponding steps, or implemented by a processor configured to perform the corresponding steps, or stored in a computer readable medium for implementation by a processor, or implemented by some combination.
[0096] The hardware structure can be implemented using a bus architecture. The bus architecture can include any number of interconnecting buses and bridges, depending on the specific application of the hardware and overall design constraints. Bus 1100 connects various circuits including one or more processors 1200, memory 1300, and / or hardware modules together. Bus 1100 can also connect various other circuits 1400 such as peripheral devices, voltage regulators, power management circuits, external antennas, etc.
[0097] Bus 1100 can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one connection line is shown in the figure, but it does not mean that there is only one bus or one type of bus.
[0098] According to the white balance gain compensation device 1000 of the present disclosure, the calibration of the second calibration parameter is introduced, and the target parameter and the satisfaction condition can be customized. According to the setting of the target parameter, the target performance of the white balance has better accuracy or subjective preference performance. The implementation of the present disclosure does not need to increase an additional color temperature sensor, and the hardware cost is reduced. The present disclosure also uses the method of forming a parallelogram and a triangular gravity center weight, so that the white balance has better accuracy or subjective preference performance. The present disclosure does not need specific platform hardware support, and has good portability.
[0099] Any process or method descriptions, or steps of the flow diagrams described herein and elsewhere can be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps in the process. As will be understood by those skilled in the art, the scope of the preferred embodiments of the present disclosure encompassed by the claims also include alternative implementations in which the functions performed by the various processes described above are implemented by a state machine that is different from the state machine shown. The scope of the preferred embodiments of the present disclosure encompassed by the claims also include alternative implementations in which the functions performed by the various processes described above are implemented by a combination of dedicated hardware and executable instructions. The scope of the preferred embodiments of the present disclosure encompassed by the claims also include alternative implementations in which the functions performed by the various processes described above are implemented by a plurality of separate computers or processors, where these computers or processors are in electronic communication with each other, by wired or wireless communication means. The scope of the preferred embodiments of the present disclosure encompassed by the claims also include alternative implementations in which the functions performed by the various processes described above are implemented by one or more computers or processors that are remotely located with respect to the computer or processor that performs one or more other functions. The scope of the preferred embodiments of the present disclosure encompassed by the claims also include alternative implementations in which one or more of the processes described above are implemented by hardware, software, firmware, or a combination thereof.
[0100] The logic and / or steps represented in the flowcharts and / or otherwise described herein can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor- containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions.
[0101] For the purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-readable medium can specifically include the following, which are non-exhaustive examples: electrical connection (electrical device), portable computer diskette (magnetic device), Random Access Memory (RAM), Read-Only Memory (ROM), Erasable Programmable Read-Only Memory (EPROM or Flash memory), optical fiber device, and portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable medium upon which the program can be printed, as the program can be electronically captured, for example, via the optical scanner of the paper or other medium, then compiled, interpreted, or otherwise processed in the electronic manner, and then stored in the memory.
[0102] It should be understood that portions of the present disclosure can be implemented with hardware, software, or a combination thereof. In the above embodiments, a plurality of steps or methods can be implemented with software stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, and as in another embodiment, any of the following technologies known in the art or their combinations can be used: discrete logic circuitry having logic gates for implementing logic functions on data signals, application-specific integrated circuits having appropriate combinational logic gates, programmable gate arrays (PGA), field programmable gate arrays (FPGA), etc.
[0103] Those of ordinary skill in the art of the present technology can understand that all or part of the steps of the above-mentioned embodiments can be completed by programs instructing relevant hardware, and the programs can be stored in a readable storage medium. When executed, the programs include one of the steps of the method embodiments or a combination thereof.
[0104] In addition, in various embodiments of the present disclosure, each function unit can be integrated in one processing module, or each unit can be physically present separately, or two or more units can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module. When the integrated module is realized in the form of a software function module and sold or used as an independent product, it can also be stored in a readable storage medium. The storage medium can be a read-only memory, a magnetic disk or an optical disk, etc.
[0105] The present disclosure also provides an electronic device, comprising: a memory storing execution instructions; and a processor or other hardware module executing the execution instructions stored by the memory, so that the processor or other hardware module executes the compensation method of the white balance gain.
[0106] The present disclosure also provides a readable storage medium, which stores execution instructions for implementing the compensation method of the white balance gain when executed by a processor.
[0107] In the description of the present specification, the description of the terms "one embodiment / way", "some embodiments / ways", "an example", "a specific example", or "some examples" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment / way or example are included in at least one embodiment / way or example of the present disclosure. In the present specification, the illustrative description of the above terms is not necessarily the same embodiment / way or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in any one or more embodiments / ways or examples. In addition, the person skilled in the art can combine and combine the different embodiments / ways or examples described in the present specification and the features of the different embodiments / ways or examples without contradiction.
[0108] In addition, the terms "first", "second" are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "a plurality of" is at least two, for example, two, three, etc., unless otherwise specifically limited.
[0109] Those skilled in the art should understand that the above embodiments are only for the purpose of clearly illustrating the present disclosure, and are not intended to limit the scope of the present disclosure. Based on the above disclosure, other changes or modifications can also be made by those skilled in the art, and these changes or modifications are still within the scope of the present disclosure.
Claims
1. A method of compensating for white balance gain, characterized by, The method comprises the following steps: According to the white balance statistical information of the gray area in each standard light source, a plurality of calibration parameters are determined, including: taking the white balance statistical information of the gray area in each standard light source as the first calibration parameter corresponding to each standard light source, wherein the white balance statistical information represents the pixel distribution state of the gray area; calculating the white balance gain of the standard light source by using the inverse of the first calibration parameter; adjusting the sample image by using the white balance gain, and obtaining the target parameter corresponding to the adjusted sample image; in response to the judgment result that the target parameter meets the preset target condition, taking the white balance gain as the second calibration parameter of the standard light source; According to the white balance gain corresponding to the calibration parameter and the white balance gain corresponding to the white balance statistical information, a target point meeting the target condition is determined in a gain coordinate system, including: calculating at least two white balance gains corresponding to at least two standard light sources when each calibration parameter is used; determining a plurality of parameter points for representing the white balance gain corresponding to the calibration parameter, and a state point for representing the white balance gain corresponding to the white balance statistical information in the gain coordinate system; according to a plurality of parameter points and the state point, at least one gain geometry is constructed; based on the positional relationship of the state point relative to the parameter point, a target point meeting the target condition is determined in at least one gain geometry; Taking the coordinate value of the target point as the compensation value of the original gain, the original image is white balanced to obtain a target image with target white color, Wherein, according to a plurality of parameter points and the state point, at least one gain geometry is constructed, including: determining the adjustment coefficient between the white balance gain corresponding to the first calibration parameter and the white balance gain corresponding to the second calibration parameter under the same standard light source; based on the adjustment coefficient, the first adjustment point and the second adjustment point corresponding to each standard light source are determined; according to the distance between the state point and at least two parameter points corresponding to the first calibration parameter, at least one target parameter point is determined between at least two parameter points corresponding to the second calibration parameter; and taking the first adjustment point, the second adjustment point and at least one target parameter point as the vertex, at least one gain geometry is constructed.
2. The method of compensating for white balance gain according to claim 1, wherein, Before the step of taking the white balance gain as the second calibration parameter of the standard light source in response to the judgment result that the target parameter meets the preset target condition, the method further comprises the following steps: In response to the judgment result that the target parameter does not meet the target condition, the weight of the white balance gain is adjusted.
3. The method of compensating for white balance gain according to claim 1 or 2, wherein, Before the step of taking the white balance gain as the second calibration parameter of the standard light source in response to the judgment result that the target parameter meets the preset target condition, the method further comprises the following steps: The target condition for measuring the state of the target parameter is set.
4. The method of compensating for white balance gain according to claim 1, wherein, The target point meeting the target condition is determined in at least one gain geometry based on the positional relationship of the state point relative to the parameter point, including: when distances between the state point and at least two parameter points corresponding to the first calibration parameter are different, taking the barycenter of the gain geometry as the target point; and when distances between the state point and at least two parameter points corresponding to the first calibration parameter are the same, respectively determining barycenters of respective gain geometries, and taking a midpoint of a line between the barycenters as the target point.
5. An apparatus for compensating for white balance gain, characterized by comprising: a white balance gain compensating unit for compensating for a white balance gain of a camera based on a color temperature of a light source. The method comprises: The calibration parameter determination module is configured to determine a plurality of calibration parameters according to white balance statistical information of a gray area in each standard light source, including: taking the white balance statistical information of the gray area in each standard light source as a first calibration parameter corresponding to each standard light source, wherein the white balance statistical information represents a pixel distribution state of the gray area; calculating a white balance gain of the standard light source by using an inverse of the first calibration parameter; adjusting a sample image by using the white balance gain, and obtaining a target parameter corresponding to the sample image after the adjustment; and in response to a judgment result that the target parameter satisfies a preset target condition, taking the white balance gain as a second calibration parameter of the standard light source; The target point determination module is configured to determine a target point satisfying a target condition in a gain coordinate system according to a white balance gain corresponding to the calibration parameter and a white balance gain corresponding to the white balance statistical information, including: respectively obtaining at least two white balance gains when each calibration parameter corresponds to at least two standard light sources; determining, in the gain coordinate system, a plurality of parameter points for representing the white balance gain corresponding to the calibration parameter and a state point for representing the white balance gain corresponding to the white balance statistical information; constructing at least one gain geometry according to the plurality of parameter points and the state point; and determining, in at least one gain geometry, a target point satisfying the target condition based on a positional relationship of the state point relative to the parameter points; The compensation module is configured to take a coordinate value of the target point as a compensation value of an original gain, to perform white balance adjustment on an original image, and to obtain a target image with a target white color. The method comprises:
6. An electronic device, comprising: The memory stores execution instructions; The processor executes the execution instructions stored in the memory, so that the processor performs the white balance gain compensation method in any one of claims 1 to 4. The memory stores execution instructions; The processor executes the execution instructions stored in the memory, so that the processor performs the white balance gain compensation method in any one of claims 1 to 4.
7. A readable storage medium, characterized by, The readable storage medium stores execution instructions, and the execution instructions are used for implementing the white balance gain compensation method in any one of claims 1 to 4 when executed by the processor.
Citation Information
Patent Citations
White balance processing method and device, terminal device and memory medium
CN108377372A