Automatic white balance method and controller
By correcting the pixel information of the overexposure area of the reference channel of the RGB image, the problem of poor correction effect of the white balance algorithm in the prior art when the G channel is overexposure is solved, and a better white balance effect is achieved.
Patent Information
- Application Number
- CN202311855668.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2025-07-01
AI Technical Summary
In the prior art, the white balance algorithm has poor correction effect when the G channel is overexposed, resulting in the overexposure area of the corrected image being expanded or biased towards magenta.
By correcting the pixel information of the overexposure area on the reference channel of the RGB image (such as the G channel), the correction gain is calculated, and the corrected reference channel is used to perform white balance correction with other color channels to avoid expansion of the overexposure area.
Improve the white balance effect, avoid the expansion of the overexposure area in the image, and ensure that the image color appears as pure white.
Smart Images

Figure HDA0004642149630000011 
Figure HDA0004642149630000012 
Figure HDA0004642149630000021
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and particularly to an automatic white balance method and a controller. Background Art
[0002] Automatic white balance is an image processing technology that can automatically adjust the white point in an image by analyzing the color information in the image, so that its color presents as "pure" white.
[0003] The wavelength range of white light is 390nm - 780nm. In the prior art, taking a color image in RGB mode as an example, the RGB image can be divided into three components: R channel, G channel, and B channel. When the G component is overexposed, using the statistical value of the G channel to calculate the gains of the R component and the B component, and then performing white balance correction on the R component and the B component according to the gains, it is easy to cause the overexposed area of the corrected image to expand. If it is corrected by reducing the correction gain, the image will tend to be magenta.
[0004] It can be seen that the white balance algorithm in the prior art has a problem of poor correction effect on overexposure. Summary of the Invention
[0005] This application provides an automatic white balance method and a controller to solve the problem that the white balance algorithm in the prior art has a poor correction effect on overexposure.
[0006] In a first aspect, this application provides an automatic white balance method, including:
[0007] Obtain a target image, where the target image includes multiple color channels, and at least one of the multiple color channels is a reference channel;
[0008] According to the pixel information of the color channels, correct the pixel information of the first overexposed area in the reference channel;
[0009] According to the corrected reference channel and the pixel information of the other color channels, correct the target image.
[0010] Optionally, the step of correcting the pixel information of the first overexposed area in the reference channel according to the pixel information of the color channels specifically includes:
[0011] When it is determined that there is the first overexposed area in the reference channel, determine the pixel positions corresponding to each of the first overexposed areas in the reference channel according to the pixel information of the reference channel;
[0012] Determine the brightness ratio of each color channel corresponding to each of the first overexposed regions according to the pixel information of the pixel positions corresponding to each of the first overexposed regions in each color channel;
[0013] According to the pixel information of the pixel positions corresponding to each of the first overexposed regions in each color channel and the brightness ratio of each color channel corresponding to each of the first overexposed regions, correct the pixel information of the pixel positions corresponding to each of the first overexposed regions in the reference channel.
[0014] Optionally, the method further includes:
[0015] When it is determined that there is no first overexposed region in the reference channel, do not correct the pixel information of the reference channel.
[0016] Optionally, the determination that there is a first overexposed region in the reference channel specifically includes:
[0017] Determine the overexposed pixel points with pixel values greater than or equal to a preset pixel value according to the pixel information of the reference channel;
[0018] Form adjacent overexposed pixel points into a connected region;
[0019] Obtain the area of each connected region;
[0020] When the area of the connected region is greater than or equal to a preset area, determine one of the connected regions as a first overexposed region.
[0021] Optionally, the determination of the brightness ratio of each color channel corresponding to each of the first overexposed regions according to the pixel information of the pixel positions corresponding to each of the first overexposed regions in each color channel specifically includes:
[0022] Determine the area of the second overexposed region of the pixel positions corresponding to each of the first overexposed regions in each color channel according to the pixel information of the pixel positions corresponding to each of the first overexposed regions in each color channel;
[0023] Statistically calculate the total area of the areas of the pixel positions corresponding to each of the first overexposed regions in each color channel;
[0024] Determine the brightness ratio of each color channel corresponding to each of the first overexposed regions according to the ratio of the area of the pixel positions corresponding to each of the first overexposed regions in each color channel to the total area.
[0025] Optionally, determining the brightness ratio of each color channel corresponding to each first overexposed area according to the ratio of the area of the region corresponding to each first overexposed area at the pixel position in each color channel to the total area specifically includes:
[0026] Calculating the ratio of the area of the region corresponding to each first overexposed area in each color channel to the total area;
[0027] Using a mapping function to map the ratio to obtain the brightness ratio of the color channel corresponding to the first overexposed area.
[0028] Optionally, the sum of the brightness ratios of each color channel corresponding to each first overexposed area is 1.
[0029] Optionally, correcting the pixel information at the pixel position corresponding to each first overexposed area in the reference channel according to the pixel information at the pixel position corresponding to each first overexposed area in each color channel and the brightness ratio of each color channel corresponding to each first overexposed area specifically includes:
[0030] Calculating the product of the pixel information at the pixel position corresponding to each first overexposed area in each color channel and the brightness ratio of each color channel corresponding to each first overexposed area to obtain the channel correction information of each first overexposed area in each color channel;
[0031] Accumulating the channel correction information of each color channel of each first overexposed area to obtain the region correction information of each first overexposed area;
[0032] Using the region correction information of each first overexposed area to replace the pixel information at the pixel position corresponding to the first overexposed area in the reference channel to obtain the pixel information of the corrected reference channel.
[0033] Optionally, correcting the target image according to the corrected reference channel and the pixel information of other color channels specifically includes:
[0034] Statistical sum of data of each color channel according to the corrected reference channel and the pixel information of other color channels;
[0035] Calculating a correction coefficient for each color channel according to the data sum of each color channel;
[0036] According to the correction coefficient of each color channel, correct the pixel information of each color channel in the target image to obtain the corrected target image.
[0037] Optionally, calculating the correction coefficient of each color channel according to the sum of data of each color channel specifically includes:
[0038] Calculate the ratio of the sum of data of the reference channel to the sum of data of each color channel, and determine the correction coefficient of each color channel.
[0039] In a second aspect, the present application provides an automatic white balance device, including:
[0040] An acquisition module, configured to acquire a target image, where the target image includes a plurality of color channels, and at least one color channel in the plurality of color channels is a reference channel;
[0041] A processing module, configured to correct the pixel information of the first overexposed area in the reference channel according to the pixel information of the color channels; and correct the target image according to the corrected reference channel and the pixel information of other color channels.
[0042] Optionally, the processing module is specifically configured to:
[0043] When it is determined that there is the first overexposed area in the reference channel, determine the pixel positions corresponding to each first overexposed area in the reference channel according to the pixel information of the reference channel;
[0044] Determine the brightness ratio of each color channel corresponding to each first overexposed area according to the pixel information of each color channel at the pixel positions corresponding to each first overexposed area;
[0045] Correct the pixel information at the pixel positions corresponding to each first overexposed area in the reference channel according to the pixel information of each color channel at the pixel positions corresponding to each first overexposed area and the brightness ratio of each color channel corresponding to each first overexposed area.
[0046] Optionally, the processing module is further configured to:
[0047] When it is determined that there is no first overexposed area in the reference channel, do not correct the pixel information of the reference channel.
[0048] Optionally, the processing module is specifically configured to:
[0049] Determine the exposed pixel points where the pixel value is greater than or equal to a preset pixel value according to the pixel information of the reference channel;
[0050] Form a connected region by combining adjacent exposed pixel points;
[0051] Obtain the area of each connected region;
[0052] When the area of the connected region is greater than or equal to a preset area, determine one of the connected regions as a first overexposed region.
[0053] Optionally, the processing module is specifically configured to:
[0054] Determine the area of the second overexposed region at the pixel position corresponding to each first overexposed region in each color channel according to the pixel information at the pixel position corresponding to each first overexposed region in each color channel;
[0055] Statistically calculate the area of each color channel at the pixel position corresponding to each first overexposed region to obtain the total area;
[0056] Determine the brightness ratio of each color channel corresponding to each first overexposed region according to the ratio of the area of each color channel at the pixel position corresponding to each first overexposed region to the total area.
[0057] Optionally, the processing module is specifically configured to:
[0058] Calculate the ratio of the area of each color channel at the pixel position corresponding to each first overexposed region to the total area;
[0059] Use a mapping function to map the ratio to obtain the brightness ratio of the color channel corresponding to the first overexposed region.
[0060] Optionally, the sum of the brightness ratios of each color channel corresponding to each first overexposed region is 1.
[0061] Optionally, the processing module is specifically configured to:
[0062] Calculate the product of the pixel information of each color channel at the pixel position corresponding to each first overexposed region and the brightness ratio of each color channel corresponding to each first overexposed region to obtain the channel correction information of each first overexposed region in each color channel;
[0063] Accumulate the channel correction information of each color channel of each first overexposed region to obtain the region correction information of each first overexposed region;
[0064] Replace the pixel information at the pixel positions corresponding to the first overexposed regions in the reference channel with the region correction information of each of the first overexposed regions, to obtain the pixel information of the corrected reference channel.
[0065] Optionally, the processing module is specifically configured to:
[0066] According to the pixel information of the corrected reference channel and the pixel information of the other color channels, count the data sum of each color channel;
[0067] Calculate the correction coefficient of each color channel according to the data sum of each color channel;
[0068] According to the correction coefficient of each color channel, correct the pixel information of each color channel in the target image, to obtain the corrected target image.
[0069] Optionally, the processing module is specifically configured to:
[0070] Calculate the ratio of the data sum of the reference channel to the data sum of each color channel, and determine the correction coefficient of each color channel.
[0071] In a third aspect, the present application provides a controller, including: a memory and a processor;
[0072] The memory is used to store a computer program; the processor is used to execute the method in the first aspect and any possible design of the first aspect according to the computer program stored in the memory.
[0073] In a fourth aspect, the present application provides a computer-readable storage medium, in which a computer program is stored. When at least one processor of the controller executes the computer program, the controller executes the method in the first aspect and any possible design of the first aspect.
[0074] In a fifth aspect, the present application provides a computer program product, the computer program product includes a computer program. When at least one processor of the controller executes the computer program, the controller executes the method in the first aspect and any possible design of the first aspect.
[0075] The automatic white balance method and controller provided by this application obtain a target image from the outside. The target image can be a multi-channel color image, and at least one reference channel can be included in multiple color channels of the target image. After obtaining the pixel information of the reference channel in the target image, it can be determined whether there is an overexposed area in the reference channel. If there is an overexposed area in the reference channel, the at least one overexposed area can be named the first overexposed area. According to the pixel information of each other color channel, the pixel information in the first overexposed area is corrected. Otherwise, if there is no overexposed area in the reference channel, the reference channel is not corrected. The corrected reference channel is used as the new reference channel. During the white balance calculation process, the new reference channel is used to compare with each other color channel to determine the correction coefficient of each other color channel, and the color channel is corrected using the correction coefficient to obtain the corrected target image, so as to realize the situation of the expansion of the overexposed area during the white balance calculation process and improve the white balance effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] In order to more clearly illustrate the technical solutions in this application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0077] Figure 1 It is a flowchart of an automatic white balance method provided by an embodiment of this application;
[0078] Figure 2 It is a flowchart of an automatic white balance method provided by an embodiment of this application;
[0079] Figure 3 It is a flowchart of an automatic white balance method provided by an embodiment of this application;
[0080] Figure 4 It is a flowchart of an automatic white balance example provided by an embodiment of this application;
[0081] Figure 5 It is a schematic structural diagram of an automatic white balance device provided by an embodiment of this application;
[0082] Figure 6 It is a schematic hardware structure diagram of a controller provided by an embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0083] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be clearly and completely described below with reference to the accompanying drawings in the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts shall fall within the scope of protection of the present application.
[0084] The terms "first", "second", "third", "fourth", etc. in the specification and claims of the present application and the above-mentioned accompanying drawings are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances. For example, without departing from the scope of this article, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0085] Automatic white balance is an image processing technology that automatically adjusts the white point in an image by analyzing the color information in the image so that its color appears as "pure" white. Since the wavelength region of white light involves 390nm - 780nm. Therefore, in an RGB image, for some scenes where the G channel is overexposed, using the statistically obtained gain to correct the R channel and the B channel will instead cause the overexposed area in the corrected image to expand. If the image is corrected by reducing the correction increment, the image will instead tend to be magenta. In summary, in the prior art, there is a problem of poor correction effect for scenes where the G channel is overexposed during automatic white balance.
[0086] Based on this situation, the present application proposes an automatic white balance method. This automatic white balance method can achieve automatic white balance correction under overexposure. Since the phenomenon of the overall overexposed area in the corrected image in the prior art is mainly caused by the overexposure of the G channel. Therefore, the method of the present application first corrects the G channel. And uses the corrected G channel together with the initial R channel and B channel to perform white balance processing on the image.
[0087] Through the three steps of counting the overexposed areas of the RGB three color channels, correcting the pixel information of the G channel, and calculating the correction gain, the white balance effect of the image is improved, and the expansion of the overexposed area is avoided. Among them, the key to the above steps lies in the correction of the pixel information of the G channel. Since the basis for the correction gain is the G channel data, if there is an overexposure phenomenon in the G channel, the correction gain will be greater than 1, which will lead to the expansion of the overexposed areas of the other two channels and the increase of the overexposed area of the finally output color image. Therefore, correcting the overexposed area of the G channel based on the pixel data of the R and B channels can greatly alleviate the expansion of the overexposed area and avoid the influence of the overexposed area on other areas in the image.
[0088] Based on the above RGB image, for 4-channel color images such as CMYK, the white balance also needs to be achieved based on a reference channel. Therefore, the method of this application can also be used to correct the reference channel first to improve the white balance effect. By analogy, for multi-channel color images, the method of this application can first correct the overexposed area in the reference channel, and then based on the reference channel, achieve the white balance correction of the multi-channel color image.
[0089] The technical solution of this application will be described in detail below with specific embodiments. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0090] Figure 1 The flowchart of an automatic white balance method provided by an embodiment of this application is shown. As Figure 1 shown, the method of this embodiment may include the following steps:
[0091] S101. Obtain a target image, where the target image includes multiple color channels, and at least one of the multiple color channels is a reference channel.
[0092] In this embodiment, the target image can be obtained from the outside. The target image can be a multi-channel color image. For example, the data mode of the color image can be the RGB mode, or the CMYK mode, etc. After obtaining the target image, the multiple color channels in the target image can be split into multiple sub-blocks. Each sub-block can include the pixel information of the color channel. Specifically, the pixel information of each sub-block can be the pixel matrix of the color channel.
[0093] Optionally, obtain the reference channel among them. For example, in an RGB color image, the reference channel can be the G channel.
[0094] S102. Correct the pixel information of the first overexposed area in the reference channel according to the pixel information of the color channel.
[0095] In this embodiment, when there is an overexposure phenomenon in the reference channel, if the reference channel is directly used to perform white balance correction on the target image, it may cause the overexposed area to expand in the target image. Therefore, the pixel information of the overexposed area of the reference channel can be corrected to improve the effect of subsequent automatic white balance.
[0096] After obtaining the pixel information of the reference channel, it is first necessary to determine whether there is an overexposed area in the reference channel.
[0097] If there is an overexposed area in the reference channel, the at least one overexposed area can be named the first overexposed area. After subsequent processing, the pixel information in the first overexposed area can be corrected according to the pixel information of each of the other color channels.
[0098] Otherwise, if there is no overexposed area in the reference channel, the reference channel may not be corrected.
[0099] S103. Correct the target image according to the corrected reference channel and the pixel information of other color channels.
[0100] In this embodiment, the corrected reference channel is used as the new reference channel. During the white balance calculation process, the new reference channel is used to compare with each of the other color channels to determine the correction coefficient of each of the other color channels, and the color channel is corrected using the correction coefficient. When the correction of all color channels is completed, the corrected target image can be obtained. The corrected target image is the target image obtained by performing white balance calculation using the corrected reference channel.
[0101] The automatic white balance method provided by this application obtains a target image from the outside. The target image can be a multi-channel color image. At least one reference channel can be included in multiple color channels of the target image. After obtaining the pixel information of the reference channel in the target image, it can be determined whether there is an overexposed area in the reference channel. If there is an overexposed area in the reference channel, the at least one overexposed area can be named as the first overexposed area. According to the pixel information of each other color channel, the pixel information in the first overexposed area is corrected. Otherwise, if there is no overexposed area in the reference channel, the reference channel can be not corrected. The corrected reference channel is used as a new reference channel. During the white balance calculation process, the new reference channel is used to compare with each other color channel to determine the correction coefficient of each other color channel, and the color channel is corrected using the correction coefficient to obtain a corrected target image. In this application, by correcting the pixel information of the first overexposed area in the reference channel, the situation of the expansion of the overexposed area during the white balance calculation process is avoided, and the white balance effect is improved.
[0102] Figure 2 The flowchart of an automatic white balance method provided by an embodiment of this application is shown. In Figure 1 On the basis of the shown embodiment, as Figure 2 shown, wherein step S102 can include the following steps:
[0103] S201. When it is determined that there is a first overexposed area in the reference channel, according to the pixel information of the reference channel, determine the pixel position corresponding to each first overexposed area in the reference channel.
[0104] In this embodiment, after obtaining the pixel information of the reference channel, first determine whether there is an overexposed area in the reference channel. If there is an overexposed area, name the overexposed area as the first overexposed area. Among them, the specific process of determining whether there is a first overexposed area in the reference channel can include the following steps:
[0105] Step 1. According to the pixel information of the reference channel, determine the exposed pixel points whose pixel values are greater than or equal to the preset pixel value.
[0106] In this step, the pixel values in the pixel information can be judged according to the set preset pixel value. The preset pixel value can be determined according to the bit depth of the image and is the maximum pixel value that the image can reach. For example, when the bit depth of the image is 8 bits, the maximum pixel value of the image is 255. The preset pixel value can be 255.
[0107] Obtain the pixel information of the reference channel. The pixel information may include the pixel values of each pixel point in the pixel matrix corresponding to the reference channel. Compare the pixel values of each pixel point with the preset pixel value. Obtain the pixel points whose pixel values are greater than or equal to the preset pixel value. Take these pixel points as the exposure pixel points.
[0108] Step 2: Combine adjacent exposure pixel points into a connected region.
[0109] In this step, according to the positional relationship between these exposure pixel points, connect adjacent exposure pixel points into a connected region. Based on these exposure pixel points, form one or more connected regions.
[0110] Step 3: Obtain the area of each connected region.
[0111] In this step, by counting the number of pixel points in each connected region, determine the area of the connected region. Optionally, when each point included in the pixel matrix of the reference channel corresponds to a pixel region, each exposure pixel point may correspond to a pixel region. The area may be the number of pixel regions. Or, the area may be the number of pixel points in the connected region.
[0112] Step 4: When the area of the connected region is greater than or equal to the preset area, determine a connected region as a first overexposed region.
[0113] In this step, according to the set preset area, determine whether the connected region is a first overexposed region. The preset area can be set by the technician. Compare the area of each connected region obtained in the above steps with the preset area. If the area of a connected region is less than the preset area, it means that the connected region is too small and the connected region may not be regarded as a first overexposed region. Otherwise, if the area of a connected region is greater than or equal to the preset area, it means that the area of the connected region is large enough and can be used as a first overexposed region. That is, obtain the region in the at least one connected region whose area is greater than or equal to the preset area as the first overexposed region.
[0114] When there is a first overexposed region in the reference channel, according to the positions of the pixel points corresponding to each first overexposed region, the pixel positions of each first overexposed region can be determined. The pixel position is actually the set of pixel points of the first overexposed region.
[0115] S202: According to the pixel information of each color channel corresponding to the pixel position of each first overexposed region, determine the brightness ratio of each color channel corresponding to each first overexposed region.
[0116] In this embodiment, after determining that there is at least one overexposed area in the reference channel, these overexposed areas can be processed one by one.
[0117] Obtain the pixel positions corresponding to an overexposed area. According to the pixel positions corresponding to the overexposed area, obtain the pixel information of the pixel positions from each color channel. Calculate the brightness ratio of each color channel corresponding to the first overexposed area according to the pixel information of the pixel positions in each color channel.
[0118] During the process of processing one by one, the brightness ratio of each color channel corresponding to each first overexposed area can be obtained.
[0119] In one example, for a first overexposed area, the sum of the brightness ratios of all its color channels can be 1.
[0120] Specifically, the calculation process of the brightness ratio of each color channel corresponding to each overexposed area can include:
[0121] Step 1: Determine the area of the second overexposed area of the pixel position corresponding to each first overexposed area in each color channel according to the pixel information of the pixel position corresponding to each first overexposed area in each color channel.
[0122] In this step, after determining the pixel position corresponding to a first overexposed area, obtain the pixel information corresponding to the pixel position from each color channel. According to the pixel values in the pixel information, count the number of overexposed pixel points whose pixel values are greater than or equal to the preset pixel value. Take this number of pixel points as the area of the color channel. The overexposed pixel points can form a second overexposed area existing inside the pixel position corresponding to the first overexposed area.
[0123] After completing the processing of each first overexposed area, the area of the second overexposed area in the pixel position corresponding to each overexposed area can be obtained.
[0124] Step 2: Count the area of the pixel position corresponding to each first overexposed area in each color channel to obtain the total area.
[0125] In this step, for a first overexposed area, the sum of the areas of each color channel corresponding to the first overexposed area can be counted. This sum is the total area. During the process of processing each first overexposed area one by one, the total areas corresponding to each first overexposed area can be counted one by one.
[0126] Step 3: Determine the brightness ratio of each color channel corresponding to each first overexposed area according to the ratio of the area of the pixel position corresponding to each first overexposed area in each color channel to the total area.
[0127] In this step, after determining the total area corresponding to a first overexposed area, the area of each color channel corresponding to the first overexposed area can be used for calculation with this total area. Specifically, the area of the color channel can be used one by one to calculate the ratio of the area of this region to the total area. Based on this ratio, further, the brightness ratio of this color channel of the first overexposed area can be obtained. In this way, the brightness ratio of each color channel corresponding to each first overexposed area can be calculated.
[0128] Among them, the process of determining the brightness ratio according to the ratio may include:
[0129] Step 3.1: Calculate the ratio of the area of the region to the total area in each color channel corresponding to each first overexposed area.
[0130] In this step, by calculating the ratio of the area of a region in a color channel corresponding to a first overexposed area to the total area corresponding to the first overexposed area, the ratio of each color channel corresponding to each first exposure area is obtained.
[0131] Step 3.2: Use a mapping function to map the ratio to obtain the brightness ratio of the color channel corresponding to the first overexposed area.
[0132] In this step, for areas with obvious overexposure phenomena, such as the reference channel, during correction, the proportion of its own pixel information should be smaller. Therefore, a negatively correlated mapping function needs to be introduced to achieve the calculation of the final brightness ratio. Optionally, the mapping function can be a simple linear function.
[0133] The mapping function can be a preset mapping function. After obtaining a ratio, this ratio can be input into the mapping function. Through this mapping function, the brightness ratio of this color channel of the first exposure area can be calculated. By mapping each ratio, the brightness ratio of each color channel corresponding to each first overexposed area can be obtained.
[0134] S203: According to the pixel information of the pixel positions corresponding to each first overexposed area in each color channel and the brightness ratio of each color channel corresponding to each first overexposed area, correct the pixel information of the pixel positions corresponding to each first overexposed area in the reference channel.
[0135] In this embodiment, the brightness ratio of each color channel corresponding to a first overexposed area is obtained. And the pixel information of the pixel area corresponding to the first overexposed area in each color channel is obtained. Calculate the product of the pixel information of each color channel and this brightness ratio. And accumulate the products of all color channels corresponding to the first overexposed area to obtain the corrected pixel information of the first overexposed area in the reference channel.
[0136] Specifically, the correction process of the pixel information in the first overexposed area of the reference channel may include the following steps:
[0137] Step 1: Calculate the product of the pixel information of the pixel positions corresponding to each first overexposed area in each color channel and the brightness ratio of each color channel corresponding to each first overexposed area, to obtain the channel correction information of each first overexposed area in each color channel.
[0138] In this step, obtain the pixel information of the pixel positions corresponding to a first overexposed area in each color channel. Obtain the brightness ratio of this first overexposed area corresponding to each color channel. Calculate the product of the brightness ratio of a color channel and the pixel information in this first overexposed area. This product is the channel correction information of this color channel of this first overexposed area.
[0139] Calculate one by one for each color channel of each first overexposed area, to obtain the channel correction information of each color channel of each first overexposed area.
[0140] Step 2: Accumulate the channel correction information of each color channel of each first overexposed area, to obtain the area correction information of each first overexposed area.
[0141] In this step, add up the channel correction information of each color channel corresponding to the first overexposed area to be processed, to obtain the area correction information of this first overexposed area. Furthermore, calculate one by one for each first overexposed area, to obtain the area correction information of each first overexposed area.
[0142] Step 3: Use the area correction information of each first overexposed area to replace the pixel information at the pixel positions corresponding to the first overexposed area in the reference channel, to obtain the pixel information of the corrected reference channel.
[0143] In this step, use the area correction information of a first overexposed area to replace the pixel information at the pixel position corresponding to this first overexposed information in this reference channel. When the replacement is completed using the area correction information of all first overexposed areas, the obtained pixel information of the reference channel is the pixel information of the corrected reference channel.
[0144] The automatic white balance method provided by this application, after obtaining the pixel information of the reference channel, first determines whether there is a first overexposed area in the reference channel. When there is a first overexposed area in the reference channel, according to the positions of the pixel points corresponding to each first overexposed area, the pixel positions of each first overexposed area can be determined. This pixel position is actually the set of pixel points of the first overexposed area. According to the pixel positions corresponding to the overexposed area, pixel information at these pixel positions is obtained from each color channel. According to the pixel information at these pixel positions in each color channel, the brightness ratio of each color channel corresponding to the first overexposed area is calculated. According to the brightness ratio of each color channel corresponding to a first overexposed area and the pixel information of the pixel area corresponding to the first overexposed area in each color channel, the product of the pixel information and the brightness ratio is calculated. And the products of all color channels corresponding to the first overexposed area are accumulated to obtain the corrected pixel information of the first overexposed area in the reference channel. In this application, by correcting the overexposed area in the reference channel, the effect of automatic white balance is improved, and the problem of the overexposed area of the target image expanding due to the overexposed area of the reference channel during the white balance process is avoided.
[0145] Figure 3 The flowchart of an automatic white balance method provided by an embodiment of this application is shown. In Figure 1 and Figure 2 On the basis of the shown embodiment, as Figure 3 shown, step S103 may include the following steps:
[0146] S301. According to the pixel information of the corrected reference channel and other color channels, the data sum of each color channel is statistically calculated.
[0147] In this embodiment, the corrected reference channel is obtained, and the data sum of the reference channel is statistically calculated. Other color channels are obtained, and the data sums of other color channels are statistically calculated. The data sum can be obtained by accumulating the pixel values of each pixel point in the pixel information of the color channel.
[0148] S104. According to the data sum of each color channel, the correction coefficient of each color channel is calculated.
[0149] In this embodiment, the correction coefficient is the correction gain. Since in this application, the reference channel is used as the reference channel data, the correction coefficient of the reference channel can be 1. According to the data sum of the reference channel and the data sum of each color channel, the correction coefficient of the color channel can be determined. Optionally, the correction coefficient can be obtained by calculating the ratio of the data sum of the reference channel to the data sum of each color channel.
[0150] S105. Correct the pixel information of each color channel in the target image according to the correction coefficient of each color channel to obtain the corrected target image.
[0151] In this embodiment, after obtaining the correction coefficient of each color channel, multiply the correction coefficient by the pixel information of the color channel to obtain the corrected pixel information of the color channel. Optionally, for the reference channel, the pixel information of the reference channel can be the corrected pixel information. The corrected pixel information of each color channel constitutes the corrected target image.
[0152] The automatic white balance method provided in this application obtains the corrected reference channel and calculates the sum of data of the reference channel. Obtain other color channels and calculate the sum of data of other color channels. The correction coefficient of the reference channel can be 1. According to the ratio of the sum of data of the reference channel to the sum of data of each color channel, the correction coefficient of the color channel can be determined. Multiply the correction coefficient by the pixel information of the color channel to obtain the corrected pixel information of the color channel. The corrected pixel information of each color channel constitutes the corrected target image. In this application, by using the corrected reference channel for white balance calculation, the effect of white balance is improved.
[0153] Figure 4 The flowchart of an automatic white balance example provided by an embodiment of this application is shown. Based on the Figures 1 to 3 embodiment shown, as Figure 4 shown, when the target image is an RGB image, the following steps may be included:
[0154] Step 1. Extract the pixel information of the three color channels of each R channel, G channel, and B channel.
[0155] Step 2. Divide the R channel, G channel, and B channel into 3 sub-blocks.
[0156] Step 3. Count the overexposed areas in each color channel.
[0157] Step 4. Determine whether there is a first overexposed area in the G channel. If so, continue to execute Step 5. Otherwise, jump to Step 9.
[0158] Step 5. Mark the same positions in the R channel and B channel according to the first overexposed area in the G channel.
[0159] Step 6. Count the second overexposed areas in the marked areas of the R channel and B channel and calculate the area of the second overexposed areas to obtain the brightness ratio of each color channel.
[0160] In this step, the area of the second overexposed region is counted. The area of the R channel region can be denoted as A, the area of the G channel region can be denoted as B, and the area of the B channel region can be denoted as C. According to the ratio of each area to the sum of the three areas, the ratio is determined. Among them, the calculation formula for the ratio α1 of the R channel can be:
[0161] α1 = A / (A + B + C)
[0162] The calculation formula for the ratio α2 of the G channel can be:
[0163] α2 = B / (A + B + C)
[0164] The calculation formula for the ratio α3 of the B channel can be:
[0165] α3 = C / (A + B + C)
[0166] Using the mapping function, according to the ratio of each channel, the brightness ratio is calculated. The mapping function can be y = -0.5x - + 0.5. The ratios α1, α2, and α3 can be used as the variable x in the mapping function. Substituting into the mapping function, y is calculated, which is the brightness ratio. The brightness ratios corresponding to the ratios α1, α2, and α3 can be denoted as brightness ratio β1, brightness ratio β2, and brightness ratio β3 respectively.
[0167] Step 7: Generate the fusion data Mix based on the brightness ratios of the G channel and the R channel.
[0168] Step 8: Generate the fusion data G_Mix based on the Mix data and the brightness ratio of the B channel.
[0169] In this step, the regional correction information G new of the first overexposed region can be calculated as:
[0170] G new = β1R + β2G + β3B
[0171] Use the regional correction information of the first overexposed region to replace the pixel information corresponding to the first overexposed region in the G channel to obtain G_Mix.
[0172] Step 9: It is not necessary to process the G channel, and directly obtain G_Mix = G.
[0173] Step 10: Count the data of G_Mix and G_MixGain.
[0174] Step 11: Count the data of the R channel and R_Gain.
[0175] Step 12: Count the data of the B channel and B_Gain.
[0176] Step 13. Determine the correction coefficient of the B channel according to the ratio of G_MixGain to B_Gain. The calculation formula of the correction coefficient γ1 of the B channel can be:
[0177] γ1 = G_MixGain / B_Gain
[0178] Step 14. Use the correction coefficient of the B channel to correct the pixel information of the B channel. The formula can be:
[0179] B new = γ1B
[0180] Step 15. Determine the correction coefficient of the R channel according to the ratio of G_MixGain to R_Gain. The calculation formula of the correction coefficient γ2 of the R channel can be:
[0181] γ2 = G_MixGain / R_Gain
[0182] Step 14. Use the correction coefficient of the R channel to correct the pixel information of the R channel. The formula can be:
[0183] R new = γ2R
[0184] Figure 5 shows a schematic structural diagram of an automatic white balance device provided by an embodiment of the present application. As Figure 5 shown, the automatic white balance device 10 in this embodiment is used to implement the corresponding automatic white balance method in any of the above method embodiments. The automatic white balance device 10 in this embodiment includes:
[0185] An acquisition module 11, configured to acquire a target image, where the target image includes multiple color channels, and at least one of the multiple color channels is a reference channel;
[0186] A processing module 12, configured to correct the pixel information of the first overexposed area in the reference channel according to the pixel information of the color channels; and correct the target image according to the corrected reference channel and the pixel information of other color channels.
[0187] Optionally, the processing module 12 is specifically configured to:
[0188] When it is determined that there is a first overexposed area in the reference channel, determine the pixel positions corresponding to each first overexposed area in the reference channel according to the pixel information of the reference channel;
[0189] Determine the brightness ratio of each color channel corresponding to each first overexposed area according to the pixel information of each color channel at the pixel positions corresponding to each first overexposed area;
[0190] According to the pixel information of the pixel positions corresponding to each first overexposed region in each color channel and the brightness ratio of each color channel corresponding to each first overexposed region, correct the pixel information of the pixel positions corresponding to each first overexposed region in the reference channel.
[0191] Optionally, the processing module 12 is further configured to:
[0192] When it is determined that there is no first overexposed region in the reference channel, do not correct the pixel information of the reference channel.
[0193] Optionally, the processing module 12 is specifically configured to:
[0194] Determine the overexposed pixel points with pixel values greater than or equal to the preset pixel value according to the pixel information of the reference channel;
[0195] Form adjacent overexposed pixel points into a connected region;
[0196] Obtain the area of each connected region;
[0197] When the area of the connected region is greater than or equal to the preset area, determine a connected region as a first overexposed region.
[0198] Optionally, the processing module 12 is specifically configured to:
[0199] Determine the area of the second overexposed region of the pixel positions corresponding to each first overexposed region in each color channel according to the pixel information of the pixel positions corresponding to each first overexposed region in each color channel;
[0200] Statistically calculate the area of the regions of the pixel positions corresponding to each first overexposed region in each color channel to obtain the total area;
[0201] Determine the brightness ratio of each color channel corresponding to each first overexposed region according to the ratio of the area of the regions of the pixel positions corresponding to each first overexposed region in each color channel to the total area.
[0202] Optionally, the processing module 12 is specifically configured to:
[0203] Calculate the ratio of the area of the region in each color channel corresponding to each first overexposed region to the total area;
[0204] Use a mapping function to map the ratio to obtain the brightness ratio of the color channel corresponding to the first overexposed region.
[0205] Optionally, the sum of the brightness ratios of the respective color channels corresponding to each first overexposed region is 1.
[0206] Optionally, the processing module 12 is specifically configured to:
[0207] Calculate the product of the pixel information of the pixel positions corresponding to each first overexposed region in each color channel and the brightness ratio of each color channel corresponding to each first overexposed region to obtain the channel correction information of each first overexposed region in each color channel;
[0208] Accumulate the channel correction information of each color channel of each first overexposed region to obtain the region correction information of each first overexposed region;
[0209] Use the region correction information of each first overexposed region to replace the pixel information of the pixel positions corresponding to the first overexposed region in the reference channel to obtain the pixel information of the corrected reference channel.
[0210] Optionally, the processing module 12 is specifically configured to:
[0211] According to the pixel information of the corrected reference channel and other color channels, count the data sum of each color channel;
[0212] Calculate the correction coefficient of each color channel according to the data sum of each color channel;
[0213] According to the correction coefficient of each color channel, correct the pixel information of each color channel in the target image to obtain the corrected target image.
[0214] Optionally, the processing module 12 is specifically configured to:
[0215] Calculate the ratio of the data sum of the reference channel to the data sum of each color channel to determine the correction coefficient of each color channel.
[0216] The automatic white balance device 10 provided in the embodiments of the present application can execute the above method embodiments, and for its specific implementation principle and technical effects, reference can be made to the above method embodiments, which will not be elaborated here in this embodiment.
[0217] Figure 6 Shows a schematic hardware structure diagram of a controller provided in the embodiments of the present application. As Figure 6 shown, the controller 20 may include: a memory 21, a processor 22, and an interface 24.
[0218] The memory 21 is used to store computer programs. The memory 21 may include a high-speed random access memory (Random Access Memory, RAM), and may also include non-volatile memory (Non-Volatile Memory, NVM), such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a disk, or an optical disc, etc.
[0219] The processor 22 is configured to execute the computer program stored in the memory to implement the automatic white balance method in the above embodiments. For specific details, reference may be made to the relevant descriptions in the foregoing method embodiments. The processor 22 may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the invention may be directly implemented by the execution of the hardware processor, or may be implemented by the combination of hardware and software modules in the processor.
[0220] Optionally, the memory 21 may be either independent or integrated with the processor 22.
[0221] When the memory 21 is a device independent of the processor 22, the controller 20 may further include a bus 23. The bus 23 is used to connect the memory 21 and the processor 22. The bus 23 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, the bus in the drawings of this application is not limited to only one bus or one type of bus.
[0222] Optionally, the interface 24 is connected to the processor 22. The interface 24 is used to obtain the target image uploaded by the external device.
[0223] Optionally, in actual use, the controller may be embedded in other devices in the form of a control module, a single-chip microcomputer, a control chip, etc., to implement the white balance processing of the images obtained by other devices.
[0224] The controller provided in this embodiment can be used to execute the above automatic white balance method, and its implementation manner and technical effects are similar, so details are not described herein again.
[0225] This application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the methods provided by the above various embodiments.
[0226] Among them, the computer-readable storage medium can be a computer storage medium or a communication medium. The communication medium includes any medium that facilitates the transfer of a computer program from one place to another. The computer storage medium can be any available medium accessible by a general-purpose or special-purpose computer. For example, the computer-readable storage medium is coupled to the processor, enabling the processor to read information from the computer-readable storage medium and write information to the computer-readable storage medium. Of course, the computer-readable storage medium can also be a component of the processor. The processor and the computer-readable storage medium can be located in an Application Specific Integrated Circuits (ASIC). Additionally, the ASIC can be located in a user device. Of course, the processor and the computer-readable storage medium can also exist as discrete components in a communication device.
[0227] Specifically, the computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically-Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable read-only memory (PROM), Read-Only Memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk. The storage medium can be any available medium accessible by a general-purpose or special-purpose computer.
[0228] This application also provides a computer program product. The computer program product includes a computer program, and the computer program is stored in a computer-readable storage medium. At least one processor of the device can read the computer program from the computer-readable storage medium, and the execution of the computer program by at least one processor enables the device to implement the methods provided by the above various embodiments.
[0229] This embodiment of the application also provides a chip. The chip includes a memory and a processor. The memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the device installed with the chip executes the methods in the above various possible embodiments.
[0230] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of devices or modules can be in electrical, mechanical or other forms.
[0231] Among them, each module can be physically separated. For example, it can be installed at different positions of a device, or installed on different devices, or distributed to multiple network units, or distributed to multiple processors. Each module can also be integrated together. For example, it can be installed in the same device, or integrated in a set of code. Each module can exist in the form of hardware, or can also exist in the form of software, or can also be implemented in the form of software plus hardware. This application can select some or all of the modules according to actual needs to achieve the purpose of the solution of this embodiment.
[0232] When the integrated modules are implemented in the form of software function modules, they can be stored in a computer-readable storage medium. The above-mentioned software function modules are stored in a storage medium and include several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute some steps of the methods of various embodiments of this application.
[0233] It should be understood that although the steps in the flowcharts in the above embodiments are displayed in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit and can be executed in other orders. Moreover, at least a part of the steps in the figure can include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same moment, but can be executed at different moments. Their execution order is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.
[0234] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than limiting them. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features. These modifications or replacements 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 application.
Claims
1. An automatic white balance method, characterized in that, The method includes: Obtaining a target image, where the target image includes multiple color channels, and at least one of the multiple color channels is a reference channel; Correcting the pixel information of the first overexposed area in the reference channel according to the pixel information of the color channels; Correcting the target image according to the corrected reference channel and the pixel information of the other color channels.
2. The method according to claim 1, characterized in that, The correcting the pixel information of the first overexposed area in the reference channel according to the pixel information of the color channels specifically includes: When it is determined that there is the first overexposed area in the reference channel, determining the pixel positions corresponding to each of the first overexposed areas in the reference channel according to the pixel information of the reference channel; Determining the brightness ratio of each color channel corresponding to each of the first overexposed areas according to the pixel information of each color channel at the pixel positions corresponding to each of the first overexposed areas; Correcting the pixel information at the pixel positions corresponding to each of the first overexposed areas in the reference channel according to the pixel information of each color channel at the pixel positions corresponding to each of the first overexposed areas and the brightness ratio of each color channel corresponding to each of the first overexposed areas.
3. The method according to claim 2, characterized in that, The method further includes: When it is determined that there is no first overexposed area in the reference channel, not correcting the pixel information of the reference channel.
4. The method according to claim 2, wherein The determining that there is the first overexposed area in the reference channel specifically includes: Determining the overexposed pixel points with pixel values greater than or equal to a preset pixel value according to the pixel information of the reference channel; Forming a connected area by the adjacent overexposed pixel points; Obtaining the area of each connected area; When the area of the connected area is greater than or equal to a preset area, determining one connected area as one first overexposed area.
5. The method according to claim 2, wherein The determining the brightness ratio of each color channel corresponding to each of the first overexposed areas according to the pixel information of each color channel at the pixel positions corresponding to each of the first overexposed areas specifically includes: Determining the area of the second overexposed area at the pixel positions corresponding to each of the first overexposed areas in each color channel according to the pixel information of each color channel at the pixel positions corresponding to each of the first overexposed areas; Counting the area of each color channel at the pixel positions corresponding to each of the first overexposed areas to obtain the total area; Determining the brightness ratio of each color channel corresponding to each of the first overexposed areas according to the ratio of the area of each color channel at the pixel positions corresponding to each of the first overexposed areas to the total area.
6. The method according to claim 5, characterized in that, The determining the brightness ratio of each color channel corresponding to each of the first overexposed areas according to the ratio of the area of each color channel at the pixel positions corresponding to each of the first overexposed areas to the total area specifically includes: Calculating the ratio of the area of each color channel at the pixel positions corresponding to each of the first overexposed areas to the total area; Using a mapping function, map the ratio to obtain the brightness ratio of the color channel corresponding to the first overexposed region.
7. The method according to claim 6, wherein The sum of the brightness ratios of each color channel corresponding to each first overexposed region is 1.
8. The method according to claim 2, characterized in that, The method of correcting the pixel information at the pixel position corresponding to each first overexposed region in each color channel according to the pixel information at the pixel position corresponding to each first overexposed region in each color channel and the brightness ratio of each color channel corresponding to each first overexposed region specifically includes: Calculate the product of the pixel information at the pixel position corresponding to each first overexposed region in each color channel and the brightness ratio of each color channel corresponding to each first overexposed region to obtain the channel correction information of each first overexposed region in each color channel; Accumulate the channel correction information of each color channel of each first overexposed region to obtain the region correction information of each first overexposed region; Use the region correction information of each first overexposed region to replace the pixel information at the pixel position corresponding to the first overexposed region in the reference channel to obtain the pixel information of the corrected reference channel.
9. The method according to any one of claims 1-8, characterized in that, The method of correcting the target image according to the pixel information of the corrected reference channel and other color channels specifically includes: According to the pixel information of the corrected reference channel and other color channels, count the data sum of each color channel; Calculate the correction coefficient of each color channel according to the data sum of each color channel; According to the correction coefficient of each color channel, correct the pixel information of each color channel in the target image to obtain the corrected target image.
10. The method according to claim 9, wherein The method of calculating the correction coefficient of each color channel according to the data sum of each color channel specifically includes: Calculate the ratio of the data sum of the reference channel to the data sum of each color channel to determine the correction coefficient of each color channel.
11. A controller, characterized in that, The controller includes: a memory, a processor; The memory is used to store a computer program; the processor is used to implement the method according to any one of claims 1 to 10 according to the computer program stored in the memory.
12. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, it is used to implement the method according to any one of claims 1 to 10.
13. A computer program product, characterized in that, The computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1 to 10.
Citation Information
Cited By
Image processing method and apparatus, and storage medium
US20240346696A1