An image brightness adjustment method and electronic device based on a defined histogram

By constructing a multi-level brightness adjustment system based on filtering, brightness shifting, and peak homogenization methods using a defined histogram, the problem of insufficient adaptability of existing brightness adjustment methods is solved, and precise control of image brightness distribution and distortion suppression are achieved, thereby improving image quality.

CN120725940BActive Publication Date: 2025-10-31JIANGSU PEREGRINE MICROELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511158316.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-19
Publication Date
2025-10-31
Estimated Expiration
2045-08-19

AI Technical Summary

Technical Problem

Existing image brightness adjustment methods fail to adequately adapt to the brightness characteristics of images themselves, resulting in distortions such as uneven brightness and false contours in special scenarios, and their adaptability is insufficient.

Method used

An image brightness adjustment method based on a defined histogram is adopted. Through operations such as filtering, brightness shifting, and peak homogenization, a multi-level brightness adjustment system is constructed. Combined with the initial brightness distribution and spatial information of the image, adaptive adjustment is performed.

Benefits of technology

It achieves precise control of brightness distribution, suppresses distortion, improves image quality, ensures the naturalness and realism of brightness adjustment, and adapts to the image enhancement needs in complex scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120725940B_ABST
    Figure CN120725940B_ABST
Patent Text Reader

Abstract

This invention discloses an image brightness adjustment method and electronic device based on a defined histogram. First, the initial brightness histogram of the image is filtered, brightness shifted, and peak homogenized to achieve different brightness adjustment targets, such as smoothing the distribution, shifting peak values, and enhancing discriminability. A defined histogram is constructed based on the spatial distribution of brightness to suppress mapping distortion and select suitable mapping values ​​from associated spatial neighbors. It is compatible with local histogram methods, forming a two-dimensional adaptive "value domain-spatial domain" model, adapting to complex scenarios. The enhancement effect can be flexibly customized to meet diverse needs, and the algorithm has low complexity and low computational resource requirements. It can efficiently optimize image quality and is applicable to various image processing types, including medical images and natural images, improving image detail observation and visual effects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to an image processing method and an electronic device, specifically to an image brightness adjustment method and an electronic device. Background Technology

[0002] Digital image acquisition is the process of converting light signals into electrical signals using sensors such as cameras, and then storing, transmitting, and displaying them in digital form. Digital image processing, on the other hand, involves optimizing the acquired digital images according to their specific purpose and application scenario. Common processing methods include image enhancement and restoration, image encoding and compression, and image description.

[0003] Image enhancement is the process of adding information or transforming data in an original image using specific methods. It selectively highlights features of interest in the image while suppressing (masking) certain unwanted features, thereby matching the image with visual response characteristics.

[0004] Image brightness adjustment, as one method, makes image details easier to observe by changing the brightness distribution of the image. Traditional image brightness adjustment methods usually use algorithms such as grayscale mapping or histogram equalization. Grayscale mapping adjusts the pixel value distribution through a preset function; histogram equalization expands the dynamic range by redistributing pixel values. Traditional methods achieve effects such as enhancing details in dark areas or low-contrast regions by changing the distribution of image brightness in the value range. Although these methods are simple to implement and generally effective, they have two key limitations: (1) they adopt a uniform processing strategy and do not take into account the brightness distribution characteristics of the image itself; (2) they are prone to distortion phenomena such as uneven brightness and false contours in special scenes.

[0005] Defined histograms, as an improved method for histogram equalization, optimize performance by matching the image histogram to the target distribution. However, existing methods mostly use fixed target histograms, which still fail to adequately adapt to the brightness characteristics of the image itself.

[0006] With the increasing demands for image quality in fields such as smart cars, smart homes, and security monitoring, developing brightness adjustment methods that can adapt to image characteristics has significant application value. The current technology's insufficient adaptability is precisely the core technical challenge that needs to be addressed. Summary of the Invention

[0007] Purpose of the invention: To address the aforementioned existing technologies, this invention proposes an image brightness adjustment method and electronic device based on a defined histogram, which enables precise control of brightness distribution, suppression of distortion, and efficient optimization of image quality.

[0008] Technical solution: An image brightness adjustment method based on a defined histogram, comprising:

[0009] Step 1: Convert the image into a luminance image that represents luminance information in a single channel;

[0010] Step 2: Perform luminance histogram statistics on the luminance image, sorting the pixel values ​​from low to high. The number of pixels corresponding to each pixel value forms a sequence S. The i-th term s in sequence S... i The number of pixels with brightness i is represented by the sequence S. After being visualized as a histogram, the sequence S becomes the brightness histogram D of the brightness image P. The range of pixel values ​​is denoted as I, and the maximum brightness is m, then I = [0, m].

[0011] Step 3: According to the image processing requirements, preprocess the brightness histogram D to obtain the target brightness histogram based on the initial image information, denoted as S. G The preprocessing includes three methods: filtering, brightness shifting, and peak homogenization.

[0012] Step 4: Adjust the brightness image using the defined histogram method to achieve the desired brightness effect.

[0013] Furthermore, in step 3, the filtering includes: performing a convolution operation on the sequence S using a one-dimensional convolution kernel to generate a sequence The i-th term s in sequence S i After filtering, the result is , where s i+j Let a be the (i+j)th term in sequence S. j These are the coefficients of the one-dimensional convolution kernel, where j is an integer in the range [-n, n], and n ranges from 5 to 10. a j ≥0, a j =a -j The generated new sequence After visualizing the result using a histogram, a new brightness histogram is obtained.

[0014] Furthermore, in step 3, the brightness shift includes: performing a brightness shift operation on the sequence S to generate a sequence. The i-th term s in sequence S i After processing, the result is , where s j Let b represent the j-th term in the sequence S, where j is an integer within the range [in, i+n]. ji Let b represent the weight, and let b be the weight. ji satisfy: .

[0015] Furthermore, in step 3, the peak homogenization includes:

[0016] 1) Filter and preprocess the sequence S to obtain the sequence Sequence The i-th term is denoted as ;

[0017] 2) Peak detection includes: first, marking the sequence All of the above satisfy The value of i is N, the total number of pixels in the image is N, and the value of θ is in the range of [2,10]. The set of all i that meet the conditions is denoted as I*. I* is divided into t sets according to consecutive elements, and each set corresponds to an independent peak.

[0018] 3) For the k-th set I k By iterating through the data, we find the brightness value that divides the peak pixel count into two equal parts. That is, the center of the peak;

[0019] 4) Perform peak homogenization based on the number of pixels and distance of each peak, including: for set I k Calculate peak weight , where i k n represents the initial brightness value of the k-th peak. k This indicates the number of brightness values ​​contained in the peak. For sequence The j-th item, accounting for The value range is [1 / 2, 3 / 4]; according to the weight ratio of each peak, the value range [0, m] is assigned to each peak to make the peaks evenly distributed in the value range. The peak center position after homogenization adjustment is... for: ,in The peak weight of the j-th peak is determined; the pixels of the original peak are shifted to the new center. At the corresponding positions, pixel values ​​are evenly distributed among points not in the peak, thus obtaining a sequence. After being visualized in the form of a histogram, the brightness histogram after peak homogenization is obtained.

[0020] Furthermore, step 4 includes the following specific steps:

[0021] 4.1) Map each pixel value x of the luminance image P to the target luminance histogram S. G The interval [p] in x ,q x ], p x For the target brightness histogram S G The total area to the left of x in the brightness histogram D must not exceed the maximum pixel value of the total area to the left of x. x For the target brightness histogram S G The total area on the left side of the brightness histogram D must be no less than the maximum pixel value of the total area on the left side of (x+1).

[0022] 4.2) For any pixel O in the brightness image, take an n*n pixel block centered on pixel O and denote it as Q. First, obtain the pixel value I of pixel O in the guiding image according to the following formula. G Preliminary valuation of (O) Wherein, pixel A in pixel block Q is denoted as the pixel in the target brightness histogram S. G The mapping interval in is [p A ,q A ];W A This represents the weight of pixel A. d(O,A) represents the spatial distance between pixel O and pixel A, and σ1 and σ2 are parameters that affect the spatial distance and the size of the mapping interval, respectively, with values ​​ranging from σ1≥2 to σ2∈[1,5]. G * (O) in the interval [p] that pixel point O can be mapped to. O ,q O Within the image, the pixel value I of pixel point O is guided. G (O) Take the corresponding value; otherwise, take the endpoint of the interval; after traversing all points in the brightness image P, the guiding image G is obtained;

[0023] 4.3) Based on the preliminary estimate of the guiding image G, further optimization is performed. By adjusting the parameters to reduce the influence of the interval range on the weight, the accuracy of histogram specification is gradually improved, and the final image after histogram specification processing is obtained.

[0024] Furthermore, in step 3, the weight b in the brightness offset ji It is obtained by Gaussian weighting combined with normalization, where Gaussian weights β represents the degree of shift towards the central brightness; the Gaussian weight W ji Normalization yields .

[0025] Furthermore, in step 4, the brightness histogram D and the target brightness histogram S... G The number of pixels corresponding to pixel value i is denoted as s. i , The original image's pixel value x is mapped to the target brightness histogram S by mapping T. G The interval [p] in x ,q x ], where the mapping T is determined as follows: ;in, This represents the mapping value with respect to x.

[0026] Furthermore, step 4.3) includes the following specific steps: For pixel point O, use the pixel value I in the guide image. G (A) By substituting the midpoint of the interval and performing a weighted average, we obtain In this case, the parameter affecting the size of the mapping interval in the weighting function is adjusted from σ2 to σ3, where σ3∈[σ2,4σ2]. The adjusted weights... ;

[0027] When I out * (O) in the interval [p O ,q O When the pixel value I of pixel point O in the final image is within the specified range, the pixel value I is... out (O) Take the corresponding value; otherwise, take the endpoint of the interval; after traversing all points in the guide image G, the final image after adjusting the brightness using the specified histogram method is obtained.

[0028] Furthermore, it also includes: after obtaining the brightness image in step 1, the brightness image is first segmented into pixel block groups, and then the operations of steps 2 to 4 are performed separately for each pixel block group. Then, a weighted average is performed based on the calculation results of the pixel values ​​in each pixel block group and their positional relationships.

[0029] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the image brightness adjustment method based on a defined histogram.

[0030] Beneficial effects: 1. By sequentially performing filtering, brightness shifting, and peak homogenization operations on the initial brightness histogram, a multi-level brightness adjustment system is constructed to accurately achieve different image brightness control targets.

[0031] Using a one-dimensional symmetric convolution kernel to filter the brightness histogram can effectively smooth the gradual change in image brightness, reduce the abruptness of brightness distribution, and improve visual continuity. Using an asymmetric filtering kernel to perform brightness shifting can directionally shift the brightness peak, optimize brightness uniformity as needed, or highlight specific details. With the help of peak uniformization processing, the brightness range with dense pixels in the value range is segmented, enhancing brightness differentiation and making image details easier to observe.

[0032] 2. A standardized histogram mapping mechanism based on brightness spatial distribution is constructed to solve the problem of pixel value abrupt changes caused by traditional single mapping values. During the mapping process, a reasonable range is defined for pixel values, and the optimal mapping value is selected from within the range by combining image spatial distribution information. By associating the spatial neighborhood relationships of pixels, the consistency of local features is fully considered, effectively avoiding image distortion and ensuring that the image is natural and realistic after brightness adjustment.

[0033] 3. This method is highly compatible with the local histogram adaptive method. The local histogram method focuses on local blocks of the image and achieves local adaptation through histogram equalization; this method performs adaptive adjustment from the perspective of brightness value range. The combination of the two forms a two-dimensional adaptive adjustment of "value range-spatial domain", which can better adapt to complex local features of the image. When processing images containing rich details and edges, it ensures a reasonable global brightness distribution while optimizing local brightness transitions and detail rendering, thus expanding its application in image enhancement for complex scenes. Attached Figure Description

[0034] Figure 1 This is a flowchart of the method of the present invention;

[0035] Figure 2 The images and corresponding histogram statistics in the examples are shown below;

[0036] Figure 3 for Figure 2 The result of filtering the middle histogram;

[0037] Figure 4 for Figure 2 The result of brightness offset processing on the center histogram;

[0038] Figure 5 This is a schematic diagram of peak homogenization;

[0039] Figure 6 This is a schematic diagram illustrating the selection of pixel block groups in the local adaptive method. Detailed Implementation

[0040] The invention will now be further explained with reference to the accompanying drawings.

[0041] Example 1:

[0042] An image brightness adjustment method based on a defined histogram is proposed. First, the image is converted into a single-channel brightness image. Then, by statistically analyzing the brightness histogram, the histogram is adjusted according to specific requirements to obtain a target brightness histogram based on the initial information of the image. Finally, the image is adjusted using a defined histogram method to achieve the desired brightness effect.

[0043] The specific steps are as follows:

[0044] Step 1: Convert the image into an image that represents brightness information in a single channel.

[0045] For common RGB format images, they are first converted to YUV format, and then the Y channel representing brightness is processed. After completing the image brightness adjustment process according to the method of this invention, it is then converted back to RGB format.

[0046] In addition to converting to YUV format, you can also choose to convert it to an image representing brightness in other ways, such as the V channel of an HSV image, or perform brightness processing on the RGB three channels separately.

[0047] In subsequent steps, the images processed are all single-channel images whose pixel values ​​represent only the brightness values, hereinafter referred to as the brightness image P.

[0048] Step 2: Perform brightness histogram statistics on the brightness image.

[0049] Perform a brightness histogram analysis on the brightness image P, that is, count the number of pixels for each possible pixel value.

[0050] Because images, when represented as digital signals, have discrete characteristics—for example, 8-bit quantized pixel values ​​are integers from 0 to 255—brightness histogram statistics can be performed by directly counting the discrete pixel values. However, in scenarios with a very wide range of pixel values, statistics can be achieved by dividing the data into equal-length intervals. Figure 2 As shown, (a) is the brightness image, and (b) is the corresponding brightness histogram statistical results.

[0051] The pixel values ​​are sorted from low to high, and the number of pixels corresponding to each pixel value forms a sequence S. The i-th term s in sequence S... i This represents the number of pixels with brightness i. The sequence S is visualized as a histogram, resulting in the brightness histogram D of the brightness image P. Let I denote the range of pixel values, and m be the maximum brightness; then I = [0, m] ∩ ℤ, where ℤ represents an integer. If 8-bit quantization is used, then m = 255.

[0052] Step 3: According to the image processing requirements, preprocess the brightness histogram D to obtain the target brightness histogram based on the initial image information.

[0053] Preprocessing includes three methods: filtering, brightness shifting, and peak homogenization. The appropriate method can be selected based on the image processing requirements to preprocess the brightness histogram D obtained in step 2, thus obtaining the desired target brightness histogram.

[0054] 1. Filtering

[0055] Traditional histogram equalization improves the dynamic range of an image by homogenizing the brightness distribution. Its goal is to ensure that all brightness levels have the same number of pixel values. By distributing the number of pixels for each brightness level evenly, the distinction between different brightness levels becomes more pronounced, thus improving image contrast. However, this method often causes significant distortion due to large variations in pixel values ​​and significant differences in the mapping values ​​corresponding to some areas of gradual brightness change. Improved methods typically use constrained histogram equalization and local adaptive strategies to mitigate this impact.

[0056] In this invention, by filtering the brightness histogram, the initial brightness distribution of the image is fully utilized to generate a smoother target brightness histogram based on the initial brightness distribution. This effectively avoids the severe distortion problem caused by traditional histogram equalization operations while ensuring uniform brightness distribution. Furthermore, the filtering process in this method can enhance the peak features of the image, serving as a pre-step for subsequent peak homogenization.

[0057] Specifically, filtering the brightness histogram involves performing a convolution operation on the sequence S using a one-dimensional convolution kernel to generate a sequence. The i-th term s in sequence S i After filtering, the result is , where s i+j Let a be the (i+j)th term in sequence S. j These are the coefficients of the one-dimensional convolution kernel, where j takes the value of an integer in the range [-n, n]. a j ≥0. Sequence a -n ,a -n+1 ,...,a n Let H be a sequence of (2n+1) terms, representing the filter kernel, and a j =a -j That is, the filter kernel is symmetric. The generated new sequence... After being visualized in the form of a histogram, a new brightness histogram D1 is obtained.

[0058] The convolution operation described above represents the computation of a sequence. The i-th term At that time, with s i Centered on the original sequence S, take the number of pixels s from position (in) to position (i+n). i+j Multiply by the corresponding coefficient a of the convolution kernel respectively j Then sum them up. If (i+j) exceeds the range of the original brightness histogram D, meaning there are no pixels corresponding to the brightness value, then s i+j Set to 0. The larger n is, the closer the convolution kernel is to the kernel of the mean filter, resulting in a smoother histogram after filtering; the smaller n is, the closer the filtered result is to the original histogram, preserving more original details. n is typically set to 5-10.

[0059] Figure 3 Given Figure 2 The brightness histograms in the image are the results after filtering. (a) corresponds to the filtering result with n=10, and (b) corresponds to the filtering result with n=5.

[0060] 2. Brightness offset

[0061] Overly bright and underly dark areas in an image are difficult to observe, and simply adjusting the brightness through mapping often fails to achieve the desired effect. For such images, the brightness histogram can be adjusted to reduce the brightness of high-brightness areas and increase the brightness of low-brightness areas. Furthermore, when it is desired that the brightness distribution of an image change according to other predetermined rules, this can also be achieved through brightness shifting.

[0062] Specifically, a brightness shift operation is performed on the sequence S to generate a sequence. The i-th term s in sequence S i After processing, the result is , where s j Let b represent the j-th term in the sequence S, where j is an integer within the range [in, i+n]. ji Indicates weight, and b ji ≥0. That is, for each target brightness i, take the brightness value in the range [in, i+n] of the original histogram D, and use the weight b ji Weighted summation, from (in) to (i+n), yields the number of pixels with the new brightness i. n typically ranges from 5 to 10.

[0063] in, This ensures that the sum of the number of pixels in the new histogram remains unchanged after the transformation, while It can be anything other than 1, it can be obtained through Measure the magnitude of the change in histogram due to brightness shift. The larger the value, the more concentrated the weights are in certain areas, and the greater the range of variation that the histogram can exhibit. When the value is close to 1: the weights are nearly uniformly distributed, the histogram changes little, and the overall brightness does not shift.

[0064] Since the desired brightness shifts towards the medium brightness region, the weights should be set as follows:

[0065] ,

[0066] .

[0067] Where m is the maximum brightness, then m / 2 represents the intermediate brightness. For j values ​​higher than the intermediate brightness, the weighted sum is required. Gradually increase the brightness of the element j, allowing the brighter element j to contribute more to the lower element i, thus reducing brightness and moving it closer to the center, resulting in darkening of bright areas. For elements j with brightness below the median, the weights are required to be... Gradually decrease the brightness, that is, let the lower brightness j contribute more to the higher brightness i, that is, increase the brightness and move towards the middle, so as to brighten the dark area.

[0068] To achieve the aforementioned brightness shift towards the center, a Gaussian weighted combined normalization construction method is given as an example.

[0069] 1) Gaussian weight generation:

[0070]

[0071] In the formula, W ji The value represents the Gaussian weight, and β represents the degree of shift towards the center brightness. β ≥ 0, and the larger the value of β, the more obvious the shift. The closer i is to the center brightness m / 2, the larger the weight; the farther i is from j, the smaller the weight.

[0072] 2) Weight normalization:

[0073]

[0074] Gaussian weights W ji Normalization, ensuring This satisfies the constraint that the total number of pixels remains unchanged.

[0075] Figure 4 for Figure 2 The result of the brightness histogram after brightness shifting is shown in blue, which is the original brightness histogram, and orange, which is the processed brightness histogram. The brightness distribution is shifted towards the center.

[0076] Areas that are too bright or too dark in an image are difficult to observe. By performing a brightness shift operation and using a weighted transformation with an intermediate brightness bias, the number of pixels at each brightness level is redistributed, causing the pixels to concentrate towards the intermediate brightness and restoring details.

[0077] 3. Peak homogenization

[0078] A peak is a region in the brightness histogram where the number of pixels is significantly higher than the surrounding values. By homogenizing the brightness peaks to make them more evenly distributed across the value range, different brightness levels can be better distinguished, highlighting image details. Figure 5 This is a schematic diagram of peak homogenization. In diagram (a), the three peaks are unevenly distributed, resulting in a weak brightness contrast between the leftmost and middle peaks in the image, while the contrast between the middle and rightmost peaks is noticeable but exceeds the level required for clear human visual distinction. Therefore, peak homogenization transforms the image into... Figure 5 (b) allows for a more reasonable differentiation of brightness and highlighting of details.

[0079] Specifically, peak homogenization can be performed in the following steps:

[0080] 1) Perform filtering preprocessing on the brightness histogram.

[0081] Filtering can transform irregular parts of the brightness histogram into more regular peaks, facilitating subsequent identification and processing. The filtering operation is described in section "1. Filtering" above, resulting in the sequence... , The i-th term is denoted as .

[0082] 2) Detect the peak.

[0083] Let N be the total number of pixels in the image and m be the maximum brightness. Then, first label the sequence. All of the above satisfy The value of i is defined as the pixel value whose number of marked pixels is more than θ times the average value, where θ ranges from [2, 10]. The set of all i values ​​that satisfy this condition is denoted as I*, i.e., I* = {i | >θN / m}. Divide I* into t sets based on consecutive elements, i.e. Each set corresponds to an independent peak, I k Let represent the k-th set. , ,k≠l,I l Let l represent the l-th set. In practice, the search can be performed in I=[0,m]∩ℤ by pixel value from low to high, starting from the first set that satisfies the condition. From the beginning of i to the first satisfaction Let j be I1, and then start from (j+1) and search in the same way to get I2, I3, ..., I t This continues until I is traversed. The resulting set is I1~I t That is, the t peaks detected.

[0084] 3) Determine the peak center.

[0085] For set I k Find I by pixel count k The median, denoted as , where i k n represents the initial brightness value of the k-th peak. k The median indicates the number of brightness values ​​contained in the peak. satisfy: , For sequence The j-th term satisfies the condition that the sum of the first half of the pixels does not exceed half of the total sum of pixels, while the sum of the second half exceeds half of the total sum of pixels. By iterating through the values, we find the brightness value that divides the peak pixel count into two equal parts, which is the peak center position.

[0086] 4) The peaks are homogenized based on the number of pixels and the distance to each peak.

[0087] Specifically, for the k-th peak, calculate the peak weight. Peak weight represents the size of the interval occupied by the peak in the value range. The first term is: The proportion of pixels within the peak to the total number of pixels, multiplied by This represents the contribution of the number of pixels to the weight; the more pixels, the larger the range it occupies in the value range. Second term: The proportion of the distance between the center of the representative peak and the center of the adjacent peak to the range of values, multiplied by Preserve the distance features of the original histogram. (Percentage) The magnitude of the influence of the two reaction items The value range is [1 / 2, 3 / 4], meaning that the pixel distance has a slightly larger impact, in order to avoid excessive changes in the histogram.

[0088] and These are defined as the minimum and maximum values ​​that a pixel can take, i.e., the lower bound 0 and upper bound m of the value range I. The peak center position after homogenization adjustment. for:

[0089]

[0090] in, Let be the peak weight of the j-th peak. That is, based on the proportion of each peak's weight, the value range [0, m] is allocated to each peak, ensuring a uniform distribution of peaks across the range. Peaks with larger weights are assigned to a value range further back in the center.

[0091] Sure Then, we only need to shift each peak to its corresponding position, that is, for k=1,2,…,t, let j=0,1,…,n k The pixels of the k-th peak are shifted to the new center. At corresponding positions, maintain the same pixel distribution; for points not within the peak, distribute pixel values ​​evenly, with the average pixel value... This yields a sequence. After visualization using a histogram, the brightness histogram D2 after peak homogenization is obtained. Peak homogenization of the brightness histogram is achieved by shifting peaks and uniformly distributing non-peak pixels, thus highlighting image details.

[0092] The brightness histograms obtained by the above three preprocessing methods are the target brightness histograms, denoted as S. G .

[0093] Step 4: Adjust the brightness image P using the defined histogram method so that the brightness histogram of the adjusted image is close to the target brightness histogram S obtained in Step 3. G .

[0094] Specifically, in the preceding steps, the original brightness histogram D and the adjusted target brightness histogram S have been obtained. G The number of pixels corresponding to pixel value i is s. i , .

[0095] 4.1) Constructing the mapping

[0096] Map each pixel value x of the brightness image P to the target brightness histogram S. G The interval [p] in x ,q x This avoids distortion caused by directly mapping individual pixel values. x For the target brightness histogram S G The target brightness histogram S satisfies the condition that the total area to the left of x is not greater than the maximum pixel value of the total area to the left of x in the brightness histogram D. G The largest pixel value that satisfies the condition that "the cumulative number of pixels on the left side is less than or equal to the cumulative number of pixels on the left side of x in the brightness histogram D". x For the target brightness histogram S G The target brightness histogram S satisfies the condition that the total area on the left side is not less than the maximum pixel value of the total area on the left side of (x+1) in the brightness histogram D. G The maximum pixel value that satisfies the condition that "the cumulative number of pixels on the left side is greater than or equal to the cumulative number of pixels on the left side of (x+1) in the brightness histogram D".

[0097] Mapping T is represented as: ,in It is the interval consisting of all connected pixel values ​​in the value range.

[0098] Mapping T is determined as follows:

[0099] .

[0100] in, This represents the mapping value with respect to x. The mapping range of pixel values ​​is determined by cumulative area matching, ensuring that the histogram shape closely approximates the target distribution.

[0101] 4.2) Generate guide image

[0102] For a single pixel, denoted as O, its value in the initial brightness image P is I(O). Centered on pixel O, a pixel block of size n*n is selected, denoted as Q, where n is typically 5 or 7. The pixel value of pixel A within pixel block Q is I(A), and the mapping T maps it to [p...]. A ,q A ], then guide the pixel value I of pixel point O in the image. G (O) is obtained as follows:

[0103] First, use the following formula to obtain I. G * (O):

[0104]

[0105] Among them, I G * (O) represents I based on spatial distribution. G The initial estimate of (O), which may not be within the range that pixel O can be mapped to, is used as an intermediate value; W A This represents the weight of pixel A. d(O,A) represents the spatial distance between pixel O and pixel A; σ1 and σ2 are parameters that affect the spatial distance and the size of the mapping interval, respectively, and can be set as needed, with values ​​ranging from σ1≥2 to σ2∈[1,5]. A The first term represents spatial distance; the closer the distance, the greater the weight. The second term represents the size of the mapped interval; the smaller the interval, the more accurate the result. Using spatial distance and interval size to construct weights ensures consistent adjustments between adjacent pixels, reducing distortion.

[0106] When I G * (O) in the interval [p] that pixel point O can be mapped to. O ,q O Within the image, the pixel value I of pixel point O is guided. G (O) Take the corresponding value; otherwise, take the endpoint of the interval.

[0107] .

[0108] After performing the above operations on all points in the brightness image P, a guide image G is obtained, which initially determines the estimated value of each pixel and its surrounding pixels in the interval obtained after mapping.

[0109] 4.3) Generation of the final image

[0110] Further optimization is performed based on the initial estimate of the guiding image G. By adjusting the parameters to reduce the influence of the interval range on the weights, the accuracy of histogram specification is gradually improved, and the final image after histogram specification processing is obtained.

[0111] Specifically, for pixel O, the pixel value I in the guide image is used. G (A) By substituting the midpoint of the interval and performing a weighted average, we obtain I. out * (O):

[0112] .

[0113] Since the guiding image has already narrowed the mapping range, the influence of the mapped interval size on the weights is reduced. Therefore, the parameter in the weight function that affects the mapping interval size is adjusted from σ2 to σ3, where σ3 ∈ [σ2, 4σ2]. The adjusted weights are then... .

[0114] When I out * (O) in the interval [p O ,q O When the pixel value I of pixel point O in the final image is within the specified range, the pixel value I is... out (O) Take the corresponding value; otherwise, take the endpoint of the interval:

[0115]

[0116] After performing the above operations on all points in the guide image G, the final image with adjusted brightness using the specified histogram method is obtained.

[0117] This step reduces distortion during histogram specification by using refined interval mapping and weighted processing to maintain the overall brightness distribution of the image.

[0118] Example 2: Using a local adaptive optimization method.

[0119] In practical engineering, depending on the needs and resource constraints, you can choose to directly apply steps 1 to 4 to the image, or choose to use a local adaptive optimization method to process each local pixel block separately before fusion, in order to achieve better results.

[0120] Specifically, after obtaining the brightness image P in step 1, the brightness image P is first segmented into pixel block groups. Then, the operations of steps 2 to 4 are performed on the pixel block groups. Finally, a weighted average is calculated based on the calculation results of the pixel values ​​in each pixel block group and their positional relationships.

[0121] For a brightness image P, it is divided into several m x n rectangular pixel blocks. Each time, a 2x2 pixel block group is taken from the rectangular pixel block, which is considered as a complete image. The operation is repeated by taking a new 2x2 pixel block group with a step size of one pixel block. Each pixel block is calculated as the bottom right, bottom left, top right, and top left pixel block in different 2x2 pixel block groups, respectively, and the corresponding four pixel values ​​are denoted as i1(x,y), i2(x,y), i3(x,y), and i4(x,y).

[0122] like Figure 6 As shown, the gray pixel blocks were calculated in the four pixel block groups illustrated. For a point with coordinates (x, y) in an m*n pixel block, where 1 ≤ x ≤ n and 1 ≤ y ≤ m, i1(x, y), i2(x, y), i3(x, y), and i4(x, y) are the pixel values ​​calculated in the 2*2 pixel block group centered on the top-left, top-right, bottom-left, and bottom-right vertices of (x, y).

[0123] The weights are assigned based on the horizontal and vertical distances between the center of the 2x2 pixel block and its four vertices. The weighted average formula is as follows:

[0124] By using this weighted average and fusing the results of local block processing, a smooth brightness transition is achieved, resulting in an image optimized by the local adaptive method. Through block segmentation and local weighting, local adaptive optimization is realized, avoiding the need to compensate for local detail differences that might be overlooked in global processing, such as brightness transitions at edges and textures. This allows the image to achieve better image processing results in each local region, while also resulting in more natural local brightness gradations and better detail preservation.

[0125] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. An image brightness adjustment method based on a defined histogram, characterized in that, The process includes: Step 1: Converting the image into a luminance image representing luminance information using a single channel; Step 2: Performing luminance histogram statistics on the luminance image, sorting pixel values ​​from low to high, and forming a sequence S with the number of pixels corresponding to each pixel value. The i-th term s in sequence S... i The number of pixels with brightness i is represented by the sequence S. After being visualized as a histogram, the sequence S becomes the brightness histogram D of the brightness image P. The range of pixel values ​​is denoted as I, and the maximum brightness is m, then I = [0, m]. Step 3: According to the image processing requirements, preprocess the brightness histogram D to obtain the target brightness histogram based on the initial image information, denoted as S. G The preprocessing includes three methods: filtering, brightness shifting, and peak homogenization. Step 4: Adjust the brightness image using the defined histogram method to achieve the desired brightness effect. Step 4 includes the following specific steps: 4.1) Map each pixel value x of the brightness image P to the target brightness histogram S. G The interval [p] in x ,q x ], p x For the target brightness histogram S G The total area to the left of x in the brightness histogram D must not exceed the maximum pixel value of the total area to the left of x. x For the target brightness histogram S G The pixel value satisfying the condition that the total area on the left side is not less than the maximum pixel value of the total area on the left side of (x+1) in the brightness histogram D; 4.2) For any pixel point O in the brightness image, take a pixel block of size n*n centered on pixel point O and denote it as Q. The pixel value I of pixel point O in the guiding image is obtained first according to the following formula. G Preliminary valuation of (O) Wherein, pixel A in pixel block Q is denoted as the pixel in the target brightness histogram S. G The mapping interval in is [p A ,q A ];W A This represents the weight of pixel A. d(O,A) represents the spatial distance between pixel O and pixel A, and σ1 and σ2 are parameters that affect the spatial distance and the size of the mapping interval, respectively, with values ​​ranging from σ1≥2 to σ2∈[1,5]. G * (O) in the interval [p] that pixel point O can be mapped to. O ,q O Within the image, the pixel value I of pixel point O is guided. G (O) Take the corresponding value; otherwise, take the endpoint of the interval; after traversing all points in the brightness image P, the guide image G is obtained; 4.3) Based on the preliminary estimate of the guide image G, further optimization is performed. By adjusting the parameters, the influence of the interval range on the weight is reduced, and the accuracy of histogram specification is gradually improved to obtain the final image after histogram specification processing.

2. The image brightness adjustment method based on a defined histogram according to claim 1, characterized in that, In step 3, the filtering includes: performing a convolution operation on the sequence S using a one-dimensional convolution kernel to generate a sequence The i-th term s in sequence S i After filtering, the result is , where s i+j Let a be the (i+j)th term in sequence S. j These are the coefficients of the one-dimensional convolution kernel, where j is an integer in the range [-n, n], and n ranges from 5 to 10. a j ≥0, a j =a -j The generated new sequence After visualizing the result using a histogram, a new brightness histogram is obtained.

3. The image brightness adjustment method based on a defined histogram according to claim 1, characterized in that, In step 3, the brightness shift includes: performing a brightness shift operation on the sequence S to generate a sequence. The i-th term s in sequence S i After processing, the result is , where s j Let b represent the j-th term in the sequence S, where j is an integer within the range [in, i+n]. ji Let b represent the weight, and let b be the weight. ji satisfy: .

4. The image brightness adjustment method based on a defined histogram according to claim 2, characterized in that, In step 3, the peak homogenization includes: 1) performing filtering preprocessing on the sequence S to obtain the sequence Sequence The i-th term is denoted as 2) Peak detection includes: first marking the sequence All of the above satisfy The value of i is given by N, where N is the total number of pixels in the image, and θ ranges from [2, 10]. The set of all i that satisfy the condition is denoted as I*. I* is divided into t sets based on consecutive elements, with each set corresponding to an independent peak. 3) For the k-th set I k By iterating through the data, we find the brightness value that divides the peak pixel count into two equal parts. , that is, the peak center position; 4) Perform uniformization processing on the peaks based on the number of pixels and distance of each peak, including: for set I k Calculate peak weight , where i k n represents the initial brightness value of the k-th peak. k This indicates the number of brightness values ​​contained in the peak. For sequence The j-th item, accounting for The value range is [1 / 2, 3 / 4]; according to the weight ratio of each peak, the value range [0, m] is assigned to each peak to make the peaks evenly distributed in the value range. The peak center position after homogenization adjustment is... for: ,in The peak weight of the j-th peak is determined; the pixels of the original peak are shifted to the new center. At the corresponding positions, pixel values ​​are evenly distributed among points not in the peak, thus obtaining a sequence. After being visualized in the form of a histogram, the brightness histogram after peak homogenization is obtained.

5. The image brightness adjustment method based on a defined histogram according to claim 3, characterized in that, In step 3, the weight b in the brightness offset ji It is obtained by Gaussian weighting combined with normalization, where Gaussian weights β represents the degree of shift towards the central brightness; the Gaussian weight W ji Normalization yields .

6. The image brightness adjustment method based on a defined histogram according to claim 1, characterized in that, In step 4, the brightness histogram D and the target brightness histogram S are... G The number of pixels corresponding to pixel value i is denoted as s. i , The original image's pixel value x is mapped to the target brightness histogram S by mapping T. G The interval [p] in x ,q x ], where the mapping T is determined as follows: ;in, This represents the mapping value with respect to x.

7. The image brightness adjustment method based on a defined histogram according to claim 1, characterized in that, Step 4.3) includes the following specific steps: For pixel point O, use the pixel value I in the guide image. G (A) By substituting the midpoint of the interval and performing a weighted average, we obtain In this case, the parameter affecting the size of the mapping interval in the weighting function is adjusted from σ2 to σ3, where σ3∈[σ2,4σ2]. The adjusted weights... ; when I out * (O) in the interval [p O ,q O When the pixel value I of pixel point O in the final image is within the specified range, the pixel value I is... out (O) Take the corresponding value; otherwise, take the endpoint of the interval; after traversing all points in the guide image G, the final image after brightness adjustment by the specified histogram method is obtained.

8. The image brightness adjustment method based on a defined histogram according to any one of claims 1-7, characterized in that, Also includes: After obtaining the brightness image in step 1, the brightness image is first segmented into pixel block groups. Then, steps 2 to 4 are performed separately for each pixel block group. Finally, a weighted average is calculated based on the calculation results of the pixel values ​​in each pixel block group and their positional relationships.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the image brightness adjustment method based on a defined histogram as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Image brightness adjustment method, computer program product, electronic device and medium

    CN115082291A

  • Image enhancement method based on multi-level contrast and dark detail optimization

    CN120219268A