A method for adjusting screen contrast
Patent Information
- Application Number
- CN202211148994.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2026-09-01
- Estimated Expiration
- 2042-09-23
AI Technical Summary
对比度不够会使得整幅图像显得灰蒙蒙,而对比度过高也会使得细节难以辨认局部过曝或过暗
[0043](1) The purpose of setting values greater than or equal to T to 1 is to control the contrast enhancement ratio of each interval. If the original count value is directly used as the reference value for each interval to calculate the CDF mapping, the intervals with particularly large count values in the mapping result will occupy more numerical space. Although the values in these intervals are more widely distributed and the contrast is enhanced, the distribution of other intervals may have little or no contrast enhancement because the values are relatively small. This also leads to the final result having a homogeneous distribution, lacking the previous distribution levels of various brightness levels, resulting in a poor mapping effect. However, setting all intervals exceeding or equal to the threshold T to 1 can avoid this situation. The contrast enhancement effect of each interval remains consistent, and the brightness levels are preserved to the maximum extent.
Smart Images

Figure CN115375534B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image display technology, specifically relating to a method for adjusting screen contrast by constructing a cumulative distribution function using histogram statistics. Background Technology
[0002] In the field of image display technology, contrast is crucial to visual effects. Insufficient contrast makes an image appear hazy, while excessive contrast makes details difficult to discern, resulting in overexposed or underexposed areas. However, visual effect is a difficult-to-quantify metric, and there is no unified and authoritative evaluation method for optimizing image visual effects using quantitative methods. Existing methods generally use histograms or numerical distributions to handle different cases based on empirical parameters. These methods each have their advantages and disadvantages, but real-world images vary greatly. Using too many empirical branches increases overhead in circuit implementation, makes optimization difficult, and conditional branches always have some exceptions.
[0003] This invention provides an adaptive method that does not rely too much on the features of the data and processes the input image using a universal approach. Summary of the Invention
[0004] This invention provides a method for adaptively adjusting the contrast of an input image by constructing a cumulative distribution function using histogram statistics, comprising:
[0005] Step 1: Calculate the brightness value of each pixel;
[0006] Step 2: Statistically analyze the distribution of brightness values;
[0007] Step 3: Preprocessing of distributed data;
[0008] Step 4: Calculate CDF. CDF is defined as the sum of probabilities of all values less than or equal to a for a continuous function: F(a) = P(x≤a).
[0009] Step 5: Construct a mapping table based on the CDF;
[0010] Step six: The mapping yields the final result.
[0011] Furthermore, in step one,
[0012] Brightness values can be calculated using appropriate formulas without many restrictions, including but not limited to...
[0013] (1) Referring to BT.601 standard, Y = 0.299*R + 0.587*G + 0.114*B
[0014] (2) Referring to BT.709 standard, Y = R * 0.2126 + G * 0.7152 + B * 0.0722
[0015] (3) Take the maximum value in RGB directly as the brightness reference value Y = max(R,G,B).
[0016] Furthermore, in step two,
[0017] Divide the brightness range into k parts, where k is a power of 2 and the division is equal. After counting, the pixel counts for the corresponding brightness range are: count1, count2, ..., count... k There are a total of k groups.
[0018] Furthermore, in step three,
[0019] First, a threshold T is determined, where the value of T is based on count1 to count in step two. k The count value in the table determines, but is not limited to:
[0020] (1) Take the Nth smallest count value after sorting the count sequence from all count values as the threshold T;
[0021] (2) Take the average of count and divide it by a number greater than 1 to get the threshold T.
[0022] Secondly, after obtaining the threshold T, count1, count2, ..., count... k Compared with T, all values less than T are recorded as 0, and all values greater than or equal to T are recorded as 1, forming a sequence of length k consisting of 0s and 1s as the preprocessing result: val1, val2, ..., val k .
[0023] Furthermore, in step four, [0, val1, val1+val2, ..., val1+val2+ ... + val k Then divide all of them by val1 + val2 + ... + val k The sum of these terms results in an increasing sequence from 0 to 1, where x∈[0,1].
[0024]
[0025] Furthermore, in step five,
[0026] Taking a mapping from 0 to 255 as an example, assuming the contrast enhancement intensity has 10 adjustable levels, and the parameter Level is used to determine it, then...
[0027] Mapping(x)=(1–Level*0.1)*x*255+Level*0.1*CDF(x)*255
[0028] x∈[0,1]
[0029] Where Level∈{1,2,3,4,5,6,7,8,9,10}.
[0030] Furthermore, in step six,
[0031] Apply the obtained mapping relationship directly to the RGB values.
[0032]
[0033]
[0034]
[0035] Furthermore, in step six, if it is necessary to maintain the RGB ratio, the original brightness value Y from step one is mapped. The ratio of the mapped brightness value Mapping(Y) to the new brightness value, multiplied by the corresponding pixel RGB value, yields a result that enhances contrast and provides more accurate colors.
[0036]
[0037]
[0038] r new =r*factorr∈[0,255]
[0039] g new = g * factor g∈[0,255]
[0040] b new = b * factor b∈[0,255]
[0041] When Y = 0, the RGB values are all 0.
[0042] The present invention binarizes data based on a threshold, and the resulting technical effect is as follows:
[0043] (1) The purpose of setting values greater than or equal to T to 1 is to control the contrast enhancement ratio of each interval. If the original count value is directly used as the reference value for each interval to calculate the CDF mapping, the intervals with particularly large count values in the mapping result will occupy more numerical space. Although the values in these intervals are more widely distributed and the contrast is enhanced, the distribution of other intervals may have little or no contrast enhancement because the values are relatively small. This also leads to the final result having a homogeneous distribution, lacking the previous distribution levels of various brightness levels, resulting in a poor mapping effect. However, setting all intervals exceeding or equal to the threshold T to 1 can avoid this situation. The contrast enhancement effect of each interval remains consistent, and the brightness levels are preserved to the maximum extent.
[0044] (2) Marking intervals with count values less than T as 0 frees up space for other intervals to increase contrast and expand the interval spacing. Since these count values are small, even compressing them into a single value minimizes the possibility of detail loss in the overall image. Even if these pixels are clustered in the two-dimensional image space, causing some detail loss, their small absolute number makes them difficult to observe when magnified into the entire image, while releasing a large amount of space provides ample room for increasing overall contrast. Considering both advantages and disadvantages, this step is essential.
[0045] (3) It has a fast processing speed, achieving the two more complex effects mentioned above, and the operation is very fast. The advantages of numerical storage and subsequent operation are also very obvious. Attached Figure Description
[0046] Figure 1 The diagram shown is a flowchart of the present invention;
[0047] Figure 2 The image shown is a comparison of the threshold binarization effect of the present invention. Detailed Implementation
[0048] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0049] Example 1
[0050] Please see Figure 1 This invention provides a method for adaptively adjusting the contrast of an input image by constructing a cumulative distribution function using histogram statistics, comprising:
[0051] Step 1: Calculate the brightness value of each pixel;
[0052] Step 2: Statistically analyze the distribution of brightness values;
[0053] Step 3: Preprocessing of distributed data;
[0054] Step 4: Calculate CDF. CDF is defined as the sum of probabilities of all values less than or equal to a for a continuous function: F(a) = P(x≤a).
[0055] Step 5: Construct a mapping table based on the CDF;
[0056] Step six: The mapping yields the final result.
[0057] Brightness values can be calculated using appropriate formulas without many restrictions, including but not limited to...
[0058] (1) Referring to BT.601 standard, Y = 0.299*R + 0.587*G + 0.114*B
[0059] (2) Referring to BT.709 standard, Y = R * 0.2126 + G * 0.7152 + B * 0.0722
[0060] (3) Take the maximum value in RGB directly as the brightness reference value Y = max(R,G,B).
[0061] Furthermore, in step two,
[0062] Divide the brightness range into k parts, where k is a power of 2 and the division is equal. After counting, the pixel counts for the corresponding brightness range are: count1, count2, ..., count... k There are a total of k groups.
[0063] First, a threshold T is determined, where the value of T is based on count1 to count in step two. k The count value in the table determines, but is not limited to:
[0064] (1) Take the Nth smallest count value after sorting the count sequence from all count values as the threshold T;
[0065] (2) Take the average of count and divide it by a number greater than 1 to get the threshold T.
[0066] Secondly, after obtaining the threshold T, count1, count2, ..., count... kCompared with T, all values less than T are recorded as 0, and all values greater than or equal to T are recorded as 1, forming a sequence of length k consisting of 0s and 1s as the preprocessing result: val1, val2, ..., val k .
[0067] Using the preprocessed data from step three as an example, the preprocessed data is: [val1, val2, ..., val k ].
[0068] CDF calculation: [0, val1, val1+val2, ..., val1+val2+ ...+val k Then divide all of them by val1 + val2 + ... + val k The sum of these terms results in an increasing sequence from 0 to 1, where x∈[0,1].
[0069]
[0070] Taking a mapping from 0 to 255 as an example, assuming the contrast enhancement intensity has 10 adjustable levels, and the parameter Level is used to determine it, then...
[0071] Mapping(x)=(1–Level*0.1)*x*255+Level*0.1*CDF(x)*255
[0072] x∈[0,1]
[0073] Where Level∈{1,2,3,4,5,6,7,8,9,10}.
[0074] Once the mapping curve is obtained, the mapping relationship of all values between 0 and 255 can be obtained.
[0075] Simply apply the obtained mapping relationship to the RGB values:
[0076]
[0077]
[0078]
[0079] If the RGB ratio needs to be maintained, the original luminance value Y from step one is mapped. The mapped luminance value Mapping(Y) is multiplied by the ratio of the new luminance value and the corresponding pixel RGB value to obtain a result that enhances contrast and provides more accurate colors.
[0080]
[0081]
[0082] r new =r*factorr∈[0,255]
[0083] g new = g * factor g∈[0,255]
[0084] b new = b * factor b∈[0,255]
[0085] When Y = 0, the RGB values are all 0.
[0086] Example 2
[0087] Please see Figure 2 The preprocessed result indicated by the upward-sloping arrow enhances contrast while preserving brightness levels. The result indicated by the downward-sloping arrow directly calculates CDF, enhancing contrast only in areas with a large number of pixels, but failing to preserve brightness levels.
[0088] This invention provides a method for adaptively adjusting the contrast of an input image by constructing a cumulative distribution function using histogram statistics, comprising:
[0089] Step 1: Obtain the brightness value of each pixel according to the actual situation. Common examples include the V value in HSV and the Y value in YUV. Other custom rules are also acceptable.
[0090] Step 2: Perform histogram statistics on the pixel brightness values. The histogram statistics interval can be divided into 16, 32, or 256 equal parts, etc., and then count the number of pixels in each brightness interval.
[0091] Step three involves preprocessing the brightness distribution, mainly by removing areas with too few values so that the accumulated result, after mapping, retains the relationship of the numerical distribution while adjusting the actual distribution, resulting in a more appropriate final result.
[0092] Step four: Sum the preprocessed data to obtain the cumulative distribution function (CDF).
[0093] Step 5: Use CDF as a mapping function to remap the values of the input image.
[0094] Step six: The mapping yields the final result.
[0095] Mapping can be done directly from RGB to CDF, or luminance can be mapped first and then converted to RGB. The results of the two methods are different. Generally speaking, mapping RGB values directly will result in more vibrant colors, but it will change the saturation and hue of the input image. Mapping to luminance first and then converting to RGB is equivalent to only changing the V value in HSV, and has less impact on the saturation and hue of the input image.
[0096] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is limited by the appended claims and their equivalents.
Claims
1. A method for adjusting screen contrast, characterized in that, Include, Step 1: Calculate the brightness value of each pixel; Step 2: Statistically analyze the distribution of brightness values; Step 3: Preprocessing of distributed data; Step 4: Calculate the CDF. The CDF is defined as the sum of the probabilities of all values less than or equal to a for a continuous function. ; Step 5: Construct a mapping table based on the CDF; Step six, mapping yields the final result; In step one, Brightness values can be calculated using appropriate formulas without many restrictions, including but not limited to... (1) Referring to BT.601 standard, Y = 0.299 * R + 0.587 * G + 0.114 * B; (2) Referring to BT.709 standard, Y = R * 0.2126 + G * 0.7152 + B * 0.0722; (3) Directly take the maximum value in RGB as the brightness reference value Y=max(R, G, B), In step two, Divide the brightness range into k parts, where k is a power of 2 and the division is equal. After the statistics are completed, the pixel count for the corresponding brightness range is obtained as follows: There are a total of k groups. In step three First, a threshold T is determined, where the value of T is determined according to step two. The count value in the table determines, but is not limited to: (1) Take the Nth smallest count value after sorting the count sequence from all count values as the threshold T; (2) Take the average of counts and divide it by a number greater than 1 to get the threshold T. Secondly, after obtaining the threshold T, respectively... Compared with T, all values less than T are recorded as 0, and all values greater than or equal to T are recorded as 1, forming a sequence of length k consisting of 0s and 1s as the result of preprocessing: ; In step four, Divide the whole by The sum of these terms results in an increasing sequence from 0 to 1. hour ; In step five, Taking a mapping of 0~255 as an example, assuming the contrast enhancement intensity has 10 adjustable levels, and the parameter Level is used to determine it, then... ; in; ; In step six, Apply the obtained mapping relationship directly to the RGB values. ; ; ; In step six, if it is necessary to maintain the RGB ratio, the original brightness value Y from step one is mapped. The ratio of the mapped brightness value Mapping(Y) to the new brightness value, multiplied by the corresponding pixel RGB value, will yield a result that enhances contrast and provides more accurate colors. ; ; ; ; ; When Y = 0, the RGB values are all 0; The purpose of setting values greater than or equal to T to 1 is to control the contrast enhancement ratio of each interval; while setting intervals that exceed or are equal to the threshold T to 1 ensures that the contrast enhancement effect of each interval remains consistent, and the brightness levels are preserved to the maximum extent. The intervals with values less than T are marked as 0. The numerical space of the intervals with very small count values is released to increase the contrast of other intervals and to provide space for the numerical spacing of other intervals.
Citation Information
Patent Citations
Global histogram equalization method of a self-adaptive threshold value
CN109801246A