A method for adaptively adjusting image contrast based on image brightness information
Through adaptive adjustment of image brightness information, the problem of inflexible image contrast adjustment is solved, precise adjustment of contrast is achieved, and the visual effect and detail performance of the image are improved.
Patent Information
- Application Number
- CN202410932918.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-12
AI Technical Summary
It is difficult to flexibly adjust the contrast according to the image content with the existing technology, which may lead to problems such as unclear dark parts, low brightness, and unclear details in the image, which affects the visual effect.
By extracting image brightness information, conducting brightness distribution statistics, judging the image type, determining the brightness adjustment curve according to the type, and adjusting the contrast point by point to ensure that the contrast of the R, G, and B channels of the image is balanced and the texture details of the image are retained.
It realizes adaptive contrast adjustment of image content, improves the clarity and visual effect of the image, and avoids the loss of details or graying caused by too high or too low contrast.
Smart Images

Figure CN118469886B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method for adaptively adjusting image contrast based on image brightness information. Background Art
[0002] The information age is developing rapidly. Images are one of the important sources of information for people. People have higher and higher requirements for image quality, and image contrast is an important indicator of the performance of various electronic video devices. Image contrast refers to the measurement of different brightness levels between the brightest white and the darkest black in the light and dark areas of an image, that is, the size of the grayscale contrast of an image. The larger the difference range, the higher the contrast, and the smaller the difference range, the lower the contrast. The impact of contrast on visual effects is very critical. Generally, the greater the contrast, the clearer and more eye-catching the image.
[0003] High contrast is very helpful for image clarity, detail expression, and grayscale expression. However, too high a contrast can easily make the image appear rough or even lose some details, while too low a contrast can make the entire image appear gray. For example, when users take pictures daily, the dark parts of the image are often unclear, the overall brightness of the image is low, and the image details are not obvious due to reasons such as light or equipment. Therefore, it is necessary to adjust the contrast appropriately according to the different content of the image so that the image can show vivid and rich details as much as possible.
[0004] The present invention designs a method for adaptively adjusting image contrast based on image brightness information, which can effectively adjust the image contrast according to different image contents, has high flexibility, can retain rich texture details of the image, and achieves better visual effects. Summary of the invention
[0005] The present invention provides a method for adaptively adjusting image contrast based on image brightness information, comprising:
[0006] Step 1, extracting the brightness information of the input image;
[0007] Step 2, perform brightness distribution statistics on the brightness information, and determine the type of the input image according to a preset threshold: low brightness, high brightness, too high contrast or too low contrast;
[0008] Step 3, determine the brightness adjustment curve according to the type of image, and adjust the contrast point by point;
[0009] Step 4: Divide the adjusted brightness information by the brightness information of the input image to obtain the gain adjustment coefficient of each pixel point, and map the R, G, and B channels of the input image respectively.
[0010] Further, step 1 comprises:
[0011] Calculate the brightness information of each pixel to obtain the initial brightness information of the input image ,
[0012] ,
[0013] in, They are the R, G, and B channel brightness information of the input image respectively;
[0014] right Perform normalization to obtain the input image brightness information :
[0015] ,
[0016] in, Represents the maximum initial brightness of all pixels in the input image. .
[0017] Further, step 2 includes:
[0018] The brightness range Equally divided, based on brightness information Constructing a brightness histogram , count the number of pixels in each brightness range , Pick , ,in, Indicates the bit width of the input image, based on the brightness histogram Calculated to be located at Brightness value at the quantile , this brightness value reflects the brightness distribution of the image. The usual value range is [80, 99];
[0019] when When , the input image is considered to be dark as a whole and is judged as a low-brightness image; when When , the input image is considered to be brighter overall and is judged as a highlight image, where They are respectively the lower and upper limits of the brightness threshold which are preset;
[0020] when When , the brightness histogram is further calculated Variance ,when Less than the preset variance adjustment threshold When , the overall image is considered to have a faded appearance, and the input image contrast is judged to be too low; when Greater than the preset variance adjustment threshold When , the dark part of the picture is considered too dark and the bright part is too bright, and the contrast of the input image is judged to be too high; when When , the input image is considered to have moderate contrast and no contrast adjustment is required.
[0021] In one case, step 3 includes:
[0022] When the input image is judged to be a low-brightness image, the brightness information is calculated according to the following curve For overall brightening:
[0023] ,
[0024] parameter Together they determine the degree of image brightening, where The preset fixed parameters determine the upper and lower limits of the image output brightness respectively. They are set according to the specific brightening requirements. In order to avoid overflow and truncation of image data, ; For The relevant adaptive adjustment parameters determine the degree of brightening of the middle grayscale and should satisfy , calculated as follows:
[0025] ,in, is the preset curve slope and deviation value, is a constant greater than 5, the deviation value Should meet .
[0026] In another case, step 3 includes:
[0027] When the input image is judged to be a highlight image, the brightness information To darken the whole:
[0028] ,
[0029] parameter Together they determine the degree of darkening of the image, where The preset fixed parameters determine the upper and lower limits of the image output brightness respectively. They are set according to the specific dimming requirements. In order to avoid overflow and truncation of image data, ; For The relevant adaptive adjustment parameters determine the degree of darkening of the middle grayscale and should satisfy , calculated as follows: ,in, is the preset curve slope and deviation value, the value range is .
[0030] In another case, step 3 includes:
[0031] When the input image contrast is judged to be too low or too high, the inflection point of the S curve is determined by the following linear function: :
[0032] ,
[0033] in, are the preset slope and deviation values, The value range is 0.8~1. The value range is 0~0.2;
[0034] The brightness information is respectively located at the inflection point of the S curve Variance of the pixel groups on both sides: Assume that The variance statistics of the pixel group is ,satisfy The variance statistics of the pixel group is :
[0035] (1) When the contrast of the input image is too low and the picture appears gray, the S curve is used to calculate the brightness information. To improve contrast, construct an S-curve as follows:
[0036] ,
[0037] in, is a preset fixed parameter. In order to avoid overflow and truncation of image data, Set to a constant not greater than 1; Set to a constant not greater than 0.05 to prevent the gradient from reversing in low-brightness areas of the image, satisfying ; For The relevant adaptive adjustment parameters determine the inflection point The degree of brightening of the input data on the right; For The relevant adaptive adjustment parameters determine the inflection point The degree of darkening of the input data on the left. , Should meet , the specific calculation is as follows:
[0038] ,
[0039] ,
[0040] in, are two sets of preset curve slopes. is a constant greater than 1.5, is a constant less than 0.4, are two sets of preset curve deviation values. The value range is , The value range is ;
[0041] (2) When the contrast of the input image is too high, the dark parts of the image are too dark and the bright parts are too bright, and some details are lost. In this case, the inverse S curve is used to appropriately reduce the brightness information. The contrast ratio is constructed by the following formula to construct the inverse S curve:
[0042] ,
[0043] in, is a preset fixed parameter. In order to avoid overflow and truncation of image data, Set to a constant not greater than 1; Set to a constant not greater than 0.05 to prevent the gradient from reversing in low-brightness areas of the image, satisfying ; For The relevant adaptive adjustment parameters determine the inflection point The degree of darkening of the input data on the right. For The relevant adaptive adjustment parameters determine the inflection point The degree of brightening of the input data on the left. satisfy , the specific calculation is as follows:
[0044] ,
[0045] ,
[0046] in, are two sets of preset curve slopes. is a constant less than 0.8, is a constant greater than 1.1, are two sets of preset curve deviation values.
[0047] The value range is , The value range is .
[0048] Furthermore, in order to control the degree of image contrast adjustment, a contrast adjustment global coefficient is introduced , calculate the output brightness information
[0049] ,
[0050] in, is the output after contrast adjustment in step 3 above, The final output brightness information.
[0051] Further, step 4 includes:
[0052] The final output brightness information With brightness information Divide to get the gain adjustment coefficient of each pixel in the image :
[0053] ,
[0054] Map the R, G, and B channels of the input image separately to get the final image :
[0055] . BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 Shown is a flow chart of image contrast adjustment of the present invention;
[0057] Figure 2 Shown is a schematic diagram of the histogram distribution of the present invention;
[0058] Figure 3 The figure shows a schematic diagram of a low-brightness image brightness mapping curve of the present invention;
[0059] Figure 4 The figure shows the effect comparison before and after the contrast of a low-brightness image is adjusted using the low-brightness image brightness mapping curve of the present invention;
[0060] Figure 5 The figure shows a schematic diagram of a highlight image brightness mapping curve of the present invention;
[0061] Figure 6 The figure shows the effect comparison before and after the contrast of the highlight image is adjusted using the highlight image brightness mapping curve of the present invention;
[0062] Figure 7 Shown is a schematic diagram of a low-contrast image brightness mapping curve of the present invention;
[0063] Figure 8 The figure shows the effect comparison before and after the low-contrast image is adjusted using the low-contrast image brightness mapping curve of the present invention;
[0064] Fig. 9 The figure shows a schematic diagram of a high contrast image brightness mapping curve of the present invention;
[0065] Fig.10 Shown is a comparison diagram of the effects before and after the high-contrast image is adjusted using the high-contrast image brightness mapping curve of the present invention. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0067] See also Figure 1 The present invention provides a method for adaptively adjusting image contrast based on image brightness information, comprising:
[0068] Step 1, extracting the brightness information of the input image;
[0069] Step 2, perform brightness distribution statistics on the brightness information, and determine the type of the input image according to a preset threshold: low brightness, high brightness, too high contrast or too low contrast;
[0070] Step 3, determine the brightness adjustment curve according to the type of image, and adjust the contrast point by point;
[0071] Step 4: Divide the adjusted brightness information by the brightness information of the input image to obtain the gain adjustment coefficient of each pixel point, and map the R, G, and B channels of the input image respectively.
[0072] See also Figure 2 , the brightness histogram describes the statistical characteristics of each brightness level of the image. Its horizontal axis is the brightness level of each pixel in the image, and the vertical axis represents the number and frequency of pixels with each brightness level in the image. We can use the histogram corresponding to the image to determine whether an image is dark or bright. Usually, the data in the histogram of a darker image is mostly concentrated on the left and middle parts, while the data in the histogram of an overall bright image is mostly concentrated on the right.
[0073] Embodiment 1: When the input image is determined to be a low-brightness image, the brightness information is calculated according to the following curve: For overall brightening:
[0074] ,
[0075] parameter Together they determine the degree of image brightening, where These are preset fixed parameters that determine the upper and lower limits of the image output brightness. They are set according to specific brightening requirements. In order to avoid overflow and truncation of image data, it is usually necessary to meet ; For The relevant adaptive adjustment parameters determine the degree of brightening of the middle grayscale and should satisfy , calculated as follows:
[0076] ,
[0077] in, is the preset curve slope and deviation value, Usually a constant greater than 5, the deviation value Should meet , the brightness mapping curve diagram of the low-brightness image is as follows Figure 3 As shown, the dotted line in the figure is the brightness information , the curve is the output brightness information after brightness enhancement . For a comparison of the effects before and after using the low-brightness image brightness mapping curve to adjust the contrast of a low-brightness image, see Figure 4 .
[0078] Embodiment 2: When the input image is determined to be a highlight image, the brightness information is overall dimmed:
[0079] ,
[0080] parameter Together they determine the degree of darkening of the image, where The preset fixed parameters determine the upper and lower limits of the image output brightness respectively. They are set according to the specific dimming requirements. In order to avoid overflow and truncation of image data, ; For The relevant adaptive adjustment parameters determine the degree of darkening of the middle grayscale and should satisfy , calculated as follows: ,in, is the preset curve slope and deviation value, the value range is , the brightness mapping curve diagram of the highlight image is as follows Figure 5 As shown, the dotted line in the figure is the brightness information , the curve is the output brightness information after brightness is dimmed . For a comparison of the effects before and after using the highlight image brightness mapping curve to adjust the contrast of the highlight image, see Figure 6 .
[0081] Embodiment 3: When it is determined that the contrast of the input image is too low or too high, the inflection point of the S curve is determined by the following linear function: :
[0082] ,
[0083] in, are the preset slope and deviation values.
[0084] The brightness information is respectively located at the inflection point of the S curve Variance of the pixel groups on both sides: Assume that The variance statistics of the pixel group is ,satisfy The variance statistics of the pixel group is :
[0085] (1) When the contrast of the input image is too low and the picture appears gray, the S curve is used to calculate the brightness information. To improve contrast, construct an S-curve as follows:
[0086] ,
[0087] in, is a preset fixed parameter. In order to avoid overflow and truncation of image data, Set to a constant not greater than 1; Set to a constant not greater than 0.05 to prevent the gradient from reversing in low-brightness areas of the image, satisfying ; For The relevant adaptive adjustment parameters determine the inflection point The degree of brightening of the input data on the right; For The relevant adaptive adjustment parameters determine the inflection point The degree of darkening of the input data on the left. , Should meet , the specific calculation is as follows:
[0088] ,
[0089] ,
[0090] in, are two sets of preset curve slopes. is a constant greater than 1.5, is a constant less than 0.4, are two sets of preset curve deviation values. The value range is , The value range is , the corresponding brightness mapping curve diagram when different inflection points are selected is as follows Figure 7 As shown, the dotted line in the figure is the brightness information , the curve is the output brightness information after contrast enhancement . For a comparison of the effects before and after using the low-contrast image brightness mapping curve to adjust the contrast of a low-contrast image, see Figure 8 .
[0091] (2) When the contrast of the input image is too high, the dark parts of the image are too dark and the bright parts are too bright, and some details are lost. In this case, the inverse S curve is used to appropriately reduce the brightness information. The contrast ratio is constructed by the following formula to construct the inverse S curve:
[0092] ,
[0093] in, is a preset fixed parameter. In order to avoid overflow and truncation of image data, Set to a constant not greater than 1; Set to a constant not greater than 0.05 to prevent the gradient from reversing in low-brightness areas of the image, satisfying ; For The relevant adaptive adjustment parameters determine the inflection point The degree of darkening of the input data on the right. For The relevant adaptive adjustment parameters determine the inflection point The degree of brightening of the input data on the left. satisfy , the specific calculation is as follows:
[0094] ,
[0095] ,
[0096] in, are two sets of preset curve slopes. is a constant less than 0.8, is a constant greater than 1.1, are two sets of preset curve deviation values. The value range is , The value range is , the corresponding brightness mapping curve diagram when different inflection points are selected is as follows Fig. 9 As shown, the dotted line in the figure is the brightness information , the curve is the output brightness information after the contrast is reduced . For a comparison of the effects before and after using the high-contrast image brightness mapping curve to adjust the contrast of a high-contrast image, see Fig.10 .
[0097] In order to better control the degree of image contrast adjustment, a contrast adjustment global coefficient is introduced , calculate the output brightness information
[0098] ,
[0099] in, is the output after contrast adjustment in step 3 above, The final output brightness information.
[0100] The final output brightness information With brightness information Divide to get the gain adjustment coefficient of each pixel in the image :
[0101] ,
[0102] Map the R, G, and B channels of the input image separately to get the final image :
[0103] .
[0104] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0105] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is limited by the appended claims and their equivalents.
Claims
1. A method for adaptively adjusting image contrast based on image brightness information, characterized in that: include: Step 1, extracting the brightness information of the input image; Step 2, perform brightness distribution statistics on the brightness information, and determine the type of the input image according to a preset threshold: low brightness, high brightness, too high contrast or too low contrast; Step 3, determine the brightness adjustment curve according to the type of image, and adjust the contrast point by point; Step 4, dividing the adjusted brightness information by the brightness information of the input image to obtain the gain adjustment coefficient of each pixel point, and mapping the R, G, and B channels of the input image respectively; Step 1 includes: Calculate the brightness information of each pixel to obtain the initial brightness information of the input image , , in, They are the R, G, and B channel brightness information of the input image respectively; right Perform normalization to obtain the input image brightness information : , in, Represents the maximum initial brightness of all pixels in the input image. ; Step 2 includes: The brightness range Equally divided, based on brightness information Constructing a brightness histogram , count the number of pixels in each brightness range , Pick , ,in, Indicates the bit width of the input image, based on the brightness histogram Calculated to be located at Brightness value at the quantile , this brightness value reflects the brightness distribution of the image. The value range of is [80, 99]; when When , the input image is considered to be dark as a whole and is judged as a low-brightness image; when When , the input image is considered to be brighter overall and is judged as a highlight image, where They are respectively the lower and upper limits of the brightness threshold which are preset; when When , the brightness histogram is further calculated Variance ,when Less than the preset variance adjustment threshold When , the overall image is considered to have a faded appearance, and the input image contrast is judged to be too low; when Greater than the preset variance adjustment threshold When , the dark part of the picture is considered too dark and the bright part is too bright, and the contrast of the input image is judged to be too high; when When , the input image is considered to have moderate contrast and no contrast adjustment is required; Step 3 includes: When the input image is judged to be a low-brightness image, the brightness information is calculated according to the following curve For overall brightening: , parameter Together they determine the degree of image brightening, where The preset fixed parameters determine the upper and lower limits of the image output brightness respectively. They are set according to the specific brightening requirements. In order to avoid overflow and truncation of image data, ; For The relevant adaptive adjustment parameters determine the degree of brightening of the middle grayscale and should satisfy , calculated as follows: , in, is the preset curve slope and deviation value, is a constant greater than 5, the deviation value Should meet ; Step 3 includes: When the input image is judged to be a highlight image, the brightness information To darken the whole: , parameter Together they determine the degree of darkening of the image, where The preset fixed parameters determine the upper and lower limits of the image output brightness respectively. They are set according to the specific dimming requirements. In order to avoid overflow and truncation of image data, ; For The relevant adaptive adjustment parameters determine the degree of darkening of the middle grayscale and should satisfy , calculated as follows: , in, is the preset curve slope and deviation value, the value range is ; Step 3 includes: When the input image contrast is judged to be too low or too high, the inflection point of the S curve is determined by the following linear function: : , in, are the preset slope and deviation values, The value range is 0.8~1. The value range is 0~0.2; The brightness information is respectively located at the inflection point of the S curve Variance of the pixel groups on both sides: Assume that The variance statistics of the pixel group is ,satisfy The variance statistics of the pixel group is : (1) When the contrast of the input image is too low and the picture appears gray, the S curve is used to calculate the brightness information. To improve contrast, construct an S-curve as follows: , in, is a preset fixed parameter. In order to avoid overflow and truncation of image data, Set to a constant not greater than 1; Set to a constant not greater than 0.05 to prevent the gradient from reversing in low-brightness areas of the image, satisfying ; For The relevant adaptive adjustment parameters determine the inflection point The degree of brightening of the input data on the right; For The relevant adaptive adjustment parameters determine the inflection point The degree of darkening of the input data on the left. , Should meet , the specific calculation is as follows: , , in, are two sets of preset curve slopes. is a constant greater than 1.5, is a constant less than 0.4, are two sets of preset curve deviation values. The value range is , The value range is ; (2) When the contrast of the input image is too high, the dark parts of the image are too dark and the bright parts are too bright, and some details are lost. In this case, the inverse S curve is used to appropriately reduce the brightness information. The contrast ratio is constructed by the following formula to construct the inverse S curve: , in, is a preset fixed parameter. In order to avoid overflow and truncation of image data, Set to a constant not greater than 1; Set to a constant not greater than 0.05 to prevent the gradient from reversing in low-brightness areas of the image, satisfying ; For The relevant adaptive adjustment parameters determine the inflection point The degree of darkening of the input data on the right. For The relevant adaptive adjustment parameters determine the inflection point The degree of brightening of the input data on the left. satisfy , the specific calculation is as follows: , , in, are two sets of preset curve slopes. is a constant less than 0.8, is a constant greater than 1.1, are two sets of preset curve deviation values. The value range is , The value range is ; In order to control the degree of image contrast adjustment, a contrast adjustment global coefficient is introduced , calculate the output brightness information , in, is the output after contrast adjustment in step 3 above, To finally output brightness information; Step 4 includes: The final output brightness information With brightness information Divide to get the gain adjustment coefficient of each pixel in the image : , Map the R, G, and B channels of the input image separately to get the final image : 。
Citation Information
Cited By
Image adjusting method and system, medium and electronic equipment
CN121194077A
