White balance correction method and device, imaging equipment and storage medium
By combining information from ambient light sensors and image sensors, and using brightness weighting coefficients and gain for white balance correction, the problem of poor white balance effect in existing technologies is solved, achieving high accuracy and stability in image color reproduction under complex lighting conditions.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-26
- Publication Date
- 2026-03-24
AI Technical Summary
The automatic white balance scheme of existing imaging equipment relies on the zonal statistical method of image sensors, which is easily affected by scene content and light intensity, resulting in poor white balance effect, especially in large areas of high saturation color blocks or low light/strong light scenes.
An ambient light sensor is used to sense ambient light information and an image sensor is used to collect image information. The ambient light information is normalized by a brightness weighting coefficient. White balance correction is performed by combining ambient light gain and image gain. The brightness weighting coefficient and gain are determined by a preset lookup table and a linear regression algorithm to reduce lighting and scene interference.
It improves the accuracy and stability of white balance under different lighting conditions, reduces interference from large areas of saturated color blocks, and enhances the accuracy and consistency of image color reproduction.
Smart Images

Figure CN121728366A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image technology, and in particular to a white balance correction method, apparatus, imaging device, and storage medium. Background Technology
[0002] Automatic white balance technology is one of the core functions of imaging devices such as mobile terminals, cameras, and surveillance cameras. By adjusting the signal gain of the R, G, and B channels of the image, it can offset color shifts under different lighting conditions and restore the true colors of the scene.
[0003] Currently, automatic white balance solutions in imaging devices primarily rely on the image sensor's zonal statistical method. This involves sampling the acquired image in zones and calculating the average values of the R, G, and B channels to estimate color temperature and gain. However, relying solely on the image sensor's signal statistics in a single dimension is susceptible to interference from scene content and lighting intensity, resulting in poor white balance performance. For example, when there are large areas of highly saturated color blocks in the image, the zonal average value will significantly deviate from the characteristics of the actual light source; in low-light or high-light scenes, the image signal-to-noise ratio decreases, causing drastic fluctuations in the statistical values. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of this application provide a white balance correction method, apparatus, imaging device, and storage medium, which can improve the accuracy and stability of white balance.
[0005] In a first aspect, embodiments of this application provide a white balance correction method applied to an imaging device, the imaging device including an image sensor and an ambient light sensor. The method includes: acquiring ambient light information sensed by the ambient light sensor and image information acquired by the image sensor; normalizing the ambient light information according to a luminance weighting coefficient to obtain normalized ambient light information, wherein the luminance weighting coefficient is used to characterize the contribution of red light, blue light, and green light to luminance in the ambient light; determining an ambient light gain according to the normalized ambient light information; and performing white balance correction on the image information according to the ambient light gain and the image gain corresponding to the image information.
[0006] In some embodiments, the method further includes: performing infrared compensation on the ambient light information according to a preset infrared sensitivity coefficient to obtain the infrared-compensated ambient light information; The step of normalizing the ambient light information according to the brightness weighting coefficient to obtain normalized ambient light information includes: The infrared-compensated ambient light information is normalized according to the brightness weighting coefficient to obtain normalized ambient light information.
[0007] In some embodiments, the method further includes: determining a brightness weighting coefficient, comprising: searching a first preset lookup table based on the ambient light information to determine ambient light source information; and searching a second preset lookup table based on the ambient light source information to determine a brightness weighting coefficient.
[0008] In some embodiments, the first preset lookup table includes the correspondence between the ambient light information and the ambient light source information; the method further includes: establishing the first preset lookup table, including: acquiring multiple sets of current ambient light information sensed by the ambient light sensor based on preset ambient light sources; establishing the correspondence between the multiple sets of current ambient light information and preset ambient light source information; repeating the above steps for each preset ambient light source to establish the correspondence between the multiple sets of ambient light information and ambient light source information corresponding to each preset ambient light source, and storing it as the first preset lookup table.
[0009] In some embodiments, the second preset lookup table includes the correspondence between ambient light source information and brightness weighting coefficients; the method further includes: establishing the second preset lookup table, including: acquiring multiple sets of current ambient light information sensed by the ambient light sensor based on a preset ambient light source; Based on a preset infrared sensitivity coefficient, infrared compensation is performed on the multiple sets of current ambient light information to obtain the infrared-compensated multiple sets of ambient light information; based on the infrared-compensated multiple sets of ambient light information, a linear regression algorithm is used to obtain the brightness weight coefficients corresponding to the current red light, green light and blue light; a correspondence between the preset ambient light source information and the brightness weight coefficients is established. For each preset ambient light source, repeat the above steps to establish the correspondence between the ambient light source information and the brightness weight coefficient corresponding to each preset ambient light source, and store it as a second preset lookup table.
[0010] In some embodiments, the ambient light information includes red light information, green light information, and blue light information; the normalization process of the infrared-compensated ambient light information according to the brightness weighting coefficient to obtain normalized ambient light information includes: linearly combining the infrared-compensated red light information, green light information, and blue light information based on the brightness weighting coefficient to obtain a normalized reference value; and performing ratio calculations between the infrared-compensated red light information, green light information, and blue light information and the normalized reference value to obtain normalized red light information, green light information, and blue light information.
[0011] In some embodiments, the step of performing white balance correction on the image information based on the ambient light gain and the image gain corresponding to the image information includes: performing weighted fusion on the ambient light gain and the image gain according to a preset fusion weight to obtain a fusion gain; performing weighted fusion on the fusion gain corresponding to the image information of the previous frame and the fusion gain corresponding to the image information of the current frame according to a preset smoothing weight to obtain a correction gain; and performing white balance correction on the image information based on the correction gain.
[0012] Secondly, embodiments of this application provide a white balance correction device, including an acquisition module, a normalization module, a determination module, and a correction module. The acquisition module is used to acquire ambient light information sensed by the ambient light sensor and image information acquired by the image sensor. The normalization module is used to normalize the ambient light information according to a luminance weighting coefficient to obtain normalized ambient light information, wherein the luminance weighting coefficient is used to characterize the contribution of red, blue, and green light to the brightness in the ambient light. The determination module is used to determine the ambient light gain according to the normalized ambient light information. The correction module is used to perform white balance correction on the image information according to the ambient light gain and the image gain corresponding to the image information.
[0013] Thirdly, embodiments of this application provide an imaging device, including an image sensor, an ambient light sensor, at least one processor, and a memory. The image sensor is used to acquire image information, the ambient light sensor is used to sense ambient light information, the at least one processor is communicatively connected to the image sensor and the ambient light sensor respectively, and the memory is communicatively connected to the at least one processor. The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above-described method.
[0014] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed, implements the above-described method.
[0015] The beneficial effects of the embodiments of this application are as follows: Unlike related technologies, the embodiments of this application provide a white balance correction method, device, imaging equipment and storage medium. On the one hand, the ambient light information is normalized based on the brightness weighting coefficient, so that the normalized light information can better reflect the spectral characteristics of the light source and reduce the interference of brightness and large-area saturated colors in the scene. On the other hand, by combining the ambient light information sensed by the ambient light sensor and the image information collected by the image sensor, the gain is calculated in a two-dimensional collaborative manner to perform white balance correction, thereby improving the accuracy and stability of white balance under different lighting scenarios. Attached Figure Description
[0016] One or more embodiments are illustrated by way of example with reference to the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements having the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0017] Figure 1 This is a schematic diagram of the structure of an imaging device provided in an embodiment of this application; Figure 2 This is a schematic flowchart of a white balance correction method provided in an embodiment of this application; Figure 3 yes Figure 2 A schematic diagram of a sub-process of step S22 in the method; Figure 4 This is a schematic flowchart illustrating the process of determining luminance weighting coefficients provided in an embodiment of this application. Figure 5 yes Figure 2 A schematic diagram of a sub-process of step S24 in the method; Figure 6 This is a schematic diagram of a process for establishing a first preset lookup table provided in an embodiment of this application; Figure 7 This is a schematic diagram of a process for establishing a second preset lookup table provided in an embodiment of this application; Figure 8 This is a schematic flowchart of another white balance correction method provided in the embodiments of this application; Figure 9 This is a schematic diagram of another process for establishing a second preset lookup table provided in an embodiment of this application; Figure 10 This is a schematic diagram of a process for calibrating a preset infrared sensitivity coefficient provided in an embodiment of this application; Figure 11 This is a schematic diagram of the structure of a white balance correction device provided in an embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0019] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, all of which are within the protection scope of this application. In addition, the terms "first" and "second" used in this application do not limit the data, but only distinguish the same or similar items with basically the same function and effect.
[0020] Understandably, in real-world shooting scenarios, imaging devices such as smartphones, cameras, and surveillance cameras face complex and variable lighting conditions or interference from scene content. For example, outdoor shooting may encounter different lighting conditions such as strong sunlight on sunny days, weak light on cloudy days, and side lighting at dawn and dusk, resulting in large areas of monochromatic light in the image, such as grass. Indoor shooting often involves mixed light sources such as LED lights, fluorescent lights, and halogen lights. In these scenarios, images captured by imaging devices are prone to color reproduction distortion, thus affecting practical needs such as daily shooting experience and the recognizability of surveillance footage. Therefore, to enable imaging devices to reproduce the true colors of scenes under different lighting environments and eliminate color shifts, white balance technology is widely used in imaging devices. The basic concept of white balance is "to restore white objects to white regardless of any light source." For color casts that occur when shooting under specific light sources, compensation is made by strengthening the corresponding complementary color.
[0021] Currently, automatic white balance schemes in imaging devices mainly rely on the image sensor's zonal statistical method. This involves sampling the acquired image in zones and calculating the average values of the R, G, and B channels to estimate color temperature and gain. However, relying solely on the image sensor's signal statistics in a single dimension is still easily affected by scene content and lighting intensity, resulting in poor white balance performance. For example, when there are large areas of highly saturated color blocks in the image, the zonal average value will deviate significantly from the characteristics of the actual light source; in low-light or high-light scenes, the image signal-to-noise ratio decreases, causing drastic fluctuations in the statistical values.
[0022] To address the aforementioned technical issues, this application provides a white balance correction method, apparatus, imaging device, and storage medium to reduce interference from scene content and lighting, thereby improving the accuracy and stability of white balance under different lighting conditions.
[0023] The technical solution of this application is described in detail below with reference to the accompanying drawings: Example 1 Please see Figure 1 , Figure 1 This is a schematic diagram of the structure of an imaging device 100 provided in an embodiment of this application.
[0024] like Figure 1As shown, the imaging device 100 includes an image sensor 11, an ambient light sensor 12, at least one processor 13, and a memory 14. The at least one processor 13 is communicatively connected to the image sensor 11, the ambient light sensor 12, and the memory 14, respectively. The image sensor 11 is used to acquire image information, and the ambient light sensor 12 is used to sense ambient light information. The memory 14 stores at least one executable instruction. When the executable instruction is executed by the at least one processor 13, the at least one processor 13 is capable of performing the white balance correction method of any of the following embodiments.
[0025] In some embodiments, the image sensor 11 is provided with a red light acquisition channel, a green light acquisition channel, and a blue light acquisition channel for acquiring images of the scene and outputting image information including the pixel array and the grayscale values of each pixel in the red, green, and blue channels. The acquisition resolution and frame rate of the image sensor 11 are determined according to the actual shooting requirements. In some examples, the image sensor 11 can be a CMOS (Complementary Metal Oxide Semiconductor) image sensor or a CCD (Charge-Coupled Device) image sensor.
[0026] In some embodiments, the ambient light sensor 12 is provided with a red light detection channel, a green light detection channel, a blue light detection channel, and a brightness detection channel. The red light detection channel, green light detection channel, blue light detection channel, and brightness detection channel respectively sense the intensity of red light, green light, blue light, and ambient global light in the environment, and output the corresponding red light information, green light information, blue light information, and brightness information.
[0027] In some embodiments, the ambient light sensor 12 is further provided with an infrared light detection channel, which senses the intensity of infrared light in the environment and outputs the corresponding infrared light information.
[0028] In some embodiments, the imaging device 100 further includes a housing, in which an image sensor 11, an ambient light sensor 12, at least one processor 13, and a memory 14 are all disposed. The image sensor 11 and the ambient light sensor 12 are disposed independently. Specifically, on the housing, the light-receiving window corresponding to the image sensor 11 and the light-receiving window corresponding to the ambient light sensor do not overlap, thus avoiding optical path interference between them.
[0029] In some embodiments, the processor 13 and the memory 14 can be connected via a bus or other means. The processor 13 is used to execute the white balance correction method in any embodiment of this application, for example: acquiring ambient light information sensed by the ambient light sensor 12 and image information acquired by the image sensor 11; normalizing the ambient light information according to the brightness weighting coefficient to obtain normalized ambient light information, wherein the brightness weighting coefficient is used to characterize the contribution of red light, blue light and green light to brightness in the ambient light; determining the ambient light gain according to the normalized ambient light information; and performing white balance correction on the image information according to the ambient light gain and the image gain corresponding to the image information.
[0030] In some embodiments, the memory 14 serves as a non-volatile computer-readable storage medium, which can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the white balance correction method in the embodiments of the present invention. The processor 13 executes various functional applications and data processing of the imaging device 100 by running the non-volatile software programs, instructions, and modules stored in the memory 14, thereby implementing the white balance correction method of the method embodiments of the present application.
[0031] In some embodiments, memory 14 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 14 may optionally include memory remotely located relative to processor 13. Examples of the above-described networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0032] The white balance correction method in any embodiment of this application can be divided into one or more functional modules and stored in the memory 14. When executed by one or more processors 13, the white balance correction method in any embodiment of this application is executed.
[0033] Example 2 Please see Figure 2 , Figure 2 This is a schematic flowchart of a white balance correction method provided in an embodiment of this application.
[0034] The white balance correction method is applied to the imaging device. Specifically, the white balance correction method is stored in memory and executed by at least one processor.
[0035] like Figure 2 As shown, the white balance correction method includes the following steps: Step S21: Obtain ambient light information sensed by the ambient light sensor and image information acquired by the image sensor.
[0036] Specifically, in some embodiments, ambient light information includes red light information, green light information, and blue light information. The red light information, green light information, blue light information, and brightness information represent the light intensity values of red, green, and blue light in the environment, respectively, and are sensed through the red light detection channel, green light detection channel, and blue light detection channel of the ambient light sensor. The red light information, green light information, and blue light information of the ambient light are used to provide a basis for determining the brightness weighting coefficient.
[0037] In some embodiments, the ambient light information also includes brightness information, which represents the light intensity value of the ambient global light and is sensed through the brightness detection channel of the ambient light sensor. Combining the ambient light brightness information further improves the matching accuracy of the brightness weighting coefficient.
[0038] In some embodiments, the ambient light information also includes infrared light information. Infrared light information represents the intensity of infrared light in the environment and is sensed through the infrared light detection channel of the ambient light sensor. Combining the infrared light information of the ambient light further improves the matching accuracy of the brightness weighting coefficient.
[0039] In some embodiments, the image sensor acquires light signals of the current shooting scene in real time through red light acquisition channels, green light acquisition channels, and blue light acquisition channels, converts them into electrical signals, and outputs digital image information containing the pixel array and the grayscale values of each pixel's red, green, and blue channels after analog-to-digital conversion. The acquisition timing of this image information is synchronized with the acquisition timing of the ambient light information of the ambient light sensor to ensure consistency between the two in the time dimension.
[0040] Step S22: Normalize the ambient light information according to the brightness weighting coefficient to obtain normalized ambient light information.
[0041] Specifically, the brightness weighting coefficient is The components are red light weighting coefficient, green light weighting coefficient, and blue light weighting coefficient, which are used to characterize the contribution of red light, blue light, and green light to brightness in ambient light and quantify the contribution ratio of red light, green light, and blue light to ambient brightness in the current light source scenario.
[0042] Please see Figure 3 , Figure 3 yes Figure 2 A sub-process of step S22. Based on the brightness weighting coefficient and ambient light information, determine the ambient light gain, including: Step S221: Based on the luminance weighting coefficient, linearly combine the red, green, and blue light information in the ambient light information to obtain the normalized baseline value. W D .
[0043] , in, R, G , B These represent the light intensity values of red light, green light, and blue light in the ambient light.
[0044] Step S222: Ratio the red light information, green light information, and blue light information to the normalized reference value to obtain the normalized red light chromaticity value. r Green light chromaticity value g and blue light chromaticity value b This refers to the normalized ambient light information.
[0045]
[0046]
[0047]
[0048] Please see Figure 4 , Figure 4 This is a schematic diagram of a process for determining the brightness weighting coefficient provided in an embodiment of this application.
[0049] like Figure 4 As shown, the process for determining the brightness weighting coefficient includes: Step S41: Determine the ambient light source information by searching the first preset lookup table based on the ambient light information; The first preset lookup table includes the correspondence between ambient light information and ambient light source information, using ambient light information as the input index and ambient light source information as the output result. Ambient light source information includes at least the light source type, color temperature, and illuminance. Light source types include one or more of LED lamps, fluorescent lamps, halogen lamps, etc., with a color temperature range of 2300K~7500K and an illuminance range of 0.1 Lux~1000,000 Lux. Ambient light information includes red light information, green light information, and blue light information; or, it includes red light information, green light information, blue light information, and brightness information; or, it includes red light information, green light information, blue light information, brightness information, and infrared light information.
[0050] The search process involves inputting ambient light information and comparing it with the parameter standard intervals corresponding to each ambient light source pre-stored in the first preset lookup table. If the ambient light information falls within a certain standard interval, the ambient light source information bound to that interval is directly output. If the input ambient light information does not completely match any standard interval, the ambient light source information corresponding to the standard interval with the highest similarity is selected. Based on the degree of deviation between the ambient light information and the standard interval, the color temperature and illuminance are corrected using a linear interpolation algorithm to improve the matching degree between the output ambient light source information and the current actual lighting scene, providing a reliable basis for the weight coefficient search in step S42.
[0051] Step S42: Based on the ambient light source information, search the second preset lookup table to determine the brightness weighting coefficient.
[0052] The second preset lookup table includes the correspondence between ambient light source information and brightness weight coefficients, with ambient light source information as the input index and brightness weight coefficients as the output result.
[0053] When executing step S42, the ambient light source information determined in step S41 is first extracted, and this ambient light source information is input. The standard ambient light source information corresponding to each brightness weight coefficient in the first preset lookup table is compared. If the ambient light source information is consistent with the pre-stored standard ambient light source information, the corresponding brightness weight coefficient is directly output; if the ambient light source information is between two standard ambient light source information, the appropriate weight coefficient is calculated using a linear interpolation algorithm.
[0054] Step S23: Determine the ambient light gain based on the normalized ambient light information.
[0055] Specifically, the ambient light gain is determined based on the red light chromaticity values, green light chromaticity values, and blue light chromaticity values. Ambient light gain Including red light gain Green light gain and blue light gain .
[0056] Based on the fact that the human eye is highly sensitive to green light and that green light has a relatively stable proportion in the spectrum of most light sources, in some embodiments, the green light chromaticity value is used. g Standard reference value g ref Then there is, .
[0057] It is understood that in other embodiments, red light chromaticity values or blue light chromaticity values may be selected as standard reference values, or the three-channel average may be used as a comprehensive reference benchmark, depending on the specific needs of the actual application scenario, in order to adapt to different color balance requirements.
[0058] Step S24: Perform white balance correction on the image information based on the ambient light gain and the image gain corresponding to the image information.
[0059] Specifically, the image gain is The components are red light image gain, green light image gain, and blue light image gain, which are used to correct the brightness and color deviation of the three-channel grayscale values of the image.
[0060] In some embodiments, image gain can be obtained through partitioned statistical calculation. For example: the image pixel array is divided into multiple statistical region blocks; overexposed and underexposed abnormal pixels in each region block are removed; the average grayscale value and the average light intensity value of the three channels (red, green, and blue) of the remaining effective pixels in each region block are calculated; a first target region block with an average grayscale value falling within a preset neutral color grayscale value range is selected to reduce interference from overly bright or dark region blocks; for the first target region block, a second target region block is selected where the average light intensity value of the three channels (red, green, and blue) is within a preset neutral color range; the total average light intensity value of the three channels (red, green, and blue) of all second target region blocks is calculated; using the total average light intensity value of any one of the three channels (red, green, and blue) as a benchmark, the red light image gain, green light image gain, and blue light image gain are calculated. Neutral color refers to a color with no color bias where the average light intensity values of the three channels (red, green, and blue) are basically equal or approximately equal.
[0061] It is understood that the method for calculating image gain is not limited to the above. It can also be calculated using other algorithms, depending on the lighting characteristics of the actual application scenario and the hardware parameters of the imaging device. In some embodiments, the process of calculating image gain further includes: calculating the confidence level of different region blocks; assigning differentiated weights based on the confidence level of different region blocks: assigning higher weights to region blocks in the center of the image and region blocks with uniform color distribution, and assigning lower weights to region blocks at the edge of the image and region blocks with complex textures; and then calculating the image gain based on the weighted three-channel mean. This method can reduce the interference of edge distortion and complex textures on neutral color judgment, and is closer to the core area of human visual focus.
[0062] Specifically, please refer to the following: Figure 5 , Figure 5 yes Figure 2 A sub-process of step S24. Based on the ambient light gain and the image gain corresponding to the image information, white balance correction is performed on the image information, including: Step S241: According to the preset fusion weights, the ambient light gain and image gain are weighted and fused to obtain the fusion gain.
[0063] , in, For fusion gain, For ambient light gain, The preset fusion weights are used. These weights can be dynamically adjusted based on the image information's illumination uniformity, color deviation, and ambient light stability. For example, if the scene has uniform illumination and stable light sources, the preset fusion weights will favor ambient light gain. Values greater than 0.5 prioritize global color consistency; if there are significant differences in local lighting and obvious color deviations in the scene, the preset fusion weights favor image gain. If the value is less than 0.5, focus on correcting local deviations.
[0064] This application embodiment, by fusing ambient light gain and image gain, not only leverages ambient light gain to adapt to the spectral characteristics and lighting conditions of the global light source, improving the overall color consistency of the image, but also uses image gain to specifically correct brightness deviations and color imbalances in local scenes, achieving an effective combination of global adaptation and local optimization. Simultaneously, by dynamically adjusting preset fusion weights, the correction strategy can be flexibly switched according to the scene's lighting uniformity, color deviation degree, and light source stability, meeting the white balance correction needs under different lighting scenarios and improving the accuracy and adaptability of image color reproduction.
[0065] Step S242: According to the preset smoothing weight, the fusion gain corresponding to the image information of the previous frame and the fusion gain corresponding to the image information of the current frame are weighted and fused to obtain the correction gain.
[0066] , in, To correct the gain, The fusion gain corresponding to the image information of the previous frame. A preset smoothing weight is used. This preset smoothing weight can be adaptively adjusted based on the degree of dynamic change in the light source and the differences between image frames. For example, by calculating the fluctuation amplitude of ambient light information between the current frame and the previous frame, and the difference in the average grayscale values of the three channels between the two frames, scene stability is comprehensively determined. If the light source fluctuation is small and the inter-frame differences are small, A value of 0.7 to 0.8 can be used to enhance the weight of the fusion gain from the previous frame, making the correction gain smoother and avoiding screen flicker; if there are large fluctuations in the light source and significant differences between frames, A value of 0.2 to 0.3 is recommended, focusing on the fusion gain of the current frame to ensure timely correction and adaptation to scene changes; if it is in an intermediate state, A value of 0.4 to 0.6 can be used to balance smoothness and response speed.
[0067] Step S243: Perform white balance correction on the image information based on the correction gain.
[0068] Specifically, for each pixel in the image information pixel array, its original red light gray value, green light gray value, and blue light gray value are extracted and multiplied by the corresponding red light correction gain, green light correction gain, and blue light correction gain, respectively, to obtain the corrected three-channel gray value, thereby restoring the offset neutral color in the image to the standard neutral color and achieving the effect of white balance correction.
[0069] In some embodiments, please refer to Figure 6 , Figure 6 This is a schematic diagram of a process for establishing a first preset lookup table provided in an embodiment of this application.
[0070] like Figure 6 As shown, a first preset lookup table is established, including: Step S61: Based on the preset ambient light source, acquire multiple sets of current ambient light information sensed by the ambient light sensor.
[0071] Set up a light source testing environment, for example, in a darkroom to eliminate external stray light interference. Within this environment, set an ambient light source, selecting one or more types such as LED lights, fluorescent lights, halogen lights, or natural sunlight. Set the power of the light source to determine the illuminance and record the color temperature. Under an ambient light source with defined light source type, illuminance, and color temperature, continuously collect multiple sets of ambient light information using an ambient light sensor.
[0072] Step S62: Establish the correspondence between multiple sets of current ambient light information and preset ambient light source information.
[0073] For multiple sets of ambient light information of the same ambient light source in step S61, the minimum-maximum value direct determination method or the mean ± standard deviation determination method is used to obtain the standard range of each component parameter of the ambient light information, and then the correspondence between the "standard range of ambient light information parameters" and the "light source type-color temperature-illuminance" ambient light source information is established.
[0074] Step S63: For each preset ambient light source, repeat the above steps to establish the correspondence between multiple sets of ambient light information and ambient light source information corresponding to each preset ambient light source, and store them as a first preset lookup table.
[0075] By successively switching preset ambient light sources, steps S61 and S62 are repeated to obtain the standard range of ambient light information parameters and the corresponding ambient light source information for each type of ambient light source. The correspondences of all preset ambient light sources are integrated and stored as a formatted file to obtain the first preset lookup table.
[0076] Please see Figure 7 , Figure 7 This is a schematic diagram of a process for establishing a second preset lookup table provided in an embodiment of this application.
[0077] like Figure 7 As shown, a second preset lookup table is established, including: Step S71: Based on the preset ambient light source, acquire multiple sets of current ambient light information sensed by the ambient light sensor.
[0078] Multiple sets of ambient light information corresponding to the same ambient light source obtained in step S61 can be used. The ambient light information is ( R , G , B , W )or,( R, G , B , W , IR ).in, R , G , B , W , IR These are the light intensity values corresponding to red light, green light, blue light, brightness, and infrared light, respectively.
[0079] Step S72: Based on multiple sets of ambient light information, obtain the brightness weight coefficients corresponding to the current red light, green light and blue light through a linear regression algorithm.
[0080] according to For multiple sets of ambient light information, the luminance weighting coefficients corresponding to these multiple sets of ambient light information are calculated using the least squares method.
[0081] Step S73: Establish the correspondence between preset ambient light source information and brightness weighting coefficients.
[0082] Based on the multiple sets of ambient light information, obtain the corresponding ambient light source information and establish the correspondence between the "light source type-color temperature-illuminance" ambient light source information and the "brightness weighting coefficient".
[0083] Step S74: For each preset ambient light source, repeat the above steps to establish the correspondence between the ambient light source information and the brightness weight coefficient corresponding to each preset ambient light source, and store it as a second preset lookup table.
[0084] The preset ambient light source is switched sequentially, and steps S71 and S72 are repeated to obtain the brightness weight coefficient and corresponding ambient light source information for each type of ambient light source. The correspondence of all preset ambient light sources is integrated and stored as a formatted file to obtain the second preset lookup table.
[0085] In this embodiment, ambient light information is normalized based on a brightness weighting coefficient, making the normalized light information more reflective of the spectral characteristics of the light source and reducing interference from brightness and large areas of saturated colors in the scene. Furthermore, by combining ambient light information sensed by an ambient light sensor with image information acquired by an image sensor, a two-dimensional collaborative gain calculation is performed for white balance correction, improving the accuracy and stability of white balance correction under different lighting conditions.
[0086] Example 3 Because various ambient light sources in shooting scenes generally contain infrared light components, and infrared light has the characteristic of penetrating R, G, and B color filters, it simultaneously affects the photosensitive elements of the red, green, and blue light acquisition channels of the image sensor. Infrared light will create superimposed interference in the photosensitive signals of each R, G, and B channel, causing the R, G, and B signals, which are originally excited only by visible light, to be "elevated." This signal distortion will be carried over to subsequent white balance correction, affecting the final image quality.
[0087] Therefore, Embodiment 3 of this application provides another white balance correction method. The difference between this method and the white balance correction method provided in Embodiment 2 is that: in this embodiment, the ambient light information is further infrared compensated according to a preset infrared sensitivity coefficient to obtain infrared compensated ambient light information; the infrared compensated ambient light information is normalized according to a brightness weighting coefficient to obtain normalized ambient light information.
[0088] Please see Figure 8 , Figure 8 This is a flowchart illustrating another white balance correction method provided in an embodiment of this application.
[0089] like Figure 8 As shown, the white balance correction method includes the following steps: Step S81: Obtain ambient light information sensed by the ambient light sensor and image information acquired by the image sensor.
[0090] Step S82: Perform infrared compensation on the ambient light information according to the preset infrared sensitivity coefficient to obtain the infrared-compensated ambient light information.
[0091] Specifically, the preset infrared sensitivity coefficient is: Each component represents the response coefficient of the red light detection channel, green light detection channel, blue light detection channel, and brightness detection channel of the ambient light sensor to infrared light. This coefficient is obtained through pre-calibration and is used to quantify the degree of interference of infrared light on the detection results of each visible light channel.
[0092] The calculation formulas for infrared compensation of red, green, and blue light information are as follows. ; ; .
[0093] in, These are the light intensity values of red light, green light, and blue light after infrared compensation, respectively. This represents the intensity value of infrared light.
[0094] Step S83: Normalize the infrared-compensated ambient light information according to the brightness weighting coefficient to obtain normalized ambient light information.
[0095] Step S84: Determine the ambient light gain based on the normalized ambient light information.
[0096] Step S85: Perform white balance correction on the image information based on the ambient light gain and the image gain corresponding to the image information.
[0097] In this embodiment, step S81 has the same technical features as step S21 in Embodiment 2. Steps S83-S85 have the same calculation process as steps S22-S24 in Embodiment 2, except that steps S83-S85 are calculated based on the ambient light information after infrared compensation. The specific implementation method of Embodiment 2 is also applicable to this embodiment, therefore, it will not be described again in this embodiment.
[0098] Please see Figure 9 , Figure 9 This is a schematic diagram of another process for establishing a second preset lookup table provided in an embodiment of this application.
[0099] like Figure 9 As shown, a second preset lookup table is established, including: Step S91: Based on the preset ambient light source, acquire multiple sets of current ambient light information sensed by the ambient light sensor 2.
[0100] Step S92: Based on the preset infrared sensitivity coefficient, perform infrared compensation on multiple sets of current ambient light information to obtain multiple sets of infrared-compensated ambient light information.
[0101] Specifically, the calculation formulas for infrared compensation of red light information, green light information, blue light information, and brightness information are as follows: ; ; in, , These represent the light intensity values of red light, green light, blue light, and brightness light, respectively, after infrared compensation. This represents the intensity value of infrared light.
[0102] Step S93: Based on the multiple sets of ambient light information after infrared compensation, obtain the brightness weight coefficients corresponding to the current red light, green light and blue light through a linear regression algorithm.
[0103] Step S94: Establish the correspondence between preset ambient light source information and brightness weighting coefficients.
[0104] Step S95: For each preset ambient light source, repeat the above steps to establish the correspondence between the ambient light source information and the brightness weight coefficient corresponding to each preset ambient light source, and store it as a second preset lookup table.
[0105] In this embodiment, step S91 has the same technical features as step S71 in Embodiment 2. Steps S93-S95 have the same calculation process as steps S72-S74 in Embodiment 2, except that steps S93-S95 are calculated based on the ambient light information after infrared compensation. The specific implementation method of Embodiment 2 is also applicable to this embodiment, therefore, it will not be described again in this embodiment.
[0106] Please see Figure 10 , Figure 10 This is a schematic diagram of a process for calibrating a preset infrared sensitivity coefficient provided in an embodiment of this application.
[0107] like Figure 10 As shown, calibrating the preset infrared sensitivity coefficient includes: Step S101: Based on preset ambient light conditions, perform visible light selection processing on the current ambient light to obtain the first ambient light information sensed by the ambient light sensor.
[0108] Set up a light source testing environment, for example, by eliminating external stray light interference in a dark box. In the light source testing environment, ambient light can be emitted through a spectrally tunable light source simulator, and an ambient light source can be set, simulating one or more types of light sources such as LED lights, fluorescent lights, halogen lights, and natural sunlight on a sunny day. The power of the light source can be set to determine the illuminance and color temperature.
[0109] Based on the same ambient light source information, the light source simulator is controlled to perform light splitting, filtering and outputting light containing only visible light components, and the light information at this time is collected by the ambient light sensor to obtain the first ambient light information.
[0110] Step S102: If the intensity value of infrared light in the first ambient light information is less than a preset threshold, infrared selection processing is performed on the current ambient light to obtain the second ambient light information sensed by the ambient light sensor.
[0111] The preset threshold refers to the critical value of infrared light intensity used to determine whether the visible light selection process is thorough and whether there is no infrared light leakage. When the infrared light intensity value in the first ambient light information is less than the preset threshold, based on the same ambient light source information as in step S101, the light source simulator is controlled to perform light splitting, filtering and outputting light containing only infrared light components, and the light information at this time is collected by the ambient light sensor to obtain the second ambient light information. R′′ , G′′ , B′′ , W′′, IR′′ ).in, R′′, G′′, B′′, W′′, IR′′ These represent the light intensity values sensed by the red light detection channel, green light detection channel, blue light detection channel, brightness detection channel, and infrared light detection channel of the ambient light sensor under pure infrared light conditions.
[0112] Step S103: Calculate the ratio of the red light information, green light information, and blue light information in the second ambient light information to the infrared light information to determine the preset infrared sensitivity coefficient.
[0113] .
[0114] In this embodiment, infrared light compensation reduces the interference of infrared light information on white balance correction, thereby further improving the accuracy of white balance correction.
[0115] Example 4 Please see Figure 11 , Figure 11 This is a schematic diagram of the structure of a white balance correction device 200 provided in an embodiment of this application.
[0116] like Figure 11 As shown, the white balance correction device 200 includes an acquisition module 201, a normalization module 202, a determination module 203, and a correction module 204. The acquisition module 201 acquires ambient light information sensed by an ambient light sensor and image information acquired by an image sensor; the normalization module 202 normalizes the ambient light information according to a luminance weighting coefficient to obtain normalized ambient light information, where the luminance weighting coefficient characterizes the contribution of red, blue, and green light to brightness in the ambient light; the determination module 203 determines the ambient light gain based on the normalized ambient light information; and the correction module 204 performs white balance correction on the image information based on the ambient light gain and the corresponding image gain.
[0117] In some embodiments, the white balance correction device 200 further includes an infrared compensation module, which performs infrared compensation on the ambient light information according to a preset infrared sensitivity coefficient to obtain infrared-compensated ambient light information. Furthermore, the normalization module 202 uses the infrared-compensated ambient light information as input data when performing normalization processing.
[0118] In this embodiment, the white balance correction device 200 can be a software module. The software module includes several instructions, which are stored in a memory. The processor can access the memory and call the instructions to execute them in order to complete the white balance correction methods of the above embodiments.
[0119] In the embodiments of this application, the white balance correction device 200 can also be constructed from hardware devices. For example, the white balance correction device 200 can be constructed from one or more chips, and the chips can work together to complete the white balance correction method described in the above embodiments. Furthermore, the white balance correction device can also be constructed from various logic devices, such as general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), microcontrollers, ARM (Acorn RISC Machine) or other programmable logic devices, discrete gate or transistor logic, discrete hardware components, or any combination of these components.
[0120] The white balance correction device 200 in this application embodiment can be a device, or it can be a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This application embodiment does not specifically limit the scope.
[0121] The white balance correction device 200 in this embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this embodiment does not specifically limit its use.
[0122] The white balance correction device 200 provided in this application embodiment can realize all the processes implemented in the method embodiment of this application, and will not be described again here to avoid repetition.
[0123] It should be noted that the above-described device can execute the white balance correction method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the device embodiments can be found in the white balance correction method provided in the embodiments of this application.
[0124] In this embodiment, the accuracy and stability of white balance can be improved by the cooperation of the various modules of the white balance correction device 200.
[0125] Example 5 This application also provides a computer-readable storage medium storing a computer program or instructions that, when executed, implement the white balance correction method in any of the above method embodiments. For example, one or more processors can execute the white balance correction method in any of the above method embodiments, or execute the various steps described above.
[0126] The apparatus or device embodiments described above are merely illustrative. The unit modules described as separate components may or may not be physically separate, and the components shown as module units may or may not be physical units; that is, they may be located in one place or distributed across multiple network module units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0127] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a general-purpose hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM (read-only memory) / RAM (random access memory), magnetic disk, optical disk, etc., including several instructions for a computer device (which may be a personal computer, server, or network device, etc.) to execute the various embodiments or some parts of the embodiments.
[0128] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; under the concept of the present invention, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the present invention as described above, which are not provided in detail for the sake of brevity; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A white balance correction method applied to an imaging device, the imaging device comprising an image sensor and an ambient light sensor, characterized in that, The method includes: The ambient light information sensed by the ambient light sensor and the image information acquired by the image sensor are obtained; The ambient light information is normalized according to the brightness weighting coefficient to obtain normalized ambient light information. The brightness weighting coefficient is used to characterize the contribution of red light, blue light and green light to the brightness in the ambient light. The ambient light gain is determined based on the normalized ambient light information. Based on the ambient light gain and the image gain corresponding to the image information, white balance correction is performed on the image information.
2. The method according to claim 1, characterized in that, The method further includes: Based on a preset infrared sensitivity coefficient, the ambient light information is infrared compensated to obtain infrared compensated ambient light information. The step of normalizing the ambient light information according to the brightness weighting coefficient to obtain normalized ambient light information includes: The infrared-compensated ambient light information is normalized according to the brightness weighting coefficient to obtain normalized ambient light information.
3. The method according to claim 1, characterized in that, The method further includes: Determine the brightness weighting coefficients, including: Based on the ambient light information, the first preset lookup table is searched to determine the ambient light source information; The brightness weighting coefficient is determined by searching a second preset lookup table based on the ambient light source information.
4. The method according to claim 3, characterized in that, The first preset lookup table includes the correspondence between the ambient light information and the ambient light source information; The method further includes: Establish a first preset lookup table, including: Based on a preset ambient light source, multiple sets of current ambient light information sensed by the ambient light sensor are acquired; Establish the correspondence between the multiple sets of current ambient light information and preset ambient light source information; For each preset ambient light source, repeat the above steps to establish a correspondence between multiple sets of ambient light information and ambient light source information corresponding to each preset ambient light source, and store them as a first preset lookup table.
5. The method according to claim 3, characterized in that, The second preset lookup table includes the correspondence between ambient light source information and brightness weighting coefficients; The method further includes: Establish a second preset lookup table, including: Based on a preset ambient light source, multiple sets of current ambient light information sensed by the ambient light sensor are acquired; Based on a preset infrared sensitivity coefficient, infrared compensation is performed on the multiple sets of current ambient light information to obtain the multiple sets of ambient light information after infrared compensation. Based on the multiple sets of ambient light information after infrared compensation, the brightness weight coefficients corresponding to the current red light, green light and blue light are obtained through a linear regression algorithm. Establish the correspondence between the preset ambient light source information and the brightness weighting coefficient; For each preset ambient light source, repeat the above steps to establish the correspondence between the ambient light source information and the brightness weight coefficient corresponding to each preset ambient light source, and store it as a second preset lookup table.
6. The method according to claim 2, characterized in that, The ambient light information includes red light information, green light information and blue light information; The normalization process of the infrared-compensated ambient light information based on the brightness weighting coefficient to obtain normalized ambient light information includes: Based on the brightness weighting coefficient, the infrared-compensated red light information, green light information and blue light information are linearly combined to obtain a normalized reference value; The infrared-compensated red, green, and blue light information are compared with the normalized reference value to obtain the normalized red, green, and blue light information.
7. The method according to any one of claims 1-6, characterized in that, The step of performing white balance correction on the image information based on the ambient light gain and the image gain corresponding to the image information includes: According to the preset fusion weights, the ambient light gain and the image gain are weighted and fused to obtain the fusion gain; Based on the preset smoothing weights, the fusion gain corresponding to the image information of the previous frame and the fusion gain corresponding to the image information of the current frame are weighted and fused to obtain the correction gain. Based on the correction gain, white balance correction is performed on the image information.
8. A white balance correction device, characterized in that, The acquisition module is used to acquire ambient light information sensed by the ambient light sensor and image information acquired by the image sensor; The normalization module is used to normalize the ambient light information according to the brightness weighting coefficient to obtain normalized ambient light information. The brightness weighting coefficient is used to characterize the contribution of red light, blue light and green light to the brightness in the ambient light. The determination module is used to determine the ambient light gain based on the normalized ambient light information; The correction module is used to perform white balance correction on the image information based on the ambient light gain and the image gain corresponding to the image information.
9. An imaging device, characterized in that, include: Image sensors are used to acquire image information; An ambient light sensor is used to sense ambient light information. At least one processor is communicatively connected to the image sensor and the ambient light sensor, respectively. A memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program or instructions that, when executed, implement the method as described in any one of claims 1-7.