An image contrast enhancement method, device, equipment and storage medium

By using a Gaussian stretch template and a grayscale mapping function, the problems of inconsistent contrast and computational complexity in existing image enhancement methods are solved, achieving fast and effective image contrast enhancement applicable to both grayscale and color images.

CN115829872BActive Publication Date: 2026-03-17CASI VISION TECH (BEIJING) CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-12
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing image enhancement methods suffer from problems such as inconsistent changes in the overall grayscale mean of the image, high computational cost, and low efficiency. In particular, image enhancement methods based on contrast stretching, Gamma correction, and Retinex theory exhibit inconsistent results and are computationally complex under different grayscale distributions.

Method used

By using a pre-constructed Gaussian stretch template and grayscale mapping function, the enhanced pixel value is determined by statistically analyzing the cumulative probability difference between the histogram of the source image and the Gaussian stretch histogram, thereby enhancing image contrast and avoiding significant changes to the overall grayscale distribution.

Benefits of technology

It achieves rapid enhancement of image contrast while maintaining the overall grayscale distribution and mean of the image, is applicable to various image types, and simplifies the calculation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115829872B_ABST
    Figure CN115829872B_ABST
Patent Text Reader

Abstract

The present disclosure provides an image contrast enhancement method, device, equipment and storage medium, which comprises the following steps: obtaining a pixel value of a source image; presetting an enhancement factor; inputting the enhancement factor and the pixel value of the source image into an enhancement function to obtain an enhanced pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian stretching template and a gray mapping function between the pixel value of the source image and the enhanced pixel value, which can not only achieve the purpose of quickly enhancing the image, but also can change the overall gray distribution and the gray mean value of the source image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing, and more particularly to a method, apparatus, device, and storage medium for enhancing image contrast. Background Technology

[0002] In the field of image analysis and processing, the contrast between the image background and the target object is the foundation of image analysis, processing, and target detection. Image blurring and low contrast will affect the visual effect of the image, as well as the image analysis, processing, and target object detection.

[0003] Existing image processing methods for image enhancement mainly include contrast stretching, gamma correction, histogram equalization, and Retinex-based image enhancement. Contrast stretching directly transforms the image's grayscale values ​​using a linear transformation function to obtain the target grayscale value, thus enhancing the image. Gamma correction uses a nonlinear function, primarily an exponential function, to nonlinearly transform the image's grayscale values ​​to obtain the target grayscale value. Histogram equalization transforms the image into a uniformly distributed grayscale value using a histogram integral probability function, achieving equalization enhancement of the source image. Retinex-based image enhancement methods calculate the relationship between the source image data and the incident and reflected component data to achieve image enhancement.

[0004] However, contrast stretching and gamma correction methods significantly alter the overall grayscale mean of the source image and cannot use a single set of standard parameters to satisfy image enhancement needs in different situations. Histogram equalization methods suffer from inconsistent grayscale transformations, causing the entire image to shift towards the grayscale 255 region. Furthermore, they are affected by the histogram distribution of the source image; the same image can have different equalization effects due to varying grayscale distribution interference. Image enhancement methods based on Retinex theory require calculating incident component data, resulting in high computational cost and low efficiency. Summary of the Invention

[0005] This disclosure provides a method, apparatus, device, and storage medium for enhancing image contrast, in order to at least solve the above-mentioned technical problems existing in the prior art.

[0006] According to a first aspect of this disclosure, an image contrast enhancement method is provided, the method comprising:

[0007] Get the pixel values ​​of the source image;

[0008] An enhancement factor is preset, and the enhancement factor and the pixel values ​​of the source image are input into an enhancement function to obtain enhanced pixel values ​​corresponding to the pixel values ​​of the source image. The enhancement function includes a pre-constructed Gaussian stretch template and a grayscale mapping function between the pixel values ​​of the source image and the enhanced pixel values.

[0009] In one possible implementation, the enhancement factor and the pixel values ​​of the source image are input into an enhancement function to obtain enhanced pixel values ​​corresponding to the pixel values ​​of the source image, including:

[0010] The enhancement factor is input into the Gaussian stretch template within the enhancement function;

[0011] Based on the pixel values ​​of the source image, a histogram of the source image is calculated;

[0012] The source image's histogram is stretched using the Gaussian stretch template to obtain the source image's Gaussian stretched histogram.

[0013] Calculate the cumulative probability difference between the cumulative probability of the histogram of the source image and the cumulative probability of the Gaussian stretched histogram of the source image;

[0014] The enhanced pixel value corresponding to the pixel value of the source image is determined by using the cumulative probability difference and the grayscale mapping function within the enhancement function.

[0015] In one possible implementation, calculating the cumulative probability difference between the histogram cumulative probability of the source image and the Gaussian stretched histogram cumulative probability of the source image includes:

[0016] The histogram of the source image is normalized, and the cumulative probability is calculated based on the normalized histogram of the source image, which is used as the cumulative histogram probability of the source image.

[0017] The Gaussian stretched histogram of the source image is normalized, and the cumulative probability is calculated based on the normalized Gaussian stretched histogram of the source image, which is used as the cumulative probability of the Gaussian stretched histogram of the source image.

[0018] Based on the cumulative probability of the histogram of the source image, calculate the cumulative probability difference between each histogram pixel value and the cumulative probability of the Gaussian stretched histogram of the source image.

[0019] In one possible implementation, determining the enhanced pixel value corresponding to the pixel value of the source image using the cumulative probability difference and the grayscale mapping function within the enhancement function includes:

[0020] Among the cumulative probability differences between each histogram pixel value of the cumulative probability of the source image and all Gaussian stretched histogram pixel values ​​of the cumulative probability of the source image, the minimum cumulative probability difference of each histogram pixel value is determined.

[0021] The Gaussian stretched histogram pixel value corresponding to the minimum cumulative probability difference of each histogram pixel value is used as the enhanced pixel value corresponding to each pixel value of the source image.

[0022] In one possible implementation, normalizing the histogram of the source image and calculating the cumulative probability based on the normalized histogram of the source image, as the cumulative histogram probability of the source image, includes:

[0023] The histogram of the source image is normalized, and the cumulative histogram probability of the source image is determined by calculating the mean cumulative probability of the normalized source image histogram. The calculation formula is as follows:

[0024]

[0025]

[0026] Where H(i) is the histogram cumulative probability of the source image, h(i) is the normalized histogram of the source image, and i is the histogram pixel value.

[0027] In one possible implementation, normalizing the Gaussian stretched histogram of the source image and calculating the cumulative probability based on the normalized Gaussian stretched histogram of the source image, as the cumulative probability of the Gaussian stretched histogram of the source image, includes:

[0028] The Gaussian stretched histogram of the source image is normalized, and the cumulative probability of the Gaussian stretched histogram of the source image is determined by calculating the mean cumulative probability of the normalized source image. The calculation formula is as follows:

[0029]

[0030]

[0031] Where H'(j) is the cumulative probability of the Gaussian stretched histogram of the source image, h'(j) is the normalized Gaussian stretched histogram of the source image, and j is the pixel value of the Gaussian stretched histogram.

[0032] In one possible implementation, before acquiring the pixel values ​​of the source image, the method further includes:

[0033] Based on the 3δ principle, the one-dimensional continuous Gaussian function is discretized to obtain the one-dimensional discretized Gaussian function.

[0034] The one-dimensional discretized Gaussian function is summed and normalized to obtain the Gaussian stretched template.

[0035] In one possible implementation, obtaining the pixel values ​​of the source image includes:

[0036] Acquire the source image;

[0037] The pixel values ​​of the source image are determined based on the image type of the source image.

[0038] In one possible implementation, determining the pixel values ​​of the source image based on the image type of the source image includes:

[0039] If the source image is determined to be a first grayscale image, then the grayscale value of the first grayscale image is used as the pixel value of the source image; or,

[0040] If the source image is determined to be a color image or an HSV image, then the color image or the HSV image is converted into a second grayscale image, and the grayscale value of the second grayscale image is used as the pixel value of the source image.

[0041] In one possible implementation, determining the pixel values ​​of the source image based on the image type of the source image includes:

[0042] If the source image is determined to be a color image, then the R-channel image, G-channel image, and B-channel image are extracted from the color image, and the grayscale values ​​of the R-channel image, G-channel image, and B-channel image are obtained as the pixel values ​​of the source image; or,

[0043] If the source image is determined to be an HSV image, then the H channel image, S channel image, and V channel image are extracted from the HSV image, and the grayscale values ​​of the H channel image, the S channel image, and the V channel image are obtained as the pixel values ​​of the source image.

[0044] In one possible implementation, the step of inputting the enhancement factor and the pixel values ​​of the source image into an enhancement function to obtain enhanced pixel values ​​corresponding to the pixel values ​​of the source image includes:

[0045] Input the enhancement factor into the enhancement function;

[0046] If the source image is determined to be a color image, then the grayscale values ​​of the R-channel image, the G-channel image, and the B-channel image are input into the enhancement function to obtain the enhanced pixel values ​​corresponding to the grayscale values ​​of the R-channel image, the G-channel image, and the B-channel image, respectively. These enhanced pixel values ​​are then synthesized into a color image using the first image conversion formula; or...

[0047] If the source image is determined to be an HSV image, the grayscale values ​​of the H-channel image, the S-channel image, and the V-channel image are input into the enhancement function to obtain enhanced pixel values ​​corresponding to the grayscale values ​​of the H-channel image, the S-channel image, and the V-channel image, respectively. These enhanced pixel values ​​are then synthesized into a color image using a second image conversion formula. According to a second aspect of this disclosure, an image contrast enhancement apparatus is provided, the apparatus comprising:

[0048] The pixel value acquisition module is used to acquire the pixel values ​​of the source image;

[0049] An enhancement module is used to preset an enhancement factor, input the enhancement factor and the pixel values ​​of the source image into an enhancement function to obtain enhanced pixel values ​​corresponding to the pixel values ​​of the source image. The enhancement function includes a pre-constructed Gaussian stretch template and a grayscale mapping function between the pixel values ​​of the source image and the enhanced pixel values.

[0050] In one possible implementation, the enhancement module is specifically used for:

[0051] The enhancement factor is input into the Gaussian stretch template within the enhancement function;

[0052] Based on the pixel values ​​of the source image, a histogram of the source image is calculated;

[0053] The source image's histogram is stretched using the Gaussian stretch template to obtain the source image's Gaussian stretched histogram.

[0054] Calculate the cumulative probability difference between the cumulative probability of the histogram of the source image and the cumulative probability of the Gaussian stretched histogram of the source image;

[0055] The enhanced pixel value corresponding to the pixel value of the source image is determined by using the cumulative probability difference and the grayscale mapping function within the enhancement function.

[0056] In one possible implementation, the enhancement module is specifically used for:

[0057] The histogram of the source image is normalized, and the cumulative probability is calculated based on the normalized histogram of the source image, which is used as the cumulative histogram probability of the source image.

[0058] The Gaussian stretched histogram of the source image is normalized, and the cumulative probability is calculated based on the normalized Gaussian stretched histogram of the source image, which is used as the cumulative probability of the Gaussian stretched histogram of the source image.

[0059] Based on the cumulative probability of the histogram of the source image, calculate the cumulative probability difference between each histogram pixel value and the cumulative probability of the Gaussian stretched histogram of the source image.

[0060] In one possible implementation, the enhancement module is specifically used for:

[0061] Among the cumulative probability differences between each histogram pixel value of the cumulative probability of the source image and all Gaussian stretched histogram pixel values ​​of the cumulative probability of the source image, the minimum cumulative probability difference of each histogram pixel value is determined.

[0062] The Gaussian stretched histogram pixel value corresponding to the minimum cumulative probability difference of each histogram pixel value is used as the enhanced pixel value corresponding to each pixel value of the source image.

[0063] In one possible implementation, the enhancement module is specifically used for:

[0064] The histogram of the source image is normalized, and the cumulative histogram probability of the source image is determined by calculating the mean cumulative probability of the normalized source image histogram. The calculation formula is as follows:

[0065]

[0066]

[0067] Where H(i) is the histogram cumulative probability of the source image, h(i) is the normalized histogram of the source image, and i is the histogram pixel value.

[0068] In one possible implementation, the enhancement module is specifically used for:

[0069] The Gaussian stretched histogram of the source image is normalized, and the cumulative probability of the Gaussian stretched histogram of the source image is determined by calculating the mean cumulative probability of the normalized source image. The calculation formula is as follows:

[0070]

[0071]

[0072] Where H'(j) is the cumulative probability of the Gaussian stretched histogram of the source image, h'(j) is the normalized Gaussian stretched histogram of the source image, and j is the pixel value of the Gaussian stretched histogram.

[0073] In one possible implementation, it further includes:

[0074] The template construction module is used to discretize the one-dimensional continuous Gaussian function according to the 3δ principle before obtaining the pixel values ​​of the source image, so as to obtain a one-dimensional discretized Gaussian function.

[0075] The one-dimensional discretized Gaussian function is summed and normalized to obtain the Gaussian stretched template.

[0076] In one possible implementation, the pixel value acquisition module is specifically used for:

[0077] Acquire the source image;

[0078] The pixel values ​​of the source image are determined based on the image type of the source image.

[0079] In one possible implementation, the pixel value acquisition module is specifically used for:

[0080] If the source image is determined to be a first grayscale image, then the grayscale value of the first grayscale image is used as the pixel value of the source image; or,

[0081] If the source image is determined to be a color image or an HSV image, then the color image or the HSV image is converted into a second grayscale image, and the grayscale value of the second grayscale image is used as the pixel value of the source image.

[0082] In one possible implementation, the pixel value acquisition module is specifically used for:

[0083] If the source image is determined to be a color image, then the R-channel image, G-channel image, and B-channel image are extracted from the color image, and the grayscale values ​​of the R-channel image, G-channel image, and B-channel image are obtained as the pixel values ​​of the source image; or,

[0084] If the source image is determined to be an HSV image, then the H channel image, S channel image, and V channel image are extracted from the HSV image, and the grayscale values ​​of the H channel image, the S channel image, and the V channel image are obtained as the pixel values ​​of the source image.

[0085] In one possible implementation, the enhancement module is specifically used for:

[0086] Input the enhancement factor into the enhancement function;

[0087] If the source image is determined to be a color image, then the grayscale values ​​of the R-channel image, the G-channel image, and the B-channel image are input into the enhancement function to obtain the enhanced pixel values ​​corresponding to the grayscale values ​​of the R-channel image, the G-channel image, and the B-channel image, respectively. These enhanced pixel values ​​are then synthesized into a color image using the first image conversion formula; or...

[0088] If the source image is determined to be an HSV image, the grayscale values ​​of the H-channel image, the S-channel image, and the V-channel image are input into the enhancement function to obtain the enhanced pixel values ​​corresponding to the grayscale values ​​of the H-channel image, the S-channel image, and the V-channel image, respectively, and then synthesized into a color image using the second image conversion formula.

[0089] According to a third aspect of this disclosure, an electronic device is provided, comprising:

[0090] At least one processor; and

[0091] A memory communicatively connected to the at least one processor; wherein,

[0092] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the methods described in this disclosure.

[0093] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions for causing the computer to perform the methods described in this disclosure.

[0094] The image contrast enhancement method, apparatus, device, and storage medium disclosed herein acquire pixel values ​​of a source image; preset an enhancement factor; input the enhancement factor and the pixel values ​​of the source image into an enhancement function to obtain enhanced pixel values ​​corresponding to the pixel values ​​of the source image. The enhancement function includes a pre-constructed Gaussian stretch template and a grayscale mapping function between the pixel values ​​of the source image and the enhanced pixel values. This not only achieves the purpose of rapidly enhancing the image but also minimizes changes to the overall grayscale distribution and grayscale mean of the source image.

[0095] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0096] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. Several embodiments of this disclosure are illustrated in the drawings by way of example and not limitation, in which:

[0097] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts.

[0098] Figure 1 A flowchart of an image contrast enhancement method provided in Embodiment 2 of this disclosure is shown;

[0099] Figure 2 This illustration shows a schematic diagram of an exemplary pixel value statistical histogram based on a source image, provided in Embodiment 2 of this disclosure;

[0100] Figure 3 A schematic diagram of an exemplary source image Gaussian stretch histogram provided in Embodiment 2 of this disclosure is shown;

[0101] Figure 4 A detailed schematic diagram of an image contrast enhancement method provided in Embodiment 2 of this disclosure is shown;

[0102] Figure 5 A schematic diagram of a source image provided in Embodiment 2 of this disclosure is shown;

[0103] Figure 6 This illustration shows a schematic diagram of a source image after undergoing image contrast enhancement operation according to Embodiment 2 of this disclosure;

[0104] Figure 7 A schematic diagram of the structure of an image contrast enhancement device provided in Embodiment 3 of this disclosure is shown;

[0105] Figure 8 A schematic diagram of the composition structure of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation

[0106] To make the objectives, features, and advantages of this disclosure more apparent and understandable, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.

[0107] Example 1

[0108] Since this embodiment requires stretching the source image based on a Gaussian stretching template when enhancing image contrast, a Gaussian stretching template is constructed before the actual image contrast enhancement operation. Specifically, based on the 3δ principle, a one-dimensional continuous Gaussian function is discretized to obtain a one-dimensional discretized Gaussian function; this discretized Gaussian function is then summed and normalized to obtain the Gaussian stretching template, as detailed in the following steps:

[0109] The Gaussian stretching module in this embodiment can be a one-dimensional Gaussian stretching template. During the initial construction, as long as a fixed parameter δ is given, a one-dimensional continuous Gaussian function can be generated, as shown in the following formula:

[0110]

[0111] Where f(a) is a one-dimensional continuous Gaussian function, δ is the standard deviation, u is the mean, and a is the independent variable.

[0112] Since the Gaussian stretch template generated in this embodiment requires stretching the histogram of the source image, and the pixel values ​​of each pixel in the source image are integers between 0 and 255, this embodiment needs to discretize the one-dimensional continuous Gaussian function to be suitable for the contrast enhancement operation of the source image. Furthermore, to better control the image contrast enhancement operation and achieve a better enhancement effect, and also to simplify the calculation, this embodiment sets u = 3δ according to the 3δ principle.

[0113] Specifically, in this embodiment, after obtaining the one-dimensional continuous Gaussian function, according to the 3δ principle, let u = 3δ, and discretize the one-dimensional continuous Gaussian function f(a) to obtain the one-dimensional discretized Gaussian function, as shown in the following formula:

[0114]

[0115] Where f(b) is a one-dimensional discretized Gaussian function, b is the discretized dependent variable, and b is an integer in the range [0, 2*3δ]. This embodiment uses the 3Sigma principle to achieve image contrast enhancement by controlling a single parameter, thereby achieving the goal of controllable image enhancement. It also has the advantages of a single parameter, is simple to apply, and has intuitive effects.

[0116] In this embodiment, the obtained one-dimensional discretized Gaussian function is summed using the following formula:

[0117]

[0118] Where SUM is a one-dimensional discretized Gaussian summation function.

[0119] Since the summation of a one-dimensional continuous Gaussian function is 1, but the summation of a one-dimensional discretized Gaussian function is not 1, this embodiment needs to normalize the one-dimensional discretized Gaussian function after summing it to generate a one-dimensional Gaussian stretching template, which will be used as the subsequent Gaussian stretching template. The formula is as follows:

[0120]

[0121] Where F(b) is a one-dimensional discretized Gaussian normalization function, also known as a Gaussian stretch template.

[0122] It should be noted that the Gaussian stretching template in this embodiment extends the histogram of the source image, which is not the same as the conventional Gaussian transformation operation on the source image histogram in the prior art. The conventional transformation of the source image histogram in the prior art converts it to a Gaussian normal distribution regardless of the original histogram distribution. However, the Gaussian stretching template provided in this embodiment does not change the approximate distribution of the source image histogram before stretching. The stretching operation is achieved by limiting the value range of b [0, 2*3δ] to limit the stretching width of the horizontal coordinate of the source image histogram. Specifically, by determining the value of δ, the stretching width of the horizontal coordinate of the source image histogram can be determined. The specific process is described in detail in Embodiment 2.

[0123] Example 2

[0124] Figure 1 This is a flowchart illustrating an image contrast enhancement method provided in Embodiment 1 of this disclosure. This method can be executed by an image contrast enhancement device provided in this embodiment, which can be implemented in software and / or hardware. Specifically, the method includes:

[0125] S110. Obtain the pixel values ​​of the source image.

[0126] In this embodiment of the disclosure, obtaining the pixel values ​​of a source image includes: obtaining the source image; and determining the pixel values ​​of the source image according to the image type of the source image.

[0127] The source image can be an image captured directly by the camera or an offline image. The source image type can be a grayscale image, a color image, an HSV image, or any other type of image.

[0128] In this embodiment of the disclosure, determining the pixel value of the source image according to the image type of the source image includes: if the image type of the source image is determined to be a first grayscale image, then the grayscale value of the first grayscale image is used as the pixel value of the source image; or, if the image type of the source image is determined to be a color image or an HSV image, then the color image or HSV image is converted into a second grayscale image, and the grayscale value of the second grayscale image is used as the pixel value of the source image.

[0129] In this context, the first grayscale image refers to a source image whose original type is grayscale, such as a directly captured grayscale image or an offline image acquired in grayscale. The second grayscale image refers to a source image that is not grayscale but has been converted to grayscale. Specifically, this embodiment can obtain the pixel values ​​of the source image. If the source image is a grayscale image, the pixel values ​​can be directly input into the subsequent enhancement function. If the source image is a color image, it can first be converted to a grayscale image, and the pixel values ​​of the converted grayscale image can be input into the subsequent enhancement function. If the source image is a hue, saturation, and brightness (HSV) channel image, the HSV channel image can also be converted to a grayscale image, and the pixel values ​​of the converted grayscale image can be input into the subsequent enhancement function.

[0130] In another embodiment, determining the pixel value of the source image based on its image type includes: if the source image is determined to be a color image, then extracting the R-channel image, G-channel image, and B-channel image from the color image, and obtaining the grayscale values ​​of the R-channel image, G-channel image, and B-channel image as the pixel value of the source image; or, if the source image is determined to be an HSV image, then extracting the H-channel image, S-channel image, and V-channel image from the HSV image, and obtaining the grayscale values ​​of the H-channel image, S-channel image, and V-channel image as the pixel value of the source image.

[0131] In another embodiment, the enhancement factor and the pixel values ​​of the source image are input into the enhancement function to obtain enhanced pixel values ​​corresponding to the pixel values ​​of the source image. This includes: inputting the enhancement factor into the enhancement function; if the source image is determined to be a color image, then the gray values ​​of the R-channel image, G-channel image, and B-channel image are input into the enhancement function to obtain enhanced pixel values ​​corresponding to the gray values ​​of the R-channel image, G-channel image, and B-channel image, respectively, and then synthesizing them into a color image using a first image conversion formula; or, if the source image is determined to be an HSV image, then the gray values ​​of the H-channel image, S-channel image, and V-channel image are input into the enhancement function to obtain enhanced pixel values ​​corresponding to the gray values ​​of the H-channel image, S-channel image, and V-channel image, respectively, and then synthesizing them into a color image using a second image conversion formula.

[0132] The first image conversion formula is for converting an RGB image to a color image, and the second image conversion formula is for converting an HSV image to a color image.

[0133] In another embodiment, the corresponding operations can also be performed channel by channel. For example, when the source image is a color image, this embodiment can divide the color image into R-channel, G-channel, and B-channel images based on RGB using a conversion formula. Pixel values ​​are extracted from each of the three primary color channels and input into a subsequent enhancement function for fast image enhancement with controllable contrast. Then, the color image is synthesized using a first image conversion formula. That is, the grayscale values ​​of the R-channel, G-channel, and B-channel images are input into the enhancement function to obtain the enhanced pixel values ​​for each channel. The enhanced pixel values ​​of each channel are then synthesized into a color image using the first image conversion formula. Similarly, when the source image is an HSV channel image, this embodiment can divide the HSV image into H-channel, S-channel, and V-channel. Pixel values ​​are extracted from each of the three primary color channels and input into a subsequent enhancement function for fast image enhancement with controllable contrast. Then, the color image is synthesized back using a second image conversion formula. That is, the grayscale values ​​of the H-channel image, S-channel image, and V-channel image are input into the enhancement function to obtain the enhanced pixel values ​​of each channel image, and then the enhanced pixel values ​​of each channel are combined into a color image through the second image conversion formula.

[0134] In another embodiment, RGB color images and HSV channel images can also be converted to each other. Pixel values ​​are extracted from the converted three channels, followed by rapid image enhancement with controllable contrast, and then synthesized back into a color image. The method provided in this embodiment is applicable to various types of source images, therefore, there is no limitation on the type of source image.

[0135] S120. Preset enhancement factor, input the enhancement factor and the pixel value of the source image into the enhancement function to obtain the enhanced pixel value corresponding to the pixel value of the source image.

[0136] The enhancement function includes a pre-constructed Gaussian stretch template and a grayscale mapping function between the pixel values ​​of the source image and the enhanced pixel values.

[0137] The enhancement factor, a value set according to user needs, determines the range of grayscale enhancement and the increase in grayscale contrast of the source image. A higher enhancement factor results in greater image contrast and a more pronounced enhancement effect. The enhancement function is used to enhance the contrast of each pixel value in the source image. The enhanced pixel value is the pixel value after the source image's pixels have been enhanced by the enhancement function, which is beneficial for defect detection in industrial applications. The Gaussian stretch template can be a pre-built template used to extend and smooth the histogram of the source image without altering its original distribution. The grayscale mapping function establishes the relationship between the pixel values ​​of the source image and the enhanced pixel values; by inputting the pixel values ​​of the source image, the corresponding enhanced pixel values ​​can be directly determined.

[0138] Specifically, the enhancement function expression in this embodiment is as follows:

[0139] e(x,y)=Enhance{f(x,y),r} (5)

[0140] Where e(x,y) is the enhanced image after enhancing the source image, composed of the enhanced pixel values ​​of each pixel in the source image; Enhance{} is the enhancement function; (x,y) are the position coordinates of each pixel in the source image; f(x,y) is the pixel value of the pixel at coordinate (x,y) in the source image. r is the enhancement factor. When r = 0, the image remains unchanged, and no enhancement processing is performed on the source image; when r ≠ 0, δ = r, that is, the enhancement factor r is assigned to δ in the Gaussian stretch template within the enhancement function for calculation, thus preparing for subsequent enhancement processing of the source image.

[0141] In this embodiment of the disclosure, the enhancement factor and the pixel values ​​of the source image are input into the enhancement function to obtain the enhanced pixel value corresponding to the pixel values ​​of the source image. This includes: inputting the enhancement factor into a Gaussian stretching template within the enhancement function; calculating the histogram of the source image based on the pixel values ​​of the source image; stretching the histogram of the source image using the Gaussian stretching template to obtain a Gaussian stretched histogram of the source image; calculating the cumulative probability difference between the cumulative probability of the source image's histogram and the cumulative probability of the Gaussian stretched histogram of the source image; and determining the enhanced pixel value corresponding to the pixel values ​​of the source image using the cumulative probability difference and the grayscale mapping function within the enhancement function.

[0142] Specifically, in this embodiment, inputting the enhancement factor into the Gaussian stretch template within the enhancement function means assigning the enhancement factor r to δ within the Gaussian stretch template of the enhancement function for calculation, which is used to determine the range within which the histogram of the source image needs to be stretched in this embodiment.

[0143] This embodiment calculates the histogram of the source image based on its pixel values, using the following formula:

[0144]

[0145] N(i)=∑n(i) (7)

[0146] Where f(x,y) is the pixel value of the pixel at coordinate (x,y) in the source image; i is the gray level of the image [0,255], which is also the pixel value; n(x,y,i) is the flag value corresponding to the pixel value i at coordinate (x,y) in the source image; N(i) is the histogram of the source image, and formulas (6) and (7) are the functional representations of the histogram of the source image.

[0147] Specifically, formulas (6) and (7) above represent, based on the coordinates (x, y) of each pixel in the source image, traversing the pixel value of each pixel in the source image, and counting the number of pixels for each pixel value, as shown above. Figure 2 As shown, Figure 2 This embodiment provides an exemplary schematic diagram of a pixel value statistical histogram based on a source image. This embodiment utilizes histogram processing to significantly reduce the amount of data processing, thereby achieving the goal of rapidly enhancing the image.

[0148] In this embodiment, after generating the source image histogram, the source image histogram is stretched using a Gaussian stretching template to obtain the Gaussian stretched histogram of the source image. Specifically, the stretching operation involves convolving the source image histogram with the Gaussian stretching template, as shown in the following formula:

[0149]

[0150] Where N'(i) is the initial Gaussian stretched histogram of the source image histogram; k is a variable, an integer in the range of [-3δ, 3δ], and F(3δ+k) is the replacement of the discretized dependent variable b in the Gaussian stretched template F(b). Since the pixel value range of the source image histogram is [0, 255], after being stretched by the Gaussian stretched template, the pixel value range may exceed the limit. For example, when the original pixel value is 255, the stretched pixel value may reach 259. Therefore, this embodiment also needs to truncate the initial Gaussian stretched histogram after convolution to ensure that the pixel value does not exceed the range. Specifically, the number of pixels with N'(i) less than 0 is accumulated to N'(0), the number of pixels with N'(i) greater than 255 is accumulated to N'(255), and the truncated initial Gaussian stretched histogram is used as the Gaussian stretched histogram of the source image, denoted as N'(j).

[0151] This embodiment uses a Gaussian stretch template to stretch the histogram, which can increase the contrast of the image in a weighted manner without significantly changing the overall grayscale distribution and grayscale mean of the input image.

[0152] Since this embodiment stretches the histogram of the source image using a Gaussian stretching template, the number of pixels counted for different pixel values ​​will change, and thus the distribution of the Gaussian stretched histogram of the source image will also be different from the previous histogram. Therefore, in order to better distinguish between the two and avoid confusion, this embodiment denotes the Gaussian stretched histogram of the source image as N'(j), where j is the pixel value of the Gaussian stretched histogram, and N(i) is the histogram of the source image, where i is the pixel value of the histogram.

[0153] Figure 3 This is a schematic diagram of an exemplary source image Gaussian stretch histogram provided in this embodiment. This embodiment uses a Gaussian stretch template to... Figure 2 The histogram of the source image is stretched, and the resulting Gaussian stretched histogram of the source image does not change the distribution of the source image histogram, such as... Figure 3 As shown in the figure. In this embodiment, after obtaining the histogram and Gaussian stretched histogram of the source image respectively, the cumulative probability difference between the cumulative probability of the source image histogram and the cumulative probability of the Gaussian stretched histogram is calculated. The enhanced pixel value corresponding to the pixel value of the source image is determined by the cumulative probability difference and the gray-level mapping function in the enhancement function.

[0154] In this embodiment of the disclosure, calculating the cumulative probability difference between the histogram cumulative probability of the source image and the cumulative probability of the Gaussian stretched histogram of the source image includes: normalizing the histogram of the source image and calculating the cumulative probability based on the normalized histogram of the source image as the histogram cumulative probability of the source image; normalizing the Gaussian stretched histogram of the source image and calculating the cumulative probability based on the normalized Gaussian stretched histogram of the source image as the Gaussian stretched histogram cumulative probability of the source image; and calculating the cumulative probability difference between the cumulative probability of the source image and all the Gaussian stretched histogram pixel values ​​of the cumulative probability of the source image based on each histogram pixel value of the histogram cumulative probability.

[0155] Specifically, in this embodiment, the histogram of the source image is normalized using the following formula:

[0156]

[0157] Where h(i) is the histogram of the normalized source image, and the cumulative probability is calculated based on the histogram of the normalized source image, which is used as the cumulative probability of the histogram of the source image.

[0158] In this embodiment of the disclosure, the histogram of the source image is normalized, and the cumulative probability is calculated based on the normalized histogram of the source image as the cumulative histogram probability of the source image. This includes: normalizing the histogram of the source image, and determining the cumulative histogram probability of the source image by calculating the mean of the cumulative histogram probability of the normalized source image. The calculation formula is as follows:

[0159]

[0160]

[0161] Where H(i) is the cumulative probability of the histogram of the source image, h(i) is the histogram of the source image after normalization, and i is the pixel value of the histogram.

[0162] Specifically, in this embodiment, special pixels with histogram pixel values ​​of 0 are calculated separately using formula (10), and pixels with histogram pixel values ​​in the range of [1, 255] are calculated using formula (11) to determine the cumulative histogram probability of the source image. Compared with the prior art, the method of calculating the cumulative histogram probability of the source image in this embodiment is more reasonable.

[0163] Similarly, in this embodiment, the Gaussian stretched histogram of the source image is normalized using the following formula:

[0164]

[0165] Where h'(j) is the normalized Gaussian stretched histogram of the source image, and the cumulative probability is calculated based on the normalized Gaussian stretched histogram of the source image, which is used as the cumulative probability of the Gaussian stretched histogram of the source image.

[0166] In this embodiment of the disclosure, the Gaussian stretched histogram of the source image is normalized, and the cumulative probability is calculated based on the normalized Gaussian stretched histogram of the source image as the cumulative probability of the Gaussian stretched histogram of the source image. This includes: normalizing the Gaussian stretched histogram of the source image, and determining the cumulative probability of the Gaussian stretched histogram of the source image by calculating the mean of the cumulative probability of the normalized Gaussian stretched histogram of the source image. The calculation formula is as follows:

[0167]

[0168]

[0169] Where H'(j) is the cumulative probability of the Gaussian stretched histogram of the source image, h'(j) is the normalized Gaussian stretched histogram of the source image, and j is the pixel value of the Gaussian stretched histogram.

[0170] Specifically, in this embodiment, special pixels with a Gaussian stretched histogram value of 0 are calculated separately using formula (13), and pixels with Gaussian stretched histogram values ​​in the range of [1, 255] are calculated using formula (14) to determine the cumulative probability of the Gaussian stretched histogram of the source image. Compared with the prior art, the method of calculating the cumulative probability of the Gaussian stretched histogram of the source image in this embodiment is also more reasonable.

[0171] Since uneven transitions have a significant impact on the cumulative probability difference D(i,j) in the later processing, it is possible that the optimal value cannot be found. However, the above formulas (9)-(14) in this embodiment can effectively improve the situation of uneven transitions in pixel values ​​(grayscale levels). By calculating the mean between the cumulative probabilities of grayscale levels, a uniformly changing cumulative probability can be obtained.

[0172] In this embodiment, after obtaining the cumulative probability of the histogram and the cumulative probability of the Gaussian stretched histogram of the source image, the cumulative probability difference between each histogram pixel value based on the cumulative probability of the source image and the cumulative probability of all Gaussian stretched histogram pixel values ​​is calculated using the following formula:

[0173] D(i,j)=|H(i)-H'(j)|, i,j∈[0,255] (15)

[0174] Where D(i,j) is the cumulative probability difference, H(i) is the histogram cumulative probability of the source image, and H'(j) is the Gaussian stretched histogram cumulative probability of the source image.

[0175] Specifically, in this embodiment, the cumulative probability difference between each histogram pixel value and all Gaussian stretched histogram pixel values ​​is calculated. For example, when the histogram pixel value i is 1, the difference between its corresponding cumulative probability value and the cumulative probability value corresponding to each Gaussian stretched histogram pixel value in the range j∈[0,255] is calculated.

[0176] In this embodiment of the disclosure, the enhanced pixel value corresponding to the pixel value of the source image is determined by the cumulative probability difference and the gray-level mapping function within the enhancement function. This includes: determining the minimum cumulative probability difference among the cumulative probability differences between each histogram pixel value of the source image and all Gaussian stretched histogram pixel values ​​of the source image; and using the Gaussian stretched histogram pixel value corresponding to the minimum cumulative probability difference as the enhanced pixel value corresponding to each pixel value of the source image, calculated using the following formula:

[0177] l(i)=j, if minD(i,j),j∈[0,255] (16)

[0178] Where l(i) is the grayscale mapping function, which is the mapping function that converts each histogram pixel value i in the source image into a Gaussian stretched histogram pixel value j.

[0179] Specifically, in this embodiment, the Gaussian stretched histogram pixel value corresponding to the minimum cumulative probability difference of each histogram pixel value is used as the enhanced pixel value corresponding to each pixel value of the final source image. Using this histogram transformation method, the minimum cumulative probability difference is selected, indicating that the enhanced histogram distribution is closest to the original histogram distribution. For example, when the histogram pixel value i is 15, the difference between its corresponding cumulative probability value and the cumulative probability value corresponding to each Gaussian stretched histogram pixel value in the range j∈[0,255] is calculated. Through formula (16), among the 256 cumulative probability differences obtained, if the Gaussian stretched histogram pixel value j corresponding to the minimum cumulative probability difference is determined to be 16, then the Gaussian stretched histogram pixel value 16 is used as the enhanced pixel value corresponding to pixel value 15 in the source image.

[0180] The image contrast enhancement method provided in this embodiment obtains the pixel values ​​of the source image; presets an enhancement factor; inputs the enhancement factor and the pixel values ​​of the source image into an enhancement function to obtain enhanced pixel values ​​corresponding to the pixel values ​​of the source image. The enhancement function includes a pre-constructed Gaussian stretch template and a grayscale mapping function between the pixel values ​​of the source image and the enhanced pixel values. This method can not only achieve the purpose of quickly enhancing the image, but also change the overall grayscale distribution and grayscale mean of the source image with less change.

[0181] Figure 4 A detailed schematic diagram of an image contrast enhancement method provided in this disclosure embodiment is shown below, with specific steps as follows:

[0182] Step ①: Input the source image. The source image can be a grayscale image, a color image, or a transformed image, such as an HSV channel image.

[0183] Step 2: Generate a one-dimensional continuous Gaussian stretch template, i.e., a one-dimensional continuous Gaussian function; generate a one-dimensional Gaussian stretch template, i.e., a Gaussian stretch template, through parameter δ.

[0184] Step 3: Calculate the histogram; Calculate the histogram of the source images.

[0185] Step 4: Histogram Gaussian stretching. The statistical histogram is stretched using the generated one-dimensional Gaussian stretching template to obtain the histogram Gaussian stretching, which is the Gaussian stretched histogram of the source image.

[0186] Step 5: Calculate the cumulative probability of each gray level (histogram pixel value) in the statistical histogram;

[0187] Step 6: Calculate the cumulative probability of each gray level (pixel value of Gaussian stretched histogram) in the Gaussian stretched histogram;

[0188] Step 7: Calculate the cumulative probability difference, and calculate the difference between the cumulative probabilities of each gray level in the histogram and the histogram Gaussian stretch;

[0189] Step 8: Construct a grayscale mapping table (grayscale mapping function) to establish the grayscale transformation mapping relationship from the source image to the enhanced image;

[0190] Step 9: Enhance the image by using a grayscale mapping table to enhance the source image.

[0191] Figure 5 This is a schematic diagram of a source image provided in an embodiment of the present disclosure. Figure 6 This is a schematic diagram illustrating a source image after undergoing image contrast enhancement operations, as provided in an embodiment of this disclosure. Figure 5 and Figure 6 For the same defective display screen image, such as Figure 5 and Figure 6 As shown in the image circled by the dashed box, the image contrast enhancement method provided in this embodiment can effectively enhance the contrast of the defect surface, making it easier to observe the defect surface and facilitating the detection of industrial appearance defects.

[0192] The image contrast enhancement method provided in this embodiment uses Gaussian stretching instead of linear stretching. Therefore, it can maintain the mean distribution of the original histogram and the overall pixel distribution without changing the original histogram. The stretching only occurs within a limited range around the original pixels. For the background area in the image, since the pixel values ​​are near the mean, the stretching has little impact on it and the change is not significant. However, for abnormal pixels, the stretched abnormal pixels will stretch faster, so the contrast will be more obvious.

[0193] Example 3

[0194] Figure 7 This is a schematic diagram of an image contrast enhancement device provided in an embodiment of this disclosure. The device specifically includes:

[0195] The pixel value acquisition module 310 is used to acquire the pixel values ​​of the source image;

[0196] The enhancement module 320 is used to preset the enhancement factor, input the enhancement factor and the pixel value of the source image into the enhancement function, and obtain the enhanced pixel value corresponding to the pixel value of the source image. The enhancement function includes a pre-constructed Gaussian stretch template and a grayscale mapping function between the pixel value of the source image and the enhanced pixel value.

[0197] In one possible implementation, the enhancement module 320 is specifically used for:

[0198] The enhancement factor is input into the Gaussian stretching template within the enhancement function; based on the pixel values ​​of the source image, the histogram of the source image is calculated; the histogram of the source image is stretched using the Gaussian stretching template to obtain the Gaussian stretched histogram of the source image; the cumulative probability difference between the cumulative probability of the source image histogram and the cumulative probability of the Gaussian stretched histogram of the source image is calculated; the enhanced pixel value corresponding to the pixel value of the source image is determined using the cumulative probability difference and the gray-level mapping function within the enhancement function.

[0199] In one embodiment, the enhancement module 320 is specifically configured to: normalize the histogram of the source image and calculate the cumulative probability based on the normalized histogram of the source image, as the cumulative probability of the histogram of the source image; normalize the Gaussian stretched histogram of the source image and calculate the cumulative probability based on the normalized Gaussian stretched histogram of the source image, as the cumulative probability of the Gaussian stretched histogram of the source image; and calculate the cumulative probability difference between the cumulative probability of the source image and all the Gaussian stretched histogram pixel values ​​of the cumulative probability of the source image's histogram based on each histogram pixel value.

[0200] In one embodiment, the enhancement module 320 is specifically configured to: determine the minimum cumulative probability difference of each histogram pixel value among the cumulative probability differences between each histogram pixel value of the cumulative probability of the source image and all Gaussian stretched histogram pixel values ​​of the cumulative probability of the source image's Gaussian stretched histogram; and use the Gaussian stretched histogram pixel value corresponding to the minimum cumulative probability difference of each histogram pixel value as the enhanced pixel value corresponding to each pixel value of the source image.

[0201] In one embodiment, the enhancement module 320 is specifically used to: normalize the histogram of the source image, and determine the cumulative histogram probability of the source image by calculating the mean cumulative probability of the normalized source image histogram, the calculation formula being:

[0202]

[0203]

[0204] Where H(i) is the cumulative probability of the histogram of the source image, h(i) is the histogram of the source image after normalization, and i is the pixel value of the histogram.

[0205] In one embodiment, the enhancement module 320 is specifically used to: normalize the Gaussian stretched histogram of the source image, and determine the cumulative probability of the Gaussian stretched histogram of the source image by calculating the mean cumulative probability of the normalized source image's Gaussian stretched histogram, the calculation formula being:

[0206]

[0207]

[0208] Where H'(j) is the cumulative probability of the Gaussian stretched histogram of the source image, h'(j) is the normalized Gaussian stretched histogram of the source image, and j is the pixel value of the Gaussian stretched histogram.

[0209] In one possible implementation, it further includes: a template building module,

[0210] The template construction module is used to discretize the one-dimensional continuous Gaussian function according to the 3δ principle before obtaining the pixel values ​​of the source image, so as to obtain a one-dimensional discretized Gaussian function; the one-dimensional discretized Gaussian function is summed and normalized to obtain the Gaussian stretched template.

[0211] In one possible implementation, the pixel value acquisition module is specifically used for: acquiring a source image; and determining the pixel values ​​of the source image based on the image type of the source image.

[0212] In one possible implementation, the pixel value acquisition module is specifically used for: if the image type of the source image is determined to be a first grayscale image, then using the grayscale value of the first grayscale image as the pixel value of the source image; or, if the image type of the source image is determined to be a color image or an HSV image, then converting the color image or HSV image into a second grayscale image, and using the grayscale value of the second grayscale image as the pixel value of the source image.

[0213] In one possible implementation, the pixel value acquisition module is specifically used for: if the source image is determined to be a color image, then extracting the R-channel image, G-channel image, and B-channel image from the color image, and obtaining the grayscale values ​​of the R-channel image, G-channel image, and B-channel image as the pixel values ​​of the source image; or, if the source image is determined to be an HSV image, then extracting the H-channel image, S-channel image, and V-channel image from the HSV image, and obtaining the grayscale values ​​of the H-channel image, S-channel image, and V-channel image as the pixel values ​​of the source image.

[0214] In one possible implementation, the enhancement module is specifically used to: input enhancement factors into an enhancement function; if the source image is determined to be a color image, then input the gray values ​​of the R-channel image, G-channel image, and B-channel image into the enhancement function respectively to obtain enhanced pixel values ​​corresponding to the gray values ​​of the R-channel image, G-channel image, and B-channel image, and synthesize them into a color image using a first image conversion formula; or, if the source image is determined to be an HSV image, then input the gray values ​​of the H-channel image, S-channel image, and V-channel image into the enhancement function respectively to obtain enhanced pixel values ​​corresponding to the gray values ​​of the H-channel image, S-channel image, and V-channel image, and synthesize them into a color image using a second image conversion formula.

[0215] According to embodiments of this disclosure, this disclosure also provides an electronic device and a readable storage medium.

[0216] Figure 8 A schematic block diagram of an example electronic device 400 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0217] like Figure 8 As shown, device 400 includes a computing unit 401, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 402 or a computer program loaded from storage unit 408 into random access memory (RAM) 403. RAM 403 may also store various programs and data required for the operation of device 400. The computing unit 401, ROM 402, and RAM 403 are interconnected via bus 404. Input / output (I / O) interface 405 is also connected to bus 404.

[0218] Multiple components in device 400 are connected to I / O interface 405, including: input unit 406, such as keyboard, mouse, etc.; output unit 407, such as various types of monitors, speakers, etc.; storage unit 408, such as disk, optical disk, etc.; and communication unit 409, such as network card, modem, wireless transceiver, etc. Communication unit 409 allows device 400 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0219] The computing unit 401 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 401 performs the various methods and processes described above, such as the image contrast enhancement method. For example, in some embodiments, the image contrast enhancement method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the image contrast enhancement method described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform the image contrast enhancement method by any other suitable means (e.g., by means of firmware).

[0220] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0221] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0222] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0223] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0224] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0225] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.

[0226] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0227] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means two or more, unless otherwise explicitly specified.

[0228] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. A method of enhancing image contrast, characterized by, The method comprises: acquiring pixel values of a source image; presetting an enhancement factor, inputting the enhancement factor and the pixel values of the source image into an enhancement function to obtain enhanced pixel values corresponding to the pixel values of the source image, wherein the enhancement function comprises a pre-constructed Gaussian stretching template and a gray mapping function between the pixel values of the source image and the enhanced pixel values; when the enhancement factor is 0, not performing enhancement processing on the source image; when the enhancement factor is not 0, assigning the enhancement factor to the standard deviation of the Gaussian stretch template ; According to Principles, a one-dimensional continuous Gaussian function is discretely valued to obtain a one-dimensional discrete Gaussian function; summing the one-dimensional discrete Gaussian function and performing normalization processing to obtain the Gaussian stretching template; the inputting the enhancement factor and the pixel values of the source image into the enhancement function to obtain the enhanced pixel values corresponding to the pixel values of the source image comprises: inputting the enhancement factor into the Gaussian stretching template in the enhancement function; based on the pixel values of the source image, counting a histogram of the source image; stretching the histogram of the source image through the Gaussian stretching template to obtain a Gaussian stretched histogram of the source image; calculating a cumulative probability difference between a cumulative probability of the histogram of the source image and a cumulative probability of the Gaussian stretched histogram of the source image; determining the enhanced pixel values corresponding to the pixel values of the source image through the cumulative probability difference and the gray mapping function in the enhancement function.

2. The method of claim 1, wherein, the calculating the cumulative probability difference between the cumulative probability of the histogram of the source image and the cumulative probability of the Gaussian stretched histogram of the source image comprises: normalizing the histogram of the source image and calculating a cumulative probability based on the normalized histogram of the source image as the cumulative probability of the histogram of the source image; normalizing the Gaussian stretched histogram of the source image and calculating a cumulative probability based on the normalized Gaussian stretched histogram of the source image as the cumulative probability of the Gaussian stretched histogram of the source image; based on each histogram pixel value of the cumulative probability of the histogram of the source image, calculating a cumulative probability difference between the histogram pixel value and all Gaussian stretched histogram pixel values of the cumulative probability of the Gaussian stretched histogram of the source image.

3. The method of claim 2, wherein, the determining the enhanced pixel values corresponding to the pixel values of the source image through the cumulative probability difference and the gray mapping function in the enhancement function comprises: determining a minimum value of the cumulative probability difference of each histogram pixel value among the cumulative probability difference between each histogram pixel value of the cumulative probability of the histogram of the source image and all Gaussian stretched histogram pixel values of the cumulative probability of the Gaussian stretched histogram of the source image; taking a Gaussian stretched histogram pixel value corresponding to the minimum value of the cumulative probability difference of each histogram pixel value as the enhanced pixel value corresponding to each pixel value of the source image.

4. The method of claim 3, wherein, the normalizing the histogram of the source image and calculating the cumulative probability based on the normalized histogram of the source image as the cumulative probability of the histogram of the source image comprises: normalizing the histogram of the source image and determining the cumulative probability of the histogram of the source image by calculating a mean value of the cumulative probability of the normalized histogram of the source image, and the calculation formula is: , =0 wherein, is the cumulative probability of the histogram of the source image, is the normalized histogram of the source image, is the histogram pixel value.

5. The method of claim 4, wherein, The normalization of the Gaussian stretch histogram of the source image and the calculation of the cumulative probability based on the normalized Gaussian stretch histogram of the source image as the Gaussian stretch histogram cumulative probability of the source image comprise: The normalization of the Gaussian stretch histogram of the source image and the calculation of the cumulative probability based on the normalized Gaussian stretch histogram of the source image as the Gaussian stretch histogram cumulative probability of the source image comprise: , wherein, is the Gaussian stretch histogram cumulative probability for the source image, is the Gaussian stretch histogram for the normalized source image, is the Gaussian stretch histogram pixel value.

6. The method of claim 1, wherein, The pixel value of the source image is obtained, comprising: The source image is obtained; The pixel value of the source image is determined according to the image type of the source image.

7. The method of claim 6, wherein, The pixel value of the source image is determined according to the image type of the source image, comprising: If it is judged that the image type of the source image is a first gray-scale image, the gray-scale value of the first gray-scale image is taken as the pixel value of the source image; or, If it is judged that the image type of the source image is a color image or an HSV image, the color image or the HSV image is converted into a second gray-scale image, and the gray-scale value of the second gray-scale image is taken as the pixel value of the source image.

8. The method of claim 6, wherein, The pixel value of the source image is determined according to the image type of the source image, comprising: If it is judged that the image type of the source image is a color image, the R channel image, the G channel image and the B channel image are extracted from the color image, the gray-scale values of the R channel image, the G channel image and the B channel image are obtained as the pixel value of the source image; or, If it is judged that the image type of the source image is an HSV image, the H channel image, the S channel image and the V channel image are extracted from the HSV image, and the gray-scale values of the H channel image, the S channel image and the V channel image are obtained as the pixel value of the source image.

9. The method of claim 8, wherein, The enhancement factor and the pixel value of the source image are input into the enhancement function to obtain the enhanced pixel value corresponding to the pixel value of the source image, comprising: The enhancement factor is input into the enhancement function; If it is judged that the image type of the source image is a color image, the gray-scale values of the R channel image, the G channel image and the B channel image are input into the enhancement function respectively to obtain the enhanced pixel value corresponding to the gray-scale values of the R channel image, the G channel image and the B channel image respectively, and the enhanced pixel value is synthesized into a color image through a first image conversion formula; or, If it is judged that the image type of the source image is an HSV image, the gray-scale values of the H channel image, the S channel image and the V channel image are input into the enhancement function respectively to obtain the enhanced pixel value corresponding to the gray-scale values of the H channel image, the S channel image and the V channel image respectively, and the enhanced pixel value is synthesized into a color image through a second image conversion formula.

10. An apparatus for enhancing image contrast, characterized by, The device comprises: A pixel value acquisition module is configured to obtain a pixel value of a source image; The enhancement module is used for presetting an enhancement factor, inputting the enhancement factor and pixel values of the source image into an enhancement function to obtain enhanced pixel values corresponding to the pixel values of the source image, wherein the enhancement function comprises a pre-constructed Gaussian stretching template and a gray mapping function between the pixel values of the source image and the enhanced pixel values; when the enhancement factor is 0, the source image is not subjected to enhancement processing; and when the enhancement factor is not 0, the enhancement factor is assigned to a standard deviation of the Gaussian stretching template ​ The enhancement module is specifically configured to input the enhancement factor into a Gaussian stretching template in the enhancement function; based on a pixel value of the source image, a histogram of the source image is counted; the histogram of the source image is stretched by the Gaussian stretching template to obtain a Gaussian stretched histogram of the source image; a cumulative probability difference between a cumulative probability of the histogram of the source image and a cumulative probability of the Gaussian stretched histogram of the source image is calculated; and an enhanced pixel value corresponding to the pixel value of the source image is determined by the cumulative probability difference and a gray mapping function in the enhancement function. The device further comprises: a template construction module, configured to, before acquiring the pixel value of the source image, construct a Gaussian stretching template according to Principles, a one-dimensional continuous Gaussian function is discretely valued to obtain a one-dimensional discrete Gaussian function; the one-dimensional discrete Gaussian function is summed and normalized to obtain the Gaussian stretching template.

11. The apparatus of claim 10, wherein, The enhancement module is specifically configured to: normalize the histogram of the source image, and calculate a cumulative probability based on the normalized histogram of the source image as the cumulative probability of the histogram of the source image; normalize the Gaussian stretched histogram of the source image, and calculate a cumulative probability based on the normalized Gaussian stretched histogram of the source image as the cumulative probability of the Gaussian stretched histogram of the source image; based on each histogram pixel value of the cumulative probability of the histogram of the source image, calculate a cumulative probability difference between the histogram pixel value and all Gaussian stretched histogram pixel values of the cumulative probability of the Gaussian stretched histogram of the source image.

12. The apparatus of claim 11, wherein, The enhancement module is specifically configured to: determine a minimum value of the cumulative probability difference of each histogram pixel value among the cumulative probability differences between each histogram pixel value of the cumulative probability of the histogram of the source image and all Gaussian stretched histogram pixel values of the cumulative probability of the Gaussian stretched histogram of the source image; determine a Gaussian stretched histogram pixel value corresponding to the minimum value of the cumulative probability difference of each histogram pixel value as an enhanced pixel value corresponding to each pixel value of the source image.

13. The apparatus of claim 12, wherein, The enhancement module is specifically configured to: normalize the histogram of the source image, and determine the cumulative probability of the histogram of the source image by calculating a mean value of the cumulative probability of the normalized histogram of the source image, with a calculation formula being: , =0 wherein, is the cumulative probability of the histogram of the source image, is the normalized histogram of the source image, is the histogram pixel value.

14. The apparatus of claim 13, wherein, The enhancement module is specifically configured to: normalize the Gaussian stretched histogram of the source image, and determine the cumulative probability of the Gaussian stretched histogram of the source image by calculating a mean value of the cumulative probability of the normalized Gaussian stretched histogram of the source image, with a calculation formula being: , wherein, is the Gaussian stretch histogram cumulative probability for the source image, is the Gaussian stretch histogram for the normalized source image, is the Gaussian stretch histogram pixel value.

15. The apparatus of claim 10, wherein, The pixel value acquisition module is specifically configured to: acquire the source image; determine the pixel value of the source image according to an image type of the source image.

16. The apparatus of claim 15, wherein, The pixel value acquisition module is specifically configured to: if it is determined that the image type of the source image is a first gray image, take a gray value of the first gray image as the pixel value of the source image; or if it is determined that the image type of the source image is a color image or an HSV image, convert the color image or the HSV image into a second gray image, and take a gray value of the second gray image as the pixel value of the source image.

17. The apparatus of claim 15, wherein, The pixel value acquisition module is specifically configured to: If it is judged that the image type of the source image is a color image, R channel image, G channel image and B channel image are extracted from the color image, and the gray values of the R channel image, the G channel image and the B channel image are obtained as the pixel values of the source image. Or, If it is judged that the image type of the source image is an HSV image, H channel image, S channel image and V channel image are extracted from the HSV image, and the gray values of the H channel image, the S channel image and the V channel image are obtained as the pixel values of the source image.

18. The apparatus of claim 17, wherein, The enhancement module is specifically configured to: input the enhancement factor into the enhancement function; If it is judged that the image type of the source image is a color image, the gray values of the R channel image, the G channel image and the B channel image are respectively input into the enhancement function, and the enhanced pixel values corresponding to the gray values of the R channel image, the G channel image and the B channel image are respectively obtained, and the enhanced pixel values are synthesized into a color image through a first image conversion formula; or, If it is judged that the image type of the source image is an HSV image, the gray values of the H channel image, the S channel image and the V channel image are respectively input into the enhancement function, and the enhanced pixel values corresponding to the gray values of the H channel image, the S channel image and the V channel image are respectively obtained, and the enhanced pixel values are synthesized into a color image through a second image conversion formula.

19. An electronic device, comprising: comprise: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.

20. A non-transitory computer-readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1-9.

Citation Information

Patent Citations

  • Image enhancing method and device

    CN104504653A

  • Image mapping method based on dynamic Gaussian parameters

    CN111563851A