Image contrast adaptive adjustment method, electronic device and storage medium
By constructing a smooth and continuous adjustment gain and offset function, the problem of excessive saturation caused by image contrast adjustment in the prior art is solved, achieving an adaptive balance between contrast and saturation, and improving the visual comfort of the image.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-04-03
AI Technical Summary
Existing threshold-based image contrast adjustment methods are prone to causing excessive image saturation when the offset is large, resulting in color distortion and affecting visual comfort, especially in dark areas.
A smooth and continuous adjustment gain function and adjustment offset function are constructed. Through initial and final adjustments, the difference between the pixel saturation index and the target saturation index is controlled to be less than a preset difference threshold, thereby achieving an adaptive balance between contrast and saturation.
While enhancing image contrast, it adaptively controls image saturation to prevent color distortion, providing a more comfortable image viewing experience.
Smart Images

Figure CN121329758B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of digital image processing technology, and in particular to an image contrast adaptive adjustment method, electronic device and storage medium. Background Technology
[0002] In RGB image processing, contrast adjustment is a key operation for improving the visual effect of an image. Current technologies typically employ threshold-based contrast adjustment: by setting upper and lower thresholds, gain and offset are calculated and adjusted, and then a linear transformation and truncation are performed on each color channel value of each pixel, which can quickly improve image contrast.
[0003] However, when the adjustment offset is large, it can lead to excessive image saturation, especially in the dark areas of the image, which not only causes color distortion but also compromises the comfort of the visual experience. Summary of the Invention
[0004] In view of the above, it is necessary to propose an image contrast adaptive adjustment method, electronic device and storage medium, which aims to solve the problem that in the existing threshold-based image contrast adjustment scheme, a large offset can easily lead to an increase in image saturation, thereby causing color distortion and affecting visual comfort.
[0005] A first aspect of this application provides an image contrast adaptive adjustment method, the method comprising:
[0006] Construct a smooth and continuous adjustment gain function and adjustment offset function;
[0007] Based on the adjustment gain function and the adjustment offset function, the contrast of the original pixels of the image to be adjusted is initially adjusted;
[0008] The target saturation index is calculated based on the initially adjusted pixel saturation index and the original pixel saturation index.
[0009] The contrast of the original pixel is finally adjusted based on the target saturation index, so that the difference between the final adjusted pixel saturation index and the target saturation index is less than a preset difference threshold.
[0010] The target image is generated based on the final adjusted pixels.
[0011] Optionally, the construction of the smooth and continuous adjustment gain function and adjustment offset function includes:
[0012] Based on the preset lower threshold and the preset upper threshold, calculate the basic adjustment gain and the basic adjustment offset;
[0013] Based on the aforementioned basic adjustment gain and basic adjustment offset, a smooth and continuous adjustment gain function and adjustment offset function are constructed.
[0014] Optionally, the initial contrast adjustment of the original pixels of the image to be adjusted based on the adjustment gain function and the adjustment offset function includes:
[0015] The first adjustment sequence is determined based on the adjustment gain function and the adjustment offset function;
[0016] The initial contrast adjustment is performed on the original pixels of the image to be adjusted based on the first adjustment sequence.
[0017] Optionally, the first adjustment sequence includes function values corresponding to the luminance component of the original pixel as the independent variable of the adjustment gain function and the independent variable of the adjustment offset function.
[0018] Optionally, the method further includes:
[0019] Determine whether the color space type of the image to be adjusted is a preset target color space;
[0020] When the image to be adjusted is not an image in the target color space, the image to be adjusted is converted to an image in the target color space.
[0021] Optionally, calculating the target saturation index based on the initially adjusted pixel saturation index and the original pixel saturation index includes:
[0022] Obtain the compression ratio;
[0023] Calculate the initial ratio between the initially adjusted pixel saturation index and the original pixel saturation index;
[0024] The compression ratio value is obtained based on the compression coefficient and the initial ratio;
[0025] The target saturation index is obtained based on the compression ratio and the original pixel saturation index.
[0026] Optionally, obtaining the compression coefficient includes:
[0027] Determine the compressibility factor used to regulate compressive strength;
[0028] The compression coefficient is determined based on the lower threshold and the compression factor.
[0029] The compression coefficient exhibits a continuous and smooth compression characteristic based on the size of the lower threshold, and the minimum value of the compression coefficient is not lower than the benchmark value, which is the minimum compression intensity critical value to ensure that the initial ratio does not undergo over-compression leading to information loss.
[0030] Optionally, the final adjustment of the contrast of the original pixel based on the target saturation index, such that the difference between the final adjusted pixel saturation index and the target saturation index is less than a preset difference threshold, includes:
[0031] Set and adjust parameters;
[0032] The second adjustment sequence is determined based on the adjustment parameters, the adjustment gain function, and the adjustment offset function;
[0033] The original pixels are then subjected to a final contrast adjustment based on the second adjustment sequence;
[0034] Determine whether the difference between the final adjusted pixel saturation index and the target saturation index is greater than a preset difference threshold;
[0035] When the difference is greater than the preset difference threshold, the adjustment parameters are adjusted, and the second adjustment sequence and pixel saturation index are re-determined based on the adjusted adjustment parameters, until the difference between the pixel saturation index and the target saturation index is less than the preset difference threshold.
[0036] A second aspect of this application provides an electronic device including a processor and a memory, wherein the processor is configured to implement the image contrast adaptive adjustment method when executing a computer program stored in the memory.
[0037] A third aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the image contrast adaptive adjustment method.
[0038] This application constructs a smooth and continuous adjustment gain function and adjustment offset function; performs initial contrast adjustment on the original pixels of the image to be adjusted based on the adjustment gain function and the adjustment offset function; calculates a target saturation index based on the initially adjusted pixel saturation index and the original pixel saturation index; performs final contrast adjustment on the original pixels based on the target saturation index, such that the difference between the final adjusted pixel saturation index and the target saturation index is less than a preset difference threshold; and generates a target image based on the final adjusted pixels. This application can simultaneously achieve contrast enhancement and saturation balance, that is, while adjusting the image contrast, it adaptively controls the image saturation to prevent some pixels from being oversaturated, thereby obtaining a more comfortable image viewing effect. Attached Figure Description
[0039] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0040] Figure 1 A schematic diagram of pixel channel value transformation functions for image contrast adjustment provided by existing technology;
[0041] Figure 2 A flowchart of the image contrast adaptive adjustment method provided in the embodiments of this application;
[0042] Figure 3 A schematic diagram illustrating the gain adjustment function, offset adjustment function, and contrast adjustment function provided in the embodiments of this application;
[0043] Figure 4 This is a schematic diagram of the image contrast adaptive adjustment device provided in the embodiments of this application;
[0044] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0045] To better understand the above-mentioned objectives, features, and advantages of this application, the application will be described in detail below with reference to the accompanying drawings and specific embodiments. Unless otherwise specified, the embodiments and features described herein can be combined with each other.
[0046] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the specification of this application is for the purpose of describing an embodiment in one alternative implementation and is not intended to be limiting of the application.
[0047] In digital image processing, contrast adjustment is a key operation for enhancing the visual effect of images. Essentially, it strengthens the distinction between bright and dark areas by stretching or compressing the dynamic range of image pixels, thereby improving the image's detail and visual impact. In RGB image processing scenarios, threshold-based contrast adjustment is widely used due to its simplicity and high computational efficiency.
[0048] The threshold-based contrast adjustment process is as follows: First, normalize the RGB channel values of each pixel in the image to the interval [0, 1]; then select a lower threshold x0 and an upper threshold x1, where 0 < x0 < x1 < 1; based on these two thresholds, calculate the adjustment gain a and the adjustment offset t, where the adjustment gain a = 1 / (x1 - x0), and the adjustment offset t = x0 / (x1 - x0). Next, transform the RGB color channel value of each pixel in the image: Assume the original value of a certain color channel is x, and the adjusted color channel value y is determined by the formula y = clip(a x - t, 0, 1), and the clip operation means restricting the calculation result to the range between 0 and 1 (taking 0 when the calculated value is less than 0 and taking 1 when it is greater than 1), to avoid the adjusted pixel value exceeding the valid value range of the RGB channel and prevent the distortion of solid color blocks caused by pixel overflow.
[0049] Take Figure 1 as an example: When the original channel value x is less than x0, the result of a x - t will be less than 0, so the output is 0; when x is between x0 and x1, it is linearly mapped to the interval [0, 1] through linear transformation to achieve the stretching of the dynamic range; when x is greater than x1, the result of a x - t will be greater than 1, so the output is 1. That is, the original pixel values are linearly mapped from the interval [x0, x1] to [0, 1] through linear stretching, and at the same time, the dark part below x0 is forced to 0 (uniformly darkened) and the bright part above x1 is forced to 1 (uniformly brightened) through dynamic range truncation. This non-linear transformation can significantly improve the separation degree of the light and dark regions in the image and achieve contrast enhancement.
[0050] However, the above scheme has obvious technical defects: When the value of the adjustment offset t is relatively large (such as t > 0.1), it will cause the problem of too high image saturation, especially in the dark part, which is particularly serious, and ultimately lead to color distortion and a decrease in visual comfort. The following analyzes the reasons for the above defects in combination with the calculation rules of saturation.
[0051] In the HSV color space, saturation S is an index describing the purity of color, and its calculation method is: For the RGB channel values (r, g, b) of a certain pixel, first determine the maximum channel value (denoted as max) and the minimum channel value (denoted as min) of this pixel, then the saturation S = (max - min) / max. It can be seen that the higher the proportion of the difference in channel values relative to the maximum channel value, the more vivid the color (the higher the saturation).
[0052] When using the above threshold-based contrast adjustment method, the maximum channel value max of the original pixel is transformed into max’ = a max - t, and the minimum channel value min of the original pixel is transformed into min’ = a If min-t, then the adjusted saturation S' = (max'-min') / max'. Since a max-t-(a min-t)=a (max-min), therefore S'=a (max-min) / (a (max-t). Combining the gain a=1 / (x1-x0), we can further derive S'=(max-min) / (max-t / a). The saturation before adjustment is S=(max-min) / max, so the ratio of the two is S' / S=max / (max-t / a).
[0053] This ratio formula clearly shows that when the adjustment offset t is large, the value of t / a will increase accordingly (because a is positively correlated with t, and the numerator of t is x0). At this time, the denominator of max-t / a will be significantly reduced, especially when max itself is small (corresponding to the dark area of the image, because the channel values of dark pixels are generally low). The reduction of the denominator will be much greater than the change of max, causing the ratio of S' / S to rise sharply.
[0054] For example, assuming x0=0.2, x1=0.8, original pixel (r, g, b)= (0.15, 0.25, 0.2), adjust gain a=1 / (0.8-0.2)=5 / 3, adjust offset t=0.2 / (0.8-0.2)=1 / 3, saturation before contrast adjustment S_before=(0.25-0.15) / 0.25=0.4, r'=(5 / 3) 0.15 - 1 / 3 = -0.083 → clip = 0, g' = (5 / 3) 0.25 - 1 / 3 = 0.0833, the saturation after contrast adjustment S_after = (0.0833 - 0) / 0.0833 = 1 (saturation reaches its maximum value), the ratio of the two is 1 / 0.4 = 2.5, it can be seen that the saturation is increased by 2.5 times, and the dark colors are severely distorted.
[0055] Clearly, as g approaches x0 (in dark areas, where g is small), the denominator (g-x0) approaches 0, causing a sharp increase in the saturation ratio before and after adjustment, resulting in a significant boost in saturation. This over-amplification of dark area saturation has a dual negative impact: firstly, details in dark areas that were originally lighter in color are processed into highly saturated, vibrant color blocks, deviating significantly from the actual color information of the image and causing obvious color distortion; secondly, low-brightness, highly saturated color blocks can easily give a dull and dirty feeling, and excessively increased saturation disrupts the overall visual harmony of the image, causing noticeable discomfort to the viewer.
[0056] In practical application scenarios, such as underwater image enhancement and low-light monitoring screen adjustment, since such scenarios are inherently dark and the signal-to-noise ratio is relatively low, the contrast of the original image processed by an Image Signal Processor (ISP) is usually low. When using threshold-based contrast adjustment, a relatively large x0 needs to be set to stretch the dynamic range of the dark part, which in turn leads to a relatively large t value. This will directly exacerbate the problem of excessive saturation increase in the dark part, significantly reducing the applicability of threshold-based contrast adjustment in such scenarios.
[0057] Therefore, to solve the above technical problems, the present application provides an image contrast adaptive adjustment method, which can effectively enhance the contrast of RGB images while adaptively balancing saturation and avoiding color distortion in the dark part, thus affecting visual comfort.
[0058] Embodiment 1
[0059] Figure 2 It is a flowchart of the image contrast adaptive adjustment method provided by an embodiment of the present application. The image contrast adaptive adjustment method specifically includes the following steps.
[0060] S21, construct a smooth and continuous adjustment gain function and adjustment offset function.
[0061] The adjustment gain function refers to the amplification / attenuation coefficient between the input and the output. The adjustment offset function refers to the overall displacement of the output relative to the ideal value.
[0062] In an optional embodiment, the construction of the smooth and continuous adjustment gain function and adjustment offset function includes:
[0063] Based on a preset lower threshold and a preset upper threshold, calculate the basic adjustment gain and the basic adjustment offset;
[0064] Based on the basic adjustment gain and the basic adjustment offset, construct a smooth and continuous adjustment gain function and adjustment offset function.
[0065] Pre-set a lower threshold x0 and an upper threshold x1, where 0 < x0 < x1 < 1. The lower threshold x0 and the upper threshold x1 can be automatically determined by histogram statistics. For example, take the 5% quantile of the cumulative distribution as the lower threshold x0 and the 95% quantile of the cumulative distribution as the upper threshold x1 to adapt to the actual brightness distribution of the image. The lower threshold x0 and the upper threshold x1 can also be determined by manual input to adapt to specific scenarios with clear visual requirements.
[0066] The base adjustment gain \(a_0 = 1 / (x_1 - x_0)\) is used to control the tensile strength, linearly stretching the pixel values within the range \(x_0\) to \(x_1\) to the full range of \(0\) to \(1\). The smaller \(x_1 - x_0\) (the narrower the dynamic range), the larger \(a_0\), and the more significant the contrast enhancement.
[0067] The base adjustment offset \(t_0 = x_0 / (x_1 - x_0)\) is used to ensure that the mapping starting point is aligned, mapping the original value corresponding to \(x_0\) to the adjusted 0 point, thereby achieving a combined transformation of translational stretching of the dynamic range. When \(x = x_0\), \(y = 0\), achieving seamless truncation.
[0068] The image contrast is essentially the degree of gray difference between the bright and dark regions in the image. The higher the contrast, the more obvious the light and dark differences, and the clearer the image details; the lower the contrast, the grayer the image and the weaker the sense of hierarchy. By constructing a smooth and continuous adjustment gain function and adjustment offset function, the adjustment process of the image contrast can be made without sudden changes or breakpoints, ensuring both the fineness of regulation and avoiding output distortion caused by parameter jumps.
[0069] In an optional embodiment, a smooth and continuous adjustment gain function \(a(x)\) and adjustment offset function \(t(x)\) are constructed based on the base adjustment gain \(a_0\) and base adjustment offset \(t_0\), where \(1\leq a(x)\leq a_0\) and \(0\leq t(x)\leq t_0\). At the same time, it is necessary to ensure that the contrast adjustment function \(f(x)=a(x)\) \(x - t(x)\) is a monotonically increasing function, and \(0\leq f(x)\leq 1\).
[0070] Set the minimum slope \(k_0\) of the dark part and the minimum slope \(k_1\) of the bright part, where \(0 < k_0,k_1 < 1\). Solve the equation \(k_0\) \(x = a_0\) \(x - t_0\), and the solution is the dark intersection point \(x_d\); solve the equation \(1 - k_1\) (1 - x)=a_0 \(x - t_0\), and the solution is the highlight intersection point \(x_b\).
[0071] When \(0\leq x < x_d\), connect the point \((x,k_0\) \(x)\) and the point \((x_1,1)\) with a straight line, and solve the system of equations \(\begin{cases}a(x)\\x - t(x)=k_0\\x\\a(x)\\x_1 - t(x)=1\end{cases}\), obtaining the adjustment gain function \(a(x)=(1 - k_0\) \(x) / (x_1 - x)\) and the adjustment offset function \(t(x)=a(x)\) \(x_1 - 1\). \(x) / (x_1 - x)\) and the adjustment offset function \(t(x)=a(x)\) \(x_1 - 1\). \(x_1 - 1\). <000,0177>
[0072] When \(x_d\leq x\leq x_b\), let \(a(x) = a_0\) and \(t(x)=t_0\), obtaining the adjusted gain function \(a(x)=a_0\) and the adjusted offset function \(t(x)=t_0\).
[0073] When \(x_b\lt x\leq1\), connect the point \((x_0,0)\) and the point \((x,1 - k_1(1 - x))\) with a straight line, and solve the system of equations \(\begin{cases}a(x)(x - t(x))=1 - k_1(1 - x)\\a(x)(x_0 - t(x)) = 0\end{cases}\), obtaining the adjusted gain function \(a(x)=\frac{k_1x + 1 - k_1}{x - x_0}\) and the adjusted offset function \(t(x)=a(x)x_0\). (1 - x)),求解方程组{a(x) x - t(x)=1 - k1 (1 - x);a(x) x0 - t(x)=0},得到调整增益函数a(x)=(k1 x + 1 - k1) / (x - x0)以及调整偏移函数t(x)=a(x) x0。
[0074] Exemplarily, assume \(x_0 = 0.2\), \(x_1 = 0.7\), \(k_0 = k_1 = 0.3\), then the basic adjusted gain \(a_0 = 2\), the basic adjusted offset \(t_0 = 0.4\). Then the adjusted gain function \(1\leq a(x)\leq2\), and the adjusted offset function \(0\leq t(x)\leq0.4\). The function graph of the adjusted gain function is as shown in (a) of Figure 3 中的(a)所示,调整偏移函数的函数图像如 Figure 3 中的(b)所示,对应的对比度调整函数的函数图像如 Figure 3 中的(c)所示。这种构建方法能够在保证图像亮度在过暗与过曝区连续过渡的同时,保证a(x)与t(x)的连续过渡,避免调整后饱和度在明暗交界处突变的问题。
[0075] S22, perform an initial contrast adjustment on the original pixels of the image to be adjusted based on the adjusted gain function and the adjusted offset function.
[0076] The image to be adjusted refers to a color image that needs to optimize the image quality due to insufficient contrast, and its common formats include RGB, HSV, YUV, etc.
[0077] Before performing the contrast adjustment on the image to be adjusted, it is necessary to first determine whether the chromaticity space type of the image to be adjusted is the preset target chromaticity space type; when the chromaticity space type of the image to be adjusted is not the preset target chromaticity space type, convert the chromaticity space type of the image to be adjusted into the preset target chromaticity space type.
[0078] The chromaticity space type of the image to be adjusted can be identified by reading the format identifier of the image file to be adjusted (such as the format field of the file header, the storage structure of the image data) or calling the format detection function of the image processing interface (such as cv2.imread() of the OpenCV library combined with channel analysis).
[0079] The target color space type can be YUV, HSV, HSL, etc.
[0080] Preferably, the target color space is the YUV color space. The core of contrast is the difference in brightness, and the YUV color space allows for independent storage and control of brightness and chromaticity. In the YUV color space, the U and V chromaticity components are completely separated from the Y luminance component. Contrast can be calculated directly based on the pixel value distribution of the Y luminance component without additional component decomposition, and it can eliminate the interference of color on brightness judgment, significantly improving calculation efficiency and accuracy. Furthermore, in the YUV color space, saturation is related to the amplitude of the U and V components (i.e., the degree to which the U and V components deviate from the reference value), and can be directly quantified through the amplitude of the U and V components. Therefore, in the YUV color space, contrast can be adjusted separately for the Y component, while saturation can be adjusted for the U and V components simultaneously without affecting each other, achieving synergistic optimization of contrast and saturation.
[0081] The image to be adjusted, converted to a preset target color space type, is normalized to map pixel values to the 0-1 range. Normalization can unify the pixel value range of different devices and avoid inconsistent adjustment results due to differences in the original value scale. Max-min value normalization, Z-Score normalization, exponential normalization, or logarithmic normalization can be used; this application does not impose any restrictions.
[0082] For ease of description, the following explanation will use the YUV color space of the image to be adjusted as an example.
[0083] In an optional embodiment, the initial contrast adjustment of the original pixels of the image to be adjusted based on the adjustment gain function and the adjustment offset function includes:
[0084] The first adjustment sequence is determined based on the adjustment gain function and the adjustment offset function;
[0085] The initial contrast adjustment is performed on the original pixels of the image to be adjusted based on the first adjustment sequence.
[0086] The first adjustment sequence includes function values corresponding to the luminance component of the original pixel as the independent variable of the adjustment gain function and the independent variable of the adjustment offset function.
[0087] Each original pixel of the image to be adjusted is referred to as the first pixel, which is represented as a triple (y, u, v), where y represents the luminance component, and u and v represent the two chrominance components. The first adjustment sequence is represented as a binary tuple (ay, ty), where ay is the function value obtained by using the luminance component y of the first pixel as the independent variable of the adjustment gain function, i.e., ay = a(y); and ty is the function value obtained by using the luminance component y of the first pixel as the independent variable of the adjustment offset function, i.e., ty = t(y).
[0088] Based on the first adjustment sequence, the contrast of the original pixels of the image to be adjusted is initially adjusted. The pixel after the initial adjustment is called the second pixel, which is represented as a triplet (y1, u1, v1), where y1 = ay y-ty, u1=ay u, v1 = ay v.
[0089] Based on the adjusted gain function a(x) and adjusted offset function t(x) obtained above, the triplet representation (y, u, v) of the initial pixel (first pixel) is adjusted as follows:
[0090] y1=a(y) yt(y);
[0091] u1=a(y) u;
[0092] v1=a(y) v.
[0093] S23, calculate the target saturation index based on the initially adjusted pixel saturation index and the original pixel saturation index.
[0094] Each original pixel (y, u, v) in the image to be adjusted is converted back to the RGB space to obtain (r, g, b). The original pixel saturation index S is calculated based on the HSV space. Let v_max = max{r, g, b} and v_min = min{r, g, b}. If v_max ≠ 0, then S = (v_max - v_min) / v_max; if v_max = 0, then S = 0.
[0095] The initially adjusted pixels (y1, u1, v1) are converted back to RGB space to obtain (r1, g1, b1). The pixel saturation index S1 of the initially adjusted pixels is calculated based on the HSV color space. Let v1_max = max{r1, g1, b1} and v1_min = min{r1, g1, b1}. If v1_max ≠ 0, then S1 = (v1_max - v1_min) / v1_max; if v1_max = 0, then S1 = 0.
[0096] For ease of distinction in the following text, the original pixel saturation index will be referred to as the first saturation index, and the initially adjusted pixel saturation index will be referred to as the second saturation index. That is, the first pixel corresponds to the first saturation index, and the second pixel corresponds to the second saturation index.
[0097] The saturation indices (first saturation index / second saturation index) in this application embodiment are quantitative indices obtained based on color component analysis of the HSV color space. In other embodiments, saturation indices can also be calculated based on color spaces such as Lab. This application does not impose any limitations on the calculation space of saturation indices.
[0098] In an optional embodiment, calculating the target saturation index based on the initially adjusted pixel saturation index and the original pixel saturation index includes:
[0099] Obtain the compression ratio;
[0100] Calculate the initial ratio between the initially adjusted pixel saturation index and the original pixel saturation index;
[0101] The compression ratio value is obtained based on the compression coefficient and the initial ratio;
[0102] The target saturation index is obtained based on the compression ratio and the original pixel saturation index.
[0103] The compression factor q is a configurable parameter that can be set from 1.0 to 3.0.
[0104] The ratio between the second saturation index S1 (the initially adjusted pixel saturation index) and the first saturation index S (the original pixel saturation index) is used as the initial ratio, p = S1 / S.
[0105] The initial ratio p is compressed according to the compression coefficient q, so that p approaches 1.
[0106] In an optional embodiment, the initial ratio p can be compressed using a power function to obtain a compression ratio p'. For example, p' = pow(p, 1 / q), where pow() is a power function that performs a q-th root operation on the initial ratio p. By changing the nonlinearity of the transformation through the compression coefficient q, a smooth scaling adjustment of the initial ratio p can be achieved. When q = 1, p' = p, there is no transformation between input and output, corresponding to an unadjusted state; when q > 1, the initial ratio p is compressed. The larger q is, the stronger the compression; the smaller q is, the weaker the compression.
[0107] The target saturation index Sstandard is obtained based on the compression ratio p' and the first saturation index S. s.
[0108] By using a single compression coefficient q, a smooth nonlinear transformation is achieved between the ratio of the initially adjusted pixel saturation index and the original pixel saturation index. Compared with linear transformation, the nonlinear transformation process of this application is continuous and differentiable, with no parameter jumps, thus avoiding discontinuities or abrupt changes in the adjusted image. In addition, this application is flexible in its control, and only the compression coefficient q needs to be changed to achieve adaptive control between compression and no adjustment.
[0109] To ensure that the original pixel saturation index is not over-compressed and results in information loss, in an optional embodiment, obtaining the compression coefficient includes:
[0110] Determine the compressibility factor used to regulate compressive strength;
[0111] The compression coefficient is determined based on the lower threshold and the compression factor.
[0112] The compression coefficient exhibits a continuous and smooth compression characteristic based on the size of the lower threshold, and the minimum value of the compression coefficient is not lower than the benchmark value, which is the minimum compression intensity critical value to ensure that the initial ratio does not undergo over-compression leading to information loss.
[0113] The lower limit threshold is used to define the basic range of compression; the compression factor is used to adjust the intensity of compression.
[0114] In an optional embodiment, the compression coefficient q = log(1 + x0) sat_gamma+β, sat_gamma represents the compression factor, which is a configurable parameter with a value range of 0.5 to 5; log() is the logarithmic function with the natural exponent as the base; β represents the base value.
[0115] Wherein, log(1+x0) represents the basic compression benchmark constructed based on the lower limit threshold, reflecting its dynamic range characteristics. After the basic compression benchmark is proportionally adjusted by the compression factor sat_gamma, a fixed benchmark value is superimposed to obtain the compression coefficient adapted to the lower limit threshold. This realizes the dynamic correlation between the lower limit threshold, the compression factor, and the compression coefficient, so that the compression coefficient can adaptively match the dynamic range characteristics of the lower limit threshold and the intensity control requirements of the compression factor. This ensures that the compression processing of saturation not only conforms to the basic range characteristics defined by the lower limit threshold, but also allows for flexible control of the compression intensity through the compression factor.
[0116] When the lower limit threshold x0 = 0 and the compression factor sat_gamma is any value, or when the compression factor sat_gamma = 0 and the lower limit threshold x0 is any value, log(1+x0) When sat_gamma is 0, the minimum compression coefficient q is β. Optionally, β can be set to 1.
[0117] The larger the lower threshold x0, the faster the saturation in the dark areas of the image increases, thus requiring stronger saturation compression. The introduction of the compression factor sat_gamma enables automatic adjustment of the compression coefficient q. Specifically, the larger the compression factor sat_gamma, the larger the corresponding compression coefficient q, and the stronger the saturation compression; conversely, the smaller the compression factor sat_gamma, the smaller the corresponding compression coefficient q, and the weaker the saturation compression. Therefore, this application eliminates the need to adjust the value of the compression coefficient q for different lower thresholds x0, effectively reducing the steps and workload of parameter adjustment and lowering the implementation cost of the technical solution.
[0118] S24, based on the target saturation index, perform a final adjustment on the contrast of the original pixel, so that the difference between the final adjusted pixel saturation index and the target saturation index is less than a preset difference threshold.
[0119] After obtaining the target saturation index, the contrast of the original pixels is finally adjusted based on the target saturation index. The difference between the final adjusted pixel saturation index and the target saturation index is calculated, and it is determined whether the difference is less than a preset difference threshold.
[0120] The difference threshold is a pre-set fixed value or dynamic threshold range used to measure whether the difference between the actual saturation index of the finally adjusted pixel and the target saturation index is within an acceptable range, thereby determining whether a second adjustment is needed.
[0121] When the difference is less than the preset difference threshold, it indicates that the actual saturation of the finally adjusted pixel has accurately matched the target saturation index, and its color performance meets the overall color control requirements of the image. There is no need to make a second adjustment to the saturation of the finally adjusted pixel. It also indicates that the current contrast-saturation linkage control strategy is effective for the pixel, and its saturation transition characteristics in the light and dark boundary area can meet the natural requirements of human subjective vision, without any defects such as saturation abrupt changes or breaks.
[0122] When the difference exceeds a preset difference threshold, it indicates a significant deviation between the actual saturation of the finally adjusted pixel and the target saturation index, resulting in a color performance that does not meet the overall color control requirements of the image. If the actual saturation index is much higher than the target saturation index, it can easily lead to overly vibrant colors and saturation overflow in the area where the pixel is located, disrupting the overall color harmony of the image. If the actual saturation index is much lower than the target saturation index, it will cause the color in that area to be dull and lack depth, failing to achieve the control goal of highlighting details in dark areas. In this case, the pixel needs to be adjusted again until the difference is less than the preset difference threshold.
[0123] In an optional embodiment, the final adjustment of the contrast of the original pixel based on the target saturation index, such that the difference between the final adjusted pixel saturation index and the target saturation index is less than a preset difference threshold, includes:
[0124] Set and adjust parameters;
[0125] The second adjustment sequence is determined based on the adjustment parameters, the adjustment gain function, and the adjustment offset function;
[0126] The original pixels are then subjected to a final contrast adjustment based on the second adjustment sequence;
[0127] Determine whether the difference between the final adjusted pixel saturation index and the target saturation index is greater than a preset difference threshold;
[0128] When the difference is greater than the preset difference threshold, the adjustment parameters are adjusted, and the second adjustment sequence and pixel saturation index are re-determined based on the adjusted adjustment parameters, until the difference between the pixel saturation index and the target saturation index is less than the preset difference threshold.
[0129] The second adjustment sequence is represented as a triple (ay, ty, w), where w represents the adjustment parameter, which is a configurable parameter and is initialized to 1.
[0130] Based on the second adjustment sequence, the contrast of the original pixels of the image to be adjusted is finally adjusted. The pixel after final adjustment is called the third pixel, which is represented as a triplet (y2, u2, v2), where y2 = ay y-ty, u2=w u, v2=w v.
[0131] Based on the adjusted gain function a(x) and adjusted offset function t(x) obtained above, the triplet representation of the initial pixel (first pixel) is adjusted as follows:
[0132] y2=a(y) yt(y);
[0133] u2=w u;
[0134] v2=w v.
[0135] The final adjusted pixel (y2, u2, v2) is converted back to RGB space to obtain (r2, g2, b2). The final adjusted pixel saturation index S2 is calculated based on the HSV color space. Let v2_max = max{r2, g2, b2} and v2_min = min{r2, g2, b2}. If v2_max ≠ 0, then S2 = (v2_max - v2_min) / v2_max; if v2_max = 0, then S2 = 0.
[0136] The final adjusted pixel is called the third saturation index. That is, the third pixel corresponds to the third saturation index. The difference between the final adjusted pixel saturation index (third saturation index) and the target saturation index is calculated. When the difference between the third saturation index and the target saturation index is less than a preset difference threshold, the RGB value (r2, g2, b2) at this time is used as the final adjusted output for this pixel. When the difference between the third saturation index and the target saturation index is greater than the preset difference threshold, the value of the adjustment parameter w is adjusted, and a second adjustment sequence is re-determined based on the adjusted w. The first pixel is then adjusted based on the re-determined second adjustment sequence to obtain a new third pixel. The third saturation index of the new third pixel is calculated until the difference between the newly calculated third saturation index and the target saturation index is less than the preset difference threshold.
[0137] For example, when the difference between the third saturation index and the target saturation index is greater than a preset difference threshold, the value of the adjustment parameter w is adjusted, and a third adjustment sequence is determined based on the adjusted w, the adjustment gain function, and the adjustment offset function. Based on the third adjustment sequence, the contrast of the original pixels of the image to be adjusted is finally adjusted; the pixel ultimately adjusted is called the fourth pixel. The fourth saturation index of the fourth pixel is calculated, and it is determined whether the difference between the fourth saturation index and the target saturation index is less than a preset difference threshold. When the difference between the fourth saturation index and the target saturation index is less than the preset difference threshold, the RGB value (r3, g3, b3) at this time is used as the final adjustment output for this pixel. When the difference between the fourth saturation index and the target saturation index is greater than the preset difference threshold, the value of the adjustment parameter w is adjusted, and the adjustment sequence is re-determined based on the adjusted w, until the difference between the newly calculated saturation index and the target saturation index is less than the preset difference threshold.
[0138] In an optional embodiment, the adjustment of the adjustment parameter w can be automatically implemented based on various parameter optimization algorithms such as linear search, gradient descent, and Newton's method. For example, when the third saturation index is less than the target saturation index, the value of the adjustment parameter w can be increased, for example, making the adjusted w value 1.1 times the original value; while when the third saturation index is greater than the target saturation index, the value of the adjustment parameter w can be decreased, for example, making the adjusted w value 0.9 times the original value; repeating this step will obtain the final desired w value.
[0139] S25, Generate the target image based on the final adjusted pixels.
[0140] The final adjusted pixel's RGB value is the final optimized pixel obtained after pixel adjustment. Traverse all original pixels in the image to be adjusted and execute steps S22-S24.
[0141] Based on the spatial coordinate information (such as row and column indices of a two-dimensional plane) of the RGB values corresponding to the final adjusted pixels, the RGB values corresponding to each final adjusted pixel are filled into the corresponding image matrix positions. This ensures that the RGB values of the pixels adjusted for dark areas correspond to the dark areas of the original image, and the RGB values of the pixels adjusted for bright areas correspond to the bright areas of the original image. This ensures that the composition logic of the target image is consistent with that of the original image, without issues such as pixel misalignment or image distortion.
[0142] The filled pixel matrix is then encapsulated according to a preset image format (such as JPG, PNG, RAW) and image metadata is embedded. The metadata may include one or more combinations of the following: color space identifier, resolution parameters, and control parameter records. The control parameter records include parameters such as gain coefficient, offset coefficient, and compression coefficient q, so that the generated target image can be recognized and displayed by conventional display devices, and the technical traceability of the processing process can be achieved.
[0143] After the pixels are adjusted in conjunction with contrast and saturation, the generated target image can achieve a clear distinction between light and dark levels and a natural color transition, solving problems such as dullness and loss of detail in the original image. Furthermore, the saturation in the dark areas can be effectively suppressed, reducing color distortion.
[0144] This application constructs a smooth and continuous adjustment gain function a(x) and adjustment offset function t(x) based on a given lower threshold x0 and upper threshold x1. Based on the adjustment gain function a(x) and adjustment offset function t(x), the initial contrast of the original pixels of the image to be adjusted is performed. A target saturation index is calculated based on the initially adjusted pixel saturation index and the original pixel saturation index. Finally, the contrast of the original pixels is adjusted based on the target saturation index, ensuring that the difference between the final adjusted pixel saturation index and the target saturation index is less than a preset difference threshold. This application can adaptively control image saturation while adjusting image contrast, preventing some pixels from becoming oversaturated, thereby achieving a more comfortable image viewing effect.
[0145] Traditional image color adjustment schemes suffer from two significant drawbacks: First, they adjust image contrast first, then uniformly increase or decrease image saturation globally. This step-by-step adjustment approach struggles to achieve coordinated adaptation between contrast and saturation. Second, blindly adjusting pixel contrast and saturation in tandem, lacking clear and quantifiable targets, easily leads to uncontrolled color adjustment effects. To address these pain points, this application innovatively decouples the contrast adjustment process into a composite of adjusting the gain function and adjusting the offset function. Through rigorous mathematical reasoning, the target saturation level to be adjusted can be precisely determined. Furthermore, this application involves fewer parameters, significantly reducing the workload of parameter tuning.
[0146] This application decouples the contrast adjustment function f(x) into a composite expression of a smooth and continuous adjustment gain function a(x) and an adjustment offset function t(x), instead of directly using a single contrast adjustment function f(x) to control image parameters. This is crucial for ensuring a natural and continuous transition of image saturation in the light-dark boundary region. Specifically, the adjustment gain function a(x) constructed in this application acts on the chromaticity component of the target chromaticity space, and the adjustment offset function t(x) acts on the luminance component of the target chromaticity space. The two form an organically coordinated control system based on a unified continuous change logic. The adjustment gain function a(x) is responsible for precise gain scaling of the chromaticity component, while the adjustment offset function t(x) achieves smooth offset compensation for the luminance component. Both functions maintain first-order continuous differentiability across the entire luminance range, ensuring that the luminance and chromaticity control process is seamless and without abrupt changes. However, in existing technical solutions, the contrast adjustment function can usually only be applied to the luminance component and cannot directly adapt to the adjustment requirements of the chrominance component. For the parameter adjustment of the chrominance component, existing technical solutions generally use the derivative of the contrast adjustment function to replace the adjustment gain function a(x) in this application. Since the derivative of the contrast adjustment function forms a step jump at the boundary of the luminance threshold, the replaced a(x) becomes a discontinuous step function, which in turn causes the image saturation to fluctuate sharply at the boundary between light and dark, ultimately resulting in obvious discontinuities and unnatural traces in the color transition, seriously affecting the overall visual effect of the image.
[0147] Furthermore, existing technologies for adjusting image saturation generally suffer from a blind approach, failing to fundamentally address the core reasons for abnormally high saturation and thus unable to propose targeted suppression strategies. This application, however, fully considers the differences in saturation growth among different pixels in an image, employing a rigorous and precise mathematical derivation process to configure differentiated saturation suppression intensities for each pixel. Simultaneously, the saturation control mechanism of this application possesses high adaptability, eliminating the need for significant manpower and material resources for manual parameter adjustment, achieving fully automated and precise control, and improving efficiency.
[0148] Extensive experiments have verified that there are significant differences in the degree of saturation change among different pixels within an image: generally, the saturation increase ratio of darker pixels is much higher than that of brighter pixels. However, due to the subjective visual perception characteristics of the human eye, the visual effect presented by a 50% saturation increase in darker pixels and a 10% saturation increase in brighter pixels is minimally different. Based on this objective law, the control logic for image saturation changes in this application does not pursue complete consistency in the saturation increase ratio of all pixels, but rather allows darker pixels to have a relatively higher saturation increase ratio to adapt to the visual perception habits of the human eye. To achieve this goal, this application introduces an exponential function to modulate the saturation increase ratio of each pixel. This exponential function has two core characteristics: First, it has a stronger suppressive effect on saturation increase ratios with larger values, which can effectively avoid color distortion caused by excessive saturation increase in dark pixels; Second, the monotonicity of the function itself can ensure that the numerical relationship of saturation increase ratios between pixels does not reverse, ensuring that the saturation increase ratio of dark pixels is always higher than that of bright pixels, thus highly matching the subjective perception of the human visual system, making the color transition of the adjusted image more natural and the visual experience more comfortable.
[0149] Finally, the lower and upper threshold values for contrast adjustment in this application can be flexibly adjusted according to the user's actual needs. Generally speaking, the larger the value of the lower threshold, the faster the saturation increase rate in the dark areas of the image. To achieve coordinated adaptation between contrast adjustment parameters and saturation suppression intensity, this application constructs an exponential function power adaptive calculation model based on the lower threshold: by using the lower threshold as the core input parameter, the power value of the exponential function is automatically derived, so that only the lower threshold, this single core parameter, needs to be adjusted to achieve precise control of the image saturation increase suppression intensity under different contrast adjustment parameters.
[0150] Example 2
[0151] Figure 4 This is a structural diagram of the image contrast adaptive adjustment device provided in the embodiments of this application.
[0152] In some embodiments, the image contrast adaptive adjustment device 40 may include multiple functional modules composed of computer program segments. The computer program for each program segment in the image contrast adaptive adjustment device 40 may be stored in the memory of an electronic device and executed by at least one processor to perform (see details). Figure 2 (Description) The function of adaptive image contrast adjustment.
[0153] In this embodiment, the image contrast adaptive adjustment device 40 can be divided into multiple functional modules according to its functions. These functional modules may include: a function construction module 401, a first adjustment module 402, an index calculation module 403, a second adjustment module 404, an image generation module 405, and a spatial conversion module 406. The term "module" in this application refers to a series of computer program segments that can be executed by at least one processor and perform a fixed function, and which are stored in memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0154] The function construction module 401 is used to construct a smooth and continuous adjustment gain function and adjustment offset function;
[0155] The first adjustment module 402 is used to perform initial contrast adjustment on the original pixels of the image to be adjusted based on the adjustment gain function and the adjustment offset function;
[0156] The index calculation module 403 is used to calculate the target saturation index based on the initially adjusted pixel saturation index and the original pixel saturation index.
[0157] The second adjustment module 404 is used to perform a final adjustment on the contrast of the original pixel based on the target saturation index, so that the difference between the final adjusted pixel saturation index and the target saturation index is less than a preset difference threshold.
[0158] The image generation module 405 is used to generate a target image based on the final adjusted pixels.
[0159] The space conversion module 406 is used to determine whether the color space type of the image to be adjusted is a preset target color space; when the image to be adjusted is not an image of the target color space, the image to be adjusted is converted into an image of the target color space.
[0160] It should be understood that the various variations and specific embodiments of the image contrast adaptive adjustment method provided in the above embodiments are also applicable to the image contrast adaptive adjustment device in this embodiment. Through the detailed description of the aforementioned image contrast adaptive adjustment method, those skilled in the art can clearly understand the implementation process of the image contrast adaptive adjustment device in this embodiment. For the sake of brevity, it will not be described in detail here.
[0161] Example 3
[0162] This embodiment provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the steps in the above-described image contrast adaptive adjustment method embodiment, for example... Figure 2 Steps S21-S25 are shown.
[0163] Alternatively, when the computer program is executed by the processor, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 4 Modules 401-406 in the document.
[0164] Example 4
[0165] See Figure 5 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this application. In a preferred embodiment of this application, the electronic device 50 includes a memory 501, at least one processor 502, and at least one communication bus 503.
[0166] Those skilled in the art should understand that Figure 5 The structure of the electronic device shown does not constitute a limitation of the embodiments of this application. It can be a bus structure or a star structure. The electronic device 50 may also include more or fewer other hardware or software than shown, or different component arrangements.
[0167] In some embodiments, the electronic device 50 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), digital processors, and embedded devices. The electronic device 50 may also include client devices, including, but not limited to, any electronic product capable of human-computer interaction with a client via a keyboard, mouse, remote control, touchpad, or voice control device, such as personal computers, tablet computers, smartphones, and digital cameras.
[0168] The electronic device 50 described is merely an example. Other existing or future electronic products that are suitable for this application should also be included within the scope of protection of this application and are incorporated herein by reference.
[0169] In some embodiments, the memory 501 stores a computer program that, when executed by the at least one processor 502, implements all or part of the steps in the image contrast adaptive adjustment method as described. The memory 501 includes a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0170] Furthermore, the computer-readable storage medium may primarily include a program storage area and a data storage area, wherein the program storage area may store the operating system, at least one application required for a function, etc.; and the data storage area may store data created based on the use of blockchain nodes, etc.
[0171] The blockchain referred to in this application is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. Essentially, a blockchain is a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity of the information (anti-counterfeiting) and generate the next block. A blockchain can include an underlying blockchain platform, a platform product service layer, and an application service layer.
[0172] In some embodiments, the at least one processor 502 is the control unit of the electronic device 50, connecting each component of the entire electronic device 50 via various interfaces and lines. It executes programs or modules stored in the memory 501 and calls data stored in the memory 501 to perform various functions and process data of the electronic device 50. For example, when the at least one processor 502 executes a computer program stored in the memory, it implements all or part of the steps of the image contrast adaptive adjustment method described in the embodiments of this application; or it implements all or part of the functions of the image contrast adaptive adjustment device. The at least one processor 502 may be composed of integrated circuits, such as a single-packaged integrated circuit or multiple integrated circuits with the same or different functions, including combinations of one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips.
[0173] In some embodiments, the at least one communication bus 503 is configured to enable communication between the memory 501 and the at least one processor 502, etc.
[0174] Although not shown, the electronic device 50 may also include a power supply (such as a battery) to power each component. Preferably, the power supply can be logically connected to the at least one processor 502 via a power management device, thereby enabling functions such as charging, discharging, and power consumption management. The power supply may also include one or more DC or AC power supplies, recharging devices, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 50 may also include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0175] The integrated unit implemented as a software functional module described above can be stored in a computer-readable storage medium. This software functional module, stored in a storage medium, includes several instructions to cause an electronic device (which may be a personal computer, electronic device, or network device, etc.) or processor to execute portions of the methods described in each embodiment of this application.
[0176] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0177] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0178] Furthermore, in each embodiment of this application, the functional modules can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0179] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that it can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within this application. No reference numerals in the claims should be construed as limiting the scope of the claims. Furthermore, it is clear that the word "comprising" does not exclude other elements or, and the singular does not exclude the plural. Multiple elements or devices recited in the specification may also be implemented by a single element or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any particular order.
[0180] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.
Claims
1. An image contrast adaptive adjustment method, characterized in that, The image contrast adaptive adjustment method includes: Construct a smooth and continuous adjustment gain function and adjustment offset function; Based on the adjustment gain function and the adjustment offset function, the contrast of the original pixels of the image to be adjusted is initially adjusted; The target saturation index is calculated based on the initially adjusted pixel saturation index and the original pixel saturation index. Set adjustment parameters; determine a second adjustment sequence based on the adjustment parameters, the adjustment gain function, and the adjustment offset function; perform a final contrast adjustment on the original pixels based on the second adjustment sequence; determine whether the difference between the final adjusted pixel saturation index and the target saturation index is greater than a preset difference threshold; when the difference is greater than the preset difference threshold, adjust the adjustment parameters, and redetermine the second adjustment sequence and pixel saturation index based on the adjusted adjustment parameters, until the difference between the pixel saturation index and the target saturation index is less than the preset difference threshold; The target image is generated based on the final adjusted pixels.
2. The image contrast adaptive adjustment method according to claim 1, characterized in that, The construction of the smooth and continuous adjustment gain function and adjustment offset function includes: Based on the preset lower threshold and the preset upper threshold, calculate the basic adjustment gain and the basic adjustment offset; Based on the aforementioned basic adjustment gain and basic adjustment offset, a smooth and continuous adjustment gain function and adjustment offset function are constructed.
3. The image contrast adaptive adjustment method according to claim 2, characterized in that, The initial contrast adjustment of the original pixels of the image to be adjusted based on the adjustment gain function and the adjustment offset function includes: The first adjustment sequence is determined based on the adjustment gain function and the adjustment offset function; The initial contrast adjustment is performed on the original pixels of the image to be adjusted based on the first adjustment sequence.
4. The image contrast adaptive adjustment method according to claim 3, characterized in that, The first adjustment sequence includes function values corresponding to the independent variables of the adjustment gain function and the adjustment offset function, with the luminance component of the original pixel as the independent variable.
5. The image contrast adaptive adjustment method according to any one of claims 1 to 4, characterized in that, The image contrast adaptive adjustment method further includes: Determine whether the color space type of the image to be adjusted is a preset target color space; When the image to be adjusted is not an image in the target color space, the image to be adjusted is converted to an image in the target color space.
6. The image contrast adaptive adjustment method according to any one of claims 2 to 4, characterized in that, The calculation of the target saturation index based on the initially adjusted pixel saturation index and the original pixel saturation index includes: Obtain the compression ratio; Calculate the initial ratio between the initially adjusted pixel saturation index and the original pixel saturation index; The compression ratio value is obtained based on the compression coefficient and the initial ratio; The target saturation index is obtained based on the compression ratio and the original pixel saturation index.
7. The image contrast adaptive adjustment method according to claim 6, characterized in that, The process of obtaining the compression coefficient includes: Determine the compressibility factor used to regulate compressive strength; The compression coefficient is determined based on the lower threshold and the compression factor. The compression coefficient exhibits continuous and smooth compression characteristics based on the size of the lower threshold, and the minimum value of the compression coefficient is not lower than the benchmark value, which is the minimum compression intensity critical value to ensure that the initial ratio does not undergo over-compression leading to information loss.
8. An electronic device, characterized in that, The electronic device includes a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the image contrast adaptive adjustment method according to any one of claims 1 to 7.
9. A computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the image contrast adaptive adjustment method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Color image enhancement method based on color constancy
CN102509272A
An adaptive contrast enhancement method for color images
CN109146811A