Image processing method and device, electronic equipment and storage medium
Through the update of the gain processing, the problems of poor accuracy and limited adjustment range of the traditional gain control algorithm are solved, and higher image adjustment accuracy and clarity are achieved.
Patent Information
- Application Number
- CN202311733959.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2025-06-17
AI Technical Summary
Due to the poor accuracy and limited adjustment range of traditional gain control algorithms, the brightness/contrast adjustment of the image is not accurate enough and the optimal display effect cannot be achieved.
By obtaining the parameter original value, parameter target value and initial gain of the image to be processed, the gain processing is performed using the initial gain, and the gain is updated until the deviation between the parameter gain value and the parameter target value is less than the preset threshold value, and the image is then processed to obtain the target image.
Improve the adjustment range and clarity of the image to ensure the optimal display effect of the target image.
Smart Images

Figure CN120163746A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of digital image processing technology, and in particular, to an image processing method, apparatus, electronic device, and storage medium. Background Art
[0002] In the field of digital image processing, gain control is an important technology, which adjusts parameters such as the brightness and contrast of an image to make the adjusted image clearer and easier to observe.
[0003] Traditional gain control algorithms usually use linear transformation to adjust parameters such as the brightness and contrast of an image. Since in the adjustment process, the signals in the digital circuit can only take a finite number of discrete values and cannot take continuous values, the value range in the digital circuit is discrete and discontinuous.
[0004] However, the adjustment range of parameters such as brightness / contrast is limited by the discontinuity of the value range, which easily leads to inaccurate adjustment of the brightness / contrast of the image, and thus cannot achieve the optimal display effect. Therefore, traditional gain control algorithms have drawbacks such as low accuracy and limited adjustment range, which in turn lead to the problem that the adjusted image is not clear in the image processing process. Summary of the Invention
[0005] This application provides an image processing method, apparatus, electronic device, and storage medium to solve the problem that the target image is not clear due to poor accuracy and limited adjustment range of the gain control algorithm in the prior art.
[0006] According to the first aspect of this application, an image processing method is provided, including:
[0007] Obtain the original parameter value, target parameter value, and initial gain of the image to be processed;
[0008] Perform gain processing on the original parameter value using the initial gain to obtain a parameter gain value;
[0009] Determine whether the deviation between the parameter gain value and the target parameter value is less than a preset threshold;
[0010] If not, repeat the following process until a preset stop condition is met:
[0011] Update the gain to obtain an updated gain; perform data processing using the updated gain to obtain an updated parameter gain value;
[0012] Wherein, the preset stop condition is that the deviation between the updated parameter gain value and the target parameter value is less than a preset threshold;
[0013] Perform image processing on the image to be processed according to the updated gain to obtain a target image.
[0014] Optionally, updating the gain to obtain the updated gain includes:
[0015] Perform numerical compensation on the gain through a preset compensation method to obtain the updated gain.
[0016] Optionally, performing numerical compensation on the gain through a preset compensation method to obtain the updated gain includes:
[0017] Determine the sum of the gain and a first preset value as the updated gain; wherein, the gain is the initial gain in the first iteration process; the first preset value is the compensation value in the preset compensation method and is a positive integer.
[0018] Optionally, using the updated gain for data processing to obtain an updated parameter gain value includes:
[0019] Obtain a parameter compensation result; wherein, the parameter compensation result is the sum of the parameter value and the first preset value; the parameter value is the original parameter value in the first iteration process;
[0020] Determine the product of the parameter compensation result and the updated gain as an intermediate calculation value;
[0021] Use the difference between the intermediate calculation value and a second preset value as the updated parameter gain value.
[0022] Optionally, obtaining the original parameter value, parameter target value, and initial gain of the image to be processed includes:
[0023] In response to a processing request for the image to be processed, parse the image to be processed, processing type, and gain configuration information carried in the processing request;
[0024] Look up the parameter type corresponding to the processing type in a preset association table between the processing type and the parameter type;
[0025] Extract the original parameter value and parameter target value corresponding to the parameter type from the image to be processed, and obtain the initial gain corresponding to the parameter type from the gain configuration information.
[0026] Optionally, the gain configuration information includes a gain adjustment method, and the gain adjustment method is automatic adjustment or manual adjustment.
[0027] Optionally, the processing type includes at least one of the following: color correction, sharpening processing, and denoising processing; the parameter type includes at least one of the following: pixels, brightness, and contrast.
[0028] According to a second aspect of the present application, there is provided an image processing apparatus, including:
[0029] An acquisition module, configured to acquire the original value of the parameter, the target value of the parameter, and the initial gain of the image to be processed;
[0030] A gain processing module, configured to perform gain processing on the original value of the parameter by using the initial gain to obtain a parameter gain value;
[0031] A determination module, configured to determine whether the deviation between the parameter gain value and the parameter target value is less than a preset threshold;
[0032] An update module, configured to, if not, repeatedly execute the following process until a preset stop condition is met:
[0033] Update the gain to obtain an updated gain; perform data processing by using the updated gain to obtain an updated parameter gain value;
[0034] wherein the preset stop condition is that the deviation between the updated parameter gain value and the parameter target value is less than a preset threshold;
[0035] An image processing module, configured to perform image processing on the image to be processed according to the updated gain to obtain a target image.
[0036] According to a third aspect of the present application, there is provided an electronic device, including: at least one processor and a memory;
[0037] The memory stores computer execution instructions;
[0038] The at least one processor executes the computer execution instructions stored in the memory, so that the at least one processor executes the image processing method described in the first aspect above.
[0039] According to a fourth aspect of the present application, there is provided a computer-readable storage medium, in which computer execution instructions are stored, and when the computer execution instructions are executed by a processor, they are used to implement the image processing method described in the first aspect above.
[0040] According to a fifth aspect of the present application, there is provided a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the image processing method described in the first aspect.
[0041] An image processing method provided by this application includes: obtaining the original parameter value, target parameter value, and initial gain of the image to be processed; performing gain processing on the original parameter value using the initial gain to obtain a parameter gain value; determining whether the deviation between the parameter gain value and the target parameter value is less than a preset threshold; if not, repeatedly execute the following process until a preset stop condition is met: update the gain to obtain an updated gain; perform data processing using the updated gain to obtain an updated parameter gain value; wherein, the preset stop condition is that the deviation between the updated parameter gain value and the target parameter value is less than the preset threshold; perform image processing on the image to be processed according to the updated gain to obtain a target image.
[0042] When the deviation between the parameter gain value and the target parameter value in this application is greater than or equal to the preset threshold, by updating the gain and performing data processing operations using the updated gain, an updated parameter gain value is obtained, so that the deviation between the updated parameter gain value and the target parameter value is less than the preset threshold, improving the adjustment range of the image to be processed and thus improving the clarity of the target image.
[0043] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of this application, nor is it used to limit the scope of this application. Other features of this application will become easily understood through the following description. Description of the Drawings
[0044] The drawings here are incorporated into the description and form a part of this description, showing embodiments consistent with this application and used together with the description to explain the principles of this application.
[0045] Figure 1 Schematic diagram of the discontinuity of the parameter gain value of the traditional DGAIN algorithm;
[0046] Figure 2 Flow schematic diagram of an image processing method provided by an embodiment of this application;
[0047] Figure 3 Provided by an embodiment of this application Figure 2 Flow schematic diagram of step S10 in
[0048] Figure 4 Flow schematic diagram of another image processing method provided by an embodiment of this application;
[0049] Figure 5 Structural schematic diagram of an image processing device provided by an embodiment of this application;
[0050] Figure 6 Structural schematic diagram of an electronic device provided by an embodiment of this application.
[0051] With the above-mentioned drawings, specific embodiments of the present application have been shown, and more detailed descriptions will be provided hereinafter. These drawings and written descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed Description of the Embodiments
[0052] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application.
[0053] Gain is generally divided into analogue gain (AGAIN) and digital gain (DGAIN). Digital gain is measured in dB and has a discontinuous characteristic. Traditional gain control algorithms usually use linear transformation to adjust parameters such as the brightness, contrast, and pixel values of an image, but this method has problems such as low accuracy and limited adjustment range. As Figure 1 shown, the 16-bit value obtained by multiplying the input data of 8'hFF (i.e., FF in 8-bit hexadecimal) by the gain data of 8'hFF using the traditional digital gain control algorithm is not the expected data 16'hFFFF, but 16'hFE01. This result shows that the value range of the digital circuit is discontinuous, that is, the value range in the digital circuit is discrete rather than continuous. This is because the signals in the digital circuit can only take a finite number of discrete values and cannot take continuous values.
[0054] As Figure 1As shown, the natural value range of 16 bits is [0, FFFF], which is continuous. However, the value range of the 16-bit digital circuit after gain is [0, FE01], which is discontinuous and cannot achieve adjustment in the range of [FE01, FFFF]. In addition, as the data bit width increases, the deviation caused by multiplying the input data by the gain data becomes larger. Compared with the continuity of the natural value range, the discontinuity of the digital circuit value range results in low accuracy of image-related parameters (i.e., the above-mentioned brightness, contrast, pixel value, etc.) and limited adjustment range. This is because the parameters in image processing are usually continuous, while the signals in the digital circuit are discrete, which in turn limits the adjustment range of the parameters in image processing. For example, in image processing, if it is necessary to adjust the value of a parameter to control the brightness of the image, due to the discontinuity of the value range of the digital circuit, the adjustment range of this parameter is limited, resulting in inaccurate adjustment of the image brightness and unable to achieve the optimal display effect. There are multiple gain algorithms with similar situations in the Image Signal Processor (ISP chip), all of which have the above problems, that is: multiplying the input data 8'hFF by the gain data 8'hFF to obtain the parameter gain value 16'hFE01, which is often less than the designed expected value 16'hFFFF in some cases where the bit width is large enough. Therefore, this application needs to propose an image processing method including a more accurate and flexible gain control algorithm to meet the image processing requirements of different scenarios and needs.
[0055] To solve the above technical problems, the overall inventive concept of this application is how to provide an image processing method applied to the field of digital image processing for improving the clarity of the target image.
[0056] The following will specifically describe the technical solutions of this application and how the technical solutions of this application solve the above technical problems with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below with reference to the drawings.
[0057] Embodiment 1:
[0058] Figure 2 It is a schematic flowchart of an image processing method provided by an embodiment of this application. As Figure 2 shown, the method of this embodiment includes the following steps:
[0059] S10. Obtain the original parameter value, target parameter value, and initial gain of the image to be processed.
[0060] In the embodiments of the present application, the original parameter value can be the original value of any type of parameter. The parameter types include, but are not limited to: pixels, brightness, contrast, etc. For the image to be processed, the processing types provided in this embodiment include, but are not limited to: color correction, sharpening processing, denoising processing, etc., and each processing type corresponds to at least one parameter type. It should be understood that the original parameter value can be the input pixel value, input brightness value, input contrast value, etc.
[0061] The embodiments of the present application provide the following three cases, where:
[0062] Case 1: If the processing type for the image to be processed is one, and this processing type corresponds to one parameter type, then in this case, the following steps can be executed sequentially.
[0063] Case 2: If the processing type for the image to be processed is one, and the parameter types corresponding to this processing type are multiple, then in this case, the embodiments of the present application execute steps S20 to step S50 for different parameter types respectively.
[0064] Case 3: If the processing types for the image to be processed are multiple, then in this case, the embodiments of the present application can execute steps S10 to step S50 for different processing types respectively.
[0065] S20. Perform gain processing on the original parameter value using the initial gain to obtain the parameter gain value.
[0066] In this embodiment, the initial gain can also be referred to as the first gain, and the updated gain hereinafter is referred to as the second gain.
[0067] Optionally, the initial gain in this embodiment can be a gain processing for the entire image to be processed, or a gain processing for a partial region of the image to be processed. Different initial gains can also be configured for different regions of the image to be processed. Therefore, the initial gain can be a specific value or a matrix.
[0068] In the embodiments of the present application, the parameter gain value is calculated based on the original parameter value and the first gain, aiming to achieve deviation detection / judgment, and then determine whether to execute the following step S40 according to the magnitude of the deviation. If the deviation is greater than or equal to the preset threshold, then execute step S40; otherwise, execute step S50.
[0069] S30. Determine whether the deviation between the parameter gain value and the parameter target value is less than the preset threshold. If not, then execute step S40; if so, then execute step S50.
[0070] It should be understood that the parameter target value is also referred to as the target value or the expected value. Taking the expected value as the brightness target value, the following is an example: Only when the brightness change is at least 0.5% - 2% (the specific value is affected by "the size of the pupil affected by the ambient brightness and darkness"), can the human eye distinguish the brightness difference. In the embodiment of the present application, the preset threshold can be set to 1%, and software can be combined to calculate the deviation between the brightness value after gain and the brightness target value. When the deviation is greater than 1%, the method provided by the embodiment of the present application can be used to reduce the deviation, thereby improving the quality and clarity of the target image.
[0071] S40. Repeatedly execute the following process until the preset stop condition is met:
[0072] Update the gain to obtain the updated gain; perform data processing using the updated gain to obtain the updated parameter gain value; wherein, the preset stop condition is that the deviation between the updated parameter gain value and the parameter target value is less than the preset threshold.
[0073] In this embodiment, when the deviation between the parameter gain value and the parameter target value is greater than or equal to the preset threshold, the gain is iteratively updated. In each iteration process, in addition to updating the gain, data processing operations are also performed using the updated gain to obtain the updated parameter gain value, and then the step of determining whether the deviation between the updated parameter gain value and the parameter target value is less than the preset threshold is executed; if not, continue the iterative process until the deviation between the updated parameter gain value and the parameter target value is less than the preset threshold.
[0074] The specific process of updating the gain and the specific process of performing data processing using the updated gain in this embodiment are described below and will not be elaborated here.
[0075] S50. Perform image processing on the image to be processed according to the updated gain to obtain the target image.
[0076] In the embodiment of the present application, the closer the updated parameter gain value is to the expected value, the more accurate the target image is. No matter which scenarios such as color correction, sharpening, and denoising are applied later, a corresponding effect can be obtained.
[0077] In the embodiment of the present application, when the deviation between the parameter gain value and the parameter target value is greater than or equal to the preset threshold, by updating the gain and performing data processing operations using the updated gain to obtain the updated parameter gain value, the deviation between the updated parameter gain value and the parameter target value is made less than the preset threshold, improving the adjustment range of the image to be processed and thus improving the clarity of the target image.
[0078] In a possible implementation manner, in step S40, updating the gain to obtain the updated gain includes:
[0079] S401. Numerically compensate the gain through a preset compensation method to obtain an updated gain.
[0080] It should be noted that in this embodiment, the parameters can also be numerically compensated through a preset compensation method to obtain a parameter compensation result. In the embodiments of the present application, different numerical compensations can be performed on the parameters and the gain respectively, or the same numerical compensation can be performed. The embodiments of the present application do not specifically limit the magnitude of this value.
[0081] In the above technical solution, through the preset compensation method, this embodiment can achieve numerical compensation for the parameters and the gain. After the numerical compensation, this embodiment calculates according to the parameter compensation result and the updated gain to obtain an updated parameter gain value, so that the deviation between the updated parameter gain value and the parameter target value is less than a preset threshold, achieving the effect of reducing the deviation.
[0082] In the embodiments of the present application, during the iteration process, the parameter compensation result is numerically different from the original parameter value, and at the same time, the gain is updated. Therefore, the deviation between the updated parameter gain value and the parameter target value gradually decreases until the deviation between the updated parameter gain value and the parameter target value is less than a preset threshold.
[0083] In a possible implementation, step S401. Numerically compensate the gain through a preset compensation method to obtain an updated gain, includes:
[0084] Determine the sum of the gain and a first preset value as the updated gain; wherein, the gain is the initial gain during the first iteration process; the first preset value is the compensation value in the preset compensation method and is a positive integer.
[0085] Similarly, in the first iteration process of this embodiment, the sum of the original parameter value and the first preset value can be determined as the parameter compensation result.
[0086] In the embodiments of the present application, the first preset value can be 1 or other values. The main reason for considering its value as 1 is that although adding other values such as 2 can also have a certain effect, adding 1 can minimize the computing resources as much as possible.
[0087] Since the embodiments of the present application can perform the same numerical compensation on the parameters and the gain respectively, the embodiments of the present application can achieve numerical compensation for the parameters by adding the first preset value to the parameters, and achieve numerical compensation for the gain by adding the first preset value to the gain.
[0088] In the above technical solution, through a specific preset compensation method, this embodiment can achieve numerical compensation for parameters and gains, so that the deviation between the updated parameter gain value and the parameter target value is less than a preset threshold, achieving the effect of reducing the deviation.
[0089] In a possible implementation manner, in step S40, using the updated gain for data processing to obtain the updated parameter gain value includes:
[0090] S4021. Obtain the parameter compensation result; where the parameter compensation result is the addition result of the parameter value and a first preset value; the parameter value is the parameter original value in the first iteration process.
[0091] S4022. Determine the product result of the parameter compensation result and the updated gain as the intermediate calculation value.
[0092] S4023. Use the difference between the intermediate calculation value and a second preset value as the updated parameter gain value.
[0093] The embodiment of the present application describes the data processing process in detail. Through the data processing process in this embodiment, the deviation between the updated parameter gain value and the parameter target value can be made less than a preset threshold, achieving the effect of reducing the deviation.
[0094] In steps S10 to S50 of the embodiment of the present application, a method for improving the calculation accuracy of a digital gain algorithm in the field of digital image processing is proposed. The specific implementation method is as follows:
[0095] (1) Obtain the input pixel value and the first gain; (2) Add 1 to the input pixel value and add 1 to the first gain; (3) Multiply the input pixel value after adding 1 and the gain after adding 1 (i.e., the second gain); (4) Subtract 1 from the multiplication result to obtain the pixel value after the final gain (i.e., the updated parameter gain value).
[0096] For example, for the case where the input pixel value of the image to be processed is 'hFF, the first gain is 'hFF, the first preset value is 1, and the second preset value is 1, using the method provided in this embodiment, it can be obtained that: the parameter compensation result is (FF + 1), the second gain is (FF + 1), the intermediate calculation value is (FF + 1)×(FF + 1), and the updated parameter gain value is (FF + 1)×(FF + 1) - 1 = FFFF.
[0097] It can be seen that by processing the non-linear image features in the image to be processed through the above method, the accuracy of the updated parameter gain value can be higher and the adjustment range can be wider.
[0098] In a possible implementation, the processing types include at least one of the following: color correction, sharpening, and denoising; the parameter types include at least one of the following: pixels, brightness, and contrast.
[0099] The embodiments of the present application can be comprehensively optimized in combination with other image processing algorithms and technologies, such as color correction, sharpening, denoising, etc., to further improve the quality and clarity of the target image.
[0100] Based on the above embodiments, the technical solution of the present application will be described in more detail below with reference to several specific embodiments.
[0101] Embodiment 2:
[0102] Figure 3 For the embodiment of the present application Figure 2 is the flowchart of step S10. Based on the embodiment shown in Figure 2 this embodiment focuses on refining S10 in Figure 2 . As shown in Figure 3 , step S10, obtaining the parameter original value, parameter target value, and initial gain of the image to be processed, includes the following steps:
[0103] S101. In response to a processing request for the image to be processed, parse out the image to be processed, processing type, and gain configuration information carried in the processing request.
[0104] S102. Look up the parameter type corresponding to the processing type in a preset association table between the processing type and the parameter type.
[0105] S103. Extract the parameter original value and parameter target value corresponding to the parameter type from the image to be processed, and obtain the initial gain corresponding to the parameter type from the gain configuration information.
[0106] By performing the operations of S101 to S103 above, the embodiments of the present application can automatically obtain the parameter original value and parameter target value, reduce user operations, and provide convenience.
[0107] In a possible implementation, in step S103, the gain configuration information includes a gain adjustment method, and the gain adjustment method is automatic adjustment or manual adjustment.
[0108] In addition to parsing out the parameter original value and parameter target value of the image to be processed from the processing request, this embodiment can also parse out the gain configuration information, and the configuration information includes the gain adjustment method. The gain adjustment method includes automatic adjustment and manual adjustment. When the gain adjustment method is automatic adjustment, this embodiment can determine the gain data in the stable state as the gain; or, when the gain adjustment method is manual adjustment, this embodiment uses the data written by the user through the input device as the gain.
[0109] For example, generally, in order to process a very dark scene, after the ISP chip has been adjusted to the set maximum threshold, the brightness still fails to meet the requirements. At this time, the embodiments of the present application can adjust the digital gain of the ISP chip. The main adjustment process is as follows: First, perform software calculations, and then apply the obtained parameter gain value to the hardware for gain processing.
[0110] Through software calculations, specifically, the configuration information includes the following parameters:
[0111] (1) DGAIN_EN: Configured as 0, it represents the manual mode; configured as 1, it represents the automatic mode; (2) DG_TARGET: Represents the target value; (3) DG_MAX: Represents the maximum value (or upper limit) of the data gain DGAIN; (4) DG_MIN: Represents the minimum value (or lower limit) of the numerical gain DGAIN; (5) DG_STABLE: Represents the stable range of the numerical gain DGAIN; (6) DG_MANUAL: Represents the manual input value of the numerical gain DGAIN.
[0112] 1) Adjustment process of the numerical gain DGAIN in the automatic mode: When DGAIN_EN is 1, the adjustment process is as follows:
[0113] ① If the target value is greater than the actual value (i.e., the parameter gain value), the numerical gain DGAIN increases and is adjusted according to the ratio between the two; ② If the target value is less than the actual value, the numerical gain DGAIN decreases and is adjusted according to the ratio between the two; ③ The adjustment ends until it is within the stable range. At this time, the numerical gain DGAIN is not adjusted and is the set stable state value.
[0114] 2) Adjustment process of the numerical gain DGAIN in the manual mode: When DGAIN_EN is 0, the adjustment process is as follows:
[0115] Taking the parameter as brightness as an example, manually configure it subjectively according to the brightness of the image.
[0116] Therefore, the DGAIN value is a value that basically meets the requirements obtained based on software algorithms. No matter what the value of DGAIN is, for digital circuits, it proportionally increases the original brightness value at the expense of continuity. Through the above description, data support can be provided for subsequent implementation of the numerical processing process.
[0117] Embodiment 3:
[0118] Figure 4 It is a schematic flowchart of another image processing method provided by the embodiments of the present application. As Figure 4 shown, the method of this embodiment includes the following steps:
[0119] S41. Obtain the original data of the image to be processed, and perform a multiplication calculation on the original data and the gain to obtain a parameter gain value. In the embodiments of the present application, the original data is the parameter original value; this gain, or the initial gain, refers to the first gain in other embodiments.
[0120] S42. Perform deviation detection / judgment on the parameter gain value to obtain the deviation between the parameter gain value and the target value, and determine whether to execute step S43 or step S44 according to the deviation. Steps S41 to S42 can prevent the situation of over-adjustment in the embodiments of the present application.
[0121] S43. When the deviation is less than the preset threshold, output the parameter.
[0122] S44. When the deviation is greater than or equal to the preset threshold, repeatedly execute the following process: In the first iteration process: perform a process of adding 1 to the original data, perform a process of adding 1 to the gain, and perform a multiplication calculation on the original data after adding 1 and the gain after adding 1 to output a new parameter gain value, and determine whether the deviation between the new parameter gain value and the target value is less than the preset threshold. If so, execute step S45; otherwise, repeatedly execute step S44: add 1 to the original data after adding 1 again, and continue to perform a process of adding 1 to the gain after adding 1 until the deviation between the new parameter gain value and the target value is less than the preset threshold. It should be understood that the gain after adding 1 is the updated gain in other embodiments. The target value is the expected value in other embodiments.
[0123] S45. Combine the gain after adding 1 and perform image processing on the image to be processed to obtain the target image.
[0124] The specific implementation manner can be selected and adjusted according to different application scenarios and hardware platforms. The following are some possible implementation manners:
[0125] (1) Hardware implementation: In the embodiments of the present application, a gain control module capable of implementing the image processing method of the embodiments of the present application can be added to the ISP chip to achieve a more precise image processing function. For example, this module can be added to a Field-Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), or a chip capable of implementing digital signal processing technology (Digital Signal Processing, DSP chip), and the gain calculation and control are implemented through a hardware circuit. The specific implementation manner can be written and tested using hardware description languages such as Verilog or VHDL.
[0126] (2) Software implementation: In the embodiments of the present application, the gain control algorithm in the image processing method provided in this embodiment can be added to the image processing software to achieve a more flexible image processing function. For example, the algorithm can be implemented in programming languages such as C, C++, or Python, and the gain calculation and control are realized through software simulation. The specific implementation method can be written and tested using image processing libraries such as OpenCV and TensorFlow.
[0127] The following will refer to Figure 4 and combine with examples to make a more detailed description of the specific implementation manners of the present application. It should be noted that the following is only an example of the present application, and the specific situation can be improved in combination with its own examples.
[0128] Example: For the convenience of display, the input image is a 17×16 row-column gradient [4:0] data matrix. The input data is processed correspondingly using the conventional DGAIN algorithm and the method provided in the embodiments of the present application, and then the corresponding data matrix is output, and the two are compared. The data matrix processing process of this example can be implemented using Matlab software.
[0129] The above [4:0] indicates that the bit width of the elements in the matrix is 5. For example, the binary 11111 is a 5-bit value, corresponding to the decimal 31.
[0130] The embodiments of the present application are in accordance with Figure 4 the image processing method shown, and perform the following steps:
[0131] First, the embodiments of the present application provide a data matrix A with an input data of 17×16:
[0132]
[0133] Using the conventional DGAIN algorithm, the row-column gradient pixel values [4:0] in the data matrix A with an input data of 17×16 are multiplied by the initial gain 5’h1F, and then shifted right by 5 bits for output. The output data matrix B is:
[0134]
[0135] It can be seen from the data matrix B that except for the first pixel value, the values obtained after processing the remaining pixel values with the maximum gain value of 5 bits are 1 less than the original values. That is:
[0136] Data_in[4:0]×DGAIN[4:0]=Data_out_temp[9:0];
[0137] Data_out_temp[9:0]>>5=Data_out[4:0].
[0138] Then perform deviation determination: Obviously, when the traditional DGAIN algorithm is used in this scenario, there are deviations for most of the values.
[0139] Next, use the gain control algorithm (including steps S41 to S44) in the method of this application embodiment to calculate the gain. First, add 1 to the input pixel value and add 1 to the initial gain; then multiply the input pixel value after adding 1 by the gain after adding 1; then subtract 1 from the multiplication result to obtain the final pixel gain result (i.e., the following data matrix C):
[0140]
[0141] It can be seen from the data matrix C that (Data_in[4:0]+1)×(DGAIN[4:0]+1)-1 = Data_out_temp[9:0]; Data_out_temp[9:0]>>5 = Data_out[4:0]. When the gain is maximum, the obtained results all meet the design expected values, completely avoiding the errors brought by the conventional DGAIN algorithm.
[0142] In the specific example provided in Embodiment 3, it can be seen from the data matrix C that using this technology completely avoids the errors brought by the conventional DGAIN algorithm.
[0143] Replacing the parameter type from pixel to brightness can also achieve the same effect. Specifically, in this embodiment, a reasonable reference value (i.e., the above-mentioned expected value) can be set first according to parameters such as brightness, and then the actual brightness value can be calculated by using the conventional DGAIN algorithm. Then, based on the deviation between the actual brightness value and the reference value, it can be determined whether the image needs to be adjusted. When the deviation exceeds a certain threshold, the image processing method provided in this embodiment can be used to calculate the optimal gain brightness value (i.e., the above-mentioned updated parameter gain value), so as to adjust the output of the brightness gain, enabling it to extract and process image information more accurately, thereby obtaining a more accurate brightness and a higher-quality target image.
[0144] Compared with the conventional DGAIN algorithm, the method provided in this embodiment has higher accuracy and better stability because it takes into account the non-linear characteristics of parameters such as image brightness and can be adjusted according to the actual deviation situation. Therefore, in practical applications, the image processing method provided in this embodiment can better meet the requirements of image processing and improve the brightness and quality of the image. In terms of contrast, it can make the dark areas darker and the bright areas brighter, with a better overall visual effect, and can improve the display effect of the target image.
[0145] Embodiment 4:
[0146] Figure 5 The following is a schematic structural diagram of an image processing apparatus provided by an embodiment of the present application. The apparatus in this embodiment can be in the form of software and / or hardware. As Figure 5 shown, the image processing apparatus provided by this embodiment includes: an acquisition module 51, a gain processing module 52, a determination module 53, an update module 54, and an image processing module 55. Among them:
[0147] The acquisition module 51 is configured to acquire the original value of the parameter, the target value of the parameter, and the initial gain of the image to be processed.
[0148] The gain processing module 52 is configured to perform gain processing on the original parameter value by using the initial gain to obtain a parameter gain value.
[0149] The determination module 53 is configured to determine whether the deviation between the parameter gain value and the parameter target value is less than a preset threshold.
[0150] The update module 54 is configured to, if not, repeat the following process until a preset stop condition is met:
[0151] Update the gain to obtain an updated gain; perform data processing by using the updated gain to obtain an updated parameter gain value; wherein, the preset stop condition is that the deviation between the updated parameter gain value and the parameter target value is less than the preset threshold.
[0152] The image processing module 55 is configured to perform image processing on the image to be processed according to the updated gain to obtain a target image.
[0153] In a possible implementation manner, the update module 54 is further configured to:
[0154] Perform numerical compensation on the gain through a preset compensation method to obtain an updated gain.
[0155] In a possible implementation manner, the update module 54 is further configured to:
[0156] Determine the sum result of the gain and a first preset value as the updated gain; wherein, the gain is the initial gain in the first iteration process; the first preset value is the compensation value in the preset compensation method and is a positive integer.
[0157] In a possible implementation manner, the update module 54 is further configured to:
[0158] Obtain a parameter compensation result; wherein, the parameter compensation result is the sum result of the parameter value and the first preset value; the parameter value is the original parameter value in the first iteration process.
[0159] Determine the product result of the parameter compensation result and the updated gain as an intermediate calculation value.
[0160] Use the difference between the intermediate calculated value and the second preset value as the updated parameter gain value.
[0161] In a possible implementation, the obtaining module 51 is further configured to:
[0162] In response to a processing request for an image to be processed, parse out the image to be processed, the processing type, and the gain configuration information carried in the processing request;
[0163] Look up the parameter type corresponding to the processing type in a preset association table between the processing type and the parameter type;
[0164] Extract the parameter original value and the parameter target value corresponding to the parameter type from the image to be processed, and obtain the initial gain corresponding to the parameter type from the gain configuration information.
[0165] In a possible implementation, the gain configuration information includes a gain adjustment method, and the gain adjustment method is automatic adjustment or manual adjustment.
[0166] In a possible implementation, the processing type includes at least one of the following: color correction, sharpening processing, and denoising processing; the parameter type includes at least one of the following: pixels, brightness, and contrast.
[0167] The image processing device provided in this embodiment can be used to execute the image processing method provided in any of the above method embodiments. The implementation principle and technical effects are similar and will not be elaborated here.
[0168] It should be noted that the user information and data involved in this application (including but not limited to data for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties. The collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions, and corresponding operation entrances are provided for users to choose to authorize or refuse.
[0169] That is to say, in the technical solution of this application, the collection, storage, use, processing, transmission, provision, and disclosure of the user's personal information involved all comply with the provisions of relevant laws and regulations and do not violate public order and good customs.
[0170] According to the embodiments of this application, this application also provides an electronic device and a readable storage medium.
[0171] Figure 6 It is a schematic structural diagram of an electronic device provided in an embodiment of this application. The electronic device includes a receiver 60, a transmitter 61, at least one processor 62, and a memory 63. The electronic device composed of the above components can be used to implement several specific embodiments of this application above, which will not be elaborated here.
[0172] An embodiment of the present application further provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, each step in the method in the above embodiment is implemented.
[0173] An embodiment of the present application further provides a computer program product, including a computer program, which implements each step in the method in the above embodiment when executed by a processor.
[0174] It should be understood that various forms of the processes shown above can be used, steps can be reordered, added or deleted. For example, the steps recorded in the disclosure of the present application can be executed in parallel, sequentially or in a different order, as long as the desired results of the technical solutions disclosed in the present application can be achieved. No limitation is made herein.
[0175] The above specific embodiments do not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the principles of the present application shall be included within the protection scope of the present application.
Claims
1. An image processing method, characterized in that, Comprising: Obtaining the original parameter value, target parameter value, and initial gain of the image to be processed; Performing gain processing on the original parameter value using the initial gain to obtain a parameter gain value; Determining whether the deviation between the parameter gain value and the target parameter value is less than a preset threshold; If not, then repeatedly execute the following process until a preset stop condition is met: Updating the gain to obtain an updated gain; performing data processing using the updated gain to obtain an updated parameter gain value; Wherein, the preset stop condition is that the deviation between the updated parameter gain value and the target parameter value is less than a preset threshold; Performing image processing on the image to be processed according to the updated gain to obtain a target image.
2. The method according to claim 1, characterized in that, The updating the gain to obtain an updated gain includes: Performing numerical compensation on the gain through a preset compensation method to obtain an updated gain.
3. The method according to claim 2, characterized in that, The performing numerical compensation on the gain through a preset compensation method to obtain an updated gain includes: Determining the sum result of adding the gain and a first preset value as the updated gain; wherein, the gain is the initial gain in the first iteration process; the first preset value is the compensation value in the preset compensation method and is a positive integer.
4. The method according to any one of claims 1 to 3, characterized in that, The performing data processing using the updated gain to obtain an updated parameter gain value includes: Obtaining a parameter compensation result; wherein, the parameter compensation result is the sum result of adding a parameter value and the first preset value; the parameter value is the original parameter value in the first iteration process; Determining the product result of multiplying the parameter compensation result and the updated gain as an intermediate calculation value; Taking the difference between the intermediate calculation value and a second preset value as the updated parameter gain value.
5. The method according to claim 1, characterized in that, The obtaining the original parameter value, target parameter value, and initial gain of the image to be processed includes: In response to a processing request for the image to be processed, parsing the image to be processed, processing type, and gain configuration information carried in the processing request; Searching in a preset association table between the processing type and the parameter type for the parameter type corresponding to the processing type; Extracting the original parameter value and target parameter value corresponding to the parameter type from the image to be processed, and obtaining the initial gain corresponding to the parameter type from the gain configuration information.
6. The method according to claim 5, characterized in that, The gain configuration information includes a gain adjustment method, and the gain adjustment method is automatic adjustment or manual adjustment.
7. The method according to claim 5, characterized in that, The processing type includes at least one of the following: color correction, sharpening processing, and denoising processing; the parameter type includes at least one of the following: pixel, brightness, and contrast.
8. An image processing apparatus, characterized in that, Comprising: An obtaining module, configured to obtain the original parameter value, target parameter value, and initial gain of the image to be processed; A gain processing module, configured to perform gain processing on the original parameter value using the initial gain to obtain a parameter gain value; A determination module, configured to determine whether the deviation between the parameter gain value and the target parameter value is less than a preset threshold; An update module, configured to, if not, then repeatedly execute the following process until a preset stop condition is met: Update the gain to obtain the updated gain; use the updated gain for data processing to obtain an updated parameter gain value; wherein the preset stop condition is that the deviation between the updated parameter gain value and the parameter target value is less than a preset threshold; An image processing module, configured to perform image processing on the image to be processed according to the updated gain to obtain a target image.
9. An electronic device, characterized in that, Comprising: At least one processor and a memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the image processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the image processing method according to any one of claims 1 to 7.