Image optimization method, device, terminal equipment and readable storage medium
By calculating the weight and brightness values of each pixel point in the image data, updating the gamma curve coefficient, and optimizing the image data, the problem of overexposure or overdark images in night vision scenes is solved, and the image quality is improved.
Patent Information
- Application Number
- CN202111148195.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-29
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2041-09-29
AI Technical Summary
In the process of image shooting, especially in night vision scenes, it is difficult to effectively solve the problem of overexposure or overdarkness of image data, resulting in poor image quality.
By determining the first weight of each pixel point in the target image data, and calculating the gamma curve coefficient based on the original brightness values of the multiple target pixel points that meet the preset conditions, updating the brightness value of each pixel point, optimizing the image data.
Effectively filter out the brightness values of pixels that do not meet the preset conditions, and calibrate only based on the original brightness values of pixels that meet the preset conditions, solve the problem of overexposure or overdarkness of the image, and improve the quality of image data.
Smart Images

Figure CN113920022B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of image processing technology, and in particular, relates to an image optimization method, apparatus, terminal device and readable storage medium. Background Art
[0002] During the image capture process, the image data quality is easily affected by the ambient light. Especially in night vision scenes, it is difficult to see the objects in the image data clearly due to the dim background light; or in night vision scenes, when the background light source is too bright, the image data is overexposed and the objects in the image data cannot be seen clearly.
[0003] The related method is usually to determine the average brightness value of the entire image data and update the brightness of the image data according to the average brightness value. However, the optimization result of the above method has low accuracy and still cannot eliminate the problem of image overexposure. Summary of the invention
[0004] The embodiments of the present application provide an image optimization method, apparatus, terminal device, and readable storage medium, which can solve the problem that the optimization results of related methods have low accuracy and cannot eliminate image overexposure.
[0005] In a first aspect, an embodiment of the present application provides an image optimization method, comprising:
[0006] Determine a first weight for each pixel in the target image data;
[0007] Determine a plurality of target pixel points that meet preset conditions, and an original brightness value of each of the target pixel points;
[0008] Calculating a gamma curve coefficient according to the first weight and the original brightness value of each of the target pixels;
[0009] Calculate the brightness update value of each pixel according to the gamma curve coefficient and the original brightness value of each pixel;
[0010] The original brightness value of each pixel is updated to the corresponding brightness update value to obtain the optimized target image data.
[0011] In one embodiment, before determining the first weight of each pixel in the target image data, the method includes:
[0012] The target image data is divided into a plurality of preset areas, and a weight coefficient of each preset area is determined.
[0013] In one embodiment, dividing the target image data into a plurality of preset areas and determining a weight coefficient for each preset area includes:
[0014] Acquire the number of targets, and divide the target image data into preset areas of the number of targets;
[0015] An expected value corresponding to each of the preset areas is obtained, and a weight coefficient of each of the preset areas is determined according to the expected value.
[0016] In one embodiment, determining a first weight of each pixel in the target image data includes:
[0017] Determine a preset area where each pixel in the target image data is located, and obtain a weight coefficient for each pixel;
[0018] The first weight of each pixel is calculated according to the weight coefficient.
[0019] In one embodiment, the determining of a plurality of target pixels satisfying a preset condition and an original brightness value of each of the target pixels comprises:
[0020] Calculate and obtain a brightness histogram of the target image data;
[0021] Selecting a plurality of target pixel points satisfying a preset condition from the target image data according to the brightness histogram;
[0022] The original brightness value of each target pixel is determined respectively.
[0023] In one embodiment, the calculating of the gamma curve coefficient according to the first weight and the original brightness value of each target pixel includes:
[0024] Calculate the second weight of each target pixel according to the original brightness value of each target pixel;
[0025] Calculating a weighted average brightness value of the target image data according to the first weight and a second weight of each of the target pixels;
[0026] The gamma curve coefficient is calculated according to the weighted average brightness value.
[0027] In one embodiment, the step of calculating the second weight of each target pixel according to the original brightness value of each target pixel includes:
[0028] When it is detected that the original brightness value of the target pixel point is less than or equal to the brightness threshold, determining that the second weight of the target pixel point is one;
[0029] When it is detected that the original brightness value of the target pixel is greater than the brightness threshold, a ratio of the original brightness value to the brightness threshold is calculated as a second weight of the target pixel.
[0030] In a second aspect, an embodiment of the present application provides an image optimization device, including:
[0031] A weight determination module, used to determine a first weight of each pixel in the target image data;
[0032] A target pixel point determination module, used to determine a plurality of target pixel points that meet preset conditions, and an original brightness value of each of the target pixel points;
[0033] A coefficient calculation module, used for calculating a gamma curve coefficient according to the first weight and an original brightness value of each target pixel;
[0034] A brightness calculation module, used to calculate the brightness update value of each pixel point according to the gamma curve coefficient and the original brightness value of each pixel point;
[0035] The image optimization module is used to update the original brightness value of each pixel to the corresponding brightness update value to obtain optimized target image data.
[0036] In one embodiment, the device further comprises:
[0037] The region division module is used to divide the target image data into a plurality of preset regions and determine a weight coefficient of each preset region.
[0038] In one embodiment, the area division module includes:
[0039] A region division unit, used for obtaining the target number and dividing the target image data into preset regions of the target number;
[0040] The weight coefficient determining unit is used to obtain an expected value corresponding to each of the preset areas, and determine the weight coefficient of each of the preset areas according to the expected value.
[0041] In one embodiment, the weight determination module includes:
[0042] An area determination unit, used to determine a preset area where each pixel point in the target image data is located, and obtain a weight coefficient of each pixel point;
[0043] The first calculation unit is used to calculate a first weight of each pixel according to the weight coefficient.
[0044] In one embodiment, the target pixel point determination module includes:
[0045] A second calculation unit, used for calculating and obtaining a brightness histogram of the target image data;
[0046] A selection unit, configured to select a plurality of target pixel points satisfying a preset condition from the target image data according to the brightness histogram;
[0047] The brightness value determining unit is used to respectively determine the original brightness value of each of the target pixel points.
[0048] In one embodiment, the coefficient calculation module includes:
[0049] A third calculation unit, used for calculating a second weight of each target pixel point according to an original brightness value of each target pixel point;
[0050] a fourth calculation unit, configured to calculate a weighted average brightness value of the target image data according to the first weight and a second weight of each of the target pixels;
[0051] A fifth calculation unit is used to calculate the gamma curve coefficient according to the weighted average brightness value.
[0052] In one embodiment, the third computing unit comprises:
[0053] A first detection subunit, configured to determine that a second weight of the target pixel is one when it is detected that the original brightness value of the target pixel is less than or equal to a brightness threshold;
[0054] The second detection subunit is used to calculate the ratio of the original brightness value to the brightness threshold as the second weight of the target pixel when it is detected that the original brightness value of the target pixel is greater than the brightness threshold.
[0055] In a third aspect, an embodiment of the present application provides a terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, an image optimization method as described in any one of the first aspects above is implemented.
[0056] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image optimization method as described in any one of the first aspects above is implemented.
[0057] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the image optimization method described in any one of the above-mentioned first aspects.
[0058] Compared with the prior art, the embodiments of the present application have the following beneficial effects: a gamma curve coefficient is calculated through the first weight of each pixel in the target image data and the original brightness values of multiple target pixels that meet preset conditions; a brightness update value of each pixel is calculated based on the gamma curve coefficient and the original brightness value of each pixel; the original brightness value of each pixel is updated to the corresponding brightness update value to obtain optimized target image data; the brightness values of pixels that do not meet the preset conditions can be screened out; the gamma curve coefficient is calculated only based on the original brightness values of pixels that meet the preset conditions; the brightness value of the image data is calibrated, the problem of overexposure or too dark an image is solved, and the quality of the image data is improved.
[0059] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0061] Figure 1 It is a flowchart of the image optimization method provided in Example 1 of the present application;
[0062] Figure 2 is another flowchart of the image optimization method provided in the second embodiment of the present application;
[0063] Figure 3 is a flow chart of step S102 of the image optimization method provided in the second embodiment of the present application;
[0064] Figure 4 is a flowchart of step S103 of the image optimization method provided in the second embodiment of the present application;
[0065] Figure 5 is a schematic diagram of target image data provided in Example 2 of the present application;
[0066] Figure 6 is a schematic diagram of optimized target image data provided in Example 2 of the present application;
[0067] Figure 7 is a structural schematic diagram of an image optimization device provided in Embodiment 3 of the present application;
[0068] Figure 8 It is a structural diagram of the terminal device provided in Example 4 of the present application. DETAILED DESCRIPTION
[0069] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0070] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0071] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0072] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0073] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0074] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0075] The image optimization method provided in the embodiment of the present application can be applied to terminal devices such as mobile phones, tablet computers, vehicle-mounted equipment, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), etc. The embodiment of the present application does not impose any restrictions on the specific type of terminal devices.
[0076] Figure 1 A schematic flow chart of the image optimization method provided in the present application is shown. As an example but not a limitation, the method can be applied to the above-mentioned laptop computer.
[0077] S101. Determine a first weight for each pixel in target image data.
[0078] Specifically, by determining the position information of each pixel in the target image data, determining the area where each pixel in the target image data is located according to the position information, and determining the first weight of each pixel according to the weight coefficient of the area where each pixel is located.
[0079] The target image data refers to the original image data obtained by photographing equipment such as a camera or a digital camera, which has overexposure or dark problems.
[0080] S102: Determine a plurality of target pixel points that meet preset conditions, and an original brightness value of each of the target pixel points.
[0081] Specifically, the original brightness value of each pixel is screened by a preset condition, a plurality of pixels satisfying the preset condition are screened as target pixels, and the original brightness value of each target pixel is determined. The original brightness value refers to the brightness value of the pixel before the image data is optimized.
[0082] Among them, the preset conditions can be specifically set according to actual conditions. For example, when the image data has an overexposure problem, the preset condition can be set as the pixel whose brightness value is much greater than the average brightness value. Correspondingly, some pixel points whose brightness value is much greater than the average brightness value are screened out, and the remaining pixel points with lower and more stable brightness values are used as calculation data to determine the gamma curve coefficient, thereby improving the overexposure problem of the image data. Alternatively, when the image data has an overdarkness problem, the preset condition can be set as the pixel whose brightness value is much less than the average brightness value. Correspondingly, some pixel points whose brightness value is much less than the average brightness value are screened out, and the remaining pixel points with higher and more stable brightness values are used as calculation data to determine the gamma curve coefficient, thereby improving the overdarkness problem of the image data.
[0083] S103: Calculate a gamma curve coefficient according to the first weight and the original brightness value of each target pixel.
[0084] Specifically, a weighted average brightness value of the target image data is determined according to the first weight and the original brightness value of each target pixel, and a gamma curve coefficient of the target image data is calculated according to the weighted average brightness value. The gamma curve coefficient is β, and the brightness value of the target image data can be calibrated according to the gamma curve coefficient.
[0085] S104: Calculate a brightness update value for each pixel according to the gamma curve coefficient and the original brightness value of each pixel.
[0086] Specifically, the brightness update value of each pixel in the target image data is calculated according to the gamma curve coefficient and the original brightness value of each pixel in the target image data.
[0087] S105 , updating the original brightness value of each pixel to a corresponding brightness update value to obtain optimized target image data.
[0088] Specifically, the original brightness value of each pixel in the target image data is updated to a brightness update value corresponding to each pixel to obtain optimized target image data.
[0089] Since the grayscale value of the pixel is in [0, 255], the corresponding update of the brightness value of each pixel can be expressed as:
[0090] y(i)=(x(i) / 256) β *255
[0091] Where x(i) represents the original brightness value of pixel i, y(i) represents the updated brightness value of pixel i, and β represents the gamma curve coefficient.
[0092] This embodiment calculates a gamma curve coefficient through the first weight of each pixel in the target image data and the original brightness values of multiple target pixels that meet the preset conditions, calculates the brightness update value of each pixel according to the gamma curve coefficient and the original brightness value of each pixel, updates the original brightness value of each pixel to the corresponding brightness update value, and obtains the optimized target image data. The brightness values of the pixels that do not meet the preset conditions can be screened out, and the brightness values of the image data are calibrated by calculating the gamma curve coefficient only based on the original brightness values of the pixels that meet the preset conditions, so as to solve the problem of overexposure or too dark images and improve the quality of image data.
[0093] Embodiment 2
[0094] This embodiment is a further explanation of the first embodiment. For details of the same or similar parts as the first embodiment, please refer to the relevant description of the first embodiment, which will not be repeated here. Figure 2 As shown, before step S101 of determining the first weight of each pixel in the target image data in this embodiment, the following steps are included:
[0095] S100: Divide the target image data into a plurality of preset areas, and determine a weight coefficient for each preset area.
[0096] Specifically, the target image data is divided into a plurality of preset areas in advance according to user requirements, and a weight coefficient corresponding to each preset area is set according to the user's expected value.
[0097] The value of the preset area can be specifically set according to user needs. For example, it is set to divide the target image data into regions by obtaining the data input by the user. When the data input by the user is 9 and 4 respectively, the target image data is divided into 9*4 preset areas. Or, when the data input by the user is 8 and 6 respectively, the target image data is divided into 8*6 preset areas.
[0098] In one embodiment, dividing the target image data into a plurality of preset areas and determining a weight coefficient for each preset area includes:
[0099] Acquire the number of targets, and divide the target image data into preset areas of the number of targets;
[0100] An expected value corresponding to each of the preset areas is acquired, and a weight coefficient of each of the preset areas is determined according to the expected value.
[0101] Specifically, a preset target number (or a target number input by a user, the acquisition method is not limited here) is obtained, and the target image data is divided according to the target data to obtain preset regions of the target number. A preset expected value (or a target number input by a user, the acquisition method is not limited here) corresponding to each preset region is obtained respectively, and a corresponding weight coefficient is assigned to each preset region according to the expected value.
[0102] Among them, the expected value can be set to different levels according to the actual situation, and the corresponding weight coefficients are assigned to the preset areas corresponding to the expected values of different levels. For example, the expected value is divided into 4 levels, and the corresponding weight coefficients are assigned to the preset areas corresponding to the expected values of each level (that is, the size of the weight coefficient of the preset area is positively correlated with the level of the expected value). For example, the expected value is 1, indicating that the level is the first level, and the corresponding weight coefficient of the preset area is 1; the expected value is 2, indicating that the level is the second level, and the corresponding weight coefficient of the preset area is 2.
[0103] Table 1 is a schematic table of weight coefficients of a preset area in image data.
[0104] 1 1 1 1 1 1 1 1 1 1 2 3 3 2 1 1 1 2 3 4 4 3 2 1 1 3 4 4 4 4 3 1 1 3 4 4 4 4 3 1 1 2 3 3 3 3 2 1
[0105] Table 1 exemplarily shows the weight coefficients of preset areas in image data. According to Table 1, the image data is currently divided into 8*6 preset areas, wherein the expected values are divided into 4 levels, the weight coefficient assigned to the preset area corresponding to the first level expected value is 1, the weight coefficient assigned to the preset area corresponding to the second level expected value is 2, the weight coefficient assigned to the preset area corresponding to the third level expected value is 3, and the weight coefficient assigned to the preset area corresponding to the fourth level expected value is 4.
[0106] In one embodiment, determining a first weight of each pixel in the target image data includes:
[0107] Determine a preset area where each pixel in the target image data is located, and obtain a weight coefficient for each pixel;
[0108] The first weight of each pixel is calculated according to the weight coefficient.
[0109] Specifically, first determine the position information of each pixel point in the target image data in the target image area, determine the preset area where the pixel point is located according to the position information of each pixel point, and use the weight coefficient of the preset area where the pixel point is located as the weight coefficient of the pixel point. The first weight of each pixel point is calculated and determined according to the weight coefficient of each pixel point.
[0110] Correspondingly, the weight calculation method for each pixel is:
[0111]
[0112] In the formula, w1(i) represents the weight value corresponding to pixel i, αi represents the weight coefficient of the preset area corresponding to pixel i, and a, b, and c are adjustment coefficients that can be used to control the difference between weights corresponding to different weight coefficients. Generally, they can be set to: a=1, b=2, and c=0.
[0113] like Figure 3 As shown, in one embodiment, the determining of a plurality of target pixels satisfying a preset condition and the original brightness value of each of the target pixels comprises:
[0114] S1021, calculating and obtaining a brightness histogram of the target image data;
[0115] S1022, selecting a plurality of target pixel points satisfying a preset condition from the target image data according to the brightness histogram;
[0116] S1023. Determine the original brightness value of each target pixel point respectively.
[0117] Specifically, the brightness histogram of the target image data is obtained by calculating the number of pixels corresponding to different grayscale values in the target image data. According to the original brightness value of each pixel in the brightness histogram, multiple pixels that meet the preset conditions are selected as target pixels, and the original brightness value of each target pixel is determined respectively, so as to calculate the gamma curve coefficient.
[0118] In this embodiment, the preset condition is set as the pixels whose brightness values are in the top 1% of all pixels. For example, there are 1000 pixels in the current target image data. All pixels are sorted according to the brightness value, and the pixels in the top 1% of the sequence (that is, the top 100 pixels with larger brightness values) are selected as non-target pixels. The remaining 99% of the pixels (that is, the last 900 pixels with smaller brightness values) are taken as target pixels, and the original brightness value of each of the above 99% of target pixels is determined.
[0119] Pixels that do not meet user needs are screened out through preset conditions, so that the gamma curve coefficient calculated based on the pixels that meet the preset conditions can more accurately adjust the brightness values of the pixels that do not meet the preset conditions, eliminate the problem of overexposure or too dark image data, and improve the stability of the overall brightness of the image data.
[0120] like Figure 4 As shown, in one embodiment, the gamma curve coefficient is calculated according to the first weight and the original brightness value of each target pixel, including:
[0121] S1031, calculating a second weight of each target pixel according to the original brightness value of each target pixel;
[0122] S1032, calculating a weighted average brightness value of the target image data according to the first weight and a second weight of each of the target pixels;
[0123] S1033. Calculate the gamma curve coefficient according to the weighted average brightness value.
[0124] Specifically, the original brightness value of each target pixel is calculated according to the first preset formula to obtain the second weight of each target pixel, the first weight of each target pixel and the second weight of each target pixel are weighted averaged according to the second preset formula to obtain the weighted average brightness value of the target image data, and the weighted average brightness value of the target image data is calculated according to the third preset formula to obtain the gamma curve coefficient.
[0125] In one embodiment, the step of calculating the second weight of each target pixel according to the original brightness value of each target pixel includes:
[0126] When it is detected that the original brightness value of the target pixel point is less than or equal to the brightness threshold, determining that the second weight of the target pixel point is one;
[0127] When it is detected that the original brightness value of the target pixel is greater than the brightness threshold, a ratio of the original brightness value to the brightness threshold is calculated as a second weight of the target pixel.
[0128] Specifically, the brightness threshold refers to a standard for determining whether the brightness value of a pixel is too low.
[0129] Specifically, when it is detected that the original brightness value of the target pixel is less than or equal to the brightness threshold, it is determined that the brightness of the target pixel is too low, and the second weight of the target pixel is set to one; when it is detected that the original brightness value of the target pixel is greater than the brightness threshold, it is determined that the brightness of the target pixel is good, and the ratio of the original brightness value of the target pixel to the brightness threshold is calculated as the second weight of the target pixel. The brightness threshold can be specifically set according to actual conditions.
[0130] Generally, when the average brightness value of the image data is greater than or equal to 128, the visibility of the image is good, and the corresponding preset brightness threshold is 128.
[0131] Among them, the first preset formula is:
[0132]
[0133] The second preset formula is:
[0134] w=∑w1(i)*w2(i)
[0135] avg=(∑x(i)*w1(i)*w2(i)) / w
[0136] The third preset formula is:
[0137] β=k*(avg / 128)+1-k
[0138] Where x(i) represents the original brightness value of pixel i, w2(i) represents the second weight of pixel i, w represents the weighted sum of pixel i, avg represents the weighted average brightness value of the target image data, and k is the parameter for adjusting the gamma curve coefficient β. In general, the default value of k is 0.4.
[0139] Figure 5 is a schematic diagram of target image data;
[0140] Figure 6 A schematic diagram of optimized target image data.
[0141] according to Figure 5 and Figure 6 It can be seen that the present application can eliminate the overexposure problem in the image data caused by the excessive brightness of the point light source, and at the same time can increase the brightness value of the dark part, making the objects in the image data in the night vision scene clearer.
[0142] This embodiment sets different weights based on the user's expected values for different preset areas, and then determines the corresponding gamma curve coefficients based on the weight values of the pixels in the different preset areas. It can dynamically adjust the brightness adjustment intensity of specific areas based on user needs, improve the optimization effect of specific areas, and improve the accuracy of image optimization results.
[0143] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0144] Embodiment 3
[0145] Corresponding to the image optimization method described in the above embodiment, Figure 7 A structural block diagram of an image optimization device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0146] Reference Figure 7 , the image optimization device 100 comprises:
[0147] A weight determination module 101 is used to determine a first weight of each pixel in the target image data;
[0148] The target pixel point determination module 102 is used to determine a plurality of target pixel points that meet a preset condition, and an original brightness value of each of the target pixel points;
[0149] A coefficient calculation module 103, configured to calculate a gamma curve coefficient according to the first weight and an original brightness value of each target pixel;
[0150] The brightness calculation module 104 is used to calculate the brightness update value of each pixel according to the gamma curve coefficient and the original brightness value of each pixel;
[0151] The image optimization module 105 is used to update the original brightness value of each pixel point to a corresponding brightness update value to obtain optimized target image data.
[0152] In one embodiment, the device further comprises:
[0153] The region division module is used to divide the target image data into a plurality of preset regions and determine a weight coefficient of each preset region.
[0154] In one embodiment, the area division module includes:
[0155] A region division unit, used for obtaining the target number and dividing the target image data into preset regions of the target number;
[0156] The weight coefficient determining unit is used to obtain an expected value corresponding to each of the preset areas, and determine the weight coefficient of each of the preset areas according to the expected value.
[0157] In one embodiment, the weight determination module includes:
[0158] An area determination unit, used to determine a preset area where each pixel point in the target image data is located, and obtain a weight coefficient of each pixel point;
[0159] The first calculation unit is used to calculate a first weight of each pixel according to the weight coefficient.
[0160] In one embodiment, the target pixel point determination module includes:
[0161] A second calculation unit, used for calculating and obtaining a brightness histogram of the target image data;
[0162] A selection unit, configured to select a plurality of target pixel points satisfying a preset condition from the target image data according to the brightness histogram;
[0163] The brightness value determining unit is used to respectively determine the original brightness value of each of the target pixel points.
[0164] In one embodiment, the coefficient calculation module includes:
[0165] A third calculation unit, used for calculating a second weight of each target pixel point according to an original brightness value of each target pixel point;
[0166] a fourth calculation unit, configured to calculate a weighted average brightness value of the target image data according to the first weight and a second weight of each of the target pixels;
[0167] A fifth calculation unit is used to calculate the gamma curve coefficient according to the weighted average brightness value.
[0168] In one embodiment, the third computing unit includes:
[0169] A first detection subunit, configured to determine that a second weight of the target pixel is one when it is detected that the original brightness value of the target pixel is less than or equal to a brightness threshold;
[0170] The second detection subunit is used to calculate the ratio of the original brightness value to the brightness threshold as the second weight of the target pixel when it is detected that the original brightness value of the target pixel is greater than the brightness threshold.
[0171] This embodiment calculates a gamma curve coefficient through the first weight of each pixel in the target image data and the original brightness values of multiple target pixels that meet the preset conditions, calculates the brightness update value of each pixel according to the gamma curve coefficient and the original brightness value of each pixel, updates the original brightness value of each pixel to the corresponding brightness update value, and obtains the optimized target image data. The brightness values of the pixels that do not meet the preset conditions can be screened out, and the brightness values of the image data are calibrated by calculating the gamma curve coefficient only based on the original brightness values of the pixels that meet the preset conditions, so as to solve the problem of overexposure or too dark images and improve the quality of image data.
[0172] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0173] Embodiment 4
[0174] Figure 8 This is a schematic diagram of the structure of the terminal device provided in this embodiment. Figure 8 As shown, the terminal device 8 of this embodiment includes: at least one processor 80 ( Figure 8 Only one is shown in the figure), a memory 81, and a computer program 82 stored in the memory 81 and executable on the at least one processor 80, wherein the processor 80 implements the steps of any of the above-mentioned image optimization method embodiments when executing the computer program 82.
[0175] The terminal device 8 may be a computing device such as a desktop computer, a notebook, a PDA, or a cloud server. The terminal device may include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art will appreciate that Figure 8 It is only an example of the terminal device 8 and does not constitute a limitation on the terminal device 8. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, it may also include input and output devices, network access devices, etc.
[0176] The processor 80 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0177] In some embodiments, the memory 81 may be an internal storage unit of the terminal device 8, such as a hard disk or memory of the terminal device 8. In other embodiments, the memory 81 may also be an external storage device of the terminal device 8, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital card (Secure Digital, SD), a flash card (Flash Card), etc. equipped on the terminal device 8. Further, the memory 81 may also include both an internal storage unit of the terminal device 8 and an external storage device. The memory 81 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program, etc. The memory 81 may also be used to temporarily store data that has been output or is to be output.
[0178] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0179] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0180] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0181] 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 present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0182] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0183] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0184] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0185] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0186] The embodiments described above 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 aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such 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, and should all be included in the protection scope of the present application.
Claims
1. An image optimization method, characterized in that: include: Determine a first weight for each pixel in the target image data; Determine a plurality of target pixel points that meet preset conditions, and an original brightness value of each of the target pixel points; Calculating a gamma curve coefficient according to the first weight and the original brightness value of each of the target pixels; Calculate the brightness update value of each pixel according to the gamma curve coefficient and the original brightness value of each pixel; Update the original brightness value of each pixel to the corresponding brightness update value to obtain optimized target image data; The step of determining a first weight of each pixel in the target image data comprises: Determine a preset area where each pixel in the target image data is located, and obtain a weight coefficient for each pixel; The first weight of each pixel is calculated according to the weight coefficient, wherein the first weight is calculated as follows: Wherein, w1(i) represents the first weight corresponding to pixel i, αi represents the weight coefficient of the preset area corresponding to pixel i, and a, b, and c are adjustment coefficients; The calculating the gamma curve coefficient according to the first weight and the original brightness value of each target pixel point includes: The second weight of each target pixel is obtained by calculating the original brightness value of each target pixel according to a first preset formula, wherein the first preset formula is: Wherein, w2(i) represents the second weight corresponding to the target pixel, and x(i) represents the original brightness value corresponding to the target pixel; The weighted average brightness value of the target image data is calculated based on the first weight and the second weight of each target pixel according to a second preset formula, wherein the second preset formula is: avg=(Σx(i)*w1(i)*w2(i)) / w Among them, w=∑w1(i)*w2(i) Where avg represents the weighted average brightness value of the target image data, x(i) represents the original brightness value corresponding to the target pixel, w1(i) represents the first weight of pixel i, w2(i) represents the second weight corresponding to the target pixel, and w represents the sum of the weights of pixel i; The gamma curve coefficient is obtained by calculating the weighted average brightness value according to a third preset formula, wherein the third preset formula is: β=k*(avg / 128)+1-k Wherein, β represents the gamma curve coefficient, k is the parameter for adjusting the gamma curve coefficient β, and avg represents the weighted average brightness value of the target image data.
2. The image optimization method according to claim 1, characterized in that: Before determining the first weight of each pixel in the target image data, the method includes: The target image data is divided into a plurality of preset areas, and a weight coefficient of each preset area is determined.
3. The image optimization method according to claim 2, characterized in that: The step of dividing the target image data into a plurality of preset areas and determining a weight coefficient for each preset area includes: Acquire the number of targets, and divide the target image data into preset areas of the number of targets; An expected value corresponding to each of the preset areas is acquired, and a weight coefficient of each of the preset areas is determined according to the expected value, wherein the expected value is positively correlated with the weight coefficient of the preset area.
4. The image optimization method according to claim 1, characterized in that: The determining of a plurality of target pixel points satisfying a preset condition and an original brightness value of each of the target pixel points comprises: Calculate and obtain a brightness histogram of the target image data; Selecting a plurality of target pixel points satisfying a preset condition from the target image data according to the brightness histogram; The original brightness value of each target pixel is determined respectively.
5. An image optimization device, characterized in that: include: A weight determination module, used to determine a first weight of each pixel in the target image data; A target pixel point determination module, used to determine a plurality of target pixel points that meet preset conditions, and an original brightness value of each of the target pixel points; A coefficient calculation module, used for calculating a gamma curve coefficient according to the first weight and an original brightness value of each target pixel; A brightness calculation module, used to calculate the brightness update value of each pixel point according to the gamma curve coefficient and the original brightness value of each pixel point; An image optimization module is used to update the original brightness value of each pixel to a corresponding brightness update value to obtain optimized target image data; The weight determination module is further used to determine a preset area where each pixel point in the target image data is located, and obtain a weight coefficient of each pixel point; The weight determination module is further used to calculate a first weight of each pixel point according to the weight coefficient, wherein the first weight is calculated as follows: Wherein, w1(i) represents the first weight corresponding to pixel i, αi represents the weight coefficient of the preset area corresponding to pixel i, and a, b, and c are adjustment coefficients; The coefficient calculation module is further used to calculate the original brightness value of each target pixel point according to a first preset formula to obtain a second weight of each target pixel point, wherein the first preset formula is: Wherein, w2(i) represents the second weight corresponding to the target pixel, and x(i) represents the original brightness value corresponding to the target pixel; The coefficient calculation module is further used to calculate the weighted average brightness value of the target image data based on the first weight and the second weight of each target pixel according to a second preset formula, wherein the second preset formula is: avg=(Σx(i)*w1(i)*w2(i)) / w Among them, w=∑w1(i)*w2(i) Where avg represents the weighted average brightness value of the target image data, x(i) represents the original brightness value corresponding to the target pixel, w1(i) represents the first weight of pixel i, w2(i) represents the second weight corresponding to the target pixel, and w represents the sum of the weights of pixel i; The coefficient calculation module is further used to calculate the gamma curve coefficient based on the weighted average brightness value according to a third preset formula, wherein the third preset formula is: β=k*(avg / 128)+1-k Wherein, β represents the gamma curve coefficient, k is the parameter for adjusting the gamma curve coefficient β, and avg represents the weighted average brightness value of the target image data.
6. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.
7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Image processing apparatus and method, and program
CN102737363A
High-dynamic-range image generation method, device and mobile terminal
CN105578068A
