Histogram processing, adjustment and image processing method, storage medium and electronic device

By adjusting the number of bin pixels and calculating the elevation coefficient in the high dynamic image histogram, the problem of insufficient contrast stretching in the prior art is solved, and the better contrast stretching effect and calculation resources of high dynamic images are achieved.

CN116029949BActive Publication Date: 2024-12-06BRIGATES MICROELECTRONICS (KUNSHAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310107330.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-13
Publication Date
2024-12-06
Estimated Expiration
2043-02-13

AI Technical Summary

Technical Problem

The prior art has poor effect on histogram adjustment of high dynamic images, resulting in insufficient contrast stretching, especially inadequate stretching on the details of the bright area.

Method used

By processing K bins in the histogram in turn, adjusting the number of pixels according to the relationship between the number of pixels of bin and its own limit value, and calculating the elevation coefficient according to the ratio of the front and rear bins, increasing or decreasing the number of pixels to update the deletion and remaining totals to ensure reasonable allocation of pixel counts and contrast stretching.

Benefits of technology

It realizes more complete contrast stretching of high dynamic images, uses grayscale, reduces computing resource requirements, and is easy to implement in hardware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116029949B_ABST
    Figure CN116029949B_ABST
Patent Text Reader

Abstract

A histogram processing, adjustment and image processing method, storage medium and electronic device. The histogram processing method includes: sequentially processing K bins in a histogram, wherein 0≤j≤K‑1, and processing the jth bin includes: when the number of pixels in the jth bin is greater than or equal to its own limiting value, adjusting the number of pixels in the jth bin to be equal to its own limiting value, and executing a first updating step; when the number of pixels in the jth bin is less than its own limiting value, increasing the number of pixels in the jth bin, and executing a second updating step, wherein the increased number of pixels is at least related to a lift coefficient, and the lift coefficient is: the ratio of the total amount of deletions updated after the j‑1th bin is processed to the total amount of remaining pixels.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to a histogram adjustment and image processing method, a readable storage medium and an electronic device. Background Art

[0002] In recent years, more and more cameras, camcorders, and mobile phone cameras can capture high dynamic range images. High dynamic range images can simultaneously record the contents of bright and dark areas in a scene. For example, when shooting a person in front of a window indoors on a sunny day, a high dynamic range image can simultaneously record the dim portrait in front of the window and the bright scenery outside the window. However, most display devices are still low dynamic range (LDR) devices with a dynamic range of 255, and cannot directly display high dynamic range (HDR) images. It is necessary to first perform dynamic range compression on high dynamic range images through image processing, usually using tone mapping to convert them into low dynamic range images.

[0003] Tone mapping based on histogram adjustment can improve the contrast of the image, make the image more in line with the observation habits of the human eye, and improve the image quality. However, it is technically difficult to implement histogram adjustment for high-dynamic images because the number of vertical bars (bins) required for statistical histograms is much larger than that for low-dynamic images. For example, for a 20-bit high-dynamic image, if 1 bin is assigned to each possible DN value (pixel value), then 2 bins will be required. 20 ≈ 1 million bins are used for histogram statistics. Such a large number of bins will result in slow calculation speed and even be difficult to implement in hardware such as FPGA and DSP.

[0004] There are many methods for adjusting histograms in the prior art, for example, Figure 1 As shown, a limit height curve limit_curve_1 is set for the original histogram hist1, and the bins in the original histogram hist1 that are larger than the limit height curve limit_curve_1 are cut off, and then the total number of cut pixels is added to each bin on average to obtain the adjusted histogram hist1-1. The limit height curve limit_curve_1 can be a horizontal line or a curve, and those skilled in the art can set it according to experiments or experience, in order to prevent the contrast of the image from being excessively enhanced. For more technical details, please refer to the Chinese patent application with publication number CN113691739A.

[0005] The above-mentioned prior art can achieve a relatively good histogram adjustment effect for low dynamic range images (LDR), but the adjustment effect for high dynamic range images is poor. Figure 2 In the 20-bit high dynamic range image shown, the bright part of the image is a transmissive resolution target, and the dark part is a background such as a reflective resolution target.

[0006] The Chinese patent application with publication number CN113691739A proposes a method of using segmented histogram adjustment to make detailed histogram bin divisions for dark areas and coarse histogram bin divisions for bright areas. Thus, while compressing the dynamic range of high-dynamic images, the compressed images have a higher contrast, and this process can be completed with a smaller number of bins, making it easy to implement in hardware. However, the technology in this patent application has a more detailed contrast stretching effect on dark areas in high-dynamic images, but the contrast stretching effect on the details of bright areas is not sufficient.

[0007] Figure 3 for Figure 2 The histogram of the image shown in FIG. 1 shows that most of the pixels are concentrated in the dark area, and the number of pixels in the bright area is relatively small. The histogram is adjusted using the existing technology: the bins truncated by the limit curve are evenly distributed to each bin, such as Figure 4 As shown in the figure. Since there are many bins to be assigned, the number of pixels assigned to the bin on the right side representing the bright area of ​​the image is small. After the histogram is adjusted, the bins in the right pixel set are still low, which will cause the calculated mapping curve to be unable to fully stretch the details of the bright area. In addition, many pixels are assigned to empty bins during the adjustment process, resulting in a certain degree of grayscale waste. Summary of the invention

[0008] The problem solved by the present invention is that the adjustment of the histogram in the prior art may result in insufficient stretching of the contrast.

[0009] To solve the above problem, the present invention provides a histogram processing method, comprising: sequentially processing K bins in the histogram, wherein 0≤j≤K-1, the processing of the jth bin comprises: when the number of pixels in the jth bin is greater than or equal to its own limiting value, adjusting the number of pixels in the jth bin to be equal to its own limiting value, and performing a first updating step; the first updating step comprises: adding the difference between the number of pixels in the jth bin and the self-limiting value to the total amount of deletion to update the total amount of deletion; subtracting the number of pixels in the jth bin from the remaining total amount to update the total amount of deletion; A new remaining total, the initial value of the remaining total is the total number of pixels of the K bins; when the number of pixels in the j-th bin is less than its own limited value, the number of pixels in the j-th bin is increased, and a second updating step is performed, wherein the increased number of pixels is at least related to a lifting coefficient, and the lifting coefficient is the ratio of the updated deleted total and the remaining total after the j-1-th bin is processed; the second updating step includes: subtracting the number of pixels increased in the j-th bin from the deleted total to update the deleted total; and subtracting the number of pixels in the j-th bin from the remaining total to update the remaining total.

[0010] Optionally, the step of increasing the number of pixels in the j-th bin includes: determining a raising coefficient based on the ratio of the total deleted amount and the remaining amount updated after processing the j-1-th bin; determining the number of pixels to be increased based on the raising coefficient and the number of pixels in the j-th bin; calculating the sum of the number of pixels in the j-th bin and the number of pixels to be increased to obtain the sum of the number of pixels; when the sum of the number of pixels is less than the self-limiting value of the j-th bin, adjusting the number of pixels in the j-th bin to be equal to the sum of the number of pixels; when the sum of the number of pixels is greater than or equal to the self-limiting value of the j-th bin, adjusting the number of pixels in the j-th bin to be equal to its self-limiting value.

[0011] Optionally, the step of increasing the number of pixels in the j-th bin includes: determining a raising coefficient based on the ratio of the total deleted amount and the remaining amount updated after processing the j-1-th bin; when the raising coefficient is less than a coefficient threshold, determining the number of pixels to be increased based on the raising coefficient and the number of pixels in the j-th bin, and when the raising coefficient is greater than or equal to the coefficient threshold, determining the number of pixels to be increased based on the coefficient threshold and the number of pixels in the j-th bin; calculating the sum of the number of pixels in the j-th bin and the number of pixels to be increased to obtain the sum of the number of pixels; when the sum of the number of pixels is less than the self-limiting value of the j-th bin, adjusting the number of pixels in the j-th bin to be equal to the sum of the number of pixels; when the sum of the number of pixels is greater than or equal to the self-limiting value of the j-th bin, adjusting the number of pixels in the j-th bin to be equal to its self-limiting value.

[0012] The present invention also provides an image processing method, comprising: obtaining an original histogram corresponding to an original image; performing the above-mentioned histogram processing method on the original histogram to obtain a processed histogram; generating a tone mapping curve according to the processed histogram; and performing tone mapping on the original image according to the tone mapping curve to obtain a target image.

[0013] The present invention also provides a histogram adjustment method, comprising: executing the above-mentioned histogram processing method in the order of brightness values ​​from small to large to obtain the first number of pixels corresponding to each bin; executing the above-mentioned histogram processing method in the order of brightness values ​​from large to small to obtain the second number of pixels corresponding to each bin; and taking the average value of the first number of pixels and the second number of pixels corresponding to the same bin as the final adjusted number of pixels of the bin.

[0014] The present invention also provides an image processing method, comprising: obtaining an original histogram corresponding to an original image; performing the above-mentioned histogram adjustment method on the original histogram to obtain an adjusted histogram; generating a tone mapping curve according to the adjusted histogram; and performing tone mapping on the original image according to the tone mapping curve to obtain a target image.

[0015] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the steps of the above method.

[0016] The present invention also provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and wherein the processor executes the steps of the above method when running the computer program.

[0017] Compared with the prior art, the technical solution of the present invention has the following advantages:

[0018] The present invention proposes a method for adjusting the histogram in proportion according to the size of the bin value, which can make full use of the grayscale and enable the bin with a relatively concentrated number of pixels to obtain better contrast stretching; and the solution requires less computing resources and is easy to implement in hardware. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a schematic diagram of an existing histogram adjustment;

[0020] Figure 2 It is a high dynamic image schematic diagram;

[0021] Figure 3 yes Figure 2 Histogram of the image shown;

[0022] Figure 4Based on existing technology Figure 3 The adjusted histogram;

[0023] Figure 5 It is a schematic flow chart of a method for processing a histogram provided by an embodiment of the present invention;

[0024] Figure 6 It is another high dynamic image schematic diagram;

[0025] Figure 7 yes Figure 6 Histogram of the image shown;

[0026] Figure 8 Based on existing technology Figure 7 The adjusted histogram;

[0027] Fig. 9 is based on Figure 8 The cumulative histogram obtained;

[0028] Fig.10 is based on Fig. 9 The tone mapping curve obtained;

[0029] Fig.11 is a histogram after positive adjustment according to an embodiment of the present invention;

[0030] Fig.12 is a histogram after reverse adjustment according to an embodiment of the present invention;

[0031] Fig.13 is a histogram after the average value is adjusted according to an embodiment of the present invention;

[0032] Fig.14 is based on Fig.13 The cumulative histogram obtained;

[0033] Fig.15 is based on Fig.14 The tone mapping curve obtained;

[0034] Fig.16 It is an LDR image processed by the existing technology;

[0035] Fig.17 This is an LDR image processed by the embodiment of the present invention. DETAILED DESCRIPTION

[0036] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0037] The embodiment of the present invention provides a method for processing a histogram, comprising: sequentially processing K bins in a histogram, wherein 0≤j≤K-1. The order of the "sequential" processing can be performed according to the brightness value of each bin, and can be performed in an order from small to large brightness values ​​(forward adjustment), or in an order from large to small brightness values ​​(reverse adjustment).

[0038] like Figure 5 As shown, the processing of the jth bin includes:

[0039] Step S11, determining whether the number of pixels in the jth bin is less than its own limit value.

[0040] When the number of pixels in the j-th bin is not less than, that is, greater than or equal to its own limiting value, execute step S12: adjust the number of pixels in the j-th bin to be equal to its own limiting value, and execute the first updating step; the first updating step includes: adding the difference between the number of pixels in the j-th bin and the self-limiting value to the total deletion amount to update the total deletion amount; subtracting the number of pixels in the j-th bin from the remaining total amount to update the remaining total amount, and the initial value of the remaining total amount is the total number of pixels in the K bins.

[0041] When the number of pixels in the j-th bin is less than its own limiting value, execute step S13: increase the number of pixels in the j-th bin, and execute a second updating step, wherein the increased number of pixels is at least related to a lifting coefficient, and the lifting coefficient is: the ratio of the total deleted amount updated after the j-1-th bin is processed to the total remaining amount; the second updating step includes: subtracting the number of pixels increased in the j-th bin from the total deleted amount to update the total deleted amount; and subtracting the number of pixels in the j-th bin from the total remaining amount to update the total remaining amount.

[0042] This scheme proposes a method for adjusting the histogram in proportion to the size of the bin value, which can make full use of the grayscale and enable the bin with a relatively concentrated number of pixels to obtain better contrast stretching; and this scheme requires less computing resources and is easy to implement in hardware.

[0043] In step S13, the step of increasing the number of pixels of the jth bin may include:

[0044] The lifting coefficient is determined according to the ratio of the total deleted amount and the remaining amount updated after the j-1th bin is processed;

[0045] Determining the number of pixels to be added based on the elevation coefficient and the number of pixels in the j-th bin;

[0046] Calculate the sum of the number of pixels in the jth bin and the number of pixels to be added to obtain the sum of the number of pixels;

[0047] When the sum of the pixel numbers is less than the self-limiting value of the j-th bin, the pixel number of the j-th bin is adjusted to be equal to the sum of the pixel numbers;

[0048] When the sum of the pixel numbers is greater than or equal to the self-limiting value of the j-th bin, the pixel number of the j-th bin is adjusted to be equal to its self-limiting value.

[0049] Assume that in the histogram hist of the original image, in the order of brightness value from small to large, the number of pixels (height) of the jth bin is hist(j), j=0,1,...,K-1, K is the total number of bins divided by the histogram statistics of the original image, the limit value of the jth bin itself is limit_curve(j), and the elevation coefficient is coef. The total number of pixels participating in the histogram statistics is N, then the total number of pixels in K bins is N:

[0050]

[0051] The first register is set to store the total deletion amount trunc_sum, that is, the total number of pixels exceeding its own limit value limit_curve.

[0052] When hist(j)≥limit_curve(j), add hist(j)-limit_curve(j) to the total amount of deletions trunc_sum stored in the first register to update the total amount of deletions trunc_sum:

[0053] trunc_sum=trunc_sum+hist(j)-limit_curve(j)

[0054] When hist(j)<limit_curve(j), the number of pixels Δbin is increased for the jth bin, and the total amount of deletion trunc_sum stored in the first register is reduced by Δbin to update the total amount of deletion trunc_sum:

[0055] trunc_sum = trunc_sum - Δbin

[0056] The second register is set to store the remaining total res_sum, that is, the total number of pixels of the remaining bins that have not been processed (including the current bin).

[0057] For positive adjustment, when the currently processed bin is the jth bin:

[0058]

[0059] For reverse adjustment, when the currently processed bin is the jth bin:

[0060]

[0061] After processing each bin, the total deletion amount trunc_sum stored in the first register and the remaining total amount res_sum stored in the second register are both updated once.

[0062] During the forward adjustment process, the initial value of the total deletion amount trunc_sum stored in the first register is 0, and the initial value of the remaining total amount res_sum stored in the second register is N. Let j traverse from 0 to K - 1 in ascending order.

[0063] If the number of pixels hist(j) in the j-th bin is greater than or equal to the self-defined limit value limit_curve(j) of the j-th bin, that is, hist(j) ≥ limit_curve(j), then perform the following steps:

[0064] Adjust the number of pixels in the j-th bin to be equal to the self-defined limit value limit_curve(j) of the j-th bin: hist_forward(j) = limit_curve(j);

[0065] hist_forward(j) represents the number of pixels in the j-th bin after forward adjustment.

[0066] Increase the difference between the number of pixels hist(j) in the j-th bin and the self-defined limit value limit_curve(j) of the j-th bin to the total deletion amount trunc_sum to update the total deletion amount trunc_sum: trunc_sum = trunc_sum + hist(j) - limit_curve(j);

[0067] Subtract the number of pixels hist(j) in the j-th bin from the remaining total amount res_sum to update the remaining total amount res_sum: res_sum = res_sum - hist(j).

[0068] If the number of pixels hist(j) in the j-th bin is less than the self-defined limit value limit_curve(j) of the j-th bin, that is, hist(j) < limit_curve(j), then perform the following steps:

[0069] Increase the number of pixels hist(j) in the j-th bin. The increased number of pixels Δbin is at least related to the elevation coefficient coef. The elevation coefficient coef is the ratio of the updated total deletion amount trunc_sum and the remaining total amount res_sum after processing the (j - 1)-th bin:

[0070]

[0071] The number of pixels to be added Δbin0 can be determined based on the elevation coefficient coef and the number of pixels in the jth bin hist(j): Δbin0=coef*hist(j);

[0072] Then, the sum of the number of pixels of the jth bin hist(j) and the number of pixels to be added Δbin0 is calculated to obtain the sum of the number of pixels;

[0073] When the sum of the number of pixels is less than the self-limiting value limit_curve(j) of the j-th bin, the number of pixels of the j-th bin is adjusted to be equal to the sum of the number of pixels; when the sum of the number of pixels is greater than or equal to the self-limiting value limit_curve(j) of the j-th bin, the number of pixels of the j-th bin is adjusted to be equal to the self-limiting value limit_curve(j) of the j-th bin:

[0074]

[0075] hist_forward(j)=hist(j)+Δbin

[0076] After increasing the number of pixels of the j-th bin hist(j), the number of pixels increased in the j-th bin Δbin is subtracted from the total amount of deletion trunc_sum to update the total amount of deletion trunc_sum: trunc_sum=trunc_sum-Δbin;

[0077] The number of pixels in the jth bin hist(j) is subtracted from the remaining total res_sum to update the remaining total res_sum: res_sum=res_sum-hist(j).

[0078] During the reverse adjustment process, the total deleted amount trunc_sum stored in the first register is initially 0, the total remaining amount res_sum stored in the second register is initially N, and j is traversed from K-1 to 0 in descending order.

[0079] If the number of pixels in the j-th bin hist(j) is greater than or equal to the j-th bin's own limit value limit_curve(j), that is, hist(j)≥limit_curve(j), then perform the following steps:

[0080] Adjust the number of pixels in the jth bin to be equal to the jth bin's own limit value limit_curve(j): hist_backward(j) = limit_curve(j);

[0081] hist_backward(j) represents the number of pixels in the j-th bin after backward adjustment.

[0082] Increase the difference between the number of pixels hist(j) in the j-th bin and the self-defined limit value limit_curve(j) of the j-th bin to the total deletion amount trunc_sum to update the total deletion amount trunc_sum: trunc_sum = trunc_sum + hist(j) - limit_curve(j);

[0083] Subtract the number of pixels hist(j) in the j-th bin from the remaining total amount res_sum to update the remaining total amount res_sum: res_sum = res_sum - hist(j).

[0084] If the number of pixels hist(j) in the j-th bin is less than the self-defined limit value limit_curve(j) of the j-th bin, that is, hist(j) < limit_curve(j), then perform the following steps:

[0085] Increase the number of pixels hist(j) in the j-th bin. The increased number of pixels Δbin is at least related to the elevation coefficient coef. The elevation coefficient coef is the ratio of the updated total deletion amount trunc_sum and the remaining total amount res_sum after processing the (j + 1)-th bin:

[0086]

[0087] Among them, the number of pixels to be increased Δbin0 can be determined first based on the elevation coefficient coef and the number of pixels hist(j) in the j-th bin: Δbin0 = coef * hist(j);

[0088] Then, calculate the sum of the number of pixels hist(j) in the j-th bin and the number of pixels to be increased Δbin0 to obtain the sum of the number of pixels;

[0089] When the sum of the number of pixels is less than the self-defined limit value limit_curve(j) of the j-th bin, adjust the number of pixels in the j-th bin to be equal to the sum of the number of pixels; when the sum of the number of pixels is greater than or equal to the self-defined limit value limit_curve(j) of the j-th bin, adjust the number of pixels in the j-th bin to be equal to the self-defined limit value limit_curve(j) of the j-th bin:

[0090]

[0091] hist_backward(j) = hist(j) + Δbin

[0092] After increasing the number of pixels of the j-th bin hist(j), the number of pixels increased in the j-th bin Δbin is subtracted from the total amount of deletion trunc_sum to update the total amount of deletion trunc_sum: trunc_sum=trunc_sum-Δbin;

[0093] The number of pixels in the jth bin hist(j) is subtracted from the remaining total res_sum to update the remaining total res_sum: res_sum=res_sum-hist(j).

[0094] In the above adjustment process, the elevation coefficient coef can represent the ratio of the total number of deleted pixels to the total number of remaining pixels. From the calculation formula of the number of pixels to be added Δbin0, it can be seen that the elevation value of the histogram bin after adjustment is proportional to the original height of the bin, which can ensure that the bin with a relatively concentrated number of pixels can be greatly elevated, thereby ensuring that the contrast of this part of the pixels is fully stretched.

[0095] In order to prevent the contrast from being over-stretched, a coefficient threshold limit_coef can be set for the elevation coefficient coef. When the elevation coefficient coef is less than the coefficient threshold limit_coef, the number of pixels to be added Δbin0 is determined based on the elevation coefficient coef and the number of pixels in the jth bin hist(j): Δbin0 = coef*hist(j). When the elevation coefficient coef is greater than or equal to the coefficient threshold limit_coef, the number of pixels to be added Δbin0 is determined based on the coefficient threshold limit_coef and the number of pixels in the jth bin hist(j): Δbin0 = limit_coef*hist(j).

[0096] To further optimize the number of pixels in the adjusted bin, the average of the number of pixels in the forward adjusted bin hist_forward(j) and the number of pixels in the backward adjusted bin hist_backward(j) can be used as the final number of pixels in the bin after adjustment.

[0097] After performing the above-mentioned histogram processing on the original histogram corresponding to the original image, a processed histogram can be obtained; a tone mapping curve is generated according to the processed histogram; and tone mapping is performed on the original image according to the tone mapping curve to obtain a target image.

[0098] Specifically, the cumulative histogram and the tone mapping curve are calculated first, and then the original image is tone mapped according to the tone mapping curve.

[0099] The calculation formula of the cumulative histogram cdf(j) is:

[0100]

[0101] The cumulative histogram is normalized. Normalization means that each value of the cumulative histogram curve is divided by its maximum value at the same time. The maximum value of the normalized cumulative histogram curve is equal to 1.

[0102] The formula for generating the tone mapping curve map_curve from the normalized cumulative histogram is:

[0103] map_curve(j)=ymin+(ymax-ymin)*cdf(j),j=0,1,...,K

[0104] Among them, ymin and ymax are the minimum and maximum values ​​of the pixel value range to be mapped. Usually, it is hoped that the range it maps to is the largest, that is, it maps to all available grayscales, so ymin = 0, ymax = Lout, and the formula of the tone mapping curve map_curve is:

[0105] map_curve(j)=Lout*cdf(j),j=0,1,...,K

[0106] Where Lout is the maximum available grayscale value of the mapped target image.

[0107] The tone mapping curve map_curve calculated above is a LUT (Look Up Table) composed of K+1 values, and a linear interpolation method can be used to map the pixel values ​​of the original image to the pixel values ​​of the target image.

[0108] The above scheme is further explained below by taking examples.

[0109] like Figure 6 As shown in , the original image is a 20-bit high-dynamic image, containing bright windows and dim indoor scenes, and the goal is to map it to an 8-bit low-dynamic LDR image. Figure 7 As shown in FIG. 1 , the 20-bit data is evenly divided into 1024 bins, and histogram statistics are performed on the input original image to obtain the histogram hist2 corresponding to the original image.

[0110] like Figure 8 As shown, if the existing histogram processing method is adopted, the number of pixels greater than the limit value (shown by the dotted line) is deleted, and then the total number of deleted pixels is evenly distributed to each bin of the histogram, an adjusted histogram hist2_0 can be formed.

[0111] like Fig. 9As shown in , according to the adjusted histogram hist2_0, the normalized cumulative histogram cdf2_0 can be obtained. Fig.10 As shown, the tone mapping curve map_curve2_0 is obtained by the normalized cumulative histogram.

[0112] from Fig.10 It can be seen that the existing histogram processing method distributes the number of deleted pixels evenly, and the number of bins to be allocated is large, and the height of each bin is slightly increased, resulting in the number of pixels in the bright area of ​​the adjusted histogram still being low in each bin. The tone mapping curve calculated by it cannot fully stretch the details of the bright area of ​​the high dynamic image (as shown in the circular dotted box), and most of the deleted pixels are allocated to empty bins during the adjustment process, resulting in a certain degree of grayscale waste.

[0113] By using the processing method described in this embodiment, the histogram of the original image is positively adjusted to obtain Fig.11 The adjusted histogram hist2_1 is shown in the figure. For the case where most pixels in the image are located in the darker dark area and a small number of pixels are located in the brighter bright area, such as Figure 6 For the image shown, only the forward adjusted histogram is used to generate the cumulative histogram and the tone mapping curve, which can achieve a better image effect.

[0114] However, if most of the pixels in the image are located in a relatively bright bright area and a small part of the pixels are located in a relatively dark dark area, using only the forward adjusted histogram to generate the cumulative histogram and the tone mapping curve will cause the problem that the contrast of the pixels in the dark area cannot be fully stretched. Therefore, this embodiment also introduces a reverse adjustment step. During the reverse adjustment process, the part of the bin with a higher brightness in the bright area is deleted and assigned to the bin in the dark area, so that the contrast of the dark area of ​​the final generated image can also be fully stretched. By reversely adjusting the histogram of the original image, it can be obtained Fig.12 The adjusted histogram hist2_2 is shown.

[0115] Regardless of whether the majority of pixels in the input image are located in a relatively dark area or in a relatively bright area, this embodiment calculates the average value of the number of pixels in the bin after positive adjustment and negative adjustment, and averages the positive adjustment result and the negative adjustment result to obtain Fig.13 The adjusted histogram hist2_3 is shown. In this way, the contrast of dark and bright areas can be fully stretched at the same time, so that the solution can ensure that the final image has a good display effect in various scenes.

[0116] like Fig.14As shown in , according to the adjusted histogram hist2_3, the normalized cumulative histogram cdf2_3 can be obtained. Fig.15 As shown, the tone mapping curve map_curve2_3 is obtained by the normalized cumulative histogram.

[0117] contrast Fig.10 and Fig.15 According to the tone mapping curve map_curve2_3 obtained in this embodiment and the tone mapping curve map_curve2_0 obtained according to the prior art, this embodiment can more fully stretch the details of the bright area of ​​the high dynamic image (as shown in the circular dotted box).

[0118] The tone mapping curve obtained above is a LUT composed of 1024 values, and the original image is a 20-bit high-dynamic image with 1048576 possible pixel values. In order to convert the input high-dynamic image into a low-dynamic LDR image that can be displayed on the monitor, tone mapping is required, that is, according to the tone mapping curve, the pixel values ​​of the high-dynamic image are mapped to the pixel values ​​of the low-dynamic image. When mapping the above pixel values, the existing linear interpolation can be used to obtain the mapping pixel value corresponding to each input pixel value, which will not be repeated here.

[0119] Apply the tone mapping curve map_curve2_0 to Figure 6 20-bit high dynamic input image, we can get Fig.16 8-bit low-motion image suitable for display. Apply the tone mapping curve map_curve2_3 to Figure 6 20-bit high dynamic input image, we can get Fig.17 8-bit low-motion images suitable for display on monitors.

[0120] Through Fig.16 and Fig.17 As can be seen from the comparison, since the number of pixels occupied by a bright window is significantly smaller than that of a dim indoor scene, the existing histogram equalization technology does not stretch the contrast of bright scenes outside the window enough, and significantly amplifies the noise of dim indoor scenes; while this embodiment can achieve moderate contrast stretching for both bright and dim areas of the image, with a comfortable visual effect and no significant noise amplification. While ensuring the contrast effect of the dark area of ​​the image, this embodiment has a better contrast stretching effect for the bright area outside the window than the traditional technology.

[0121] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.

Claims

1. A histogram processing method, characterized in that: include: Process the K bins in the histogram in sequence, where 0≤j≤K-1, and the processing of the jth bin includes: When the number of pixels in the j-th bin is greater than or equal to its own limiting value, the number of pixels in the j-th bin is adjusted to be equal to its own limiting value, and the first updating step is performed; The first updating step includes: adding the difference between the number of pixels in the jth bin and the self-limited value to the total amount of deletion to update the total amount of deletion; subtracting the number of pixels in the jth bin from the remaining total to update the remaining total, and the initial value of the remaining total is the total number of pixels in the K bins; When the number of pixels in the j-th bin is less than its own limit value, the number of pixels in the j-th bin is increased, and a second updating step is performed, wherein the increased number of pixels is at least related to the raising coefficient, and the raising coefficient is: the ratio of the total amount of deletion updated after the j-1-th bin is processed to the total amount of remaining; The second updating step includes: subtracting the number of pixels added in the j-th bin from the total amount of deletion to update the total amount of deletion; and subtracting the number of pixels in the j-th bin from the total amount of remainder to update the total amount of remainder.

2. The histogram processing method according to claim 1, characterized in that: The steps to increase the number of pixels in the jth bin include: The lifting coefficient is determined according to the ratio of the total deleted amount to the total remaining amount updated after the j-1th bin is processed; Determining the number of pixels to be added based on the elevation coefficient and the number of pixels in the j-th bin; Calculate the sum of the number of pixels in the jth bin and the number of pixels to be added to obtain the sum of the number of pixels; When the sum of the pixel numbers is less than the self-limiting value of the j-th bin, the pixel number of the j-th bin is adjusted to be equal to the sum of the pixel numbers; When the sum of the number of pixels is greater than or equal to the self-limiting value of the j-th bin, the number of pixels of the j-th bin is adjusted to be equal to its self-limiting value.

3. The histogram processing method according to claim 1, characterized in that: The steps to increase the number of pixels in the jth bin include: The lifting coefficient is determined according to the ratio of the total deleted amount to the total remaining amount updated after the j-1th bin is processed; When the elevation coefficient is less than the coefficient threshold, the number of pixels to be added is determined based on the elevation coefficient and the number of pixels in the j-th bin; when the elevation coefficient is greater than or equal to the coefficient threshold, the number of pixels to be added is determined based on the coefficient threshold and the number of pixels in the j-th bin; Calculate the sum of the number of pixels in the jth bin and the number of pixels to be added to obtain the sum of the number of pixels; When the sum of the pixel numbers is less than the self-limiting value of the j-th bin, the pixel number of the j-th bin is adjusted to be equal to the sum of the pixel numbers; When the sum of the number of pixels is greater than or equal to the self-limiting value of the j-th bin, the number of pixels of the j-th bin is adjusted to be equal to its self-limiting value.

4. An image processing method, characterized in that: include: Get the original histogram corresponding to the original image; Performing the histogram processing method described in any one of claims 1 to 3 on the original histogram to obtain a processed histogram; Generate a tone mapping curve based on the processed histogram; According to the tone mapping curve, tone mapping is performed on the original image to obtain a target image.

5. A histogram adjustment method, characterized in that: include: Execute the histogram processing method described in any one of claims 1 to 3 in order of brightness values ​​from small to large to obtain the first pixel number corresponding to each bin; Execute the histogram processing method described in any one of claims 1 to 3 in descending order of brightness values ​​to obtain the second pixel number corresponding to each bin; The average of the first pixel number and the second pixel number corresponding to the same bin is taken as the final adjusted pixel number of the bin.

6. An image processing method, characterized in that: include: Get the original histogram corresponding to the original image; Performing the histogram adjustment method according to claim 5 on the original histogram to obtain an adjusted histogram; Generate a tone mapping curve based on the adjusted histogram; According to the tone mapping curve, tone mapping is performed on the original image to obtain a target image.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the steps of the method according to any one of claims 1 to 3.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the steps of the method according to claim 4.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the steps of the method according to claim 5.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the steps of the method according to claim 6.

11. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, wherein: When the processor runs the computer program, the steps of the method according to any one of claims 1 to 3 are performed.

12. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, wherein: The processor executes the steps of the method of claim 4 when running the computer program.

13. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, wherein: The processor executes the steps of the method of claim 5 when running the computer program.

14. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: The processor executes the steps of the method of claim 6 when running the computer program.