Image contrast enhancement method and apparatus
By performing contrast enhancement and luminance histogram equalization on the image, combined with compensation for luminance and chrominance components, the problem that existing contrast enhancement methods cannot guarantee image quality and detail preservation is solved, achieving the effects of contrast enhancement and image quality equalization.
Patent Information
- Application Number
- CN202110484737.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-30
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2041-04-30
AI Technical Summary
Existing image contrast enhancement methods, while improving image contrast, struggle to ensure that overall image quality and detail information are not lost.
By performing contrast enhancement processing on the target image and equalizing the brightness histogram after contrast enhancement, an equalized brightness histogram is obtained. The brightness and chromaticity components of each pixel are determined based on the equalized brightness histogram. The chromaticity components are compensated by the brightness gain ratio, and the image is finally adjusted to achieve overall contrast enhancement and preservation of detail information.
It achieves a significant improvement in overall image contrast while preserving detail and maintaining a balanced histogram distribution, avoiding excessive stretching and enhancing overall image quality.
Smart Images

Figure CN115272090B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing, and more specifically, to an image contrast enhancement method and apparatus. Background Technology
[0002] With the development of the video display industry and the upgrading of display technologies such as LED and OLED, the hardware infrastructure for high-definition video displays has made significant progress, laying a solid hardware foundation for better presenting high-definition content. The presentation of high-definition video is a complete end-to-end process; it not only relies on hardware upgrades, but also on improving the image quality at the video source end, which is a crucial factor in achieving high-definition video presentation.
[0003] High-quality video images primarily focus on enhancing contrast, color, and detail, with contrast being the most crucial element. Currently, various methods exist for enhancing video image contrast, such as basic histogram equalization and dynamic contrast enhancement (DCE). However, each has its own advantages and disadvantages, making it difficult to guarantee that maximizing contrast while maintaining overall image quality and preserving detail is equally important.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides an image contrast enhancement method and apparatus to at least solve the technical problem in related technologies that, while improving image contrast, it is difficult to guarantee overall image quality and prevent the loss of detail information.
[0006] According to one aspect of the present invention, an image contrast enhancement method is provided, comprising: performing contrast enhancement processing on a target image, and performing equalization processing on the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; determining the luminance components of each pixel of the target image after equalization processing and contrast enhancement based on the equalized luminance histogram; determining the luminance gain ratio of each pixel of the target image based on the luminance components of each pixel; compensating the chrominance components of the target image based on the luminance gain ratio to obtain the chrominance components of the processed target image; and adjusting the target image based on the luminance components and the chrominance components.
[0007] Optionally, performing contrast enhancement processing on the target image and equalizing the brightness histogram of the contrast-enhanced target image to obtain an equalized brightness histogram includes: adjusting the brightness histogram of the target image for contrast enhancement to obtain an enhanced brightness histogram; and equalizing the enhanced brightness histogram to obtain the equalized brightness histogram.
[0008] Optionally, performing contrast enhancement adjustment on the brightness histogram of the target image to obtain an enhanced brightness histogram includes: statistically analyzing the brightness values of each pixel in the target image to obtain the brightness histogram; setting multiple first brightness value ranges and statistically analyzing the total number of pixels within each first brightness value range, using the ratio of the total number of pixels within each first brightness value range to the total number of pixels in the target image as a weighting coefficient for the first brightness value range; determining the enhanced brightness value of each pixel in the target image using the enhancement mapping function corresponding to the first brightness value range and the corresponding weighting coefficient; and statistically analyzing the enhanced brightness values of each pixel in the target image to generate the enhanced brightness histogram.
[0009] Optionally, equalizing the enhanced brightness histogram to obtain an equalized brightness histogram includes: dividing the enhanced brightness histogram into Z groups of histogram units, where Z is a positive integer, and the number of pixels in each group of histogram units is within a preset range; performing histogram equalization on each group of histogram units within the brightness value range, and recording the target brightness value after equalization for each group of histogram units; and mapping the target brightness value onto the corresponding histogram unit to obtain the equalized brightness histogram.
[0010] Optionally, dividing the enhanced brightness histogram into Z groups of histogram units includes: determining the average number of pixels in each group of histogram units based on the total number of pixels in the target image and the number of histogram units Z; determining the range of pixel counts in the divided histogram units based on the average number of pixels and a preset allowable value; grouping histograms adjacent to the brightness values of the enhanced brightness histogram into a group of histogram units according to a preset order, and determining whether the number of pixels in the histogram unit is within the specified range; if the number of pixels in the histogram unit is within the specified range, merging the histogram with adjacent histograms to determine the histogram unit; if the number of pixels in the histogram unit is not within the specified range, continuing to add adjacent histograms to the histogram unit until the number of pixels in the histogram unit is within the specified range.
[0011] Optionally, performing histogram equalization on each group of histogram units within the brightness value range and recording the target brightness value after equalization of each group of histogram units includes: determining the value range of the brightness value of the target image; determining and recording the target brightness value corresponding to each group of histogram units based on the value range and the number of histogram units Z; and performing equalization on multiple histogram units.
[0012] Optionally, based on the value range and the number of histogram units Z, the target brightness value corresponding to each group of histogram units is determined and recorded. The equalization process for multiple histogram units includes: dividing the value range by the number of groups Z to obtain the average brightness value of multiple groups of histogram units; determining and recording the target brightness value corresponding to the histogram unit by multiplying the value of the number of groups Z corresponding to the histogram unit by the average brightness value, wherein the histogram unit with the smallest number of groups Z has the smallest brightness value.
[0013] Optionally, mapping the target brightness value onto the corresponding histogram cell to obtain a balanced brightness histogram includes: determining a second brightness value range for the balanced histogram cell corresponding to the histogram cell based on the target brightness value of the histogram cell, wherein the second brightness value range is from the target brightness value of the adjacent previous histogram cell to the target brightness value corresponding to the histogram cell; mapping the brightness values of the pixels of the histogram cell to the second brightness value range in an arithmetic progression to obtain a balanced histogram cell; and combining the balanced histogram cells corresponding to all histogram cells to obtain the balanced brightness histogram.
[0014] Optionally, mapping the brightness values of the pixels in the histogram unit to a balanced histogram unit in an arithmetic progression according to the second brightness value range to obtain a balanced histogram unit includes: dividing the brightness difference corresponding to the second brightness value range by the number of pixels in the histogram unit to obtain the arithmetic difference value of the pixel mapped to the balanced histogram unit, wherein the brightness difference value is the maximum target brightness value minus the minimum target brightness value in the second brightness value range; determining the brightness value of the pixel in the histogram unit to be mapped to the brightness value in the corresponding mapped histogram unit based on the arithmetic difference value; and determining the balanced histogram unit based on the multiple pixels in the balanced histogram unit and the brightness value of the pixel.
[0015] Optionally, determining the mapping of the brightness value of the pixel in the histogram unit to the brightness value in the corresponding mapped histogram unit based on the arithmetic difference includes: mapping the brightness value of the pixel corresponding to the maximum or minimum brightness value in the histogram unit to the maximum or minimum value of the second brightness value range of the corresponding balanced histogram unit, wherein the brightness of the pixel corresponding to the minimum brightness value in the histogram unit is the minimum brightness value of the second brightness value range, and the brightness of the pixel corresponding to the maximum brightness value in the histogram unit is the maximum brightness value of the second brightness value range; adding or subtracting the arithmetic difference to the brightness value of each pixel corresponding to the maximum or minimum brightness value, and rounding to obtain the mapped brightness value of the pixel corresponding to the subsequent brightness value.
[0016] Optionally, determining the luminance component of each pixel after equalization and contrast enhancement of the target image based on the equalization luminance histogram includes: taking the luminance value corresponding to each pixel in the equalization luminance histogram as the luminance component of the pixel after equalization and contrast enhancement; determining the luminance gain ratio of each pixel in the target image based on the luminance component of each pixel includes: determining the luminance gain ratio based on the ratio of the luminance value corresponding to the luminance component of each pixel in the equalization luminance histogram to the luminance value of the pixel before contrast enhancement and equalization.
[0017] Optionally, compensating the chromaticity components of the target image according to the luminance gain ratio to obtain the chromaticity components after processing the target image includes: multiplying the luminance gain ratio by the chromaticity components of each pixel in the target image as the chromaticity components after processing the target image.
[0018] According to another aspect of the present invention, an image contrast enhancement method is also provided, comprising: performing contrast enhancement processing on a target image, and performing equalization processing on the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; determining the luminance component of each pixel after equalization processing and contrast enhancement of the target image based on the equalized luminance histogram; determining the chromaticity component of each pixel after processing the target image based on the luminance component of each pixel; and adjusting the target image based on the luminance component and the chromaticity component.
[0019] Optionally, determining the chromaticity components of each pixel after processing the target image based on the luminance components of each pixel includes: determining the luminance gain ratio of each pixel in the target image based on the luminance components of each pixel; and compensating the chromaticity components of the target image based on the luminance gain ratio to obtain the chromaticity components after processing the target image.
[0020] According to another aspect of the present invention, an image contrast enhancement apparatus is also provided, comprising: a processing module, configured to perform contrast enhancement processing on a target image and perform equalization processing on the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; a first determining module, configured to determine the luminance components of the target image after equalization processing and contrast enhancement based on the equalized luminance histogram; a second determining module, configured to determine the luminance gain ratio of each pixel of the target image based on the luminance components of each pixel; a compensation module, configured to compensate the chrominance components of the target image based on the luminance gain ratio to obtain the chrominance components of the target image after contrast enhancement; and an adjustment module, configured to adjust the target image based on the luminance components and the chrominance components.
[0021] According to another aspect of the present invention, an image contrast enhancement apparatus is also provided, comprising: a processing module, configured to perform contrast enhancement processing on a target image and perform equalization processing on the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; a third determining module, configured to determine the luminance component of each pixel after equalization processing and contrast enhancement of the target image based on the equalized luminance histogram; a fourth determining module, configured to determine the chromaticity component of each pixel after processing of the target image based on the luminance component of each pixel; and an adjustment module, configured to adjust the target image based on the luminance component and the chromaticity component.
[0022] According to another aspect of the present invention, a processor is also provided, the processor being configured to run a program, wherein the program, when running, executes the image contrast enhancement method described in any one of the foregoing embodiments.
[0023] According to another aspect of the present invention, a computer storage medium is also provided, the computer storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer storage medium is located to perform the image contrast enhancement method described in any one of the above embodiments.
[0024] In this embodiment of the invention, the target image undergoes contrast enhancement processing, and the luminance histogram of the contrast-enhanced target image is then equalized to obtain an equalized luminance histogram. Based on the equalized luminance histogram, the luminance components of each pixel in the target image after equalization and contrast enhancement are determined. The luminance gain ratio of each pixel in the target image is determined based on its luminance components. The chrominance components of the target image are compensated based on the luminance gain ratio to obtain the processed chrominance components. The target image is adjusted based on both the luminance and chrominance components, and the luminance histogram of the contrast-enhanced target image is then equalized. The luminance component and luminance gain ratio of the processed target image are determined based on the balanced luminance histogram. Then, the chrominance component of the processed target image is determined based on the luminance gain ratio. The target image is adjusted based on the luminance and chrominance components. This achieves the goal of determining the processed target image based on the balanced luminance histogram. This technical effect is to fully improve the overall contrast of the target image while ensuring the preservation of detail information and the balance of the overall histogram distribution, avoiding excessive stretching. This solves the technical problem in related image contrast enhancement methods that are difficult to guarantee overall image quality and prevent loss of detail information while improving image contrast. Attached Figure Description
[0025] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0026] Figure 1 This is a flowchart of an image contrast enhancement method according to an embodiment of the present invention;
[0027] Figure 2 This is a flowchart of an image contrast enhancement method according to an embodiment of the present invention;
[0028] Figure 3-1 This is a schematic diagram of the low-brightness mapping function T1 according to an embodiment of the present invention;
[0029] Figure 3-2 This is a schematic diagram of the brightness mapping function T2 according to an embodiment of the present invention;
[0030] Figure 3-3 This is a schematic diagram of the brightness mapping function T3 according to an embodiment of the present invention;
[0031] Figure 4-1 This is a schematic diagram of the brightness histogram of the target image according to an embodiment of the present invention;
[0032] Figure 4-2This is a schematic diagram of contrast enhancement after applying a brightness histogram according to an embodiment of the present invention.
[0033] Figure 4-3 This is a schematic diagram of the brightness histogram after contrast enhancement and equalization according to an embodiment of the present invention.
[0034] Figure 5 This is a schematic diagram of an image contrast enhancement device according to an embodiment of the present invention;
[0035] Figure 6 This is a schematic diagram of an image contrast enhancement device according to an embodiment of the present invention. Detailed Implementation
[0036] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0037] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0038] According to an embodiment of the present invention, a method embodiment for enhancing the contrast of an image is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0039] Figure 1 This is a flowchart of an image contrast enhancement method according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0040] Step S102: Perform contrast enhancement processing on the target image, and perform equalization processing on the brightness histogram of the contrast-enhanced target image to obtain an equalized brightness histogram.
[0041] Step S104: Determine the brightness components of each pixel after equalization and contrast enhancement of the target image based on the equalization brightness histogram.
[0042] Step S106: Determine the brightness gain ratio of each pixel in the target image based on the brightness component of each pixel.
[0043] Step S108: Compensate the chromaticity components of the target image according to the luminance gain ratio to obtain the chromaticity components of the target image after processing.
[0044] Step S110: Adjust the target image according to the luminance component and the chrominance component.
[0045] Through the above steps, the target image can be contrast-enhanced, and the luminance histogram of the contrast-enhanced target image can be equalized to obtain an equalized luminance histogram. Based on the equalized luminance histogram, the luminance components of each pixel in the target image after equalization and contrast enhancement can be determined. Based on the luminance components of each pixel, the luminance gain ratio of each pixel in the target image can be determined. Based on the luminance gain ratio, the chrominance components of the target image can be compensated to obtain the processed chrominance components. The target image is then adjusted based on the luminance and chrominance components, and the luminance histogram of the contrast-enhanced target image is equalized. The luminance component and luminance gain ratio of the processed target image are determined based on the balanced luminance histogram. Then, the chrominance component of the processed target image is determined based on the luminance gain ratio. The target image is adjusted based on the luminance and chrominance components. This achieves the goal of determining the processed target image based on the balanced luminance histogram. This technical effect is to fully improve the overall contrast of the target image while ensuring the preservation of detail information and the balance of the overall histogram distribution, avoiding excessive stretching. This solves the technical problem in related image contrast enhancement methods that are difficult to guarantee overall image quality and prevent loss of detail information while improving image contrast.
[0046] The target image mentioned above can be a video image. Frame-by-frame contrast enhancement of the video image can achieve contrast enhancement. The target image can also be a single image. The brightness histogram of the target image can be a statistical histogram generated by statistically analyzing the brightness values of the pixels in the target image, with the horizontal axis representing the brightness value and the vertical axis representing the number of pixels. The brightness value can be represented by the pixel value, which is a value assigned by the computer when the image is digitized. It represents the average brightness information of a region within a pixel in the image, or the average reflectance (transmission) density information of a region within a pixel. In this embodiment, the brightness value of a pixel can be represented by its pixel value.
[0047] It should be noted that the target image in this embodiment is a YUV space image. If the given target image belongs to the RGB space, it needs to be converted to the YUV space, and its luminance component Y is extracted and calculated as: Y = 0.299 × R + 0.587 × G + 0.114 × B. This accurately obtains the luminance component, or luminance value, of the target image for subsequent processing.
[0048] The aforementioned contrast enhancement processing of the target image can be achieved using the adaptive dynamic contrast enhancement method found in related technologies. This method effectively optimizes the mapping equation by analyzing the histogram distribution of the image to be processed, thereby ensuring the degree of contrast enhancement and the presentation of detail information. The specific processing procedure is as follows:
[0049] (i) The target images of the input video are divided into three scene types: dark scene, normal scene, and bright scene. Furthermore, three different mapping functions are designed for each of the three different scenes to adapt to the contrast enhancement of the video images in each scene. Since the brightness distribution range of each target image varies greatly, the enhancement curve is fitted only based on its brightness transformation. Figure 3-1 This is a schematic diagram of the low-brightness mapping function T1 according to an embodiment of the present invention; Figure 3-2 Figure 3-3 is a schematic diagram of the brightness mapping function T2 according to an embodiment of the present invention; Figure 3-3 is a schematic diagram of the brightness mapping function T3 according to an embodiment of the present invention. Figures 3-1 to 3-3 These are the mapping functions T1, T2, and T3 corresponding to the three brightness levels: low, medium, and high. The mapping curves corresponding to T3.
[0050] (ii) Next, it is necessary to obtain the histogram distribution of the input video image. Here, the histogram is divided into three parts for statistical analysis, namely the low, medium and high brightness levels, and the proportion of each part in the entire histogram is calculated and denoted as the weighting coefficients δ1, δ2 and δ3.
[0051] (III) Finally, using the weight coefficients δ1, δ2, and δ3 obtained in (II) and the mapping functions T1, T2, and T3 designed in (I) for the three intervals, respectively... By combining T3 and T4, we can obtain the final mapping transformation function:
[0052] f(x)=δ1T1(x)+δ2T2(x)+δ3T3(x)
[0053] Where x is the pixel value of the pixel corresponding to the input video image, and f(x) is the mapping result calculated for that pixel.
[0054] The above adjustments significantly improved the video image quality, enhanced dynamic contrast, and mitigated the detail loss and overstretching issues associated with histogram equalization. However, due to the coordination and suppression of the three mapping curves, and the limitations imposed by the design of the three weight curves, the overall dynamic range enhancement was still weaker compared to the original histogram equalization, and the dynamic range (overall contrast) was not adequately improved.
[0055] By equalizing the histogram of the contrast-enhanced target image, the overall contrast of the target image is adjusted. This ensures that while fully enhancing the overall contrast of the target image, it also preserves detail information and maintains a balanced overall histogram distribution, thus avoiding the technical effect of overstretching.
[0056] The above equalization process is histogram equalization, a method in image processing that adjusts contrast using an image's histogram. It's commonly used to increase the global contrast of many images, especially when the contrast of the image data is quite similar; equalization can better distribute the contrast across the histogram. It can enhance local contrast without affecting the overall contrast. It's particularly suitable for images where both the background and foreground are too bright or too dark.
[0057] Based on the equalized luminance histogram, the luminance components of the target image after contrast enhancement and equalization are determined, along with the luminance gain ratio. This luminance gain ratio is the ratio of the luminance components before and after contrast enhancement and equalization to the luminance components after the enhancement and equalization. The chrominance components of the target image are then compensated using this luminance gain ratio to obtain the chrominance components after contrast enhancement and equalization. These luminance and chrominance components determine the target image after contrast enhancement and equalization, thus achieving contrast enhancement of the target image. This process significantly improves the overall contrast while preserving detail and maintaining a balanced histogram distribution, avoiding excessive stretching.
[0058] This method achieves the goal of determining the processed target image based on the balanced luminance histogram by equalizing the luminance histogram. It then determines the processed luminance component and luminance gain ratio based on the equalized luminance histogram, and further determines the processed chrominance component based on the luminance gain ratio. By adjusting the target image based on the luminance and chrominance components, the method effectively enhances the overall contrast of the target image while preserving detail and maintaining a balanced histogram distribution, thus avoiding excessive stretching. This solves the problem in related image contrast enhancement methods that, while improving contrast, often fail to maintain overall image quality and prevent loss of detail.
[0059] Optionally, the target image is subjected to contrast enhancement processing, and the brightness histogram of the contrast-enhanced target image is subjected to equalization processing to obtain an equalized brightness histogram, including: adjusting the brightness histogram of the target image to enhance contrast and obtain an enhanced brightness histogram; and performing equalization processing on the enhanced brightness histogram to obtain an equalized brightness histogram.
[0060] The above-mentioned contrast enhancement adjustment of the brightness histogram of the target image can be achieved through the adaptive dynamic contrast enhancement method (ACE). By analyzing the histogram distribution of the target image, the mapping equation can be effectively optimized, thereby ensuring the degree of contrast enhancement and the presentation of detail information. This significantly improves the effect of the target image, enhances dynamic contrast, and also improves the problems of detail loss and overstretching caused by histogram equalization.
[0061] The enhanced brightness histogram after the contrast enhancement adjustment is then subjected to equalization processing. This effectively combines contrast enhancement adjustment and equalization, significantly improving the overall contrast of the video image while maintaining the advantages of adaptive dynamic contrast enhancement methods. It ensures the preservation of detail information and a balanced overall histogram distribution, avoiding over-stretching. This solves the technical problem in related image contrast enhancement methods that, while improving contrast, struggle to maintain overall image quality and prevent loss of detail.
[0062] Optionally, the contrast enhancement adjustment of the brightness histogram of the target image to obtain the enhanced brightness histogram includes: statistically analyzing the brightness values of each pixel in the target image to obtain a brightness histogram; setting multiple first brightness value ranges and statistically analyzing the total number of pixels in each first brightness value range, using the ratio of the total number of pixels in each first brightness value range to the total number of pixels in the target image as a weighting coefficient for the first brightness value range; determining the enhanced brightness value of each pixel in the target image through the enhancement mapping function corresponding to the first brightness value range and the corresponding weighting coefficient; and statistically analyzing the enhanced brightness values of each pixel in the target image to generate an enhanced brightness histogram.
[0063] The brightness values of each pixel in the target image are statistically analyzed to obtain a brightness histogram. The brightness components, i.e., brightness values, of the input image can be statistically analyzed point by point to obtain the image brightness histogram. The horizontal axis of the brightness value histogram is the brightness value of the pixel, and the vertical axis is the number of pixels.
[0064] Multiple first brightness value ranges are set, which are the dynamic ranges of the target image under different scenes. For example, three dynamic ranges [m1,n1], [m2,n2], and [m3,n3] are set, corresponding to dark scenes, normal scenes, and bright scenes of the target image, respectively. Among them, m1, m2, and m3 correspond to the minimum brightness values of dark scenes, normal scenes, and bright scenes, respectively, and n1, n2, and n3 correspond to the maximum brightness values of dark scenes, normal scenes, and bright scenes, respectively. The total number of pixels in each first brightness value range is counted, and the ratio of the total number of pixels in each first brightness value range to the total number of pixels in the target image is used as the weight coefficient of the first brightness value range. For example, by calculating the ratio of the number of pixels in different scenes to the total number of pixels in the target image, the weight coefficients δ1, δ2, and δ3 for the mapping curves of three different scene types are obtained. The enhancement mapping function corresponding to the first brightness value range mentioned above can be the enhancement mapping function designed for the three different scene types respectively. For example, the mapping functions for dark scenes, normal scenes, and bright scenes can be the mapping functions T1 corresponding to the three brightness levels of low, medium, and high. 、T3.
[0065] By using the enhancement mapping function corresponding to the first brightness value range and the corresponding weight coefficient, the enhanced brightness value of each pixel in the target image is determined. The following formula can be used to transform each brightness pixel in the input video image to obtain a new mapping value for each pixel, thereby obtaining a video image with the brightness component initially enhanced by adaptive dynamic contrast enhancement: OutImageY'(x)=δ1T1(x)+δ2T2(x)+δ3T3(x), where OutImageY'(x) is the enhanced brightness value of the pixel, and x is the x-th pixel in the target image.
[0066] Optionally, equalizing the enhanced brightness histogram to obtain an equalized brightness histogram includes: dividing the enhanced brightness histogram into Z groups of histogram cells, where Z is a positive integer, and the number of pixels in each group of histogram cells is within a preset range; performing histogram equalization on each group of histogram cells within the brightness value range, and recording the target brightness value after equalization for each group of histogram cells; and mapping the target brightness value to the corresponding histogram cell to obtain the equalized brightness histogram.
[0067] When dividing the enhanced brightness histogram into Z groups of histogram units where the number of pixels is within a preset range, you can first set the number of histogram groups Z to be divided, remove histograms with 0 pixels, select the group with the fewest histograms, and merge it with the smaller values from its two adjacent groups. This process is iterated until the required number of histogram groups is reached, ultimately achieving a consistency in the histogram values across all groups. For example, dividing the enhanced brightness histogram of a 256-bin target image into 16 groups based on the pixel values of the brightness component on the horizontal axis (i.e., brightness values), specifically H1 to H2, would result in Z = 16. 16 The aforementioned 256 bins refer to the target image's brightness being divided into 256 levels, represented by grayscale values from 0 to 255. During grouping, H1 to H... 16 The total number of pixels in each group's histogram is similar, all close to the average number of pixels. Where M×N represents the total number of pixels in the target image, which is also the resolution of the target image; since the number of pixels in each histogram unit is kept to be basically consistent, the range of brightness values corresponding to each histogram unit can be different. When the number of pixels corresponding to a brightness value is small, the range of brightness values for that histogram unit can be increased until the number of pixels in that histogram unit falls within the range. Within this range, Δ represents the allowable number of pixels, which is the maximum difference between the allowed number of pixels in a histogram cell and the average number of pixels.
[0068] For each group of histogram cells, histogram equalization is performed within the brightness value range to obtain the target brightness value corresponding to the histogram cell. The target brightness value after equalization of each group of histogram cells is recorded. The target brightness value is then mapped onto the pixel of the corresponding histogram cell to obtain the equalized brightness histogram.
[0069] Optionally, dividing the enhanced brightness histogram into Z groups of histogram units includes: determining the average number of pixels in each group of histogram units based on the total number of pixels in the target image and the number of histogram units Z; determining the range of pixel counts for each histogram unit based on the average number of pixels and a preset allowable value; grouping histograms adjacent to the brightness value of the enhanced brightness histogram into a group of histogram units according to a preset order, for example, starting from the histogram with the largest or smallest number of pixels, and determining whether the number of pixels in the histogram unit is within the allowed range, where the horizontal axis of the enhanced brightness histogram represents the brightness value and the vertical axis represents the number of pixels; if the number of pixels in the histogram unit is within the allowed range, merging the histogram with adjacent histograms to determine the histogram unit; if the number of pixels in the histogram unit is not within the allowed range, continuing to add adjacent histograms to the histogram unit until the number of pixels in the histogram unit is within the allowed range.
[0070] The total number of pixels in the target image can be determined based on the resolution of the target histogram, which is M×N, where M is the number of rows and N is the number of columns in the target image. The number of histogram cells Z can be preset by the user or determined empirically. For example, based on historical data of processed target images, if the size and brightness of the processed target image are similar to the target image mentioned above, the number of cells Z in the historical data can be directly used.
[0071] The average number of pixels corresponding to each histogram unit is equal to the total number of pixels in the target image divided by the number of histogram units. For example, the 256-bin enhanced brightness histogram is divided into 16 groups according to the pixel value of the brightness component on the horizontal axis, i.e., the brightness value, that is, Z=16, specifically H1 to H2. 16 Its average number of pixels is Where M×N is the total number of pixels in the target image, which is also the resolution of the target image, M is the number of rows of pixels in the target image, and N is the number of columns of pixels in the target image.
[0072] The number range is determined based on the average pixel count and a preset tolerance value. Since the number of pixels in each bar of the enhanced brightness histogram varies significantly, and each histogram cell contains the entire bar, the aforementioned bar chart is essentially a bar chart composed of the brightness value range indicated in the enhanced brightness histogram and the corresponding pixel count. This can lead to the pixel count of the final determined histogram cell being difficult to keep in line with the average pixel count. Therefore, a tolerance value is set, and a number range is determined based on the average pixel count and the tolerance value. Pixels falling within this range are considered to have a pixel count in the histogram cell that is comparable to the average pixel count. This number range can be... Within this range, Δ represents the allowable number of pixels, which is the maximum difference between the allowed number of pixels in a histogram cell and the average number of pixels. This can be determined by the user based on experience. For example, if the average number of pixels is 300, the allowable number can be 30, and the range can be (270, 330).
[0073] Starting with the histogram with the largest or smallest number of pixels in the brightness enhancement histogram, histograms adjacent to the brightness values of those histograms are grouped into a single histogram unit. The histogram with the largest or smallest number of pixels is adjacent to two histograms in the brightness enhancement histogram. If there are two adjacent histograms, one can be randomly selected first. It is then determined whether the number of pixels in the histogram unit formed after adding the adjacent histograms falls within a certain range. The horizontal axis of the brightness enhancement histogram represents the brightness value, and the vertical axis represents the number of pixels. This brightness enhancement histogram includes multiple adjacent brightness value ranges and histograms formed by the number of pixels corresponding to those brightness value ranges. This histogram is composed of brightness value ranges and the number of pixels corresponding to those brightness value ranges; in other words, it is a bar chart within the histogram.
[0074] If the number of pixels in a histogram unit is within a certain range, it indicates that the number of pixels constituting that histogram unit is at an average level. The histograms constituting that unit are then merged; that is, the histogram with the largest or smallest number of pixels is merged with its adjacent histograms to determine the histogram unit. Specifically, the brightness value range of this histogram unit is the union of the brightness value ranges of the histograms constituting that unit, and the corresponding number of pixels is the sum of the number of pixels in the histograms constituting that unit.
[0075] If the number of pixels in a histogram cell is outside the acceptable range, it means that the number of pixels in that histogram cell is not within the acceptable range. Continue adding adjacent histograms to the histogram cell until the number of pixels in the histogram cell is within the acceptable range. It should be noted that there are two cases where the number of pixels in a histogram cell is outside the acceptable range: if the number of pixels in the histogram cell is less than the acceptable range, it means that the number of pixels in that histogram cell is below the acceptable range. In this case, continue adding adjacent histograms to the histogram cell and determine the number of pixels in the histogram cell. If the number of pixels in the histogram cell is greater than the acceptable range, it means that before adding this histogram, the number of pixels in the histogram cell was below the acceptable range, but after adding this histogram, the number of pixels in the histogram cell is above the acceptable range. Then, determine the first difference between the number of pixels in the histogram cell before it was added to the histogram and the average number of pixels, and the second difference between the number of pixels in the histogram cell after it was added to the histogram and the average number of pixels. For example, if the number of pixels in the histogram cell before it was added to the histogram was 80, and the number of pixels in the histogram cell after it was added to the histogram was 130, that is, the number of pixels added to the histogram was 50. This number cannot be satisfied before or after the addition of the histogram. In this case, it is necessary to make a judgment based on the average number of pixels. If the average number of pixels is 100, the first difference is 100-80=20, and the second difference is 130-100=30.
[0076] When determining the histogram based on the average number of pixels, the histogram unit with a pixel count closer to the average number of pixels is selected. Specifically, if the first difference is less than or equal to the second difference, the histograms of the histogram unit before its current addition to the histogram are merged to determine the histogram unit; if the first difference is greater than the second difference, the histograms of the histogram unit after its current addition to the histogram are merged to determine the histogram unit.
[0077] Optionally, histogram equalization is performed on each group of histogram units within the brightness value range, and the target brightness value after equalization of each group of histogram units is recorded, including: determining the value range of the brightness value of the target image; determining and recording the target brightness value corresponding to each group of histogram units according to the value range and the number of histogram units Z, and performing equalization on multiple histogram units.
[0078] Using multiple histogram cells as units after grouping, histogram equalization is performed within the range of brightness values in the target image to obtain the target brightness value, and the target pixel value after mapping each group of histograms is recorded. This achieves the equalization processing of grouped histogram cells.
[0079] Optionally, based on the value range and the number of histogram cells Z, the target brightness value corresponding to each group of histogram cells is determined and recorded. The equalization process for multiple histogram cells includes: dividing the value range by the number of groups Z to obtain the average brightness value of multiple groups of histogram cells; determining and recording the target brightness value corresponding to the histogram cell by multiplying the value of the number of groups Z corresponding to the histogram cell by the average brightness value, wherein the histogram cell with the smallest number of groups Z has the smallest brightness value.
[0080] For example, the brightness value of the target image ranges from 0 to 255. Based on the value range and the number of histogram units Z, the target brightness value corresponding to each histogram unit is determined. For example, if the number of units Z = 16, dividing the value range by the number of units Z yields an average brightness value of 16. The histogram unit with the smallest brightness value also has the smallest target brightness value. This average brightness value is used as the target brightness value of the histogram unit with the smallest brightness value. The 16 histogram units are then arranged according to their brightness values, specifically I1 to I... 16 I1 can be the histogram unit with the smallest brightness value mentioned above. The value of the corresponding group number Z of I2 is 2. Multiplying it by the average brightness value of 16, the target brightness value of I2 is 32.
[0081] Optionally, mapping the target brightness value to the corresponding histogram cell to obtain the balanced brightness histogram includes: determining a second brightness value range for the balanced histogram cell corresponding to the histogram cell based on the target brightness value of the histogram cell, wherein the second brightness value range is from the target brightness value of the adjacent previous histogram cell to the target brightness value corresponding to the histogram cell; mapping the brightness values of the pixels of the histogram cell to the second brightness value range in an arithmetic progression to obtain the balanced histogram cell; and combining the balanced histogram cells corresponding to all histogram cells to obtain the balanced brightness histogram.
[0082] Based on the target brightness value of the histogram unit, the second brightness value range of the corresponding balanced histogram unit is determined. This second brightness value range extends from the target brightness value of the preceding histogram unit to the target brightness value of the corresponding histogram unit. For example, if the target brightness value of the aforementioned histogram unit is 32, the second brightness value range of the corresponding balanced histogram unit is from the target brightness value of the preceding histogram unit to the target brightness value of the corresponding histogram unit, ranging from 16 to 32. This process can be repeated to obtain the second brightness value ranges of the balanced histograms corresponding to multiple histogram units. If a histogram unit has no preceding histogram unit, the second brightness value range of the corresponding balanced histogram unit is from 0 to the target brightness value of that histogram unit.
[0083] The equalization histogram cells corresponding to all histogram cells are combined to obtain the equalization brightness histogram. That is, the intersection of the brightness value ranges of multiple equalization histogram cells is taken to obtain the brightness value range of the equalization brightness histogram. The brightness value ranges of the histograms in the equalization histogram cells are mapped to the equalization brightness histogram, and the length of the histogram is determined based on the number of pixels in that histogram, thus generating the equalization brightness histogram.
[0084] Optionally, mapping the brightness values of pixels in the histogram unit to the second brightness value range in an arithmetic progression to obtain an equalized histogram unit includes: dividing the brightness difference corresponding to the second brightness value range by the number of pixels in the histogram unit to obtain the arithmetic difference value of the pixel mapping to the equalized histogram unit, wherein the brightness difference value is the maximum target brightness value minus the minimum target brightness value in the second brightness value range; determining the brightness value of the pixel in the histogram unit to be mapped to the corresponding brightness value in the mapped histogram unit based on the arithmetic difference value; and determining the equalized histogram unit based on multiple pixels in the equalized histogram unit and the brightness values of the pixels.
[0085] The brightness difference corresponding to the second brightness value range is divided by the number of pixels in the histogram unit to obtain the arithmetic difference value mapped from the pixel to the equalization histogram unit. The brightness difference is the maximum target brightness value minus the minimum target brightness value within the second brightness value range. In other words, the brightness difference corresponding to the second brightness value range is the difference between the maximum and minimum brightness values within that range. For example, if the second brightness value range is 16 to 32, the corresponding brightness difference is 32 - 16 = 16. If the number of pixels in the histogram unit is 100, the arithmetic difference is 16 / 100 = 0.16. If the number of pixels in the histogram unit is 10, the arithmetic difference is 16 / 10 = 1.6.
[0086] Optionally, determining the mapping of the brightness value of a pixel in a histogram unit to the brightness value in the corresponding mapped histogram unit based on the arithmetic difference includes: mapping the brightness value of the pixel corresponding to the maximum or minimum brightness value in the histogram unit to the maximum or minimum value of the second brightness value range of the corresponding balanced histogram unit, wherein the brightness of the pixel corresponding to the minimum brightness value in the histogram unit is the minimum brightness value of the second brightness value range, and the brightness of the pixel corresponding to the maximum brightness value in the histogram unit is the maximum brightness value of the second brightness value range; adding or subtracting the arithmetic difference to the brightness value of each pixel corresponding to the maximum or minimum brightness value, and rounding the result to obtain the mapped brightness value of the pixel corresponding to the subsequent brightness value.
[0087] The brightness value of the pixel corresponding to the maximum or minimum brightness value in the histogram unit is mapped to the maximum or minimum brightness value in the second brightness range of the corresponding balanced histogram unit. It should be noted that the brightness values of pixels in the histogram unit correspond to the brightness values of pixels in the balanced histogram unit; maximum values correspond to maximum values, and minimum values correspond to minimum values. That is, the brightness of the pixel corresponding to the minimum brightness value in the histogram unit is the minimum brightness value in the second brightness range, and the brightness of the pixel corresponding to the maximum brightness value in the histogram unit is the maximum brightness value in the second brightness range. For example, if the minimum brightness value of a pixel in the above histogram unit is 3, and the minimum value in the second brightness range of the balanced histogram is 16, then the brightness value of that pixel in the original histogram unit will be modified to 16.
[0088] If the difference between equal intervals is greater than or equal to 1, it means the difference in brightness values between different pixels is greater than or equal to 1. When the brightness value has a decimal, it needs to be rounded to avoid problems with the computer not being able to recognize and process it. Therefore, the brightness value of the pixel corresponding to the maximum brightness value is added to or subtracted from the difference between equal intervals for each pixel to determine the mapped brightness value of the subsequent brightness value. For example, if the difference between equal intervals is 1.2, the brightness of the pixel with the minimum value in the second brightness value range is 16. The brightness value of the pixel adjacent to it is 16 + 1.2 = 17.2, rounded to 17. Similarly, the brightness value of the subsequent pixel is 17.2 + 1.2 = 18.4, rounded to 18.
[0089] If the difference between equal intervals is less than 1, it means the difference in brightness values between different pixels is less than 1. In this case, the brightness value of the pixel corresponding to the maximum brightness value is added to or subtracted from the difference between equal intervals, and then rounded to determine the mapped brightness value of the subsequent brightness value. This results in multiple pixels having the same value. For example, if the difference between equal intervals is 0.3, the brightness of the pixel with the minimum value in the second brightness value range is 16. The brightness value of the pixel adjacent to it is 16 + 0.3 = 16.3, rounded to 16. Similarly, the brightness value of the subsequent pixel is 16.3 + 0.3 = 16.9, rounded to 16. This will result in all three pixels having the same brightness value.
[0090] Optionally, determining the luminance component of each pixel after equalization and contrast enhancement of the target image based on the equalization luminance histogram includes: taking the luminance value corresponding to each pixel in the equalization luminance histogram as the luminance component of the pixel after equalization and contrast enhancement; determining the luminance gain ratio of each pixel in the target image based on the luminance component of each pixel includes: determining the luminance gain ratio based on the ratio of the luminance value corresponding to the luminance component of each pixel in the equalization luminance histogram to the luminance value of the pixel before contrast enhancement and equalization.
[0091] The luminance gain ratio is determined using the following formula:
[0092]
[0093] YGain (m,n) (x) represents the brightness gain ratio for processing position (m,n), OutImageY (m,n) (x) For the luminance component after contrast enhancement and equalization processing at position (m,n), InImageY (m,n) (x) refers to the luminance component before contrast enhancement and equalization processing at position (m,n).
[0094] Optionally, the chromaticity components of the target image are compensated according to the luminance gain ratio to obtain the chromaticity components after processing the target image, including: multiplying the luminance gain ratio by the chromaticity components of each pixel in the target image as the chromaticity components after processing the target image.
[0095] The chromaticity components, including the U and V components, of the target image after contrast enhancement and equalization are calculated using the following formula:
[0096] OutImageU (m,n) (x U ) = YGain (m,n) (x)×InImageU (m,n) (x U )
[0097] OutImageV (m,n) (x V ) = YGain (m,n) (x)×InImageV (m,n) (x V )
[0098] In the formula, YGain (m,n) (x) represents the luminance gain ratio for processing position (m,n), OutImageU (m,n)(x) For the U component after contrast enhancement and equalization processing at position (m,n), InImageU (m,n) (x) For the U component before contrast enhancement and equalization processing at position (m,n); OutImageV (m,n) (x) For the V component after contrast enhancement and equalization processing at position (m,n), InImageV (m,n) (x) refers to the V component before contrast enhancement and equalization processing at position (m,n).
[0099] Figure 2 This is a flowchart of an image contrast enhancement method according to an embodiment of the present invention, such as... Figure 2 As shown, according to another aspect of the present invention, an image contrast enhancement method is also provided, comprising the following steps:
[0100] Step S202: Perform contrast enhancement processing on the target image, and perform equalization processing on the brightness histogram of the contrast-enhanced target image to obtain an equalized brightness histogram.
[0101] Step S204: Determine the brightness components of each pixel after equalization and contrast enhancement of the target image based on the equalization brightness histogram.
[0102] Step S206: Determine the chromaticity components of each pixel after processing the target image based on the luminance components of each pixel.
[0103] Step S208: Adjust the target image according to the luminance component and the chrominance component.
[0104] Through the above steps, the target image undergoes contrast enhancement processing, and the luminance histogram of the enhanced target image is then equalized to obtain an equalized luminance histogram. Based on the equalized luminance histogram, the luminance components of each pixel after equalization and contrast enhancement are determined. Based on the luminance components of each pixel, the chrominance components of the processed target image are determined. The target image is then adjusted based on these luminance and chrominance components. This process, by equalizing the luminance histogram of the contrast-enhanced target image, determining the luminance components based on the equalized luminance histogram, and then determining the chrominance components based on the luminance components, achieves the goal of determining the processed target image based on the equalized luminance histogram. This achieves the technical effect of significantly improving the overall contrast of the target image while preserving detail information and maintaining a balanced overall histogram distribution, avoiding excessive stretching. This solves the technical problem in related image contrast enhancement methods that, while improving image contrast, struggle to maintain overall image quality and prevent loss of detail information.
[0105] Optionally, determining the chromaticity components of each pixel after processing the target image based on the luminance components of each pixel includes: determining the luminance gain ratio of each pixel in the target image based on the luminance components of each pixel; and compensating the chromaticity components of the target image based on the luminance gain ratio to obtain the chromaticity components after processing the target image.
[0106] Optionally, the target image is subjected to contrast enhancement processing, and the brightness histogram of the contrast-enhanced target image is subjected to equalization processing to obtain an equalized brightness histogram, including: adjusting the brightness histogram of the target image to enhance contrast and obtain an enhanced brightness histogram; and performing equalization processing on the enhanced brightness histogram to obtain an equalized brightness histogram.
[0107] Optionally, the contrast enhancement adjustment of the brightness histogram of the target image to obtain the enhanced brightness histogram includes: statistically analyzing the brightness values of each pixel in the target image to obtain a brightness histogram; setting multiple first brightness value ranges and statistically analyzing the total number of pixels in each first brightness value range, using the ratio of the total number of pixels in each first brightness value range to the total number of pixels in the target image as a weighting coefficient for the first brightness value range; determining the enhanced brightness value of each pixel in the target image through the enhancement mapping function corresponding to the first brightness value range and the corresponding weighting coefficient; and statistically analyzing the enhanced brightness values of each pixel in the target image to generate an enhanced brightness histogram.
[0108] Optionally, equalizing the enhanced brightness histogram to obtain an equalized brightness histogram includes: dividing the enhanced brightness histogram into Z groups of histogram cells, where Z is a positive integer, and the number of pixels in each group of histogram cells is within a preset range; performing histogram equalization on each group of histogram cells within the brightness value range, and recording the target brightness value after equalization for each group of histogram cells; and mapping the target brightness value to the corresponding histogram cell to obtain the equalized brightness histogram.
[0109] Optionally, dividing the enhanced brightness histogram into Z groups of histogram units includes: determining the average number of pixels in each group of histogram units based on the total number of pixels in the target image and the number of histogram units Z; determining the range of pixel counts for each histogram unit based on the average number of pixels and a preset allowable value; grouping histograms with adjacent brightness values into a single histogram unit according to a preset order in the enhanced brightness histogram, and determining whether the number of pixels in the histogram unit is within the allowed range; merging the histogram with adjacent histograms to determine the histogram unit if the number of pixels in the histogram unit is within the allowed range; and adding adjacent histograms to the histogram unit if the number of pixels in the histogram unit is not within the allowed range, until the number of pixels in the histogram unit is within the allowed range.
[0110] Optionally, histogram equalization is performed on each group of histogram units within the brightness value range, and the target brightness value after equalization of each group of histogram units is recorded, including: determining the value range of the brightness value of the target image; determining and recording the target brightness value corresponding to each group of histogram units according to the value range and the number of histogram units Z, and performing equalization on multiple histogram units.
[0111] Optionally, based on the value range and the number of histogram cells Z, the target brightness value corresponding to each group of histogram cells is determined and recorded. The equalization process for multiple histogram cells includes: dividing the value range by the number of groups Z to obtain the average brightness value of multiple groups of histogram cells; determining and recording the target brightness value corresponding to the histogram cell by multiplying the value of the number of groups Z corresponding to the histogram cell by the average brightness value, wherein the histogram cell with the smallest number of groups Z has the smallest brightness value.
[0112] Optionally, mapping the target brightness value to the corresponding histogram cell to obtain the balanced brightness histogram includes: determining a second brightness value range for the balanced histogram cell corresponding to the histogram cell based on the target brightness value of the histogram cell, wherein the second brightness value range is from the target brightness value of the adjacent previous histogram cell to the target brightness value corresponding to the histogram cell; mapping the brightness values of the pixels of the histogram cell to the second brightness value range in an arithmetic progression to obtain the balanced histogram cell; and combining the balanced histogram cells corresponding to all histogram cells to obtain the balanced brightness histogram.
[0113] Optionally, mapping the brightness values of pixels in the histogram unit to the second brightness value range in an arithmetic progression to obtain an equalized histogram unit includes: dividing the brightness difference corresponding to the second brightness value range by the number of pixels in the histogram unit to obtain the arithmetic difference value of the pixel mapping to the equalized histogram unit, wherein the brightness difference value is the maximum target brightness value minus the minimum target brightness value in the second brightness value range; determining the brightness value of the pixel in the histogram unit to be mapped to the corresponding brightness value in the mapped histogram unit based on the arithmetic difference value; and determining the equalized histogram unit based on multiple pixels in the equalized histogram unit and the brightness values of the pixels.
[0114] Optionally, determining the mapping of the brightness value of a pixel in a histogram unit to the brightness value in the corresponding mapped histogram unit based on the arithmetic difference includes: mapping the brightness value of the pixel corresponding to the maximum or minimum brightness value in the histogram unit to the maximum or minimum value of the second brightness value range of the corresponding balanced histogram unit, wherein the brightness of the pixel corresponding to the minimum brightness value in the histogram unit is the minimum brightness value of the second brightness value range, and the brightness of the pixel corresponding to the maximum brightness value in the histogram unit is the maximum brightness value of the second brightness value range; adding or subtracting the arithmetic difference to the brightness value of each pixel corresponding to the maximum or minimum brightness value, and rounding the result to obtain the mapped brightness value of the pixel corresponding to the subsequent brightness value.
[0115] Optionally, determining the luminance components of each pixel after equalization and contrast enhancement of the target image based on the equalization luminance histogram includes: taking the luminance value corresponding to each pixel in the equalization luminance histogram as the luminance component of the pixel after equalization and contrast enhancement; determining the luminance gain ratio of each pixel in the target image based on the luminance components of each pixel includes: determining the luminance gain ratio based on the ratio of the luminance value corresponding to the luminance component of each pixel in the equalization luminance histogram to the luminance value of the pixel before contrast enhancement and equalization.
[0116] Optionally, the chromaticity components of the target image are compensated according to the luminance gain ratio to obtain the chromaticity components after processing the target image, including: multiplying the luminance gain ratio by the chromaticity components of each pixel in the target image as the chromaticity components after processing the target image.
[0117] It should be noted that this embodiment also provides an optional implementation method, which will be described in detail below.
[0118] Histogram equalization is the most commonly used and simplest contrast enhancement method. However, because it adjusts the contrast based on the distribution ratio of individual pixels in the histogram, its enhancement effect has the following problems:
[0119] (1) After the transformation, some gray levels are reduced and some details are lost;
[0120] (2) Some video images, such as those with peaks in their histograms, exhibit an unnatural and excessive enhancement in contrast after enhancement.
[0121] To address the negative effects of histogram equalization for contrast enhancement, the most commonly used method is adaptive dynamic contrast enhancement. This method analyzes the histogram distribution of the image to be processed and effectively optimizes the mapping equation, thereby ensuring both the degree of contrast enhancement and the presentation of detail. The specific processing steps are as follows:
[0122] (iv) Color space conversion of the input video image. Since this method processes the luminance component of the input video image, if the given video image belongs to the RGB space, it needs to be converted to the YUV space, and its Y component is extracted for calculation:
[0123] Y=0.299×R+0.587×G+0.114×B
[0124] (v) The input video images are divided into three scene types: dark scene, normal scene, and bright scene. Furthermore, three different mapping functions are designed for each of the three different scenes to adapt to the contrast enhancement of the video images in each scene. Since the brightness distribution range of each image varies greatly, the enhancement curve is fitted only based on its brightness transformation. Figure 3-1 This is a schematic diagram of the low-brightness mapping function T1 according to an embodiment of the present invention; Figure 3-2 This is a schematic diagram of the brightness mapping function T2 according to an embodiment of the present invention; Figure 3-3 This is a schematic diagram of the brightness mapping function T3 according to an embodiment of the present invention, as shown below. Figures 3-1 to 3-3 These are the mapping functions T1, T2, and T3 corresponding to the low, medium, and high brightness levels, respectively. T3:
[0125] (vi) Next, the histogram distribution of the input video image needs to be obtained. Here, the histogram is divided into three parts for statistical analysis, namely the low, medium, and high brightness levels, and the proportion of each part in the entire histogram is calculated and denoted as the corresponding weight coefficient δ1. δ3;
[0126] (vii) Finally, using the weighting coefficients δ1 obtained in (iii), δ3 and the mapping function T1 designed for the three different intervals in (II), By combining T3 and T4, we can obtain the final mapping transformation function:
[0127] f(x)=δ1T1(x)+δ2T2(x)+δ3T3(x)
[0128] Where x is the pixel value of the pixel corresponding to the input video image, and f(x) is the mapping result calculated for that pixel.
[0129] The above adjustments clearly show a significant improvement in the processed video image quality, enhancing dynamic contrast and mitigating the detail loss and overstretching issues caused by histogram equalization. However, due to the coordination and suppression of the three mapping curves, and also due to the limitations imposed by the design of the three weight curves, the overall dynamic range enhancement is still weaker compared to the original histogram equalization, and the dynamic range (overall contrast) is not sufficiently improved.
[0130] Based on the shortcomings of the aforementioned adaptive dynamic contrast enhancement method compared to histogram equalization, this embodiment effectively combines the two technical approaches. While fully improving the overall contrast of the video image, it also maintains the advantages of the adaptive dynamic contrast enhancement method, ensuring the preservation of detail information and the balance of the overall histogram distribution, without the disadvantage of excessive stretching.
[0131] This implementation method improves the overall contrast of video images mainly in two aspects:
[0132] (I) The brightness histogram of the input video image is adjusted using an adaptive dynamic contrast enhancement method. The main process includes:
[0133] (1) Count the brightness components of the input image point by point to obtain the image brightness distribution histogram;
[0134] (2) Set three dynamic ranges [m1,n1], [m2,n2], [m3,n3], and count the total number of pixels in each dynamic range. Then, calculate the weight coefficients δ1, δ2, and δ3 for the mapping curves of three different scene types.
[0135] (3) Design corresponding enhancement mapping functions T1 for the three different scenario types. T3 (as in the adaptive dynamic contrast enhancement described above, the mapping functions T1, T2, and T3 for the low, medium, and high brightness levels are respectively) T3);
[0136] (4) Transform each luminance pixel of the input video image using the following formula to obtain a new mapping value for each pixel, thereby obtaining a preliminary video image of the luminance component using adaptive dynamic contrast enhancement:
[0137] OutImageY'(x)=δ1T1(x)+δ2T2(x)+δ3T3(x)
[0138] (II) Further stretching of the histogram processed in (I). To avoid overstretching caused by directly applying histogram equalization, a grouped histogram equalization (GLG) method is used to further stretch the histogram of the video image output in (I) to expand its dynamic range. The main process includes:
[0139] (1) Grouping: Set the number of histogram groups Z to be divided. Remove groups with histograms of 0. Select the group with the fewest histograms and merge it with the smaller values in its two adjacent groups. Iterate in this way until the required number of histogram groups is reached, so that the histogram values in each group are basically consistent. For example, a 256-bin histogram is divided into 16 groups, H1 to H2. 16 This can guarantee H1~H 16 The total values of the histograms in each group are similar, all close to... Where M×N is the total number of pixels in the input video image;
[0140] (2) Grouped Histogram Equalization: Using the grouping results in (1) as the unit, perform histogram equalization within the range of 0-255, and record the target brightness value H after mapping each group of histograms. i ′, where i = 1, ..., 16;
[0141] (3) Degrouping: Based on the output results in (2), perform grayscale mapping on the brightness values in each group. The mapping value H′ of the previous group... i-1 Starting from point H′ iUsing the endpoint as the starting point, the tolerance of each group is calculated based on its range of brightness values and the number of merged histograms. The brightness values of each group are then mapped to grayscale values at equal intervals between the starting and ending points using an arithmetic progression. The final output image is then obtained, featuring brightness components enhanced by histogram equalization.
[0142] Figure 4-1 This is a schematic diagram of the brightness histogram of the target image according to an embodiment of the present invention. Figure 4-2 This is a schematic diagram showing the contrast enhancement of the luminance histogram according to an embodiment of the present invention. Figure 4-3 This is a schematic diagram of the contrast enhancement and equalization of the luminance histogram according to an embodiment of the present invention, as shown below. Figure 4-1 , Figure 4-2 , Figure 4-3 As shown, the histogram distribution of the input image after the above two steps is shown: (the horizontal axis represents brightness, and the vertical axis represents the number of pixels). Figure 4-1 The image shown is a histogram of the brightness distribution of the input image; as shown... Figure 4-2 As shown, the brightness distribution histogram after adaptive dynamic contrast adjustment; Figure 4-3 As shown, after dynamic contrast adjustment, the brightness distribution histogram is expanded using GLG histogram equalization to extend the dynamic range. It can be seen that after two stages of adjustment, the overall brightness distribution histogram not only maintains no significant shape change globally, but also achieves a clear expansion of the dynamic range.
[0143] (III) Using the mapped brightness calculated in (II), calculate the brightness gain ratio of each pixel to compensate for the UV components in the YUV components. The calculation formula is as follows:
[0144]
[0145] OutImageU (m,n) (x U ) = YGain (m,n) (x)×InImageU (m,n) (x U )
[0146] OutImageV (m,n) (x V ) = YGain (m,n) (x)×InImageV (m,n) (x V )
[0147] Among them, YGain (m,n) (x) represents the luminance gain ratio for processing position (m,n), OutImageU(m,n) (x U ) and OutImageV (m,n) (x V ) are the compensated values of the UV components at positions (m,n).
[0148] By using this embodiment to enhance the display contrast of the input video image, the maximum enhancement of the display contrast of the input video image can be obtained. This not only effectively preserves the detailed information of the input video image, but also avoids the problem of image distortion caused by excessive stretching due to traditional histogram equalization.
[0149] Figure 5 This is a schematic diagram of an image contrast enhancement device according to an embodiment of the present invention, such as... Figure 5 As shown, according to another aspect of the present invention, an image contrast enhancement device is also provided, including: a processing module 502, a first determining module 504, a second determining module 506, a compensation module 508, and an adjustment module 510. The device will be described in detail below.
[0150] Processing module 502 is used to perform contrast enhancement processing on the target image and equalize the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; first determining module 504, connected to the processing module 502, is used to determine the luminance components of the target image after equalization and contrast enhancement based on the equalized luminance histogram; second determining module 506, connected to the first determining module 504, is used to determine the luminance gain ratio of each pixel of the target image based on the luminance components of each pixel; compensation module 508, connected to the second determining module 506, is used to compensate the chrominance components of the target image based on the luminance gain ratio to obtain the chrominance components of the target image after contrast enhancement; adjustment module 510, connected to the compensation module 508, is used to adjust the target image based on the luminance components and chrominance components.
[0151] Using the aforementioned apparatus, processing module 502 performs contrast enhancement processing on the target image and equalizes the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; first determining module 504 determines the luminance component of each pixel after equalization and contrast enhancement of the target image based on the equalized luminance histogram; second determining module 506 determines the luminance gain ratio of each pixel of the target image based on the luminance component of each pixel; compensation module 508 compensates the chrominance component of the target image based on the luminance gain ratio to obtain the chrominance component after processing the target image; adjustment module 510 adjusts the target image based on the luminance and chrominance components, thereby enhancing the contrast... The brightness histogram of the target image is equalized. Based on the equalized brightness histogram, the brightness component and brightness gain ratio of the processed target image are determined. Then, based on the brightness gain ratio, the chromaticity component of the processed target image is determined. The target image is adjusted according to the brightness and chromaticity components. This achieves the goal of determining the processed target image based on the equalized brightness histogram. Thus, it achieves the technical effect of fully improving the overall contrast of the target image while ensuring the preservation of detail information and the balance of the overall histogram distribution, avoiding excessive stretching. This solves the technical problem in related image contrast enhancement methods that, while improving image contrast, are difficult to guarantee overall image quality and prevent the loss of detail information.
[0152] Optionally, the processing module includes: an enhancement unit for contrast enhancement adjustment of the brightness histogram of the target image to obtain an enhanced brightness histogram; and an equalization unit for equalization processing of the enhanced brightness histogram to obtain an equalized brightness histogram.
[0153] Optionally, the enhancement unit includes: a statistics unit, used to count the brightness values of each pixel in the target image to obtain a brightness histogram; a setting unit, used to set multiple first brightness value ranges, and count the total number of pixels in each first brightness value range, using the ratio of the total number of pixels in each first brightness value range to the total number of pixels in the target image as a weighting coefficient for the first brightness value range; a weighting unit, used to determine the enhanced brightness value of each pixel in the target image through the enhancement mapping function corresponding to the first brightness value range and the corresponding weighting coefficient; and a generation unit, used to count the enhanced brightness values of each pixel in the target image to generate an enhanced brightness histogram.
[0154] Optionally, the equalization unit includes: a grouping subunit, used to divide the enhanced brightness histogram into Z groups of histogram units, where Z is a positive integer, and the number of pixels in each group of histogram units is within a preset range; an equalization subunit, used to perform histogram equalization processing on each group of histogram units within the brightness value range, and record the target brightness value after equalization processing for each group of histogram units; and a mapping subunit, used to map the target brightness value onto the corresponding histogram unit to obtain the equalized brightness histogram.
[0155] Optionally, the grouping subunit includes: a first determining secondary subunit, used to determine the average number of pixels corresponding to each group of histogram units based on the total number of pixels in the target image and the number of histogram units Z; a second determining secondary subunit, used to determine the range of pixel counts for the divided histogram units based on the average number of pixels and a preset allowable value; a merging secondary subunit, used to group histograms with adjacent brightness values into a group of histogram units in a preset order in the enhanced brightness histogram, and determine whether the number of pixels in the histogram unit is within the range; a merging secondary subunit, used to merge the histogram with adjacent histograms to determine the histogram unit if the number of pixels in the histogram unit is within the range; and an adding secondary subunit, used to continue adding adjacent histograms to the histogram unit if the number of pixels in the histogram unit is not within the range, until the number of pixels in the histogram unit is within the range.
[0156] Optionally, the equalization subunit includes: a third determining secondary subunit, used to determine the range of brightness values of the target image; and a fourth determining secondary subunit, used to determine and record the target brightness value corresponding to each group of histogram units according to the value range and the number of histogram units Z, and to perform equalization processing on multiple histogram units.
[0157] Optionally, the fourth determination of the secondary sub-unit includes: first determining the tertiary sub-unit, used to obtain the average brightness of multiple histogram units by dividing the value range by the number of groups Z; second determining the tertiary sub-unit, used to determine and record the target brightness value corresponding to the histogram unit by multiplying the value of the number of groups Z corresponding to the histogram unit with the average brightness value, wherein the histogram unit with the smallest value of the number of groups Z corresponds to the smallest brightness value.
[0158] Optionally, the mapping subunit includes: a fifth determining secondary subunit, used to determine the second brightness value range of the equalization histogram unit corresponding to the histogram unit based on the target brightness value of the histogram unit, wherein the second brightness value range is from the target brightness value of the adjacent previous group of histogram units to the target brightness value corresponding to the histogram unit; a mapping secondary subunit, used to map the brightness values of the pixels of the histogram unit to the second brightness value range in an arithmetic manner to obtain the equalization histogram unit; and a combining secondary subunit, used to combine the equalization histogram units corresponding to all histogram units to obtain the equalization brightness histogram.
[0159] Optionally, the mapping second-level subunit includes: a third determining third-level subunit, used to obtain the arithmetic difference value of the pixel mapping to the equalization histogram unit by dividing the brightness difference value corresponding to the second brightness value range by the number of pixels in the histogram unit, wherein the brightness difference value is the maximum value of the target brightness value in the second brightness value range minus the minimum value of the target brightness value; a fourth determining third-level subunit, used to determine the mapping of the brightness value of the pixel in the histogram unit to the brightness value in the corresponding mapping histogram unit based on the arithmetic difference value; and a fifth determining third-level subunit, used to determine the equalization histogram unit based on multiple pixels in the equalization histogram unit and the brightness value of the pixel.
[0160] Optionally, the fourth determination of the third-level subunit includes: a mapping fourth-level subunit, used to map the brightness value of the pixel corresponding to the maximum or minimum brightness value in the histogram unit to the maximum or minimum value of the second brightness value range of the corresponding equalization histogram unit, wherein the brightness of the pixel corresponding to the minimum brightness value in the histogram unit is the minimum brightness value of the second brightness value range, and the brightness of the pixel corresponding to the maximum brightness value in the histogram unit is the maximum brightness value of the second brightness value range; and a first determination fourth-level subunit, used to add or subtract the arithmetic difference to the brightness value of the pixel corresponding to the maximum or minimum brightness value one by one, and after rounding, determine the brightness value of the pixel corresponding to the subsequent brightness value after mapping.
[0161] Optionally, the first determining module includes: taking the brightness value corresponding to each pixel in the equalization brightness histogram as the brightness component of the pixel after equalization and contrast enhancement; the second determining module includes: determining the brightness gain ratio based on the ratio of the brightness value corresponding to the brightness component of each pixel in the equalization brightness histogram to the brightness value of the pixel before contrast enhancement and equalization.
[0162] Optionally, the compensation module includes: multiplying the luminance gain ratio by the chromaticity components of each pixel in the target image as the chromaticity components of the processed target image.
[0163] Figure 6 This is a schematic diagram of an image contrast enhancement device according to an embodiment of the present invention, such as... Figure 6 As shown, according to another aspect of the present invention, an image contrast enhancement device is also provided, including: a processing module 602, a third determining module 604, a fourth determining module 606, and an adjustment module 608. The device will be described in detail below.
[0164] Processing module 602 is used to perform contrast enhancement processing on the target image and equalize the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; third determining module 604, connected to the processing module 602, is used to determine the luminance component of each pixel after equalization and contrast enhancement of the target image based on the equalized luminance histogram; fourth determining module 606, connected to the third determining module 604, is used to determine the chromaticity component of each pixel after processing the target image based on the luminance component of each pixel; adjustment module 608, connected to the fourth determining module 606, is used to adjust the target image based on the luminance component and the chromaticity component.
[0165] Using the above apparatus, processing module 602 performs contrast enhancement processing on the target image and equalizes the luminance histogram of the contrast-enhanced target image to obtain an equalized luminance histogram; third determining module 604 determines the luminance component of each pixel after equalization and contrast enhancement of the target image based on the equalized luminance histogram; fourth determining module 606 determines the chromaticity component of each pixel after processing the target image based on the luminance component of each pixel; and adjustment module 608 adjusts the target image based on the luminance and chromaticity components by equalizing the luminance histogram of the contrast-enhanced target image. The method involves determining the luminance component of the processed target image based on the balanced luminance histogram, then determining the chrominance component based on the luminance component, and adjusting the target image based on the luminance and chrominance components. This achieves the goal of determining the processed target image based on the balanced luminance histogram, thereby ensuring the preservation of detail information and the balanced distribution of the overall histogram while significantly improving the overall contrast of the target image and avoiding excessive stretching. This solves the technical problem in related image contrast enhancement methods that, while improving image contrast, struggle to maintain overall image quality and prevent the loss of detail information.
[0166] Optionally, the fourth determining module 606 includes: a first determining unit, used to determine the luminance gain ratio of each pixel of the target image based on the luminance component of each pixel; and a second determining unit, used to compensate the chrominance component of the target image based on the luminance gain ratio to obtain the chrominance component after processing the target image.
[0167] Optionally, the processing module includes: an enhancement unit for contrast enhancement adjustment of the brightness histogram of the target image to obtain an enhanced brightness histogram; and an equalization unit for equalization processing of the enhanced brightness histogram to obtain an equalized brightness histogram.
[0168] Optionally, the enhancement unit includes: a statistics unit, used to count the brightness values of each pixel in the target image to obtain a brightness histogram; a setting unit, used to set multiple first brightness value ranges, and count the total number of pixels in each first brightness value range, using the ratio of the total number of pixels in each first brightness value range to the total number of pixels in the target image as a weighting coefficient for the first brightness value range; a weighting unit, used to determine the enhanced brightness value of each pixel in the target image through the enhancement mapping function corresponding to the first brightness value range and the corresponding weighting coefficient; and a generation unit, used to count the enhanced brightness values of each pixel in the target image to generate an enhanced brightness histogram.
[0169] Optionally, the equalization unit includes: a grouping subunit, used to divide the enhanced brightness histogram into Z groups of histogram units, where Z is a positive integer, and the number of pixels in each group of histogram units is within a preset range; an equalization subunit, used to perform histogram equalization processing on each group of histogram units within the brightness value range, and record the target brightness value after equalization processing for each group of histogram units; and a mapping subunit, used to map the target brightness value onto the corresponding histogram unit to obtain the equalized brightness histogram.
[0170] Optionally, the grouping subunit includes: a sixth determining secondary subunit, used to determine the average number of pixels corresponding to each group of histogram units based on the total number of pixels in the target image and the number of histogram units Z; a seventh determining secondary subunit, used to determine the range of pixel counts for the divided histogram units based on the average number of pixels and a preset allowable value; a merging secondary subunit, used to group histograms with adjacent brightness values into a group of histogram units in a preset order in the enhanced brightness histogram, and determine whether the number of pixels in the histogram unit is within the range; a merging secondary subunit, used to merge the histogram with adjacent histograms to determine the histogram unit if the number of pixels in the histogram unit is within the range; and an adding secondary subunit, used to continue adding adjacent histograms to the histogram unit if the number of pixels in the histogram unit is not within the range, until the number of pixels in the histogram unit is within the range.
[0171] Optionally, the equalization subunit includes: an eighth secondary subunit for determining the range of brightness values of the target image; and a ninth secondary subunit for determining and recording the target brightness value corresponding to each group of histogram units based on the range of values and the number of histogram units Z, and performing equalization processing on multiple histogram units.
[0172] Optionally, the ninth step of determining the second-level sub-unit includes: the sixth step of determining the third-level sub-unit, used to obtain the average brightness value of the second brightness value range of multiple histogram units by dividing the value range by the number of groups Z; and the seventh step of determining the third-level sub-unit, used to determine and record the target brightness value corresponding to the histogram unit by multiplying the value of the number of groups Z corresponding to the histogram unit with the average brightness value, wherein the second brightness value range corresponding to the histogram unit with the smallest value of the number of groups Z is the smallest.
[0173] Optionally, the mapping subunit includes: a tenth determining secondary subunit, used to determine the second brightness value range of the equalization histogram unit corresponding to the histogram unit based on the target brightness value of the histogram unit, wherein the second brightness value range is from the target brightness value of the adjacent previous group of histogram units to the target brightness value corresponding to the histogram unit; a mapping secondary subunit, used to map the brightness values of the pixels of the histogram unit to the second brightness value range in an arithmetic manner to obtain the equalization histogram unit; and a combining secondary subunit, used to combine the equalization histogram units corresponding to all histogram units to obtain the equalization brightness histogram.
[0174] Optionally, the mapping secondary subunit includes: an eighth third-level subunit, used to obtain the arithmetic difference value of the pixel mapping to the equalization histogram unit by dividing the brightness difference value corresponding to the second brightness value range by the number of pixels in the histogram unit, wherein the brightness difference value is the maximum value of the target brightness value in the second brightness value range minus the minimum value of the target brightness value; a ninth third-level subunit, used to determine the mapping of the brightness value of the pixel in the histogram unit to the brightness value in the corresponding mapping histogram unit based on the arithmetic difference value; and a tenth third-level subunit, used to determine the equalization histogram unit based on multiple pixels in the equalization histogram unit and the brightness value of the pixel.
[0175] Optionally, the ninth determination of the third-level sub-unit includes: a mapping fourth-level sub-unit, used to map the brightness value of the pixel corresponding to the maximum or minimum brightness value in the histogram unit to the maximum or minimum value of the second brightness value range of the corresponding equalization histogram unit, wherein the brightness of the pixel corresponding to the minimum brightness value in the histogram unit is the minimum brightness value of the second brightness value range, and the brightness of the pixel corresponding to the maximum brightness value in the histogram unit is the maximum brightness value of the second brightness value range; and a second determination of the fourth-level sub-unit, used to add or subtract equal difference values to the brightness values of the pixels corresponding to the maximum or minimum brightness values one by one, and after rounding, determine the brightness value of the pixel corresponding to the subsequent brightness value after mapping.
[0176] Optionally, the third determining module 604 includes: taking the brightness value corresponding to each pixel in the equalization brightness histogram as the brightness component of the pixel after equalization and contrast enhancement; the first determining unit includes: determining the brightness gain ratio based on the ratio of the brightness value corresponding to the brightness component of each pixel in the equalization brightness histogram to the brightness value of the pixel before contrast enhancement and equalization.
[0177] Optionally, the second determining unit includes: multiplying the luminance gain ratio by the chromaticity components of each pixel in the target image as the chromaticity components after processing the target image.
[0178] According to another aspect of the present invention, a processor is also provided, which is used to run a program, wherein the program executes the image contrast enhancement method of any one of the above embodiments.
[0179] According to another aspect of the present invention, a computer storage medium is also provided, the computer storage medium including a stored program, wherein, when the program is running, it controls the device where the computer storage medium is located to execute the image contrast enhancement method of any one of the above.
[0180] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0181] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0182] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0183] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0184] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0185] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0186] 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. A method of contrast enhancement of an image, characterized by, The method comprises the following steps: contrast enhancement processing is performed on the target image, and histogram equalization processing is performed on the brightness histogram of the target image after contrast enhancement, to obtain an equalized brightness histogram; determining the brightness component of each pixel point of the target image after histogram equalization processing and contrast enhancement according to the equalized brightness histogram; determining a brightness gain ratio according to the ratio of the brightness value corresponding to the brightness component of each pixel point to the brightness value of the pixel point without contrast enhancement and histogram equalization processing; multiplying the brightness gain ratio by the chroma component of each pixel in the target image to obtain the chroma component of the target image after processing; adjusting the target image according to the brightness component and the chroma component; wherein the contrast enhancement processing is performed on the target image, and the histogram equalization processing is performed on the brightness histogram of the target image after contrast enhancement, to obtain an equalized brightness histogram, which comprises the following steps: adjusting the brightness histogram of the target image by contrast enhancement to obtain an enhanced brightness histogram; dividing the enhanced brightness histogram into Z groups of histogram units, wherein Z is a positive integer, and the number of pixel points in each group of histogram units is within a preset range; determining the value range of the brightness value of the target image; performing histogram equalization processing on each group of histogram units within the value range, and recording the target brightness value after histogram equalization processing of each group of histogram units; mapping the target brightness value in the corresponding histogram unit to obtain the equalized brightness histogram.
2. The method of claim 1, wherein, The method of adjusting the brightness histogram of the target image by contrast enhancement to obtain an enhanced brightness histogram comprises the following steps: statistically obtaining the brightness value of each pixel of the target image to obtain the brightness histogram; setting a plurality of first brightness value ranges, and statistically obtaining the total number of pixel points in each first brightness value range; the ratio of the total number of pixel points in each first brightness value range to the total number of pixel points of the target image is used as the weight coefficient of the first brightness value range; determining the enhanced brightness value of each pixel point of the target image through the corresponding enhancement mapping function of the first brightness value range and the corresponding weight coefficient; statistically obtaining the enhanced brightness value of each pixel point of the target image to generate the enhanced brightness histogram.
3. The method of claim 1, wherein, The method of dividing the enhanced brightness histogram into Z groups of histogram units comprises the following steps: determining the average number of pixels corresponding to each group of histogram units according to the total number of pixel points of the target image and the number Z of groups of histogram units; determining the number range of pixel points of the divided histogram units according to the average number of pixels and a preset number tolerance value; determining whether the number of pixel points of the histogram unit is within the number range according to the preset order in the enhanced brightness histogram, and grouping the histogram units with adjacent brightness values; in the case that the number of pixel points of the histogram unit is within the number range, merging the histogram and the adjacent histogram to determine the histogram unit; If the number of pixels of the histogram unit is not in the number range, continue to add adjacent histograms to the histogram unit until the number of pixels of the histogram unit is in the number range.
4. The method of claim 1, wherein, The histogram equalization processing is performed on each group of the histogram units in the value range, and a target brightness value of each group of the histogram units after the equalization processing is recorded. According to the value range and the number Z of groups of the histogram units, a target brightness value corresponding to each group of the histogram units is determined and recorded, and the equalization processing is performed on the plurality of histogram units.
5. The method of claim 4, wherein, According to the value range and the number Z of groups of the histogram units, a target brightness value corresponding to each group of the histogram units is determined and recorded, and the equalization processing is performed on the plurality of histogram units. According to the value range and the number Z of groups of the histogram units, a target brightness value corresponding to each group of the histogram units is determined and recorded, and the equalization processing is performed on the plurality of histogram units. According to the value range and the number Z of groups of the histogram units, a target brightness value corresponding to each group of the histogram units is determined and recorded, and the equalization processing is performed on the plurality of histogram units.
6. The method of claim 1, wherein, According to the value range and the number Z of groups of the histogram units, a target brightness value corresponding to each group of the histogram units is determined and recorded, and the equalization processing is performed on the plurality of histogram units. The target brightness value is mapped in the corresponding histogram unit to obtain an equalized brightness histogram. According to the target brightness value of the histogram unit, a second brightness value range of an equalized histogram unit corresponding to the histogram unit is determined, wherein the second brightness value range is from a target brightness value of an adjacent histogram unit of a previous group to the target brightness value of the histogram unit. The second brightness value range is mapped to the brightness value of the pixel of the histogram unit in an arithmetic progression manner to obtain an equalized histogram unit.
7. The method of claim 6, wherein, All the equalized histogram units corresponding to the histogram units are combined to obtain the equalized brightness histogram. The second brightness value range is mapped to the brightness value of the pixel of the histogram unit in an arithmetic progression manner to obtain an equalized histogram unit. According to the brightness difference value corresponding to the second brightness value range, the equalized difference value of the pixel points of the histogram unit is obtained by dividing the number of pixel points of the histogram unit, wherein the brightness difference value is a maximum target brightness value minus a minimum target brightness value of the second brightness value range. According to the equalized difference value, the brightness value of the pixel point of the histogram unit is mapped to the brightness value in the corresponding mapping histogram unit.
8. The method of claim 7, wherein, According to the equalized difference value, the brightness value of the pixel point of the histogram unit is mapped to the brightness value in the corresponding mapping histogram unit. According to the equalized difference value, the brightness value of the pixel point of the histogram unit is mapped to the brightness value in the corresponding mapping histogram unit. The maximum brightness value of the pixel point corresponding to the maximum brightness value in the histogram unit is mapped to the maximum value of the second brightness value range of the corresponding equalized histogram unit, wherein the minimum brightness value of the pixel point corresponding to the minimum brightness value in the histogram unit is the minimum brightness value of the second brightness value range, and the maximum brightness value of the pixel point corresponding to the maximum brightness value in the histogram unit is the maximum brightness value of the second brightness value range. The maximum and minimum luminance values of the target image are adjusted to obtain an enhanced luminance histogram; the enhanced luminance histogram is divided into Z groups of histogram units, where Z is a positive integer, and the number of pixel points in each group of histogram units is within a preset range; the range of luminance values of the target image is determined; histogram equalization processing is performed on each group of histogram units within the range of luminance values, and the target luminance value after the histogram equalization processing of each group of histogram units is recorded; and the target luminance value is mapped to the corresponding histogram unit to obtain an equalized luminance histogram.
9. The method according to any one of claims 1 to 8, characterized in that, The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram.
10. An apparatus for contrast enhancement of an image, characterized by The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram.
11. A processor, comprising: The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram.
12. A computer storage medium, characterized in that The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according to the equalized luminance histogram. The luminance component of each pixel point of the target image after the equalization and contrast enhancement is determined according
Citation Information
Patent Citations
Dynamic contrast enhancement device and method
CN102231264A