Image white balance data collecting and processing method and system
By calculating the color and intensity weights of image sub-windows, constructing multi-level histograms and generating mapping curves, and adjusting image pixel values, the problem of slow speed and low accuracy of existing white balance algorithms is solved, achieving faster and more accurate image white balance data processing.
Patent Information
- Application Number
- CN202511147508.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2025-11-21
AI Technical Summary
In existing white balance algorithms, the statistical data collected by the hardware is too simple, which leads to slow speed and low accuracy in the software implementation of weighted summation of R gain and B gain, thus affecting the image color reproduction effect.
By calculating the color weight and intensity weight of the image sub-window, a pixel weighting factor is obtained. A multi-level histogram is constructed using a sliding window and an upward stacking mechanism to generate a mapping curve and adjust the image pixel values to achieve white balance.
It improves the running speed and accuracy of the white balance algorithm, solves the problems of slow speed and low accuracy in the existing technology, and realizes faster and more accurate image white balance data collection and processing.
Smart Images

Figure CN121000856A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, and in particular to a method and system for collecting and processing image white balance data. BACKGROUND
[0002] In digital image processing, white balance adjustment is a key step to ensure the accuracy of color restoration, and the core is to collect white balance data in the image, calculate appropriate gain coefficients, and make white objects appear white under different lighting conditions.
[0003] In existing white balance algorithms, the statistical data collected by hardware is too simple, and the weighted sum of R gain and B gain needs to be realized by software, which has the problems of slow speed and low accuracy, affecting the effect of white balance adjustment. Therefore, a faster and more accurate image white balance data collection and processing method is needed. SUMMARY
[0004] In view of the above-mentioned deficiencies in the prior art, the present application provides a method for collecting and processing image white balance data, which calculates the color weight and intensity weight of the image sub-window to obtain the pixel weighting factor, and then calculates the white balance statistical data of each sub-window.
[0005] To achieve the above-mentioned purposes, the embodiments of the present application adopt the following technical solutions:
[0006] A method for collecting and processing image white balance data, comprising the following steps:
[0007] Obtain an original image including pixel value information;
[0008] Divide the original image into sub-windows of the same size;
[0009] Obtain the pixel weighting factor of each sub-window;
[0010] According to the pixel weighting factor, obtain the white balance statistical data of each sub-window.
[0011] According to an aspect of the present application, the method for collecting and processing image white balance data comprises:
[0012] Based on the sliding window and the upward superposition mechanism, a multi-level histogram is constructed for the original image;
[0013] According to the multi-level histogram, a mixed histogram is obtained;
[0014] According to the mixed histogram, a mapping curve is generated;
[0015] Using the mapping curve for pixel mapping, adjusting the pixel value of the original image, and dynamically expanding the dynamic range of the original image.
[0016] According to an aspect of the present application, the method for collecting and processing the image white balance data comprises:
[0017] dividing the sub-window into 2x2 Bayer cells;
[0018] when the pixel value in the cell is within a preset threshold range, the cell is included in the data statistics of the sub-window.
[0019] According to an aspect of the present application, the method for obtaining the pixel weighting factor of each sub-window comprises:
[0020] obtaining the color weight CW of each sub-window;
[0021] obtaining the intensity weight IW of each sub-window;
[0022] the pixel weighting factor W of each sub-window = CW*IW.
[0023] According to an aspect of the present application, the method for obtaining the color weight CW of each sub-window comprises:
[0024] establishing a two-dimensional grid with R gain as the x-axis and B gain as the y-axis;
[0025] assigning a color weight value to each grid intersection point;
[0026] obtaining the R gain and B gain of each pixel point to determine its corresponding position in the two-dimensional grid;
[0027] obtaining the color weight CW of each pixel point by using bilinear interpolation method.
[0028] According to an aspect of the present application, the method for obtaining the intensity weight IW of each sub-window comprises:
[0029] obtaining the luminance value of each pixel point;
[0030] obtaining the intensity weight IW of each pixel point according to a preset luminance value and intensity weight correspondence.
[0031] According to an aspect of the present application, the preset luminance and intensity weight correspondence comprises:
[0032] taking the luminance value as the x-axis and the intensity weight as the y-axis;
[0033] dividing the luminance value into N parts, and setting the intensity weight of each division point;
[0034] calculating the intensity weight IW corresponding to each luminance value by using linear interpolation method.
[0035] According to one aspect of the present application, the obtaining of the white balance statistical data of each sub-window according to the pixel weighting factor comprises:
[0036] The R gain, B gain and weighted sum of RGB pixel values of each sub-window are obtained.
[0037] According to one aspect of the present application, the method for collecting and processing image white balance data comprises:
[0038] The method is written into a processing program and solidified in the chip hardware of the image processing module.
[0039] A system for collecting and processing image white balance data based on the method for collecting and processing image white balance data as described above comprises:
[0040] An image acquisition module for acquiring an original image comprising pixel value information;
[0041] A segmentation module for segmenting the original image into sub-windows of the same size;
[0042] A weight acquisition module for acquiring pixel weighting factors of each sub-window;
[0043] A statistical module for obtaining white balance statistical data of each sub-window according to the pixel weighting factor.
[0044] Advantages of the present application:
[0045] The present application provides a method for collecting and processing image white balance data, which obtains pixel weighting factors by calculating color weight and intensity weight of image sub-windows, and calculates white balance statistical data of each sub-window. The steps of the method are easy to implement in chip design, and can improve the overall running speed of the white balance algorithm when solidified in the chip, thus solving the problems of slow speed and low accuracy in the prior art. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort based on these drawings.
[0047] Figure 1 A flowchart of the method for collecting and processing image white balance data according to the present application;
[0048] Figure 2 A two-dimensional grid of R gain and B gain according to the present application;
[0049] Figure 3 Color weight value assigned to the intersection of the grid described in the present application;
[0050] Figure 4 Plank color temperature curve described in the present application;
[0051] Figure 5 Color weight acquisition method of the pixel point described in the present application;
[0052] Figure 6 A kind of luminance value and intensity weight corresponding relationship described in the second embodiment of the present application. DETAILED DESCRIPTION
[0053] The technical solutions in the embodiments of the present application will be described clearly and completely below with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0054] Embodiment one
[0055] As shown in the figure, a method for collecting and processing image white balance data includes the following steps: Figure 1
[0056] S1: Obtain an original image including pixel value information.
[0057] The original image used in the present method needs to include red, green and blue channel pixel information, so as to process the pixel data of each channel. Specifically, BAYER RAW format image data or common RGB format image data can be used.
[0058] Preferably, before the original image is subjected to white balance data statistics, the original image can be subjected to dynamic range expansion, and the specific steps include:
[0059] A1: Based on a sliding window and upward superposition mechanism, a multi-level histogram is constructed for the original image.
[0060] Specifically, step A1 includes:
[0061] A11: The multi-level histogram is preset to M layers;
[0062] The multi-level histogram constructed by the method is similar to a pyramid structure, the first layer is constructed based on the original image; the second layer is constructed based on the first layer, the third layer is constructed based on the second layer, and so on, until the M-1th layer; and the last Mth layer is directly constructed based on the original image as a whole. For example, when the multi-level histogram constructed in actual application is 4 layers, M=4.
[0063] A12: constructing a basic histogram L1 based on the original image based on a sliding window;
[0064] According to the preset size and step length of the sliding window, a histogram based on brightness is constructed for the sub-image in each window.
[0065] The window size is (HWx, HWy), and the step length is (HUx, HUy). The window starts from the upper left corner of the image with a horizontal offset HOx and a vertical offset HOy. The window must be completely within the image range, and the border configuration is considered illegal.
[0066] A histogram is constructed for each window, and the specific method is as follows:
[0067] First, the brightness distribution of the window is counted, and the calculation formula of the brightness is:
[0068] L=(10R+4B+9(Gr+Gb))>>5
[0069] The horizontal axis of the histogram is the brightness level, and the vertical axis is the number of pixels. The brightness is evenly divided into N levels, that is, the number of histogram bins is N. The number of pixels corresponding to each brightness level is counted, and the horizontal direction jump number BSx and the vertical direction jump number BSy can be set to skip part of the pixels to reduce the calculation amount.
[0070] If the window is set to be large, the bin count is high, so BSx and BSy (down scalar factor) are introduced to skip part of the pixels to reduce the bin count. Starting from the upper left corner of each window, BSx and BSy represent the number of pixels to be skipped in the horizontal and vertical directions after calculating one pixel. For example, in a 128x128 window, when BSx=2 and BSy=1, only 42 columns and 64 rows of pixels will be selected for collection, and the total number of pixels counted is reduced from 128x128=16384 to 42x64=2688.
[0071] A13: constructing intermediate layer histograms L2-LM-1 by upward stacking based on the basic histogram L1;
[0072] The window width and height of the i-th layer are 2 times of the width and height of the (i-1)-th layer, and the middle layer histogram Li is obtained by adding four adjacent histograms of the lower layer histogram Li-1; wherein, 1 < i < M.
[0073] A14: Constructing a global histogram LM based on the basic histogram L1.
[0074] Adding all the basic histograms to obtain the global histogram LM. The window range of the global histogram covers the entire image.
[0075] The more the histogram levels, the greater the calculation amount, and the effect of expanding the dynamic range of the image will also appear marginal diminishing. In practical applications, it is found through experiments that it is more appropriate to construct 4 levels of histograms, which can control the calculation amount and achieve a certain expansion effect.
[0076] A2: Obtaining a mixed histogram according to the multi-level histogram.
[0077] Specifically, step A2 includes:
[0078] A21: Calculating the mean and variance of each histogram respectively.
[0079] The mean value calculation formula of the histogram is:
[0080]
[0081] Wherein, Mean represents the mean value of the histogram; N is the number of histogram bins; H[x] represents the number of pixels corresponding to the histogram bin x, and x is the brightness level.
[0082] The variance calculation formula of the histogram is:
[0083]
[0084] Wherein, Var represents the variance of the histogram; N is the number of histogram bins; H[x] represents the number of pixels corresponding to the histogram bin x, and x is the brightness level.
[0085] A22: Obtaining an equalization weight W according to a preset rule.
[0086] The specific method of this step is:
[0087] A221: Obtaining a variance weight WV according to a preset variance and variance weight corresponding relationship.
[0088] The user can set the mapping relationship of the variance range of the histogram and the variance weight, and generally, the greater the variance, the greater the variance weight WV. For example, the user can directly set a lookup table, and different variance ranges correspond to different variance weight values. The user can also set a function relationship, and according to the function relationship, the variance weight is calculated by using the variance.
[0089] A222: Obtain the spatial weight WS according to the preset correspondence between the histogram level and the spatial weight.
[0090] The spatial weight WS of each layer is determined by the histogram level, and the specific mapping relationship can be set by the user and adjusted according to the actual effect. Generally, the lower the level, the greater the spatial weight WS.
[0091] A223: Obtain the balance weight according to the variance weight and the spatial weight.
[0092] The final balance weight of each layer histogram is calculated by combining the variance weight WV and the spatial weight WS, and the final balance weight = WVm*WSm, where m is the level of the histogram.
[0093] A23: Obtain the mixed histogram according to the multi-level histogram and the balance weight.
[0094] The calculation formula of the mixed histogram is:
[0095]
[0096] Where H[x] represents the vertical axis value of the final obtained mixed histogram binx; M is the number of layers of the multi-level histogram; Wm is the balance weight of the mth level histogram; Hm[x] is the number of pixels of binx of the mth level histogram, and x is the brightness level.
[0097] A3: Generate a mapping curve according to the mixed histogram.
[0098] Specifically, step A3 includes:
[0099] Obtain the cumulative distribution function of the mixed histogram;
[0100] Generate a mapping curve according to the cumulative distribution function.
[0101] The calculation formula of the histogram cumulative distribution function is:
[0102]
[0103] Where C[i] represents the cumulative distribution, and i is the brightness level; H[x] represents the vertical axis value corresponding to the mixed histogram binx.
[0104] The vertical axis values corresponding to each bin are connected to generate a mapping curve of pixel gain corresponding to different luminance by normalizing the cumulative distribution function to the entire luminance range.
[0105] A4: performing pixel mapping using the mapping curve to adjust the pixel values of the original image, and performing dynamic range expansion on the original image.
[0106] Specifically, step A4 includes:
[0107] A41: dividing the original image into subunits and calculating the luminance L of each subunit.
[0108] For example, the pixels of the original image can be grouped into 2x2 Bayer subunits, and the luminance L thereof is calculated.
[0109] A42: looking up the mapping curve according to the luminance L, and obtaining the pixel gain by linear interpolation of adjacent curve points.
[0110] According to the luminance L of the subunit, the vertical axis values corresponding to the luminance level and adjacent luminance levels on the mapping curve are looked up according to the luminance level where the luminance L is located, and the vertical axis value A corresponding to the luminance L is obtained by linear interpolation of adjacent curve points, so that the pixel gain value at this position is A / L.
[0111] A43: adjusting the pixel values of the original image according to the pixel gain.
[0112] The pixel value adjustment formula of the final original image is:
[0113]
[0114] Wherein, R', Gr', Gb' and B' are the adjusted RGB pixel values, and R, Gr, Gb and B are the pixel values of the original image.
[0115] By constructing and fusing the multi-level histogram, local and global statistical information can be combined, and the balance between details and overall exposure can be balanced. The dynamic mapping curve can be generated, the adaptive gain adjustment can be performed based on the histogram cumulative distribution function, the bright and dark details can be preserved, and the problem of insufficient dynamic range of the original image can be well solved.
[0116] S2: dividing the original image into subwindows of the same size.
[0117] In actual application, the original image can be divided into 16x16=256 subwindows.
[0118] Preferably, the method further includes:
[0119] dividing the subwindows into 2x2 Bayer cells;
[0120] When the pixel value in a cell falls within a preset threshold range, that cell is included in the data statistics of its corresponding sub-window. Specifically:
[0121] AWB_WS_RL < R < AWB_WS_RU
[0122] AWB_WS_GRL < Gr < AWB_WS_GRU
[0123] AWB_WS_GBL < Gb < AWB_WS_GBU
[0124] AWB_WS_BL < B < AWB_WS_BU
[0125] Among them, AWB_WS_RL, AWB_WS_GRL, AWB_WS_GBL, and AWB_WS_BL are the lower bounds of the threshold range, while AWB_WS_RU, AWB_WS_GRU, AWB_WS_GBU, and AWB_WS_BU are the upper bounds of the threshold range. These values can be set according to actual needs.
[0126] S3: Get the pixel weighting factor for each sub-window.
[0127] Specifically, step S3 includes:
[0128] S31: Get the color weight CW of each child window.
[0129] Step S31 includes:
[0130] (1) As Figure 2 As shown, a two-dimensional grid is established with R gain as the x-axis and B gain as the y-axis.
[0131] When specifically calculating the color weights (CW), the values of R gain and B gain are limited to a range of 0.0 to 3.0. Then, the coordinate system is divided into a grid with a step size of 0.25, forming a 13×13 grid, and each intersection point is assigned a color weight value.
[0132] (2) Figure 3 As shown, color weight values are assigned to each grid intersection.
[0133] like Figure 4 As shown, this is a color temperature coordinate system with Rgain as the horizontal axis and Bgain as the vertical axis, and the green line represents the Planck color temperature curve. Since pixels closer to the Planck color temperature curve are more likely to be white, when calculating the color weight (CW) of each pixel, pixels closer to the Planck color temperature curve are given a higher weight.
[0134] (3) Obtain the R gain and B gain of each pixel and determine its corresponding position in the two-dimensional grid.
[0135] (4) As shown in the following formula (4), the color weight CW of each pixel point is obtained by using the bilinear interpolation method. Figure 5
[0136] According to the four grid intersection points around the position of the current pixel point, the color weight of the pixel point can be calculated by using the bilinear interpolation method according to the color weight values of the four grid intersection points.
[0137] The purpose of color weight calculation is to make the pixels close to the Planck curve participate in the calculation of the final white point as much as possible.
[0138] S32: Obtain the intensity weight IW of each sub-window.
[0139] Step S32 includes:
[0140] Obtain the luminance value of each pixel point;
[0141] According to the preset correspondence between the luminance value and the intensity weight, obtain the intensity weight IW of each pixel point.
[0142] The user can set the lookup table according to the actual situation. Different luminance values correspond to different intensity weights. The corresponding intensity weight IW of each pixel point is obtained directly through the lookup table.
[0143] S33: Pixel weighting factor W of each sub-window = CW*IW.
[0144] S4: Obtain the white balance statistical data of each sub-window according to the pixel weighting factor.
[0145] Specifically, step S4 includes:
[0146] Obtain the weighted sum of R gain, B gain, RGB pixel value, etc. of each sub-window, specifically as follows:
[0147]
[0148] Where i represents the i-th pixel point of the sub-window.
[0149] Preferably, the method further includes:
[0150] The method is written into a processing program and solidified in the chip hardware of the image processing module.
[0151] The beneficial effects of the embodiment are:
[0152] The method obtains the pixel weighting factor by calculating the color weight and intensity weight of the image sub-window, and calculates the white balance statistical data of each sub-window.
[0153] The steps of the method are easy to implement in chip design, and when solidified into the chip, the overall running speed of the white balance algorithm can be improved, solving the problems of slow speed and low accuracy in the prior art.
[0154] Embodiment two
[0155] As Figure 1 shown, a method for collecting and processing image white balance data includes the following steps:
[0156] S1: Obtain an original image including pixel value information.
[0157] The original image used in the method needs to include red, green, and blue channel pixel information in order to process the pixel data of each channel. Specifically, BAYER RAW format image data or ordinary RGB format image data can be used.
[0158] Preferably, the method can first perform dynamic range expansion on the original image before performing white balance data statistics on the original image. The specific steps include:
[0159] A1: Based on a sliding window and an upward stacking mechanism, a multi-level histogram is constructed for the original image.
[0160] Specifically, step A1 includes:
[0161] A11: The multi-level histogram is preset to M levels;
[0162] The multi-level histogram constructed by the method is similar to a pyramid structure. The first level is constructed based on the original image; the second level is constructed based on the first level; the third level is constructed based on the second level; and so on, until the M-1th level. The last Mth level is directly constructed based on the original image as a whole. For example, when the multi-level histogram constructed in actual application is 4 levels, M=4.
[0163] A12: Based on a sliding window, a basic histogram L1 is constructed for the original image.
[0164] Based on the sliding window with a preset size and step, a brightness-based histogram is constructed for the sub-image in each window.
[0165] The window size is (HWx, HWy) and the step is (HUx, HUy). The window starts from the top left corner of the image with a horizontal offset HOx and a vertical offset HOy. The window must be completely within the image range, and the out-of-bound configuration is considered illegal.
[0166] For each window, a histogram is constructed, specifically:
[0167] First, the brightness distribution of the window is counted. The calculation formula of brightness is:
[0168] L = (10R + 4B + 9(Gr + Gb)) » 5
[0169] The horizontal axis of the histogram is the luminance level, and the vertical axis is the number of pixels. The luminance is evenly divided into N levels, i.e., the number of histogram bins is N. The number of pixels corresponding to each luminance level is counted. The number of horizontal direction jumps BSx and the number of vertical direction jumps BSy can be set to skip some pixels to reduce the amount of calculation.
[0170] If the window is set to be large, the bin count is high, so BSx and BSy (down scalar factor) are introduced to skip a part of the pixels to reduce the bin count. BSx and BSy represent the number of pixels to be skipped in the horizontal direction and the vertical direction, respectively, after calculating one pixel, starting from the top-left corner of each window. For example, in a 128x128 window, when BSx = 2 and BSy = 1, only 42 columns and 64 rows of pixels will be selected for collection, and the total number of pixels counted is reduced from 128x128 = 16384 to 42x64 = 2688.
[0171] A13: Based on the base histogram L1, an intermediate layer histogram L2-LM-1 is constructed by upward stacking;
[0172] The specific method of this step is as follows:
[0173] The width and height of the i-th layer window are 2 times the width and height of the (i-1)-th layer, respectively, and the intermediate layer histogram Li is obtained by adding the four adjacent histograms of the lower layer histogram Li-1; where 1 < i < M.
[0174] A14: Based on the base histogram L1, a global histogram LM is constructed.
[0175] All base histograms are added to obtain the global histogram LM. The window range of the global histogram covers the entire image.
[0176] The more the number of histogram levels, the greater the amount of calculation, and the marginal diminishing effect of expanding the dynamic range of the image will also appear. In practical applications, it is found through experiments that it is more appropriate to construct 4 levels of histograms, which can control the amount of calculation and achieve a certain expansion effect.
[0177] A2: Obtain a mixed histogram according to the multi-level histogram.
[0178] Specifically, step A2 includes:
[0179] A21: Calculate the mean and variance of each histogram, respectively.
[0180] The mean value of the histogram is calculated as follows:
[0181]
[0182] Where Mean represents the mean of the histogram; N is the number of histogram bins; H[x] represents the number of pixels corresponding to histogram binx, and x is the brightness level.
[0183] The formula for calculating the variance of a histogram is:
[0184]
[0185] Where Var represents the variance of the histogram; N is the number of histogram bins; H[x] represents the number of pixels corresponding to histogram binx, and x is the brightness level.
[0186] A22: Obtain the equilibrium weight W according to the preset rules.
[0187] The specific steps for this process are as follows:
[0188] A221: Obtain the variance weight WV based on the preset correspondence between variance and variance weight.
[0189] Users can configure the mapping relationship between the variance ranges and variance weights of a histogram; generally, the larger the variance, the larger the variance weight (WV). For example, users can directly set up a lookup table where different variance ranges correspond to different variance weight values. Users can also set up a function relationship to calculate the variance weights based on the variance.
[0190] A222: Obtain the spatial weight WS based on the preset histogram layer level and spatial weight correspondence.
[0191] The spatial weight (WS) of each layer is determined by the histogram layer level. The specific mapping relationship can be set by the user and adjusted according to the actual effect. Generally, the lower the layer, the larger the spatial weight (WS).
[0192] A223: Obtain the equilibrium weights based on variance weights and spatial weights.
[0193] By combining the variance weight WV and the spatial weight WS, the final equilibrium weight of each histogram layer is calculated as WVm * WSm, where m is the histogram layer.
[0194] A23: Obtain a mixed histogram based on the multi-level histogram and balanced weights.
[0195] The formula for calculating a mixture histogram is:
[0196]
[0197] H[x] = H[x] + WmHm[x], x = 1, 2, 3, …, M (1) wherein, H[x] represents the vertical axis value of the final obtained mixed histogram binx; M is the number of layers of the multi-level histogram; Wm is the equalization weight of the mth level histogram; Hm[x] is the pixel number of the binx of the mth level histogram, and x is the brightness level.
[0198] A3: generating a mapping curve according to the mixed histogram.
[0199] Specifically, step A3 includes:
[0200] obtaining a cumulative distribution function of the mixed histogram;
[0201] generating a mapping curve according to the cumulative distribution function.
[0202] The calculation formula of the histogram cumulative distribution function is:
[0203]
[0204] wherein, C[i] represents the cumulative distribution, i is the brightness level; and H[x] represents the vertical axis value corresponding to the binx of the mixed histogram.
[0205] The cumulative distribution function is normalized to the entire brightness range, the vertical axis values corresponding to the bins are connected, and a mapping curve of the pixel gain corresponding to different brightnesses is generated.
[0206] A4: performing pixel mapping using the mapping curve, adjusting the pixel value of the original image, and performing dynamic range expansion on the original image.
[0207] Specifically, step A4 includes:
[0208] A41: dividing the original image into subunits, and calculating the brightness L of each subunit.
[0209] For example, the pixels of the original image can be grouped into 2x2 Bayer subunits, and the brightness L thereof is calculated.
[0210] A42: looking up the mapping curve according to the brightness L, and obtaining the pixel gain by a linear interpolation method of adjacent curve points.
[0211] According to the brightness L of the subunit, the vertical axis values corresponding to the brightness level and the adjacent brightness level on the mapping curve are found according to the brightness level where the brightness L is located, the vertical axis value A corresponding to the brightness L is obtained by linear interpolation of adjacent curve points, and accordingly the pixel gain value at this place is A / L.
[0212] A43: adjusting the pixel value of the original image according to the pixel gain.
[0213] The pixel value adjustment formula of the final original image is:
[0214]
[0215] Wherein, R', Gr', Gb', B' are the adjusted RGB pixel values respectively; R, Gr, Gb, B are the pixel values of the original image respectively.
[0216] By constructing and fusing multi-level histograms, local and global statistical information can be combined, and details and overall exposure can be balanced; dynamic mapping curves can be generated, adaptive gain adjustment can be performed based on the cumulative distribution function of the histogram, bright and dark details can be preserved, and the problem of insufficient dynamic range of the original image can be better solved.
[0217] S2: The original image is divided into sub-windows of the same size.
[0218] In practical applications, the original image can be divided into 16x16=256 sub-windows.
[0219] Preferably, the method further comprises:
[0220] The sub-window is divided into 2x2 Bayer cells;
[0221] When the pixel values in the cell are within a preset threshold range, the cell is included in the data statistics of the sub-window. Specifically:
[0222] AWB_WS_RL < R < AWB_WS_RU
[0223] AWB_WS_GRL < Gr < AWB_WS_GRU
[0224] AWB_WS_GBL < Gb < AWB_WS_GBU
[0225] AWB_WS_BL < B < AWB_WS_BU
[0226] Wherein, AWB_WS_RL, AWB_WS_GRL, AWB_WS_GBL, AWB_WS_BL, are the lower bounds of the threshold range, and AWB_WS_RU, AWB_WS_GRU, AWB_WS_GBU, AWB_WS_BU are the upper bounds of the threshold range. These values can be set according to actual needs.
[0227] S3: Obtain the pixel weighting factor of each sub-window.
[0228] Specifically, step S3 comprises:
[0229] S31: Obtain the color weight CW of each sub-window.
[0230] Step S31 comprises:
[0231] (1) AsFigure 2 A two-dimensional grid is established with R gain as the x-axis and B gain as the y-axis.
[0232] When the color weight CW is specifically calculated, the value range of R gain and B gain is limited to 0.0 to 3.0. Then the coordinate system is divided by a step of 0.25 to form a grid with 13x13 intersection points, and each intersection point is assigned a color weight value.
[0233] (2) As shown in Figure 3 , each grid intersection point is assigned a color weight value.
[0234] As shown in Figure 4 , it is a color temperature coordinate system formed by Rgain as the horizontal axis and Bgain as the vertical axis. The green line is the Planck color temperature curve. Since the pixel points closer to the Planck color temperature curve are more likely to be white points, when calculating the color weight CW of each pixel point, the weight of the pixel points closer to the Planck color temperature curve is considered to be larger.
[0235] (3) Obtain the R gain and B gain of each pixel point to determine its corresponding position in the two-dimensional grid.
[0236] (4) As shown in Figure 5 , the color weight CW of each pixel point is obtained by using the bilinear interpolation method.
[0237] According to the color weight values of the four grid intersection points around the current pixel point, the color weight of the pixel point can be calculated by using the bilinear interpolation method.
[0238] The purpose of color weight calculation is to allow pixels close to the Planck curve to participate in the final white point calculation.
[0239] S32: Obtain the intensity weight IW of each sub-window.
[0240] Step S32 includes:
[0241] Obtain the luminance value of each pixel point; calculate the luminance value I of the pixel = (R*5+G*9+B*2) / 16
[0242] According to the preset luminance value and intensity weight correspondence relationship, obtain the intensity weight IW of each pixel point.
[0243] As shown in Figure 6 , the specific method is:
[0244] Take the luminance value as the x-axis and the intensity weight as the y-axis;
[0245] Divide the luminance value into N parts, and set the intensity weight of each boundary point;
[0246] The linear interpolation method is used to calculate the intensity weight IW corresponding to each luminance value.
[0247] The horizontal axis is the luminance value I, and the vertical axis is the intensity weight value IW. The horizontal axis is divided into 15 parts, and (V0, S0) corresponds to the luminance 0, and (V15, S15) corresponds to the luminance 256. The values of (V0, S0) to (V15, S15) can be set by the user.
[0248] The purpose of the luminance weight calculation is to avoid the participation of the overexposed area in the final white point calculation.
[0249] S33: The pixel weighting factor W of each sub-window is CW*IW.
[0250] S4: According to the pixel weighting factor, the white balance statistical data of each sub-window is obtained.
[0251] Specifically, step S4 includes:
[0252] The weighted sum of the R gain, B gain, RGB pixel value, etc. of each sub-window is obtained, and the specific process is as follows:
[0253]
[0254] Where i represents the i-th pixel point of the sub-window.
[0255] The beneficial effects of the embodiment are:
[0256] The method calculates the color weight and intensity weight of the image sub-window to obtain the pixel weighting factor, and then calculates the white balance statistical data of each sub-window.
[0257] The steps of the method are easy to implement in chip design, and when solidified into the chip, the overall running speed of the white balance algorithm can be improved, solving the problems of slow speed and low accuracy in the prior art.
[0258] Embodiment three
[0259] An image white balance data collection and processing system based on the image white balance data collection and processing method of embodiments one or two, comprising:
[0260] An image acquisition module for acquiring an original image comprising pixel value information;
[0261] A segmentation module for segmenting the original image into sub-windows of the same size;
[0262] A weight acquisition module for acquiring the pixel weighting factor of each sub-window;
[0263] A statistics module is configured to obtain white balance statistics of each sub-window according to the pixel weighting factor.
[0264] Embodiment four
[0265] A computer program product comprises a computer program which, when executed, implements the steps of the method for collecting and processing image white balance data as described in embodiment one or two.
[0266] Embodiment five
[0267] A readable storage medium having stored thereon a computer program as described in embodiment four, which, when executed, implements the steps of the method for collecting and processing image white balance data as described in embodiment one or two.
[0268] The above merely provides the specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of the changes or replacements within the technical scope disclosed by the present application, which should be covered by the protection scope of the present application.
[0269] Therefore, the protection scope of the present application should be subject to the
[0270] application.
Claims
1. A method for collecting and processing image white balance data, characterized by, The method comprises the following steps: obtaining an original image comprising pixel value information; segmenting the original image into sub-windows of the same size; obtaining a pixel weighting factor of each sub-window; obtaining white balance statistical data of each sub-window according to the pixel weighting factor.
2. The method of collecting and processing image white balance data according to claim 1, wherein, The method for collecting and processing image white balance data comprises: constructing a multi-level histogram for the original image based on a sliding window and an upward stacking mechanism; obtaining a mixed histogram according to the multi-level histogram; generating a mapping curve according to the mixed histogram; performing pixel mapping using the mapping curve to adjust the pixel value of the original image and to expand the dynamic range of the original image.
3. The method of collecting and processing image white balance data according to claim 1, wherein, The method for collecting and processing image white balance data comprises: dividing the sub-window into 2x2 Bayer cells; when the pixel value in the cell is within a preset threshold range, the cell is included in the data statistics of the sub-window.
4. The method of collecting and processing image white balance data according to claim 1, wherein, The method for obtaining a pixel weighting factor of each sub-window comprises: obtaining a color weight CW of each sub-window; obtaining an intensity weight IW of each sub-window; the pixel weighting factor W of each sub-window = CW*IW.
5. The method of collecting and processing image white balance data according to claim 4, wherein, The method for obtaining a color weight CW of each sub-window comprises: establishing a two-dimensional grid with R gain as the x-axis and B gain as the y-axis; assigning a color weight value to each grid intersection point; obtaining the R gain and B gain of each pixel point to determine its corresponding position in the two-dimensional grid; obtaining the color weight CW of each pixel point using bilinear interpolation.
6. The method of collecting and processing image white balance data according to claim 4, wherein, The method for obtaining an intensity weight IW of each sub-window comprises: obtaining the luminance value of each pixel point; obtaining the intensity weight IW of each pixel point according to a preset luminance value and intensity weight correspondence.
7. The method of collecting and processing image white balance data according to claim 6, wherein, The preset luminance and intensity weight correspondence comprises: taking luminance value as x-axis and intensity weight as y-axis; dividing the luminance value into N parts and setting the intensity weight of each boundary point; calculating the intensity weight IW corresponding to each luminance value using linear interpolation.
8. The method of collecting and processing image white balance data according to claim 1, wherein, The method for obtaining white balance statistical data of each sub-window according to the pixel weighting factor comprises: obtaining the weighted sum of R gain, B gain and RGB pixel value of each sub-window.
9. The method of collecting and processing image white balance data according to claim 1, wherein, The method for collecting and processing image white balance data comprises: writing the method into a processing program and solidifying it in the chip hardware of the image processing module.
10. An image white balance data collection and processing system, characterized by, The method for collecting and processing image white balance data according to any one of claims 1 to 9 comprises: an image acquisition module for obtaining an original image comprising pixel value information; a segmentation module for segmenting the original image into sub-windows of the same size; a weight acquisition module for obtaining a pixel weighting factor of each sub-window; a statistical module for obtaining white balance statistical data of each sub-window according to the pixel weighting factor.