Image contrast enhancement method and system

By performing color space conversion and histogram analysis on the image, adaptively calculate the Gamma parameter value for Gamma transformation, solving the problem of excessive or insufficient in image contrast enhancement in the prior art, improving the visual effect of the image and simplifying the parameter selection process .

CN114494471BActive Publication Date: 2024-12-03XIAN PEIHUA UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210142774.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-16
Publication Date
2024-12-03
Estimated Expiration
2042-02-16

AI Technical Summary

Technical Problem

Existing image contrast enhancement techniques are prone to the problem of excessive enhancement or insufficient enhancement, especially in scenarios where the input image histogram has a high peak, and it is time-consuming to manually select the Gamma parameter value and it is difficult to obtain the better enhancement results of a single image.

Method used

By converting color space and separating the enhanced image, calculating the normalization coefficient and preset weight of the histogram, adaptively calculate the Gamma parameter value, and performing Gamma transformation to obtain the enhanced image, avoiding excessive enhancement or insufficient enhancement question.

Benefits of technology

It achieves the improvement of image contrast while avoiding excessive enhancement or insufficient enhancement, improving the visual effect of the image, and simplifying the parameter selection process, making the processing of each image more efficient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114494471B_ABST
    Figure CN114494471B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for image contrast enhancement, belonging to the field of image processing technology, the system includes an image acquisition module to be enhanced, a grayscale image acquisition module, a histogram generation module, a histogram normalization module, a preset weight generation module, a Gamma parameter value calculation module and an enhanced image generation module, the method includes: 1. inputting an image to be enhanced; 2. performing color space conversion and channel separation on the input image to be enhanced to obtain a grayscale image I of the image to be enhanced; 3. calculating a histogram of the grayscale image; 4. calculating a normalization coefficient of the histogram; 5. calculating a preset weight of a Gamma parameter value; 6. calculating a Gamma parameter value; 7. performing a Gamma transformation on the grayscale image to be enhanced using the Gamma parameter value and obtaining an enhanced image through channel merging and color space conversion. The present invention effectively solves the problem of over-enhancement or under-enhancement of an image while improving image contrast, and improves the visual effect of the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing, and in particular relates to an image contrast enhancement method and system. Background Art

[0002] Image contrast enhancement is a digital image enhancement technology that improves contrast by adjusting the dynamic range of the brightness distribution of each pixel in the image. Digital images have been widely used in all aspects of our current life. However, unfavorable acquisition conditions, such as cloudy days, night scenes, and lack of lighting, often lead to reduced image contrast and dynamic range, resulting in reduced usability of subsequent image analysis and understanding tasks. Therefore, using image contrast enhancement technology to improve visual quality plays a vital role in applications such as computer vision, pattern recognition, and digital image processing.

[0003] HE (histogram equalization) is a classic image contrast enhancement method. It is based on the idea of ​​transforming the histogram distribution of an image into a distribution that is as uniform as possible, and selects the CDF (cumulative distribution function) of the image histogram as the mapping function of the brightness of each pixel in the image before and after enhancement. The image histogram after enhancement by this method is approximately close to a uniform distribution, which greatly improves the contrast. However, since the mapping function of the brightness of each pixel before and after image enhancement does not conform to the visual characteristics of the human eye, it is easy to cause over-enhancement problems, especially in scenes where the input image histogram has a high peak. In order to improve the performance of HE, many methods have been proposed to adjust the input image histogram and then apply histogram equalization, such as WTHE (weighted and thresholded histogram equalization) and CLAHE (contrast-limited adaptive histogram equalization), but these methods cannot completely avoid the problem of over-enhancement, and may even introduce the problem of under-enhancement due to the need to avoid over-enhancement.

[0004] Gamma transform is another commonly used contrast enhancement method because it is consistent with the visual characteristics of the human eye. It selects an exponential function as the mapping function of the brightness of each pixel in the image before and after enhancement. The power exponential parameter of the exponential function used in the gamma transform is usually called the gamma parameter. The setting of this parameter directly affects the result of image contrast enhancement. Inappropriate parameter setting may lead to over-enhancement or under-enhancement, and different input images usually require different parameters to obtain better enhancement results. Most existing applications use traversing multiple parameter values ​​to manually select the optimal enhancement result or set a parameter value based on experience. Manually selecting the gamma parameter value is extremely time-consuming and basically impossible to implement in applications such as video processing. The gamma parameter value set based on experience can usually only obtain roughly good enhancement results, and it is difficult to obtain better enhancement results for a single image. Summary of the invention

[0005] The purpose of the present invention is to solve the problems in the prior art and to provide an image contrast enhancement method and system.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] A method for enhancing image contrast, the method comprising the following steps:

[0008] Step 1: Input the image to be enhanced;

[0009] Step 2: Perform color space conversion and channel separation on the input image to be enhanced to obtain a grayscale image of the image to be enhanced;

[0010] Step 3: Calculate the histogram of the grayscale image;

[0011] Step 4: Calculate the normalization coefficient of the histogram;

[0012] Step 5: Calculate the preset weight of the Gamma parameter value according to the gray level of the histogram;

[0013] Step 6: Calculate the Gamma parameter value according to the histogram obtained in steps 3, 4, and 5, the normalization coefficient of the histogram, and the preset weight;

[0014] Step 7: Use the Gamma parameter value to perform Gamma transformation on the grayscale image, and obtain the enhanced image through channel merging and color space conversion.

[0015] Furthermore, step 2 is as follows: the input image to be enhanced is converted into the HSV space to obtain the HSV image of the image to be enhanced, and then the converted HSV image is channel separated into three channels of hue, saturation and brightness, and the brightness channel image is used as the grayscale image of the image to be enhanced.

[0016] Furthermore, when the image to be enhanced input in step 1 is a grayscale image, the grayscale image in step 2 is the input image to be enhanced.

[0017] Furthermore, in step 3, the histogram of the grayscale image is hist I (i), i=0,1,…K-2,K-1, where hist I (i) represents the total number of pixels with gray value i in the grayscale image I, K is the total grayscale level, and K is any integer value greater than 2.

[0018] Furthermore, in step 4, the normalization coefficient Z is calculated as follows:

[0019]

[0020] Furthermore, in step 5, the grayscale level preset weight of the histogram is a weight corresponding to each grayscale level of the grayscale histogram, and the preset weight ω i The calculation expression is as follows:

[0021]

[0022] Furthermore, in step six, the calculation expression of the Gamma parameter value γ is:

[0023]

[0024] The present invention also provides an image contrast enhancement system, comprising:

[0025] (1) An image acquisition module to be enhanced, used to acquire an image to be enhanced with problems such as overexposure, underexposure or backlight as an input image;

[0026] (2) A grayscale image acquisition module for the image to be enhanced, which is used to perform color space conversion and channel separation on the input image to extract the grayscale image of the image to be enhanced;

[0027] (3) a histogram generation module, used to calculate the histogram of the grayscale image of the image to be enhanced;

[0028] (4) a histogram normalization module, used to calculate the histogram normalization coefficient of the grayscale image to be enhanced;

[0029] (5) a preset weight generation module, used to obtain a preset weight for calculating a Gamma parameter value;

[0030] (6) a Gamma parameter value calculation module, used to calculate the Gamma parameter value using the histogram of the grayscale image to be enhanced, the normalization coefficient of the histogram, and the preset weight of the Gamma parameter value;

[0031] (7) An enhanced image generation module is used to apply Gamma transformation to the grayscale image to be enhanced to obtain an enhanced image grayscale image, and to generate an enhanced image by channel merging and color space inverse conversion of the enhanced image grayscale image.

[0032] Compared with the prior art, the present invention has the following beneficial effects:

[0033] The present invention provides an image contrast enhancement method and system. The method obtains appropriate Gamma transformation parameter values ​​by calculating the histogram of a grayscale image, the normalization coefficient of the histogram, and the preset weights of the Gamma parameter value. For each input image, time-consuming traversal search is not required. Instead, the Gamma parameter of the Gamma transformation that makes the image histogram evenly distributed is directly selected through calculation and adaptiveness. The enhanced image is obtained through Gamma transformation, channel merging, and color space conversion. The problem of over-enhancement or under-enhancement of the image while improving the image contrast is effectively solved, and the visual effect of the image is improved and easy to implement. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 It is a workflow diagram of an image contrast enhancement method provided by the present invention;

[0035] Figure 2 is the grayscale image sample 1 to be enhanced used in the first embodiment of the present invention;

[0036] Figure 3 is an enhanced image after the image sample 1 in the first embodiment of the present invention is subjected to Gamma transformation using different Gamma parameters;

[0037] Figure 4 is an enhanced image of the image sample 1 in the first embodiment of the present invention after using the method of the present invention;

[0038] Figure 5 is the color image sample 1 to be enhanced used in the second embodiment of the present invention;

[0039] Figure 6 is an enhanced image after the image sample 1 in the second embodiment of the present invention is subjected to Gamma transformation using different Gamma parameters;

[0040] Figure 7 is an enhanced image of the image sample 1 in the second embodiment of the present invention after the method of the present invention is used;

[0041] Figure 8 is the color image sample 2 to be enhanced used in the second embodiment of the present invention;

[0042] Fig. 9 is an enhanced image obtained by using different histogram equalization-based methods for the image sample 2 in the second embodiment of the present invention;

[0043] Fig.10 is an enhanced image of the image sample 2 in the second embodiment of the present invention after using the method of the present invention;

[0044] Fig.11 is the color image sample 3 to be enhanced used in the second embodiment of the present invention;

[0045] Fig.12 is an enhanced image obtained by using different histogram equalization-based methods for the image sample 3 in the second embodiment of the present invention;

[0046] Fig.13 is an enhanced image of the image sample 3 in the second embodiment of the present invention after using the method of the present invention;

[0047] Fig.14 It is a module diagram of an image contrast enhancement system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0048] The present invention is further described in detail below in conjunction with the accompanying drawings:

[0049] like Figure 1 As shown, the present invention provides an image contrast enhancement method, the method comprising the following steps:

[0050] Step 1: Input the image to be enhanced;

[0051] Step 2: Perform color space conversion and channel separation on the input image to be enhanced to obtain a grayscale image of the image to be enhanced;

[0052] Step 3: Calculate the histogram of the grayscale image to obtain the histogram of the grayscale image to be enhanced;

[0053] Step 4: Calculate the normalization coefficient of the histogram;

[0054] Step 5: Calculate the preset weight of the Gamma parameter value based on the grayscale level of the histogram;

[0055] Step 6: Calculate the Gamma parameter value according to the histogram obtained in steps 3, 4, and 5, the normalization coefficient of the histogram, and the preset weight;

[0056] Step 7: Use the Gamma parameter value to perform Gamma transformation on the grayscale image, and obtain the enhanced image through channel merging and color space conversion.

[0057] The specific implementation methods of steps 2 to 7 are described in detail below based on different implementation scenarios.

[0058] Embodiment 1: Taking the input image as a grayscale image and the histogram grayscale level K=256 as an example, the specific implementation methods of steps 2 to 7 of the present invention are described in detail.

[0059] Step 2: Since the input image X is a grayscale image, the grayscale image I of the image to be enhanced is the input image, that is, I=X.

[0060] Step 3: Obtain the histogram of the grayscale image I of the image to be enhanced.

[0061] If the histogram grayscale level is 256, the obtained histogram is hist I (i), i=0,1,…254,255. Among them, hist I (i) represents the total number of pixels with grayscale value i in grayscale image I. I (i) represents the total number of pixels with grayscale value i in the grayscale image I.

[0062] Step 4: Obtain the normalization coefficient of the grayscale histogram of the image to be enhanced. The method for calculating the histogram normalization coefficient Z is:

[0063]

[0064] Step 5: Preset the weights used to calculate the Gamma parameter value. The preset weight calculation method is:

[0065]

[0066] Preset weight ω i ,i=0,1,…254,255 can be calculated offline and stored in the cache, and then read from the cache when the system is used in real time.

[0067] Step 6: Calculate the Gamma parameter value of the Gamma transformation. The calculation method of the Gamma parameter value γ is

[0068]

[0069] Step 7: Obtain the enhanced image Y.

[0070] Since the image to be enhanced input in step 1 is a grayscale image, the grayscale value of each pixel in the enhanced image Y is obtained by Gamma transformation of the grayscale value of the corresponding pixel position in the grayscale image I of the image to be enhanced, that is, Where M is the total number of rows of the image to be enhanced, and N is the total number of columns of the image to be enhanced.

[0071] Embodiment 2: Taking the input image as a color image and the histogram grayscale level K=256 as an example, the specific implementation methods of steps 2 to 7 of the present invention are described in detail.

[0072] In the method provided by the present invention, when the input image in step 1 is a color image, its specific implementation process will be different from that in embodiment 1 in the processing of step 2 and step 7.

[0073] Step 2: Obtain a grayscale image I of the image to be enhanced. When the input image to be enhanced X is a color image, this step includes multiple sub-steps.

[0074] Step 2.1: Obtain the HSV image of the image to be enhanced X according to the color space conversion formula

[0075] Step 2.2: Convert the HSV image Channel separation is performed into three channels: hue H, saturation S, and brightness V, and the images X corresponding to the three channels are obtained respectively. H , X S and X V .

[0076] Step 2.3: Use the brightness channel image as the grayscale image I of the image to be enhanced, that is, I = X V .

[0077] The implementation method of steps 3 to 6 is the same as that of the first embodiment.

[0078] Step 7: Obtain enhanced image Y. Since the image to be enhanced input in step 1 is a color image, this step includes multiple sub-steps.

[0079] Step 7.1: Calculate the grayscale image J of the enhanced image. The grayscale value of each pixel in J is obtained by Gamma transformation of the grayscale value of the corresponding pixel position in the grayscale image I of the image to be enhanced, that is, γ is the Gamma parameter value calculated in step 6.

[0080] Step 7.2: Get the HSV image of the enhanced image Merge the hue H channel image and saturation S channel image separated in step 2 and the grayscale image of the enhanced image obtained in step 7.1 to obtain the HSV image of the enhanced image.

[0081] Step 7.3: HSV image of the enhanced image Apply the inverse color space transformation corresponding to step 2.1 to obtain the enhanced image Y.

[0082] The effect of the present invention is specifically described below in conjunction with embodiments:

[0083] Figure 2 It is the grayscale image sample 1 to be enhanced used in the first embodiment of the present invention. Figure 3 Yes Figure 2 The image samples in the figure are enhanced images obtained by Gamma transformation using different Gamma parameters, where (a) Gamma parameter is 0.4; (b) Gamma parameter is 0.8; (c) Gamma parameter is 1.2. It can be seen that Figure 2 The middle image is obviously brighter due to overexposure. Figure 3 The enhanced image obtained by using a smaller Gamma parameter has a worse visual effect than the image to be enhanced, and the enhanced image obtained by using a Gamma parameter of 1.2 has a relatively better visual effect than the image to be enhanced. Figure 4 Yes Figure 2 The image samples in FIG. 1 are enhanced images obtained by using the method of the present invention. It can be seen that the enhanced images obtained by using the method of the present invention have the best visual effect.

[0084] Figure 5 It is the color image sample 1 to be enhanced used in the second embodiment of the present invention. Figure 6 yes Figure 5 The enhanced images obtained by Gamma transformation using different Gamma parameters for the images in , where (a) Gamma parameter is 0.4; (b) Gamma parameter is 0.8; (c) Gamma parameter is 1.2. Figure 7 yes Figure 5 The image in the figure is an enhanced image obtained by the method of the present invention. It can be seen that Figure 5 The image in the figure has obvious dark areas due to underexposure. Figure 6 The enhanced image obtained by using a smaller Gamma parameter has a relatively better visual effect. Figure 7 The enhanced image obtained by using the method of the present invention has the best visual effect.

[0085] Figure 8 It is the color image sample 2 to be enhanced used in the second embodiment of the present invention. Fig. 9 yes Figure 8 The images in the figure are enhanced using different histogram equalization based methods, (a) HE; (b) CLAHE; (c) WTHE. Fig.10 yes Figure 8 The image in the figure is enhanced using the method of the present invention. It can be seen that the images enhanced by HE and WTHE are relatively Figure 8 The contrast of the original image in is significantly improved, but the problem of over-enhancement also occurs. Although CLAHE avoids over-enhancement, the contrast of the forest area in the figure is insufficient. Fig.10 The enhanced image obtained by using the method of the present invention has the best visual effect.

[0086] Fig.11 It is the color image sample 3 to be enhanced used in the second embodiment of the present invention. Fig.12yes Fig.11 The enhanced images obtained by using different histogram equalization-based methods in the middle image: (a) HE; (b) CLAHE; (c) WTHE. Fig.13 yes Fig.11 The image in the figure is enhanced using the method of the present invention. It can be seen that the images enhanced by HE and WTHE are relatively Fig.11 The contrast of the original image is significantly improved, but the white cup and plate area on the table is over-enhanced. Although CLAHE avoids over-enhancement, the contrast of the flowers in the corner of the image is not improved enough. Fig.13 The enhanced image obtained by using the method of the present invention has the best visual effect.

[0087] Fig.14 : is a module diagram of an image contrast enhancement system according to an embodiment of the present invention. Fig.14 As shown, the system consists of an image acquisition module to be enhanced, an image grayscale image acquisition module to be enhanced, a histogram generation module, a histogram normalization module, a preset weight generation module, a Gamma parameter value calculation module and an enhanced image generation module. Among them, the image acquisition module to be enhanced is used to obtain the image to be enhanced with problems such as overexposure, underexposure or backlight as the input image; the grayscale image acquisition module to be enhanced is used to perform color space conversion and channel separation on the input image to extract the grayscale image of the image to be enhanced; the histogram generation module is used to calculate the histogram of the extracted grayscale image of the image to be enhanced; the histogram normalization module is used to calculate the histogram normalization coefficient of the grayscale image of the image to be enhanced; the preset weight generation module is used to obtain the preset weight for calculating the Gamma parameter value, which can be calculated offline in advance and stored in the cache, but is read from the cache when applied in real time; the Gamma parameter value calculation module is used to calculate the Gamma parameter value using the histogram of the grayscale image of the image to be enhanced, the histogram normalization coefficient of the grayscale image of the image to be enhanced, and the preset weight; the enhanced image generation module is used to apply the Gamma transformation to the grayscale image of the image to be enhanced to obtain the grayscale image of the enhanced image, and generate the enhanced image by channel merging and color space inverse conversion of the enhanced image grayscale image.

[0088] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for enhancing image contrast, It is characterized in that The method comprises the following steps: Step 1: Input the image to be enhanced; Step 2: Perform color space conversion and channel separation on the input image to be enhanced to obtain a grayscale image of the image to be enhanced; Step 3: Calculate the histogram of the grayscale image. The histogram of the grayscale image is , i=0,1,…K-2,K-1, where, Represents grayscale image I The total number of pixels with gray value i, K is the total gray level, and K is any integer value greater than 2; Step 4: Calculate the normalization coefficient Z of the histogram. The specific calculation method is: ; Step 5: Calculate the preset weight of the Gamma parameter value according to the grayscale level of the histogram. The preset weight of the grayscale level of the histogram is a weight for each grayscale level of the grayscale histogram. The preset weight 𝜔 i The calculation expression is as follows: ; Step 6: Calculate Gamma based on the histogram obtained in steps 3, 4, and 5, the normalization coefficient of the histogram, and the preset weights The calculation expression of parameter value 𝛾,𝛾 is: ; Step 7: Use the Gamma parameter value to perform Gamma transformation on the grayscale image, and obtain the enhanced image through channel merging and color space conversion.

2. The image contrast enhancement method according to claim 1, It is characterized in that Step 2 is as follows: convert the input image to be enhanced into the HSV space to obtain the HSV image of the image to be enhanced, then perform channel separation on the converted HSV image into three channels of hue, saturation and brightness, and use the brightness channel image as the grayscale image of the image to be enhanced.

3. The image contrast enhancement method according to claim 1, It is characterized in that When the image to be enhanced input in step 1 is a grayscale image, the grayscale image in step 2 is the input image to be enhanced.

4. An image contrast enhancement system based on the image contrast enhancement method according to claim 1, It is characterized in that include: (1) An image acquisition module to be enhanced, used to acquire an image to be enhanced with problems such as overexposure, underexposure or backlight as an input image; (2) A grayscale image acquisition module for the image to be enhanced, which is used to perform color space conversion and channel separation on the input image to extract the grayscale image of the image to be enhanced; (3) A histogram generation module, used to calculate the histogram of the grayscale image of the image to be enhanced; (4) Histogram normalization module, used to calculate the histogram normalization coefficient of the grayscale image to be enhanced; (5) A preset weight generation module, used to obtain the preset weight for calculating the Gamma parameter value; (6) a Gamma parameter value calculation module, used to calculate the Gamma parameter value using the histogram of the grayscale image to be enhanced, the normalization coefficient of the histogram and the preset weight of the Gamma parameter value; (7) An enhanced image generation module is used to apply Gamma transformation to the grayscale image to be enhanced to obtain an enhanced image grayscale image, and to generate an enhanced image by channel merging and color space inverse conversion of the enhanced image grayscale image.