Image brightness adjusting method based on specified histogram and electronic equipment

Through the filtering, brightness offset and peak equalization methods based on the prescribed histogram, the problem of insufficient adaptability in image brightness adjustment is solved, the precise control of image brightness distribution and distortion suppression are achieved, and the image quality and detail observation effect are improved.

CN120725940AActive Publication Date: 2025-09-30JIANGSU PEREGRINE MICROELECTRONICS CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing image brightness adjustment methods fail to fully adapt to the brightness characteristics of the image itself, resulting in distortion phenomena such as uneven brightness and false contours in special scenarios, and lack of adaptability.

Method used

An image brightness adjustment method based on a prescribed histogram is adopted. Through filtering, brightness shift and peak equalization operations, a multi-level brightness adjustment system is constructed. The brightness spatial distribution information is combined for adaptive control, and a prescribed histogram mapping mechanism is constructed.

Benefits of technology

It achieves precise control of brightness distribution, suppresses distortion, improves image quality, enhances detail observation, and adapts to image enhancement needs in complex scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120725940A_ABST
    Figure CN120725940A_ABST
Patent Text Reader

Abstract

The invention discloses an image brightness adjustment method based on a specified histogram and electronic equipment, and the method comprises the steps: carrying out the filtering, brightness offset, peak homogenization and other operations on an image initial brightness histogram, and achieving different brightness adjustment targets, such as smooth distribution, peak value translation and discrimination enhancement; a specified histogram is constructed based on luminance spatial distribution, mapping distortion is suppressed, and a spatial neighborhood is associated to select an adaptive mapping value. And the method is compatible with a local histogram method, so that'value domain-space domain 'two-dimensional self-adaption is formed, and the method is adaptive to a complex scene. The method can flexibly customize the enhancement effect, meets multiple requirements, is low in algorithm complexity, is low in requirement for computing resources, can efficiently optimize the image quality, is suitable for processing various types of images such as medical images and natural images, and improves the image detail observability and visual effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an image processing method and electronic equipment, and in particular to an image brightness adjustment method and electronic equipment. Background Art

[0002] Digital image acquisition is the process of converting optical signals into electrical signals using sensors such as cameras, and then storing, transmitting, and displaying them in digital form. Digital image processing is the process of optimizing captured digital images based on their specific purpose and application scenario. Common processing methods include image enhancement and restoration, image coding and compression, and image description.

[0003] Image enhancement is to add information to the original image or perform data transformation through specific means, selectively highlighting the features of interest in the image while suppressing (masking) certain unnecessary features, so that the image matches the visual response characteristics.

[0004] Image brightness adjustment is one of the methods that 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 or low-contrast areas 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 use a unified processing strategy and are not based on the brightness distribution characteristics of the image itself; (2) they are prone to distortion such as brightness non-smoothing and pseudo-contours in special scenarios.

[0005] As an improved method for histogram equalization, regularized histograms optimize the effect by matching the image histogram to the target distribution. However, existing methods mostly use a fixed target histogram and still fail to fully adapt to the brightness characteristics of the image itself.

[0006] As image quality requirements increase in areas such as smart cars, smart homes, and security surveillance, developing brightness adjustment methods that can adapt to image characteristics has significant application value. The lack of adaptability in current technologies is precisely the core technical difficulty that needs to be addressed. Summary of the Invention

[0007] Purpose of the invention: In response to the above-mentioned existing technologies, a method and electronic device for adjusting image brightness based on a standardized histogram are proposed to achieve precise control of brightness distribution, suppress distortion, and efficiently optimize image quality.

[0008] Technical solution: A method for adjusting image brightness based on a standardized histogram, comprising:

[0009] Step 1: Convert the image into a brightness image with a single channel representing brightness information;

[0010] Step 2: Perform brightness histogram statistics on the brightness image, sort the pixel values ​​from low to high, and the number of pixel points corresponding to the pixel values ​​constitutes a sequence S. The i-th item s in the sequence S is i Represents the number of pixels with brightness i. The sequence S is visualized in the form of a histogram, which is the brightness histogram D of the brightness image P. The range of pixel values ​​is recorded 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 ; Among them, preprocessing includes three methods: filtering, brightness shift and peak equalization;

[0012] Step 4: Adjust the brightness image by using the normalized histogram method so that the brightness of the adjusted image reaches the expected effect.

[0013] Furthermore, in step 3, the filtering includes: performing a convolution operation on the sequence S with a one-dimensional convolution kernel to generate a sequence ; The i-th item s in the sequence S i , after filtering, we get , where s i+j is the (i+j)th item in the sequence S, a j is the coefficient of the one-dimensional convolution kernel, j is an integer in [-n,n], n is in the range of 5 to 10, and , a j ≥0, a j =a- j ; The new sequence generated After visualization in the form of 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 item s in the sequence S i , after processing, we get , where s j represents the jth item in the sequence S, where j is an integer in [in,i+n], and b ji represents the weight, and the weight b ji satisfy: .

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

[0016] 1) Perform filter preprocessing on the sequence S to obtain the sequence , the series The i-th item of ;

[0017] 2) Detect the peaks, including: first mark the sequence All satisfied The value of i, N is the total number of pixels in the image, and the value range of θ is [2,10]. The set of all i that meet the conditions is recorded as I*. I* is divided into t sets according to the continuous elements, and each set corresponds to an independent peak;

[0018] 3) For the kth set I k , by traversing to find the brightness value that divides the number of peak pixels into two equal parts , which is the peak center position;

[0019] 4) Peaks are homogenized based on the number of pixels and distance of each peak, including: k , calculate peak weights , where i k Indicates the starting brightness value of the k-th peak, n k Indicates the number of brightness values ​​contained in the peak, is a sequence The jth item, accounting for The value range is [1 / 2, 3 / 4]. According to the weight ratio of each peak, the range [0, m] is assigned to each peak so that the peaks are evenly distributed in the range. The peak center position after uniform adjustment for: ,in is the peak weight of the j-th peak; the pixels of the original peak are translated to the new center as a whole Corresponding positions, the pixel values ​​of the points not in the peak are evenly distributed, thus obtaining the series ,After visual presentation in the form of a histogram, the brightness histogram after peak ,uniformization processing is obtained.

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

[0021] 4.1) Map each pixel value x of the brightness image P to the target brightness histogram S G The interval [p x ,q x ], p x is the target brightness histogram S G The maximum pixel value of the total area on the left side of the brightness histogram D is not greater than the total area on the left side of x, q x is the target brightness histogram S G The maximum pixel value of the total area on the left side of (x+1) in the brightness histogram D is satisfied;

[0022] 4.2) For any pixel point O in the brightness image, take a pixel block of size n*n centered at pixel point O and record it as Q. The pixel value I of pixel point O in the guidance image is first obtained according to the following formula: G Preliminary valuation of (O) , where the pixel point A in the pixel block Q is recorded in the target brightness histogram S G The mapping interval in is [p A ,q A ]; W A represents the weight of pixel A, , d(O,A) is 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, and the range of values ​​is: σ1≥2, σ2∈[1,5]; when I G * (O) The interval [p O ,q O ], the pixel value I of the pixel point O in the guide image G (O) Take the corresponding value; otherwise, take the interval endpoint; traverse all points in the brightness image P to obtain the guide image G;

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

[0024] Furthermore, in step 3, the weight b in the brightness offset ji It is obtained by combining Gaussian weighting and normalization, where Gaussian weight , β represents the degree of shift to the middle brightness; the Gaussian weight W ji Normalized, we get .

[0025] Furthermore, in step 4, the brightness histogram D and the target brightness histogram S G The number of pixels corresponding to the pixel value i is recorded as s i 、 , by mapping T, each pixel value x of the original image is mapped to the target brightness histogram S G The interval [p x ,q x ], where the mapping T is determined as follows: ;in, 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) Substitute the midpoint of the interval for weighted averaging and get , where the parameter that affects the size of the mapping interval in the weight function is adjusted from σ2 to σ3, σ3∈[σ2,4σ2], then the adjusted weight ;

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

[0028] Furthermore, the method further includes: after obtaining the brightness image in step 1, first segmenting the brightness image into pixel block groups, then performing the operations of steps 2 to 4 on each pixel block group separately, and then performing weighted averaging based on the calculation results and positional relationships of the pixel values ​​in each pixel block group.

[0029] An electronic device comprises a memory, a processor and a computer program stored in the memory and operable on the processor. When the processor executes the program, the image brightness adjustment method based on the prescribed histogram is implemented.

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

[0031] Using a one-dimensional symmetric convolution kernel to filter the brightness histogram can effectively smooth the gradual brightness changes of the image, reduce the abruptness of the brightness distribution, and improve visual continuity; using an asymmetric filter kernel to implement brightness offset can directionally shift the brightness peak, optimize the brightness uniformity as needed, or highlight specific details in a targeted manner; with the help of peak equalization processing, the brightness intervals with dense pixels in the value range are segmented, the brightness distinction is enhanced, and the image details are easier to observe.

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

[0033] 3. This method is deeply compatible with local histogram adaptive methods. Local histogram methods focus on local image blocks and achieve local adaptation through histogram equalization; this method performs adaptive control based on the brightness range dimension. Combining these two approaches creates a dual-dimensional adaptive adjustment strategy, "range-spatial domain," that better adapts to complex local image features. When processing images rich in detail and edges, it ensures a reasonable global brightness distribution while optimizing local brightness transitions and detail rendering, broadening its application in image enhancement for complex scenes. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 Flow chart of the method of the present invention;

[0035] Figure 2 The image and corresponding histogram statistics in the embodiment;

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

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

[0038] Figure 5 Schematic diagram of peak homogenization;

[0039] Figure 6 Select a schematic diagram for the pixel block group in the local adaptive method. DETAILED DESCRIPTION

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

[0041] Example 1:

[0042] A method for adjusting image brightness based on a prescribed histogram is proposed. The image is first converted into a single-channel brightness image. Then, the brightness histogram is statistically analyzed and adjusted according to specific requirements to obtain a target brightness histogram based on the initial image information. Finally, the image is adjusted using the prescribed histogram method to achieve the desired image brightness effect.

[0043] The specific steps are as follows:

[0044] Step 1: Convert the image into an image with a single channel representing brightness information.

[0045] For common RGB format images, first convert them into YUV format images, and then process the Y channel representing brightness. After completing the image brightness adjustment process according to the method of the present invention, convert them into RGB format.

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

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

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

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

[0050] Since images have discrete characteristics when represented by digital signals, for example, the pixel values ​​of 8-bit quantization are integers from 0 to 255, the brightness histogram statistics can be directly counted according to the discrete values ​​of the pixel values. If the pixel value range is too wide, the statistics can be achieved by dividing the pixels into equal-length intervals. Figure 2 As shown, (a) is the brightness image and (b) is the corresponding brightness histogram statistical result.

[0051] The pixel values ​​are sorted from low to high, and the number of pixel points corresponding to the pixel values ​​constitutes a sequence S. The i-th item s in the sequence S is i This represents the number of pixels with brightness i. After visualizing the sequence S as a histogram, we obtain the brightness histogram D of the brightness image P. Let the range of pixel values ​​be I and the maximum brightness be m, 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 equalization. You can select an appropriate method based on the image processing requirements to preprocess the brightness histogram D obtained in step 2 to obtain the desired target brightness histogram.

[0054] 1. Filtering

[0055] Traditional histogram equalization increases the dynamic range of image information by evenly distributing brightness. The goal is to achieve an equal number of pixel values ​​across all brightness levels. By evenly distributing pixels across all brightness levels, the distinction between different brightness levels becomes more distinct, improving image contrast. However, this method often causes significant distortion due to large variations in pixel values ​​and large discrepancies in the mapped values ​​corresponding to areas of gradual brightness changes. Improved methods generally mitigate this effect through constrained histogram equalization and local adaptive strategies.

[0056] The method presented here, however, utilizes the image's initial brightness distribution by filtering the brightness histogram. This generates a smoother target brightness histogram based on the initial brightness distribution, effectively avoiding the severe distortion associated with traditional histogram equalization while ensuring a uniform brightness distribution. Furthermore, this filtering process enhances the image's peak characteristics, serving as a precursor to subsequent peak equalization.

[0057] Specifically, the brightness histogram is filtered by performing a convolution operation on the sequence S using a one-dimensional convolution kernel to generate a sequence The i-th item s in the sequence S i , after filtering, we get , where s i+j is the (i+j)th item in the sequence S, a j is the coefficient of the one-dimensional convolution kernel, j is an integer in [-n,n], and , a j ≥ 0. Sequence a -n ,a -n+1 ,...,a n is a (2n+1)-term sequence, denoted as H, representing the filter kernel, and a j =a- j , that is, the filter kernel is symmetric. The new sequence generated After visualization in the form of a histogram, a new brightness histogram D1 is obtained.

[0058] The above convolution operation indicates that the calculation sequence The i-th item When s i As the center, take the number of pixels s from (in) to (i+n) in the original sequence S i+j , multiplied by the convolution kernel corresponding coefficient a j If (i+j) exceeds the value range of the original brightness histogram D, that is, there is no pixel with the corresponding brightness value, then s i+j Set to 0. The larger n is, the closer the convolution kernel is to the convolution kernel of the mean filter, and the smoother the filtered histogram is. The smaller n is, the closer the filtered result is to the original histogram, which means that more original details are preserved. n is generally set to 5-10.

[0059] Figure 3 Given Figure 2 The brightness histogram in the figure is filtered, where (a) corresponds to the filtering result when n is 10, and (b) corresponds to the filtering result when n is 5.

[0060] 2. Brightness offset

[0061] Excessively bright and dark areas in an image are difficult to observe, and simply adjusting the image with a mapping function often fails to achieve the desired effect. For such images, adjusting the brightness histogram can reduce the brightness of high-brightness areas and increase the brightness of low-brightness areas. Furthermore, if you wish to adjust the image's brightness distribution according to other predetermined patterns, this can also be achieved through brightness offsetting.

[0062] Specifically, the brightness shift operation is performed on the sequence S to generate the sequence The i-th item s in the sequence S i , after processing, we get , where s j represents the jth item in the sequence S, where j is an integer in [in,i+n], and b ji represents the weight, and , b ji ≥0. That is, for each target brightness i, take the brightness value in the range [in,i+n] in the original histogram D, and use the weight b ji The weighted summation, j, is from (in) to (i+n), and the number of pixels with the new brightness i is obtained. The value of n is generally 5-10.

[0063] in, It ensures that the sum of the number of pixels in the new histogram remains unchanged after the transformation, and It can be different from 1 and can be A measure of how much the histogram changes due to brightness shift. The larger the value, the more concentrated the weights are in certain areas, and the greater the histogram can vary; When close to 1: the weight is close to uniform distribution, the histogram changes little, and the overall brightness does not shift.

[0064] Since the desired brightness is shifted towards the medium brightness area, the weights should be set as follows:

[0065] ,

[0066] .

[0067] Where m is the maximum brightness, and m / 2 represents the middle brightness. For j higher than the middle brightness, the weight and Gradually increase, that is, let the high brightness j "contribute" more to the lower i, that is, reduce the brightness and move towards the middle, so that the bright part becomes darker. For j below the middle brightness, the weight and Gradually decrease, that is, let the low-brightness j "contribute" more to the higher i, that is, the brightness increases, moves towards the middle, and the dark part becomes brighter.

[0068] In order to achieve the above-mentioned shift to the middle brightness, a construction method combining a set of Gaussian weights and normalization is given as an example.

[0069] 1) Gaussian weight generation:

[0070]

[0071] Where W ji represents the Gaussian weight, β represents the degree of shift towards the middle brightness, β ≥ 0. A larger β value indicates a more significant shift. The closer i is to the middle brightness m / 2, the greater the weight; the farther i is from j, the smaller the weight.

[0072] 2) Weight normalization:

[0073]

[0074] The Gaussian weight W ji Normalization, guarantee , that is, the constraint that the total number of pixels remains unchanged is satisfied.

[0075] Figure 4 for Figure 2 The brightness histogram of the image is processed with brightness offset. The blue is the original brightness histogram, and the orange is the processed brightness histogram. The brightness distribution is offset to the middle brightness.

[0076] Overly bright or overly dark areas of 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 of each brightness is redistributed, allowing the pixels to concentrate on the intermediate brightness and restore details.

[0077] 3. Peak homogenization

[0078] Peaks are areas in the brightness histogram where the number of pixels is significantly higher than the surrounding values. By smoothing out the brightness peaks and making them more evenly distributed across the range, we can better distinguish between different brightness levels and highlight image details. Figure 5 This is a schematic diagram of peak equalization, where (a) indicates that the three "peaks" are unevenly distributed. This will make the brightness contrast between the leftmost peak and the middle peak unclear in the image, while the contrast between the middle peak and the right peak is obvious but beyond the level required for the human eye to clearly distinguish. Therefore, the peak equalization process becomes Figure 5 (b) can more reasonably distinguish brightness and highlight details.

[0079] Specifically, peak homogenization can be divided into the following steps:

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

[0081] Filtering can transform the irregular parts of the brightness histogram into more regular peaks, which is convenient for subsequent identification and processing. The filtering operation refers to the above "1. Filtering" section, and the resulting sequence is , The i-th item of .

[0082] 2) Detect the peak.

[0083] Let the total number of pixels in the image be N and the maximum brightness be m, then first mark the sequence All satisfied The i value, that is, the pixel value whose number of marked pixels is θ times higher than the average value, the value range of θ is [2,10]. The set of all i that meet the conditions is recorded as I*, that is, I*={i | >θN / m}. Divide I* into t sets according to the continuous elements, that is, , each set corresponds to an independent peak, I k represents the kth set. , , k≠l, I l In actual operation, we can search from low to high pixel values ​​in I=[0,m]∩ℤ, starting from the first pixel that satisfies the I started to meet the first j is I1, and then starting from (j+1), the same method is used to search for I2, I3, ..., I t , until I is traversed. The resulting set I1~I t That is, the t peaks detected.

[0084] 3) Determine the peak center.

[0085] For set I k , find I by the number of pixels k The median of , where i k Indicates the starting brightness value of the k-th peak, n k Indicates the number of brightness values ​​contained in the peak, then the median satisfy: , is a sequence The jth item of , that is, the sum of the pixels in the first half does not exceed half of the total pixel sum, and the sum of the pixels in the second half exceeds half of the total pixel sum. By traversing, find the brightness value that divides the number of peak pixels into two equal parts, which is the peak center position.

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

[0087] Specifically, for the kth peak, calculate the peak weight , the peak weight represents the size of the interval occupied by the peak in the value range. Among them, the first item: Represents the ratio of the number of pixels in the peak to the total number of pixels, multiplied by Indicates the contribution of the number of pixels to the weight, where the more pixels there are, the larger the interval occupied in the value range. The second item: Represents the ratio of the distance between the peak and the adjacent peak center to the range of the value, multiplied by Retain the distance characteristics of the original histogram. The effect size of the two responses, The value range is [1 / 2, 3 / 4], which means that the pixel distance has a slightly larger impact to avoid excessive changes in the histogram.

[0088] and They 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 uniform adjustment for:

[0089]

[0090] in, is the peak weight of the jth peak. That is, based on the weight ratio of each peak, the range [0, m] is assigned to each peak, so that the peaks are evenly distributed across the range. Peaks with larger weights are assigned a range further back in the center.

[0091] Sure After that, we only need to translate each peak to the corresponding position, that is, for k=1,2,…,t, let ,j=0,1,…,n k , translate the pixels of the k-th peak to the new center as a whole The corresponding position keeps the number of pixels unchanged; the pixel values ​​are evenly distributed for the points not in the peak, and the average pixel value . Thus we get the series After visualization in the form of a histogram, the brightness histogram D2 after peak equalization is obtained. By shifting the peak and evenly distributing non-peak pixels, the peak of the brightness histogram is equalized, highlighting the image details.

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

[0093] Step 4: Adjust the brightness image P by the normalized 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 previous steps, the original brightness histogram D and the adjusted target brightness histogram S are obtained. G , the number of pixels corresponding to the pixel value i is s i 、 .

[0095] 4.1) Constructing a Mapping

[0096] Map each pixel value x of the brightness image P to the target brightness histogram S G The interval [p x ,q x ], avoiding the distortion caused by directly mapping a single pixel value. x is the target brightness histogram S G The maximum pixel value of the total area on the left side of the target brightness histogram S is not greater than the total area on the left side of the brightness histogram D. G The maximum pixel value that satisfies "the cumulative number of pixels on the left ≤ the cumulative number of pixels on the left of x in the brightness histogram D". x is the target brightness histogram S G The maximum pixel value of the total area on the left side of the brightness histogram D is not less than the total area on the left side of (x+1), that is, the target brightness histogram S G The maximum pixel value that satisfies "the cumulative number of pixels on the left ≥ the cumulative number of pixels on the left of (x+1) in the brightness histogram D".

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

[0098] The mapping T is determined as follows:

[0099] .

[0100] in, Represents the mapping value with respect to x. The mapping interval of pixel values ​​is determined by cumulative area matching to ensure that the histogram shape is close to the target distribution.

[0101] 4.2) Generate guidance image

[0102] For a pixel, let it be O. The pixel value in the initial brightness image P is I(O). With the pixel O as the center, take a pixel block of size n*n and let it be Q, where n is usually 5 or 7. Let the pixel value of pixel A in the pixel block Q be I(A), and the mapping T will map it to [p A ,q A ], then the pixel value I of the pixel point O in the guide image G (O) is obtained as follows:

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

[0104]

[0105] Among them, I G * (O) indicates I based on spatial distribution G The initial estimate of (O), which may not be within the range to which the pixel point O can be mapped, is used as an intermediate value; W A represents the weight of pixel A, , d(O,A) is 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. They can be set as needed, and the value range is: σ1≥2, σ2∈[1,5]; W A The first term represents the spatial distance; closer distances lead to greater weights. The second term represents the size of the interval to which the image is mapped; smaller intervals yield more accurate results. Using spatial distance and interval size to construct weights ensures consistent adjustments to adjacent pixels, minimizing distortion.

[0106] When I G * (O) The interval [p O ,q O ], the pixel value I of the pixel point O in the guide image G (O) Take the corresponding value; otherwise take the interval endpoint.

[0107] .

[0108] After performing the above operations on all points in the brightness image P, the guidance image G is obtained, and the estimated values ​​of each pixel and its surrounding pixels in the interval obtained after mapping are preliminarily determined.

[0109] 4.3) Generation of the final image

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

[0111] Specifically, for pixel O, use the pixel value I in the guidance image G (A) Substitute the midpoint of the interval for weighted average and get I out * (O):

[0112] .

[0113] Among them, since the guide image has narrowed the mapping range, the influence of the mapped interval size on the weight is reduced, and the parameter affecting the mapping interval size in the weight function is adjusted from σ2 to σ3, σ3∈[σ2,4σ2], then the adjusted weight .

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

[0115]

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

[0117] This step reduces the distortion in the histogram normalization process while maintaining the overall brightness distribution of the image through refined interval mapping and weighted processing.

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

[0119] In actual projects, based on requirements and resource limitations, you can choose to directly apply steps 1 to 4 to the image, or use a local adaptive optimization method to process each local pixel block separately and then fuse them to achieve better results.

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

[0121] For the luminance image P, divide it into several rectangular pixel blocks with m rows and n columns. Each time, a 2x2 pixel block group within the rectangular pixel block is taken as the complete image, and the operation is repeated with a step of one pixel block. Each pixel block in a different 2x2 pixel block group serves as the bottom right, bottom left, top right, and top left pixel block for calculation, and the corresponding four pixel values ​​are recorded as i1(x,y), i2(x,y), i3(x,y), and i4(x,y).

[0122] like Figure 6 As shown, the gray pixel blocks are calculated for each of the four pixel block groups shown. For a point with coordinates (x, y) in an m*n pixel block, 1≤x≤n, 1≤y≤m, i1(x, y), i2(x, y), i3(x, y), and i4(x, y) are the pixel values ​​calculated for the 2*2 pixel block groups 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 2*2 pixel block group and the four vertices. The weighted average formula is:

[0124] This weighted average combines the results of local block processing to achieve a smooth brightness transition, resulting in an image optimized using a locally adaptive method. By implementing local adaptive optimization through block division and local weighting, we can avoid compensating for local details that might be overlooked by global processing, such as brightness transitions at edges and textures. This allows for better image processing results in each local area, while also achieving more natural local brightness gradients and better detail preservation.

[0125] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A method for adjusting image brightness based on a standardized histogram, characterized in that: It includes: step 1: converting the image into a brightness image with a single channel to represent brightness information; step 2: performing brightness histogram statistics on the brightness image, sorting the pixel values ​​from low to high, and the number of pixel points corresponding to the pixel values ​​constitutes a sequence S, and the i-th item s in the sequence S is i Represents the number of pixels with brightness i. The sequence S is visualized as a histogram, which is 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 ; Among them, the preprocessing includes three methods: filtering, brightness offset and peak equalization; Step 4: Adjust the brightness image through the prescribed histogram method so that the brightness of the adjusted image reaches the expected effect.

2. The image brightness adjustment method based on the standardized histogram according to claim 1, characterized in that: In step 3, the filtering includes: performing a convolution operation on the sequence S with a one-dimensional convolution kernel to generate a sequence ; The i-th item s in the sequence S i , after filtering, we get , where s i+j is the (i+j)th item in the sequence S, a j is the coefficient of the one-dimensional convolution kernel, j is an integer in [-n,n], n is in the range of 5 to 10, and , a j ≥0, a j =a- j ; The new sequence generated After visualization in the form of a histogram, a new brightness histogram is obtained.

3. The image brightness adjustment method based on the standardized 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 the sequence ; The i-th item s in the sequence S i , after processing, we get , where s j represents the jth item in the sequence S, where j is an integer in [in,i+n], and b ji represents the weight, and the weight b ji satisfy: .

4. The image brightness adjustment method based on the standardized histogram according to claim 2, characterized in that: In step 3, the peak equalization includes: 1) performing filtering preprocessing on the sequence S to obtain the sequence , the series The i-th item of ; 2) Detect the peak, including: first mark the sequence All satisfied The value of i, N is the total number of pixels in the image, and the value range of θ is [2,10]. The set of all i that meet the conditions is recorded as I*, and I* is divided into t sets according to the continuous elements, each set corresponds to an independent peak; 3) For the kth set I k , by traversing to find the brightness value that divides the number of peak pixels into two equal parts , which is the peak center position; 4) Based on the number of pixels and distance of each peak, the peaks are homogenized, including: for set I k , calculate peak weights , where i k Indicates the starting brightness value of the k-th peak, n k Indicates the number of brightness values ​​contained in the peak, is a sequence The jth item, accounting for The value range is [1 / 2, 3 / 4]. According to the weight ratio of each peak, the range [0, m] is assigned to each peak so that the peaks are evenly distributed in the range. The peak center position after uniform adjustment for: ,in is the peak weight of the j-th peak; the pixels of the original peak are translated to the new center as a whole Corresponding positions, the pixel values ​​of the points not in the peak are evenly distributed, thus obtaining the series ,After visual presentation in the form of a histogram, the brightness histogram after peak ,uniformization processing is obtained.

5. The image brightness adjustment method based on the standardized histogram according to claim 1, characterized in that: The step 4 includes the following specific steps: 4.1) Mapping each pixel value x of the brightness image P to the target brightness histogram S G The interval [p x ,q x ], p x is the target brightness histogram S G The maximum pixel value of the total area on the left side of the brightness histogram D is not greater than the total area on the left side of x, q x is the target brightness histogram S G The maximum pixel value of the total area on the left side of (x+1) in the brightness histogram D is satisfied; 4.2) For any pixel point O in the brightness image, take a pixel block of size n*n centered at pixel point O and record it as Q. The pixel value I of pixel point O in the guidance image is first obtained according to the following formula: G Preliminary valuation of (O) , where the pixel point A in the pixel block Q is recorded in the target brightness histogram S G The mapping interval in is [p A ,q A ]; W A represents the weight of pixel A, , d(O,A) is 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, and the range of values ​​is: σ1≥2, σ2∈[1,5]; when I G * (O) The interval [p O ,q O ], the pixel value I of the pixel point O in the guide image G (O) Take the corresponding value; otherwise, take the interval endpoint; traverse all points in the brightness image P to obtain the guidance image G; 4.3) Further optimize based on the preliminary estimate of the guidance image G, by adjusting parameters to reduce the influence of the interval range on the weight, gradually improve the accuracy of the histogram regulation, and obtain the final image after regulation histogram processing.

6. The image brightness adjustment method based on the standardized histogram according to claim 3, characterized in that: In step 3, the weight b in the brightness offset ji It is obtained by combining Gaussian weighting and normalization, where Gaussian weight , β represents the degree of shift to the middle brightness; the Gaussian weight W ji Normalized, we get .

7. The image brightness adjustment method based on the standardized histogram according to claim 5, characterized in that: In step 4, the brightness histogram D and the target brightness histogram S G The number of pixels corresponding to the pixel value i is recorded as s i 、 , by mapping T, each pixel value x of the original image is mapped to the target brightness histogram S G The interval [p x ,q x ], where the mapping T is determined as follows: ;in, Represents the mapping value with respect to x.

8. The image brightness adjustment method based on the standardized histogram according to claim 5, 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) Substitute the midpoint of the interval for weighted averaging and get , where the parameter that affects the size of the mapping interval in the weight function is adjusted from σ2 to σ3, σ3∈[σ2,4σ2], then the adjusted weight ; when I out * (O) In the interval [p O ,q O ], the pixel value I of pixel O in the final image out (O) Take the corresponding value; otherwise take the interval endpoint; after traversing all points in the guide image G, the final image after brightness adjustment using the standardized histogram method is obtained.

9. The image brightness adjustment method based on a standardized histogram according to any one of claims 1 to 8, 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 performed based on the calculated pixel values ​​in each pixel block group and their positional relationships.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the image brightness adjustment method based on the prescribed histogram according to any one of claims 1 to 9 is implemented.

Citation Information

Patent Citations

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

    CN115082291A

  • Automatic driving high-dynamic scene image optimization method and system, terminal and medium

    CN116152094A

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

    CN120219268A

  • Image processing method and apparatus, computer device, and readable storage medium

    WO2025161649A1