Image gain self-suppression method, device and storage medium
By calculating the threshold and adjustment coefficient of each channel and performing pixel value truncation and gradient operations, the parameter configuration of lens shading correction (LSC) is simplified, the problem of image overbrightness or overexposure is solved, and the efficiency and quality of image processing are improved.
Patent Information
- Application Number
- CN202310308103.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-27
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2043-03-27
AI Technical Summary
In the prior art, the parameter adjustment of lens shading correction (LSC) is complex, which may lead to problems of overbrightness or overexposure of images.
By calculating the threshold and adjustment coefficient of each channel, pixel value truncation and gradient operations are performed to simplify the parameter configuration of the highlight suppression module HLR and reduce the difficulty of software adjustment.
It effectively adjusts the effects of overbright or overexposed images, simplifies parameter adjustment, and improves the efficiency and quality of image processing.
Smart Images

Figure CN116347053B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a method, device and storage medium for image gain self-suppression. Background Art
[0002] The automatic digital gain (ADG) contains four modules, namely digital gain (DG), lens shading correction (LSC), white balance gain (WBG) and high light recovery (HLR).
[0003] Digital gain, white balance gain, and lens shading correction are common functions in the Image Signal Processor (ISP) pipeline. Essentially, they multiply the pixels in each of the four channels of the Bayer array by their corresponding gain values. This process requires constant parameter adjustment to prevent overbrightening and overexposure. While DG and WBG have fewer parameters and are easy to adjust, lens shading correction (LSC) requires a larger reference table and is more complex to adjust. Summary of the Invention
[0004] The embodiments of the present application provide a method, device, and storage medium for image gain self-suppression, which are used to simplify the complex parameter adjustment work to adjusting a few parameter configurations of the highlight suppression module HLR, reduce the difficulty of parameter adjustment in software, and effectively adjust the overbrightness or overexposure of the image caused by excessive gain.
[0005] A first aspect of the present application provides a method for self-suppression of image gain, which may include:
[0006] Calculate the threshold of each channel according to the preset maximum pixel value, the digital gain value of each channel and the lens shading correction gain value of each channel;
[0007] When the pixel value of the G channel is greater than or equal to the target channel threshold, and the pixel value of the target channel is greater than the target channel threshold, the pixel value of the target channel is truncated so that the truncated target channel pixel value is equal to the corresponding target channel threshold;
[0008] Calculating an adjustment coefficient of the G channel according to the preset maximum pixel value, the pixel adjustment threshold, the truncated pixel value of the G channel, and the pre-gain pixel value;
[0009] New pixel values of the G channel, new pixel values of the R channel, and new pixel values of the B channel are calculated based on the adjustment coefficient of the G channel, the truncated pixel values of the G channel, the truncated pixel values of the R channel, and the truncated pixel values of the B channel.
[0010] A second aspect of the present application provides a device for self-suppression of image gain, which may include:
[0011] A calculation module is used to calculate the threshold value of each channel according to a preset maximum pixel value, a digital gain value of each channel and a lens shading correction gain value of each channel;
[0012] a truncation module, configured to, when the pixel value of the G channel is greater than or equal to the target channel threshold and the pixel value of the target channel is greater than the target channel threshold, truncate the pixel value of the target channel so that the truncated pixel value of the target channel is equal to the corresponding target channel threshold;
[0013] The calculation module is further configured to calculate an adjustment coefficient of the G channel based on the preset maximum pixel value, the pixel adjustment threshold, the truncated pixel value of the G channel, and the pre-gain pixel value;
[0014] The calculation module is also used to calculate the new pixel value of the G channel, the new pixel value of the R channel and the new pixel value of the B channel based on the adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel and the truncated pixel value of the B channel.
[0015] A third aspect of the present application provides a device for self-suppression of image gain, which may include:
[0016] a memory storing executable program code;
[0017] a processor coupled to the memory;
[0018] The processors are used to respectively execute the methods described in the first aspect of this application.
[0019] Another aspect of an embodiment of the present application provides a computer-readable storage medium, comprising instructions, which, when executed on a processor, enable the processor to execute the method described in the first aspect of the present application.
[0020] On another aspect, an embodiment of the present application discloses a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the method described in the first aspect of the present application.
[0021] Another aspect of an embodiment of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes the method described in the first aspect of the present application.
[0022] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0023] In an embodiment of the present application, the threshold values of each channel are calculated based on a preset maximum pixel value, a digital gain value of each channel, and a lens shading correction gain value of each channel; when the pixel value of the G channel is greater than or equal to the target channel threshold value, and the pixel value of the target channel is greater than the target channel threshold value, the pixel value of the target channel is truncated so that the truncated target channel pixel value is equal to the corresponding target channel threshold value; the adjustment coefficient of the G channel is calculated based on the preset maximum pixel value, the pixel adjustment threshold value, the truncated pixel value of the G channel, and the pixel value before gain; and the new pixel value of the G channel, the new pixel value of the R channel, and the new pixel value of the B channel are calculated based on the adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel, and the truncated pixel value of the B channel. This method is used to simplify complex parameter adjustment work to adjusting a few parameter configurations of the highlight suppression module HLR, reduce the difficulty of parameter adjustment in software, and effectively adjust the overbrightness or overexposure of images caused by excessive gain. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments and the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application, and other drawings can be obtained based on these drawings.
[0025] Figure 1A Schematic diagram of four combinations of Bayer arrays;
[0026] Figure 1B This is a schematic diagram before lens shading correction;
[0027] Figure 1C This is a schematic diagram after lens shading correction;
[0028] Figure 1D Detailed analysis diagram of Lens Shading Correction (LSC);
[0029] Figure 2A Schematic diagram of automatic image gain ADG in an embodiment of the present application;
[0030] Figure 2B A flowchart of a highlight suppression algorithm in an embodiment of the present application;
[0031] Figure 3 This is a schematic diagram of an embodiment of a method for self-suppression of image gain in an embodiment of the present application;
[0032] Figure 4A A schematic diagram of truncating pixel values of the R channel and the B channel in an embodiment of the present application;
[0033] Figure 4B A schematic diagram of performing gradient calculation in an embodiment of the present application;
[0034] Figure 4C This is a diagram showing the effect of not undergoing gain suppression processing in the embodiment of the present application;
[0035] Figure 4D This is a diagram showing the effect of gain suppression processing in an embodiment of the present application;
[0036] Figure 5 This is a schematic diagram of an embodiment of a device for self-suppression of image gain in an embodiment of the present application;
[0037] Figure 6 Schematic diagram of another embodiment of the device for self-suppression of image gain in an embodiment of the present application. DETAILED DESCRIPTION
[0038] The embodiments of the present application provide a method, device, and storage medium for image gain self-suppression, which are used to simplify the complex parameter adjustment work to adjusting a few parameter configurations of the highlight suppression module HLR, reduce the difficulty of parameter adjustment in software, and effectively adjust the overbrightness or overexposure of the image caused by excessive gain.
[0039] In order to enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All embodiments in the present invention should fall within the scope of protection of the present invention.
[0040] Images processed by Auto Digital Gain (ADG) usually follow the Bayer Pattern arrangement. The Bayer Array is a mainstream pixel arrangement method named after its inventor Bayer. In an image, there are three types of pixels: red, green, and blue. The Bayer Pattern stipulates that green pixels can only exist in diagonal positions, and the green pixels that are in the same row as the red pixel R are called Gr, and the green pixels that are in the same row as the blue pixel B are called Gb. According to the above rules, it can be seen that the Bayer Pattern of an image can only have 4 combinations: (1) RGrGbB, (2) BGbGrR, (3) GrRBGb and (4) GbBRGr. For example Figure 1A The following are schematic diagrams of four combinations of Bayer arrays.
[0041] ADG includes four modules: Digital Gain (DG), Lens Shading Correction (LSC), White Balance Gain (WBG) and Highlight Recovery (HLR).
[0042] Photos taken under different lighting conditions will have different color temperatures, so the color of objects will change depending on the color of the projected light. The white balance gain (WBG) module adjusts the ratio of red, green, and blue that make up a pixel. At any color temperature, an image that the human eye perceives as white should also appear white after WBG processing by the image signal processor (ISP). Taking the RGrGbB Bayer array as an example, the gain values for each of the four pixel types in the white balance gain are independent of each other. Its calculation is as follows:
[0043]
[0044] The calculation method of digital gain DG is the same as that of white balance gain. However, since the purpose of digital gain is to enhance pixel intensity, the gain value of the four pixels is the same.
[0045] Lens shading is the brightness drop, which is approximated as a function of the radius from the center to the corner. Lens shading correction (LSC) compensates for the brightness drop by using a shading calibration table, which is the inverse of the pure light source downsampling. Bicubic interpolation is used to amplify the shading calibration table into a gain table for shading compensation. Figure 1B As shown in, it is a schematic diagram before lens shading correction; Figure 1C The figure shows the schematic diagram after lens shading correction.
[0046] Lens shading correction is mainly used to increase the brightness of the periphery of the image. Pixels in different areas will be multiplied by different gains. Figure 1D The figure below shows a detailed analysis of Lens Shading Correction (LSC). The original frame is divided into four channels: R, Gr, Gb, and B. Pixels in different channels are bicubicly interpolated using a 4x4 region in the shading calibration table based on their coordinates. The pixel is then multiplied by the final interpolated value to obtain the corrected pixel value. Different channels have different shading calibration table values.
[0047] Digital gain, white balance gain, and lens shading correction are common functions in the Image Signal Processor (ISP) pipeline. Essentially, they multiply the pixels in each of the four channels of the Bayer array by their corresponding gain values. This process requires constant parameter adjustment to prevent overbrightening and overexposure. While DG and WBG have fewer parameters and are easy to adjust, lens shading correction (LSC) requires a larger reference table and is more complex to adjust.
[0048] In the technical solution of this application, the automatic image gain (ADG) module consists of four parts: DG, LSC, WBG and HLR. Figure 2A , which is a schematic diagram of the automatic image gain ADG in an embodiment of the present application.
[0049] The purpose of the High Brightness Reduction (HLR) module is to suppress the overbright or overexposed pixel values generated by the digital gain, white balance gain, and lens shading correction in the ISP pipeline. This module dynamically adjusts the intensity of each original pixel based on the gain value of the previous stage (i.e. DG, LSC, WBG, and HLR). Figure 2B The figure shows a flowchart of the highlight suppression algorithm in the embodiment of the present application. The maximum pixel value refers to the guidance value given by the high dynamic range (HDR) of the previous module in the ISP pipeline, which means the upper limit of the data entering the ADG.
[0050] The technical solution of this application is further described below by way of examples. Figure 3 FIG. 1 is a schematic diagram of an embodiment of a method for self-suppression of image gain in an embodiment of the present application, which may include:
[0051] 301. Calculate and obtain a threshold value of each channel according to a preset maximum pixel value, a digital gain value of each channel, and a lens shading correction gain value of each channel.
[0052] Optionally, calculating the threshold value of each channel according to a preset maximum pixel value, a digital gain value of each channel, and a lens shading correction gain value of each channel may include:
[0053] Calculate the threshold of each channel according to the first formula;
[0054] The first formula is: thr = MP*DG*LSCG;
[0055] Wherein, thr is the threshold value of each channel, MP is the preset maximum pixel value, DG is the digital gain value of each channel, and LSCG is the lens shading correction gain value of each channel.
[0056] Optionally, the channels include a G channel, an R channel, and a B channel. The G channel further includes a Gr channel and a Gb channel. The thresholds of the channels may be different or the same, and are not specifically limited thereto.
[0057] It's understandable that the maximum pixel value (Mega-Pixels, MP) is a universal value that remains the same across the entire image. The DG gain value is a per-channel value, interpolated from the LSC to obtain the Lens Shading Correction Gain (LSCG). Since each channel uses a different shading correction table and the spatial locations of pixels are different, the LSC for each channel is likely to be different.
[0058] In practical applications, the gain of the Gb and Gr channels is typically 1. This results in the R and B channels (with a gain greater than 1) exceeding the maximum pixel value after the pixel value of the Gb or Gr channel reaches its maximum pixel value, thus overflowing. Therefore, the present embodiment performs truncation processing, as described below.
[0059] 302. When the pixel value of the G channel is greater than or equal to the target channel threshold and the pixel value of the target channel is greater than the target channel threshold, truncate the pixel value of the target channel so that the truncated pixel value of the target channel is equal to the corresponding target channel threshold.
[0060] The target channel here can be the Gb channel, the Gr channel, the R channel, or the B channel.
[0061] For example, Figure 4A As shown in FIG, a schematic diagram of truncating the pixel values of the R channel and the B channel in an embodiment of the present application. Figure 4A In the figure, the R channel threshold is the same as the B channel threshold. If the R channel threshold is different from the B channel threshold, the clipped pixel value of the R channel is also different from the clipped pixel value of the B channel.
[0062] When the pixel value of the Gb channel is greater than or equal to the Gr channel threshold, and the pixel value of the Gr channel is greater than the Gr channel threshold, the pixel value of the Gr channel is truncated so that the truncated Gr channel pixel value is equal to the corresponding Gr channel threshold;
[0063] When the pixel value of the Gb channel is greater than or equal to the R channel threshold, and the pixel value of the R channel is greater than the R channel threshold, the pixel value of the R channel is truncated so that the truncated R channel pixel value is equal to the corresponding R channel threshold;
[0064] When the pixel value of the Gb channel is greater than or equal to the B channel threshold, and the pixel value of the B channel is greater than the B channel threshold, the pixel value of the B channel is truncated so that the truncated B channel pixel value is equal to the corresponding B channel threshold;
[0065] When the pixel value of the Gb channel is greater than the Gb channel threshold, the pixel value of the Gb channel is truncated so that the truncated Gb channel pixel value is equal to the corresponding Gb channel threshold;
[0066] When the pixel value of the Gr channel is greater than or equal to the Gb channel threshold, and the pixel value of the Gb channel is greater than the Gb channel threshold, the pixel value of the Gb channel is truncated so that the truncated Gb channel pixel value is equal to the corresponding Gb channel threshold;
[0067] When the pixel value of the Gr channel is greater than or equal to the R channel threshold, and the pixel value of the R channel is greater than the R channel threshold, the pixel value of the R channel is truncated so that the truncated R channel pixel value is equal to the corresponding R channel threshold;
[0068] When the pixel value of the Gr channel is greater than or equal to the B channel threshold, and the pixel value of the B channel is greater than the B channel threshold, the pixel value of the B channel is truncated so that the truncated B channel pixel value is equal to the corresponding B channel threshold;
[0069] When the pixel value of the Gr channel is greater than the Gr channel threshold, the pixel value of the Gb channel is truncated so that the truncated Gr channel pixel value is equal to the corresponding Gr channel threshold.
[0070] Optionally, the method may further include: when the pixel value of the G channel is greater than or equal to the target channel threshold, and the pixel value of the target channel is less than the target channel threshold, the pixel value of the target channel is not truncated, and the pixel value of the target channel can be used as the truncated pixel value of the target channel to perform the following steps.
[0071] 303. Calculate an adjustment coefficient of the G channel according to the preset maximum pixel value, the pixel adjustment threshold, the truncated pixel value of the G channel, and the pre-gain pixel value.
[0072] Optionally, calculating the adjustment coefficient of the G channel based on the preset maximum pixel value, pixel adjustment critical value, the truncated pixel value of the G channel and the pixel value before gain may include: calculating the adjustment value of the G channel based on the preset maximum pixel value, pixel adjustment critical value, the truncated pixel value of the G channel and the pixel value before gain; calculating the adjustment coefficient of the G channel based on the adjustment value of the G channel and the truncated pixel value of the G channel.
[0073] It is understandable that in the process of calculating the adjustment coefficient, gradient operations can be performed according to the parameters, which will make it closer to the curve. For example, Figure 4B As shown in FIG, a schematic diagram of performing gradient calculation in an embodiment of the present application is shown. Figure 4B In the figure, ori represents the pixel value before gain, ori gain It represents the pixel value after gain, and also represents the pixel value before truncation. When the pixel value is between alt and MP, four gradient intervals are divided. It should be noted that the number of gradient intervals is not limited here and can be divided according to actual needs. The higher the gradient, the closer it is to the curve, and the better the array smoothing effect can be achieved. The gradient division method is shown in the following formula, where the y component represents the output value and the x component represents the input value. Use alt to represent a pixel adjustment threshold. Only pixel values above this pixel adjustment threshold are adjusted.
[0074] posy[0]=alt;
[0075]
[0076]
[0077] posy[3]=MP;
[0078]
[0079]
[0080]
[0081] posx[3]=MP。
[0082] The calculation of the adjustment factor is as follows:
[0083] Compare ori with posx to determine which gradient interval the current pixel is in. The adjustment value calculation methods for different gradient intervals are different, and the adjustment value can be represented by adj. gain It is represented as.
[0084] When ori <= posx[0], the current pixel is in gradient interval 1;
[0085] adj gain = ori gain ;
[0086] When posx[0] < ori <= posx[1], the current pixel is in gradient interval 2;
[0087]
[0088] When posx[1] < ori <= posx[2], the current pixel is in gradient interval 3;
[0089] [[ID= 24]]
[0090] When posx[2] < ori <= posx[3], the current pixel is in gradient interval 4.
[0091]
[0092] Let the adjustment coefficient be adj coef , and the calculation formula is:
[0093] adj coef [[ID= 40]]= adj gain ori gain ;
[0094] Among them, if ori gain is 0, then adj coef [ takes 1024.
[0095] 304. Calculate the new pixel values of the G channel, the new pixel values of the R channel, and the new pixel values of the B channel according to the adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel, and the truncated pixel value of the B channel.
[0096] Optionally, the calculating of new pixel values of the G channel, new pixel values of the R channel and new pixel values of the B channel based on the adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel and the truncated pixel value of the B channel may include: smoothing the adjustment coefficient of the G channel to obtain the smoothed adjustment coefficient of the G channel; and calculating new pixel values of the G channel, new pixel values of the R channel and new pixel values of the B channel based on the smoothed adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel and the truncated pixel value of the B channel.
[0097] Optionally, the smoothing of the adjustment coefficient of the G channel to obtain the smoothed adjustment coefficient of the G channel may include: selecting an adjustment coefficient set of G channel pixel points within a preset array range around the target pixel point; and calculating the average value of the adjustment coefficient set as the smoothed adjustment coefficient of the G channel.
[0098] Optionally, the preset array range includes a 3*3 array, a 5*5 array or a 7*7 array, etc., which is not specifically limited here.
[0099] It is understood that the adjustment coefficients of the G channel can be smoothed. The purpose of smoothing the adjustment coefficients is to ensure uniformity between different pixels and to prevent color casts. If smoothing is performed, for example, the adjustment coefficients of the G channel pixels within a 3*3 array around the target pixel can be selected, and these adjustment coefficients can be added and averaged. This average value is used as the adjustment coefficient for the G channel to calculate the new pixel value of the G channel to ensure that the reconstructed new pixel value is not too bright or overexposed.
[0100] It should be noted that the technical solution of the present application adopts a combination of adjustment coefficient gradient operation and smoothing processing in the suppression link to perform two rounds of smoothing, which greatly avoids the color deviation caused by suppression and ensures pixel uniformity.
[0101] Optionally, the G channel includes a Gr channel and a Gb channel, and the new pixel value of the G channel, the new pixel value of the R channel and the new pixel value of the B channel are calculated based on the adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel and the truncated pixel value of the B channel, which may include: obtaining the new pixel value of the Gr channel based on the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel; obtaining the new pixel value of the Gb channel based on the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel; obtaining the new pixel value of the R channel based on the new pixel value of the Gr channel, the truncated pixel value of the Gr channel and the truncated pixel value of the R channel; and obtaining the new pixel value of the B channel based on the new pixel value of the Gb channel, the truncated pixel value of the Gb channel and the truncated pixel value of the B channel.
[0102] Optionally, obtaining the new pixel value of the Gr channel according to the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel may include: calculating the product of the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel as the new pixel value of the Gr channel; that is, Gr'=k1*Gr, wherein k1 is the adjustment coefficient of the Gr channel, Gr is the truncated pixel value of the Gr channel, and Gr' is the new pixel value of the Gr channel;
[0103] Obtaining the new pixel value of the Gb channel based on the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel may include: calculating the product of the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel as the new pixel value of the Gb channel; that is, Gb'=k2*Gb, where k2 is the adjustment coefficient of the Gb channel, Gb is the truncated pixel value of the Gb channel, and Gb' is the new pixel value of the Gb channel.
[0104] Obtaining the new pixel value of the R channel according to the new pixel value of the Gr channel, the truncated pixel value of the Gr channel, and the truncated pixel value of the R channel may include: calculating a first product of the new pixel value of the Gr channel and the truncated pixel value of the R channel, and dividing the first product by the truncated pixel value of the Gr channel to obtain the new pixel value of the R channel; that is, R'=Gr'*R / Gr, wherein R is the truncated pixel value of the R channel, Gr is the truncated pixel value of the Gr channel, Gr' is the new pixel value of the Gr channel, and R' is the new pixel value of the R channel;
[0105] Obtaining the new pixel value of the B channel based on the new pixel value of the Gb channel, the truncated pixel value of the Gb channel, and the truncated pixel value of the B channel may include: calculating a second product of the new pixel value of the Gb channel and the truncated pixel value of the B channel, and dividing the second product by the truncated pixel value of the Gb channel to obtain the new pixel value of the B channel. That is, B'=Gb'*B / Gb, where B is the truncated pixel value of the B channel, Gb is the truncated pixel value of the Gb channel, Gb' is the new pixel value of the Gb channel, and B' is the new pixel value of the B channel.
[0106] That is, after reconstructing the pixel values of the Gr and Gb channels, the pixel values of the R and B channels can be reconstructed based on this to obtain new pixel values of the R channel and new pixel values of the B channel. For example, Figure 4C As shown, this is an effect diagram without gain suppression processing in the embodiment of the present application; Figure 4D As shown, it is a diagram showing the effect of gain suppression processing in an embodiment of the present application.
[0107] This technical solution proposes an ISP image processing process that amplifies an image and automatically suppresses it based on the gain value during the process. In the suppression phase, a two-round smoothing process is performed by combining an adjustment coefficient gradient operation and a smoothing process, which greatly avoids color cast caused by suppression and ensures pixel uniformity.
[0108] In an embodiment of the present application, the threshold values of each channel are calculated based on a preset maximum pixel value, a digital gain value of each channel, and a lens shading correction gain value of each channel; when the pixel value of the G channel is greater than the target channel threshold value, and the pixel value of the target channel is greater than the target channel threshold value, the pixel value of the target channel is truncated so that the truncated target channel pixel value is equal to the corresponding target channel threshold value; the adjustment coefficient of the G channel is calculated based on the preset maximum pixel value, the pixel adjustment critical value, the truncated pixel value of the G channel, and the pixel value before gain; and the new pixel value of the G channel, the new pixel value of the R channel, and the new pixel value of the B channel are calculated based on the adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel, and the truncated pixel value of the B channel. This method is used to simplify complex parameter adjustment work to adjusting a few parameter configurations of the highlight suppression module HLR, reduce the difficulty of parameter adjustment in software, and effectively adjust the overbrightness or overexposure of images caused by excessive gain.
[0109] like Figure 5 FIG. 1 is a schematic diagram of an embodiment of a device for self-suppression of image gain in an embodiment of the present application, which may include:
[0110] A calculation module 501 is configured to calculate a threshold value for each channel based on a preset maximum pixel value, a digital gain value for each channel, and a lens shading correction gain value for each channel;
[0111] A truncation module 502 is configured to, when the pixel value of the G channel is greater than or equal to the target channel threshold and the pixel value of the target channel is greater than the target channel threshold, truncate the pixel value of the target channel so that the truncated pixel value of the target channel is equal to the corresponding target channel threshold;
[0112] The calculation module 501 is further configured to calculate an adjustment coefficient of the G channel according to the preset maximum pixel value, the pixel adjustment threshold, the truncated pixel value of the G channel, and the pre-gain pixel value;
[0113] The calculation module 501 is also used to calculate the new pixel value of the G channel, the new pixel value of the R channel and the new pixel value of the B channel based on the adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel and the truncated pixel value of the B channel.
[0114] Optionally, a calculation module 501 is specifically configured to calculate the threshold of each channel according to a first formula;
[0115] The first formula is: thr = MP*DG*LSCG;
[0116] Wherein, thr is the threshold value of each channel, MP is the preset maximum pixel value, DG is the digital gain value of each channel, and LSCG is the lens shading correction gain value of each channel.
[0117] Optionally, the calculation module 501 is specifically used to calculate the adjustment value of the G channel based on the preset maximum pixel value, the pixel adjustment critical value, the truncated pixel value of the G channel and the pixel value before gain; and calculate the adjustment coefficient of the G channel based on the adjustment value of the G channel and the truncated pixel value of the G channel.
[0118] Optionally, the calculation module 501 is specifically used to smooth the adjustment coefficient of the G channel to obtain the smoothed adjustment coefficient of the G channel; based on the smoothed adjustment coefficient of the G channel, the truncated pixel value of the G channel, the truncated pixel value of the R channel and the truncated pixel value of the B channel, the new pixel value of the G channel, the new pixel value of the R channel and the new pixel value of the B channel are calculated.
[0119] Optionally, the calculation module 501 is specifically configured to select an adjustment coefficient set for G channel pixel points within a preset array range around a target pixel point; and calculate an average value of the adjustment coefficient set as the adjustment coefficient for the G channel after smoothing.
[0120] Optionally, the G channel includes a Gr channel and a Gb channel, and the calculation module 501 is specifically used to obtain a new pixel value of the Gr channel based on the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel; obtain a new pixel value of the Gb channel based on the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel; obtain a new pixel value of the R channel based on the new pixel value of the Gr channel, the truncated pixel value of the Gr channel and the truncated pixel value of the R channel; obtain a new pixel value of the B channel based on the new pixel value of the Gb channel, the truncated pixel value of the Gb channel and the truncated pixel value of the B channel.
[0121] Optionally, the calculation module 501 is specifically used to calculate the product of the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel as the new pixel value of the Gr channel; calculate the product of the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel as the new pixel value of the Gb channel; calculate the first product of the new pixel value of the Gr channel and the truncated pixel value of the R channel, and then divide the first product by the truncated pixel value of the Gr channel to obtain the new pixel value of the R channel; calculate the second product of the new pixel value of the Gb channel and the truncated pixel value of the B channel, and then divide the second product by the truncated pixel value of the Gb channel to obtain the new pixel value of the B channel.
[0122] like Figure 6 FIG. 1 is a schematic diagram of another embodiment of a device for self-suppression of image gain in an embodiment of the present application, which may include:
[0123] A memory 601 storing executable program code;
[0124] a processor 602 coupled to the memory 601;
[0125] The processor 602 is configured to execute the following steps:
[0126] Calculate the threshold of each channel according to the preset maximum pixel value, the digital gain value of each channel and the lens shading correction gain value of each channel;
[0127] When the pixel value of the G channel is greater than or equal to the target channel threshold, and the pixel value of the target channel is greater than the target channel threshold, the pixel value of the target channel is truncated so that the truncated target channel pixel value is equal to the corresponding target channel threshold;
[0128] Calculating an adjustment coefficient of the G channel according to the preset maximum pixel value, the pixel adjustment threshold, the truncated pixel value of the G channel, and the pre-gain pixel value;
[0129] New pixel values of the G channel, new pixel values of the R channel, and new pixel values of the B channel are calculated based on the adjustment coefficient of the G channel, the truncated pixel values of the G channel, the truncated pixel values of the R channel, and the truncated pixel values of the B channel.
[0130] Optionally, the processor 602 is specifically configured to perform the following steps:
[0131] Calculate the threshold of each channel according to the first formula;
[0132] The first formula is: thr = MP*DG*LSCG;
[0133] Wherein, thr is the threshold value of each channel, MP is the preset maximum pixel value, DG is the digital gain value of each channel, and LSCG is the lens shading correction gain value of each channel.
[0134] Optionally, the processor 602 is specifically configured to perform the following steps:
[0135] The adjustment value of the G channel is calculated based on the preset maximum pixel value, the pixel adjustment critical value, the truncated pixel value of the G channel and the pre-gain pixel value; the adjustment coefficient of the G channel is calculated based on the adjustment value of the G channel and the truncated pixel value of the G channel.
[0136] Optionally, the processor 602 is specifically configured to perform the following steps:
[0137] The adjustment coefficient of the G channel is smoothed to obtain the smoothed adjustment coefficient of the G channel; new pixel values of the G channel, new pixel values of the R channel, and new pixel values of the B channel are calculated based on the smoothed adjustment coefficient of the G channel, the truncated pixel values of the G channel, the truncated pixel values of the R channel, and the truncated pixel values of the B channel.
[0138] Optionally, the processor 602 is specifically configured to perform the following steps:
[0139] An adjustment coefficient set of G channel pixel points within a preset array range around a target pixel point is selected; and an average value of the adjustment coefficient set is calculated as the adjustment coefficient of the G channel after smoothing.
[0140] Optionally, the G channel includes a Gr channel and a Gb channel, and the processor 602 is specifically configured to perform the following steps:
[0141] A new pixel value of the Gr channel is obtained according to the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel; a new pixel value of the Gb channel is obtained according to the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel; a new pixel value of the R channel is obtained according to the new pixel value of the Gr channel, the truncated pixel value of the Gr channel and the truncated pixel value of the R channel; a new pixel value of the B channel is obtained according to the new pixel value of the Gb channel, the truncated pixel value of the Gb channel and the truncated pixel value of the B channel.
[0142] Optionally, the processor 602 is specifically configured to perform the following steps:
[0143] Calculate the product of the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel as the new pixel value of the Gr channel; calculate the product of the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel as the new pixel value of the Gb channel; calculate a first product of the new pixel value of the Gr channel and the truncated pixel value of the R channel, and divide the first product by the truncated pixel value of the Gr channel to obtain the new pixel value of the R channel; calculate a second product of the new pixel value of the Gb channel and the truncated pixel value of the B channel, and divide the second product by the truncated pixel value of the Gb channel to obtain the new pixel value of the B channel.
[0144] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center by wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode to another website, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).
[0145] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0146] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0147] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0148] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0149] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0150] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for self-suppression of image gain, characterized in that: include: Calculate the threshold of each channel according to the preset maximum pixel value, the digital gain value of each channel and the lens shading correction gain value of each channel; When the pixel value of the G channel is greater than or equal to the target channel threshold, and the pixel value of the target channel is greater than the target channel threshold, the pixel value of the target channel is truncated so that the truncated target channel pixel value is equal to the corresponding target channel threshold; Calculating an adjustment coefficient of the G channel according to the preset maximum pixel value, the pixel adjustment threshold, the truncated pixel value of the G channel, and the pre-gain pixel value; The G channel includes a Gr channel and a Gb channel; a new pixel value of the Gr channel is obtained according to the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel; Obtaining a new pixel value of the Gb channel according to the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel; Obtaining a new pixel value of the R channel according to the new pixel value of the Gr channel, the truncated pixel value of the Gr channel, and the truncated pixel value of the R channel; The new pixel value of the B channel is obtained according to the new pixel value of the Gb channel, the truncated pixel value of the Gb channel and the truncated pixel value of the B channel.
2. The method according to claim 1, characterized in that The threshold value of each channel is calculated based on the preset maximum pixel value, the digital gain value of each channel, and the lens shading correction gain value of each channel, including: Calculate the threshold of each channel according to the first formula; The first formula is: thr=MP*DG*LSCG; Wherein, thr is the threshold value of each channel, MP is the preset maximum pixel value, DG is the digital gain value of each channel, and LSCG is the lens shading correction gain value of each channel.
3. The method according to claim 1, characterized in that The step of calculating the adjustment coefficient of the G channel according to the preset maximum pixel value, the pixel adjustment threshold, the truncated pixel value of the G channel, and the pre-gain pixel value includes: Calculating an adjustment value of the G channel according to the preset maximum pixel value, the pixel adjustment critical value, the truncated pixel value of the G channel, and the pixel value before gain; An adjustment coefficient of the G channel is calculated according to the adjustment value of the G channel and the clipped pixel value of the G channel.
4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Smoothing the adjustment coefficient of the G channel to obtain a smoothed adjustment coefficient of the G channel; New pixel values of the G channel, new pixel values of the R channel, and new pixel values of the B channel are calculated based on the adjustment coefficient after smoothing of the G channel, the truncated pixel values of the G channel, the truncated pixel values of the R channel, and the truncated pixel values of the B channel.
5. The method according to claim 4, characterized in that The step of smoothing the adjustment coefficient of the G channel to obtain the smoothed adjustment coefficient of the G channel includes: Select an adjustment coefficient set for G channel pixels within a preset array range around the target pixel; An average value of the adjustment coefficient set is calculated as the adjustment coefficient after the G channel smoothing process.
6. The method according to any one of claims 1 to 3, characterized in that Obtaining a new pixel value of the Gr channel according to the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel includes: Calculate the product of the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel as the new pixel value of the Gr channel; Obtaining a new pixel value of the Gb channel according to the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel includes: Calculate the product of the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel as the new pixel value of the Gb channel; Obtaining the new pixel value of the R channel according to the new pixel value of the Gr channel, the truncated pixel value of the Gr channel, and the truncated pixel value of the R channel includes: Calculate a first product of the new pixel value of the Gr channel and the truncated pixel value of the R channel, and divide the first product by the truncated pixel value of the Gr channel to obtain a new pixel value of the R channel; The obtaining of the new pixel value of the B channel according to the new pixel value of the Gb channel, the truncated pixel value of the Gb channel, and the truncated pixel value of the B channel includes: A second product of the new pixel value of the Gb channel and the truncated pixel value of the B channel is calculated, and the second product is divided by the truncated pixel value of the Gb channel to obtain a new pixel value of the B channel.
7. A device for self-suppression of image gain, characterized in that: include: A calculation module is used to calculate the threshold value of each channel according to a preset maximum pixel value, a digital gain value of each channel and a lens shading correction gain value of each channel; a truncation module, configured to, when the pixel value of the G channel is greater than or equal to the target channel threshold and the pixel value of the target channel is greater than the target channel threshold, truncate the pixel value of the target channel so that the truncated pixel value of the target channel is equal to the corresponding target channel threshold; The calculation module is further configured to calculate an adjustment coefficient of the G channel according to the preset maximum pixel value, the pixel adjustment critical value, the truncated pixel value of the G channel, and the pre-gain pixel value; the G channel includes a Gr channel and a Gb channel; The calculation module is further used to obtain a new pixel value of the Gr channel based on the adjustment coefficient of the Gr channel and the truncated pixel value of the Gr channel; obtain a new pixel value of the Gb channel based on the adjustment coefficient of the Gb channel and the truncated pixel value of the Gb channel; obtain a new pixel value of the R channel based on the new pixel value of the Gr channel, the truncated pixel value of the Gr channel and the truncated pixel value of the R channel; and obtain a new pixel value of the B channel based on the new pixel value of the Gb channel, the truncated pixel value of the Gb channel and the truncated pixel value of the B channel.
8. A device for self-suppression of image gain, characterized in that: include: a memory storing executable program code; a processor coupled to the memory; The processor is configured to execute the method according to any one of claims 1 to 6.
9. A computer-readable storage medium comprising instructions, which, when executed on a processor, causes the processor to perform the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image overexposure correction method and circuit system
CN113038109A
Bayer image highlight recovery device, method and system
CN115665386A