CN115829872A - Method, device and equipment for enhancing image contrast and storage medium - Google Patents

Method, device and equipment for enhancing image contrast and storage medium Download PDF

Info

Publication number
CN115829872A
CN115829872A CN202211591466.4A CN202211591466A CN115829872A CN 115829872 A CN115829872 A CN 115829872A CN 202211591466 A CN202211591466 A CN 202211591466A CN 115829872 A CN115829872 A CN 115829872A
Authority
CN
China
Prior art keywords
source image
histogram
image
gaussian
pixel value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211591466.4A
Other languages
Chinese (zh)
Inventor
胡昌欣
张武杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Casi Vision Technology Luoyang Co Ltd
Casi Vision Technology Beijing Co Ltd
Original Assignee
Casi Vision Technology Luoyang Co Ltd
Casi Vision Technology Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Casi Vision Technology Luoyang Co Ltd, Casi Vision Technology Beijing Co Ltd filed Critical Casi Vision Technology Luoyang Co Ltd
Priority to CN202211591466.4A priority Critical patent/CN115829872A/en
Publication of CN115829872A publication Critical patent/CN115829872A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Image Processing (AREA)

Abstract

The present disclosure provides a method, an apparatus, a device and a storage medium for enhancing image contrast, by obtaining a pixel value of a source image; presetting an enhancement factor, and inputting the enhancement factor and the pixel value of the source image into an enhancement function to obtain an enhancement pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian extension template and a gray mapping function between the pixel value of the source image and the enhancement pixel value, so that the purpose of rapidly enhancing the image can be realized, and the integral gray distribution and the gray average value of the source image can be changed less.

Description

Method, device and equipment for enhancing image contrast and storage medium
Technical Field
The present disclosure relates to the field of image processing, and in particular, to a method, an apparatus, a device, and a storage medium for enhancing image contrast.
Background
In the field of image analysis and processing, the contrast of an image background and a target object is the basis of image analysis processing and target detection, and image blurring and small contrast affect the visual effect of an image and simultaneously affect the image analysis processing and the target object detection.
In the prior art, image processing methods for image enhancement mainly include contrast stretching, gamma correction, histogram equalization, image enhancement based on Retinex theory, and the like. The contrast stretching method is to utilize a linear transformation function to directly carry out linear transformation on the gray value of an image to obtain a target gray value, so as to achieve the purpose of enhancing the image; the Gamma correction method adopts a nonlinear function, mainly an exponential function, and carries out nonlinear transformation on the gray value of an image to obtain a target gray value; the histogram equalization method utilizes a histogram integral probability function to convert the histogram integral probability function into an image with uniformly distributed gray value probability, so as to realize the equalization enhancement of the source image; the image enhancement method based on Retinex theory utilizes the relation of source image data, incident component data and reflection component data to calculate, and achieves image enhancement.
However, the contrast stretching method and the Gamma correction method can change the overall gray level mean value of the source image to a large extent, and cannot adopt a set of standard parameters to meet the image enhancement under different conditions. The histogram equalization method has the problem that different gray scale transformations are inconsistent, so that the whole image is transformed to a region with the gray scale of 255 and is influenced by the histogram distribution of a source image, and the equalization effect of the same image is different due to the fact that different gray scale distribution interferences exist. The image enhancement method based on the Retinex theory needs to calculate the incident component data, so that the image enhancement method has the defects of large calculation amount and low efficiency.
Disclosure of Invention
The present disclosure provides a method, an apparatus, a device and a storage medium for enhancing image contrast, so as to at least solve the above technical problems in the prior art.
According to a first aspect of the present disclosure, there is provided a method of enhancing image contrast, the method comprising:
acquiring 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 enhancement pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian extension template and a gray mapping function between the pixel value of the source image and the enhancement pixel value.
In an embodiment, 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 includes:
inputting the enhancement factor into a gaussian stretch template within the enhancement function;
counting a histogram of the source image based on pixel values 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 the histogram cumulative probability of the source image and the Gaussian stretched histogram cumulative probability of the source image;
and determining an enhanced pixel value corresponding to the pixel value of the source image through the accumulated probability difference value and a gray mapping function in the enhanced function.
In an embodiment, said calculating a cumulative probability difference between said histogram cumulative probability of said source image and said gaussian stretched histogram cumulative probability of said source image comprises:
normalizing the histogram of the source image, and calculating a cumulative probability based on the histogram of the normalized source image, wherein the cumulative probability is used as the histogram cumulative probability of the source image;
normalizing the Gaussian extension histogram of the source image, and calculating a cumulative probability based on the normalized Gaussian extension histogram of the source image to serve as the cumulative probability of the Gaussian extension histogram of the source image;
and calculating the cumulative probability difference value of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian stretching histogram pixel values of the Gaussian stretching histogram cumulative probability of the source image.
In an embodiment, the determining, by the cumulative probability difference value and a gray scale mapping function within the enhancement function, an enhanced pixel value corresponding to a pixel value of the source image includes:
determining a cumulative probability difference minimum value of each histogram pixel value in the cumulative probability difference values of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian spread histogram pixel values of the Gaussian spread histogram cumulative probability of the source image;
and taking the Gaussian extension histogram pixel value corresponding to the minimum value of the cumulative probability difference value of each histogram pixel value as an enhanced pixel value corresponding to each pixel value of the source image.
In an implementation manner, the 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 includes:
normalizing the histogram of the source image, and determining the histogram cumulative probability of the source image by calculating the mean value of the histogram cumulative probability of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000031
Figure BDA0003994631270000032
h (i) is the histogram cumulative probability of the source image, H (i) is the histogram of the normalized source image, and i is the histogram pixel value.
In an implementation, the normalizing the gaussian spread histogram of the source image and calculating the cumulative probability based on the normalized gaussian spread histogram of the source image as the gaussian spread histogram cumulative probability of the source image includes:
normalizing the Gaussian extension histogram of the source image, and determining the Gaussian extension histogram cumulative probability of the source image by calculating the mean value of the Gaussian extension histogram cumulative probabilities of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000033
Figure BDA0003994631270000034
h '(j) is the Gaussian extension histogram accumulation probability of the source image, H' (j) is the normalized Gaussian extension histogram of the source image, and j is the Gaussian extension histogram pixel value.
In an embodiment, before the acquiring the pixel values of the source image, the method further includes:
discretizing the one-dimensional continuous Gaussian function according to a 3 delta principle to obtain a one-dimensional discretized Gaussian function;
and summing the one-dimensional discretization Gaussian functions, and performing normalization processing to obtain the Gaussian extension template.
In an embodiment, the obtaining pixel values of the source image includes:
acquiring the source image;
and determining the pixel value of the source image according to the image type of the source image.
In an implementation, the determining the pixel values of the source image according to the image type of the source image comprises:
if the image type of the source image is judged to be a first gray image, taking the gray value of the first gray image as the pixel value of the source image; alternatively, the first and second liquid crystal display panels may be,
if the image type of the source image is judged to be a color image or an HSV image, the color image or the HSV image is converted into a second gray image, and the gray value of the second gray image is used as the pixel value of the source image.
In an embodiment, the determining the pixel values of the source image according to the image type of the source image comprises:
if the image type of the source image is judged to be a color image, extracting an R channel image, a G channel image and a B channel image from the color image, and acquiring gray values of the R channel image, the G channel image and the B channel image as pixel values of the source image; alternatively, the first and second electrodes may be,
if the image type of the source image is judged to be an HSV image, extracting an H-channel image, an S-channel image and a V-channel image through the HSV image, and obtaining gray values of the H-channel image, the S-channel image and the V-channel image as pixel values of the source image.
In an embodiment, the 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 includes:
inputting the enhancement factor into the enhancement function;
if the image type of the source image is judged to be a color image, inputting the gray values of the R channel image, the G channel image and the B channel image into the enhancement function respectively to obtain enhanced pixel values corresponding to the gray values of the R channel image, the G channel image and the B channel image respectively, and synthesizing the enhanced pixel values into the color image through a first image conversion formula; alternatively, the first and second electrodes may be,
if the image type of the source image is judged to be an HSV image, the gray values of the H channel image, the S channel image and the V channel image are input into the enhancement function respectively to obtain enhanced pixel values corresponding to the gray values of the H channel image, the S channel image and the V channel image respectively, and the enhanced pixel values are synthesized into a color image through a second image conversion formula. According to a second aspect of the present disclosure, there is provided an apparatus for enhancing image contrast, the apparatus comprising:
the pixel value acquisition module is used for acquiring the pixel value of the source image;
and the enhancement module is used for presetting an enhancement factor, inputting the enhancement factor and the pixel value of the source image into an enhancement function, and obtaining an enhancement pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian extension template and a gray mapping function between the pixel value of the source image and the enhancement pixel value.
In an embodiment, the enhancement module is specifically configured to:
inputting the enhancement factor into a gaussian stretch template within the enhancement function;
counting a histogram of the source image based on pixel values 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 the histogram cumulative probability of the source image and the Gaussian stretched histogram cumulative probability of the source image;
and determining an enhanced pixel value corresponding to the pixel value of the source image through the accumulated probability difference value and a gray mapping function in the enhanced function.
In an embodiment, the enhancement module is specifically configured to:
normalizing the histogram of the source image, and calculating a cumulative probability based on the histogram of the normalized source image, wherein the cumulative probability is used as the histogram cumulative probability of the source image;
normalizing the Gaussian extension histogram of the source image, and calculating a cumulative probability based on the normalized Gaussian extension histogram of the source image, wherein the cumulative probability is used as the cumulative probability of the Gaussian extension histogram of the source image;
and calculating the cumulative probability difference value of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian stretching histogram pixel values of the Gaussian stretching histogram cumulative probability of the source image.
In an embodiment, the enhancement module is specifically configured to:
determining a cumulative probability difference minimum value of each histogram pixel value in the cumulative probability difference values of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian spread histogram pixel values of the Gaussian spread histogram cumulative probability of the source image;
and taking the Gaussian expansion histogram pixel value corresponding to the minimum value of the cumulative probability difference value of each histogram pixel value as an enhanced pixel value corresponding to each pixel value of the source image.
In an embodiment, the enhancement module is specifically configured to:
normalizing the histogram of the source image, and determining the histogram cumulative probability of the source image by calculating the mean value of the histogram cumulative probability of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000061
Figure BDA0003994631270000062
h (i) is the histogram cumulative probability of the source image, H (i) is the histogram of the normalized source image, and i is the histogram pixel value.
In an embodiment, the enhancement module is specifically configured to:
normalizing the Gaussian extension histogram of the source image, and determining the Gaussian extension histogram cumulative probability of the source image by calculating the mean value of the Gaussian extension histogram cumulative probabilities of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000063
Figure BDA0003994631270000071
h '(j) is the Gaussian extension histogram accumulation probability of the source image, H' (j) is the normalized Gaussian extension histogram of the source image, and j is the Gaussian extension histogram pixel value.
In one embodiment, the method further comprises:
the template construction module is used for discretizing the one-dimensional continuous Gaussian function according to the 3 delta principle before the pixel value of the source image is obtained to obtain the one-dimensional discretized Gaussian function;
and summing the one-dimensional discretization Gaussian functions, and performing normalization processing to obtain the Gaussian extension template.
In an implementation manner, the pixel value obtaining module is specifically configured to:
acquiring the source image;
and determining the pixel value of the source image according to the image type of the source image.
In an implementation manner, the pixel value obtaining module is specifically configured to:
if the image type of the source image is judged to be a first gray image, taking the gray value of the first gray image as the pixel value of the source image; alternatively, the first and second electrodes may be,
if the image type of the source image is judged to be a color image or an HSV image, the color image or the HSV image is converted into a second gray image, and the gray value of the second gray image is used as the pixel value of the source image.
In an implementation manner, the pixel value obtaining module is specifically configured to:
if the image type of the source image is judged to be a color image, extracting an R channel image, a G channel image and a B channel image from the color image, and acquiring gray values of the R channel image, the G channel image and the B channel image as pixel values of the source image; alternatively, the first and second electrodes may be,
if the image type of the source image is judged to be an HSV image, extracting an H-channel image, an S-channel image and a V-channel image through the HSV image, and obtaining gray values of the H-channel image, the S-channel image and the V-channel image as pixel values of the source image.
In an embodiment, the enhancement module is specifically configured to:
inputting the enhancement factor into the enhancement function;
if the image type of the source image is judged to be a color image, inputting the gray values of the R channel image, the G channel image and the B channel image into the enhancement function respectively to obtain enhanced pixel values corresponding to the gray values of the R channel image, the G channel image and the B channel image respectively, and synthesizing the enhanced pixel values into the color image through a first image conversion formula; alternatively, the first and second liquid crystal display panels may be,
if the image type of the source image is judged to be an HSV image, the gray values of the H channel image, the S channel image and the V channel image are input into the enhancement function respectively to obtain enhanced pixel values corresponding to the gray values of the H channel image, the S channel image and the V channel image respectively, and the enhanced pixel values are synthesized into a color image through a second image conversion formula.
According to a third aspect of the present disclosure, there is provided an electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods of the present disclosure.
According to a fourth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of the present disclosure.
According to the method, the device, the equipment and the storage medium for enhancing the image contrast, the pixel value of a source image is obtained; presetting an enhancement factor, and inputting the enhancement factor and the pixel value of the source image into an enhancement function to obtain an enhancement pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian extension template and a gray mapping function between the pixel value of the source image and the enhancement pixel value, so that the purpose of rapidly enhancing the image can be realized, and the integral gray distribution and the gray average value of the source image can be changed less.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present disclosure will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present disclosure are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
in the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Fig. 1 shows a flowchart of an image contrast enhancement method provided in the second embodiment of the present disclosure;
FIG. 2 is a diagram illustrating an exemplary statistical histogram of pixel values based on a source image provided by a second embodiment of the present disclosure;
FIG. 3 is a schematic diagram illustrating an exemplary Gaussian stretched histogram of a source image according to a second embodiment of the disclosure;
fig. 4 is a detailed schematic diagram illustrating an image contrast enhancement method provided in the second embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a source image provided in the second embodiment of the disclosure;
fig. 6 is a schematic diagram illustrating a source image subjected to an image contrast enhancement operation according to a second embodiment of the disclosure;
fig. 7 is a schematic structural diagram of an image contrast enhancement apparatus provided in a third embodiment of the present disclosure;
fig. 8 shows a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, features and advantages of the present disclosure more apparent and understandable, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are only a part of the embodiments of the present disclosure, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
Example one
Since the present embodiment needs to perform the stretching operation on the source image according to the gaussian stretching template when performing the image contrast enhancement operation, the gaussian stretching template is constructed before formally performing the image contrast enhancement operation. Discretizing the one-dimensional continuous Gaussian function according to a 3 delta principle to obtain a one-dimensional discretized Gaussian function; summing the one-dimensional discretization Gaussian functions, and carrying out normalization processing to obtain a Gaussian extension template, wherein the method specifically comprises the following steps:
the gaussian stretching module of this embodiment may be a one-dimensional gaussian stretching template, and when initially constructed, a one-dimensional continuous gaussian function can be generated as long as a fixed parameter δ is given, and the formula is as follows:
Figure BDA0003994631270000101
wherein f (a) is a one-dimensional continuous Gaussian function, delta is a standard deviation, u is a mean value, and a is an independent variable.
Because the gaussian stretching template generated in this embodiment needs to stretch the histogram of the source image, and the pixel value of each pixel in the source image is an integer between 0 and 255, this embodiment needs to discretize the one-dimensional continuous gaussian function to be applicable to the contrast enhancement operation of the source image. In this embodiment, in order to better control the enhancement operation of image contrast and achieve a better enhancement effect, and in order to simplify the operation, according to the 3 δ principle, u =3 δ.
Specifically, in this embodiment, after obtaining the one-dimensional continuous gaussian function, according to the 3 δ principle, let u =3 δ, discretize the one-dimensional continuous gaussian function f (a) to obtain a one-dimensional discretized gaussian function, where the formula is as follows:
Figure BDA0003994631270000102
wherein f (b) is a one-dimensional discretization Gaussian function, b is a discretization value dependent variable, and b is an integer of [0,2 x 3 delta ]. This embodiment adopts the 3Sigma principle, realizes the enhancement effect of single parameter control image contrast to realize the controllable image enhancement's of contrast purpose, and have the advantage of single parameter, use simply, the effect is directly perceived.
In this embodiment, the obtained one-dimensional discretization gaussian function is subjected to summation, and the summation formula is as follows:
Figure BDA0003994631270000111
wherein SUM is a one-dimensional discretized gaussian SUM function.
Since the one-dimensional continuous gaussian function sum is 1, but the one-dimensional discretization gaussian function sum is not 1, in this embodiment, after the one-dimensional discretization gaussian function sum, normalization processing is performed on the one-dimensional discretization gaussian function sum, and a one-dimensional gaussian stretching template is generated and used as a subsequent gaussian stretching template, where the formula is as follows:
Figure BDA0003994631270000112
wherein, F (b) is a one-dimensional discretization Gaussian normalization function, namely a Gaussian extension template.
It should be noted that, the gaussian expansion template in this embodiment expands the histogram of the source image, which is not the same as the conventional gaussian transformation operation performed on the histogram of the source image in the prior art, and the conventional transformation performed on the histogram of the source image in the prior art is to convert the original histogram into a gaussian normal distribution regardless of the distribution of the original histogram. The gaussian expansion template provided in this embodiment expands without changing the approximate distribution of the source image histogram, the expansion operation is realized by defining the expansion width of the abscissa of the source image histogram by defining the value range [0,2 × 3 δ ] of b, specifically, by determining the δ size, the width of the gaussian expansion template expanding the abscissa of the source image histogram can be determined, and the specific process is described in detail by the second embodiment.
Example two
Fig. 1 is a flowchart of a method for enhancing image contrast according to an embodiment of the present disclosure, where the method may be executed by an apparatus for enhancing image contrast according to an embodiment of the present disclosure, and the apparatus may be implemented in software and/or hardware. The method specifically comprises the following steps:
and S110, acquiring a pixel value of the source image.
In an embodiment of the present disclosure, acquiring pixel values of a source image includes: acquiring a source image; and determining the pixel value of the source image according to the image type of the source image.
The source image may be an image directly captured by a camera or an offline image. The type of source image may be a grayscale image, a color image, an HSV image, or any other type of image.
In an embodiment of the present disclosure, determining a pixel value of a source image according to an image type of the source image includes: if the image type of the source image is judged to be the first gray image, taking the gray value of the first gray image as the pixel value of the source image; or if the image type of the source image is judged to be a color image or an HSV image, converting the color image or the HSV image into a second gray image, and taking the gray value of the second gray image as the pixel value of the source image.
The first grayscale image refers to that the original type of the source image is a grayscale image, for example, a grayscale image directly taken, or the type of the acquired offline image is a grayscale image. The second gray scale image refers to a gray scale image formed by converting the image, wherein the source image type is a non-gray scale image type. Specifically, the embodiment can obtain the pixel value of the source image, and if the source image is a gray image, the pixel value of the image can be directly input into a subsequent enhancement function; if the source image is a color image, the color image can be converted into a gray image, and the pixel value of the converted gray image is input into a subsequent enhancement function; if the source image is a Hue, saturation and Value (HSV) channel image, the HSV channel image may also be converted into a grayscale image, and the pixel Value of the converted grayscale image may be input to a subsequent enhancement function.
In another embodiment, determining the pixel values of the source image based on the image type of the source image comprises: if the image type of the source image is judged to be a color image, extracting an R channel image, a G channel image and a B channel image from the color image, and acquiring gray values of the R channel image, the G channel image and the B channel image as pixel values of the source image; or if the image type of the source image is judged to be an HSV image, extracting an H-channel image, an S-channel image and a V-channel image through the HSV image, and obtaining gray values of the H-channel image, the S-channel image and the V-channel image as pixel values of the source image.
In another embodiment, inputting 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, includes: inputting the enhancement factor into the enhancement function; if the image type of the source image is judged to be a color image, inputting the gray values of the R channel image, the G channel image and the B channel image into an enhancement function respectively to obtain enhanced pixel values corresponding to the gray values of the R channel image, the G channel image and the B channel image respectively, and synthesizing the enhanced pixel values into the color image through a first image conversion formula; or if the image type of the source image is judged to be the 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, enhancement 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 enhancement pixel values are synthesized into a color image through a second image conversion formula.
The first image conversion formula is a conversion formula for converting an RGB image into a color image, and the second image conversion formula is a conversion formula for converting an HSV image into the color image.
In another embodiment, the corresponding operation can be performed by channels. For example, for a case that a source image is a color image, the present embodiment may divide the color image into an R channel image, a G channel image, and a B channel image through a conversion formula based on RGB, extract pixel values from the three primary color channel images respectively, input the pixel values into subsequent enhancement functions, perform contrast-controllable fast image enhancement, and then synthesize the color image through a first image conversion formula. That is, the gray 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 of the respective channel images, and then the enhanced pixel values of the respective channels are synthesized into the color image through the first image conversion formula. Similarly, for the case that the source image is an HSV channel image, the present embodiment may divide the HSV image into an H channel, an S channel, and a V channel, extract pixel values from the three primary color channels respectively, input the subsequent enhancement function, perform contrast-controllable fast image enhancement, and synthesize the image back into a color image through a second image conversion formula. That is, the gray 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 of the respective channel images, and then the enhanced pixel values of the respective channels are synthesized into the color image through the second image conversion formula.
In another embodiment, the RGB color image and the HSV channel image may also be converted into each other, and pixel values are extracted from the converted three channels, and then synthesized into a color image after subsequent contrast-controllable fast image enhancement. The method provided by the embodiment is suitable for various types of source images, and therefore, the source image types are not limited.
S120, presetting an enhancement factor, and 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 values of the source image and the enhancement pixel values.
The enhancement factor may be a value set according to a user requirement, and is used to determine a gray scale range and a gray scale contrast ratio by which to enhance the source image, where the larger the enhancement factor value is, the larger the image contrast ratio is, and the more obvious the image enhancement effect is. The enhancement function refers to a function for contrast enhancing respective pixel values of a source image. The enhanced pixel value refers to a pixel value obtained by enhancing each pixel value of the source image through an enhancement function, and is beneficial to defect detection of industrial appearance. The Gaussian extension template can be a pre-constructed template and is used for extending and smoothing the histogram of the source image statistics on the basis of not changing the distribution of the original source image. The gray mapping function is a function for constructing the relationship between the pixel value of the source image and the enhanced pixel value, and is used for inputting the pixel value of the source image, so that the enhanced pixel value corresponding to the pixel value can be directly determined.
Specifically, the enhancement function expression of this embodiment is:
e(x,y)=Enhance{f(x,y),r} (5)
wherein e (x, y) is an enhanced image obtained by enhancing a source image and consists of enhanced pixel values of all pixel points in the source image; enhance { } is an enhancement function; (x, y) is the position coordinates of each pixel point of the source image; f (x, y) is the pixel value of the pixel point at the (x, y) position of the source image coordinates. r is an enhancement factor, when r =0, the image is kept unchanged, and the source image is not subjected to enhancement processing; when r ≠ 0, δ = r, that is, δ is calculated by assigning an enhancement factor r to δ in a gaussian stretching template within the enhancement function, so as to prepare for subsequent enhancement processing of the source image.
In the embodiment of the present disclosure, inputting 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, includes: inputting the enhancement factor into a Gaussian expansion template in the enhancement function; counting a histogram of the source image based on pixel values of the source image; stretching the histogram of the source image through a Gaussian stretching template to obtain a Gaussian stretched histogram of the source image; calculating the cumulative probability of the histogram of the source image and the cumulative probability difference value between the Gaussian extension histogram cumulative probabilities of the source image; and determining an enhanced pixel value corresponding to the pixel value of the source image through the accumulated probability difference value and a gray mapping function in the enhanced function.
Specifically, in this embodiment, inputting the enhancement factor into the gaussian stretching template in the enhancement function means that the enhancement factor r is assigned to δ in the gaussian stretching template in the enhancement function for calculation, so as to determine a range in which the histogram of the source image needs to be stretched in this embodiment.
The embodiment is used for counting the histogram of the source image based on the pixel values of the source image, and the formula is as follows:
Figure BDA0003994631270000151
N(i)=∑n(i) (7)
wherein f (x, y) is the pixel value of the pixel point at the (x, y) position of the source image coordinate; i is the image gray scale [0,255], i.e. the pixel value; n (x, y, i) is a mark value corresponding to the pixel value of the pixel point at the position where the source image coordinate is (x, y) as i; n (i) is the histogram of the source image, and equations (6) and (7) are functional representations of the histogram of the source image.
Specifically, the above formulas (6) and (7) represent that the pixel value of each pixel point in the source image is traversed according to the coordinates (x, y) of each pixel point in the source image, and the number of pixel points of each pixel value is counted, as shown in fig. 2, fig. 2 is a schematic diagram of an exemplary pixel value statistical histogram based on the source image provided in this embodiment. The embodiment greatly reduces the processing amount of data based on histogram processing, thereby achieving the purpose of rapidly enhancing the image.
In this embodiment, after the histogram of the source image is generated, the histogram of the source image is extended by using a gaussian extension template to obtain the gaussian extension histogram of the source image, and the specific extension operation is to perform convolution calculation on the histogram of the source image and the gaussian extension template, where the formula is as follows:
Figure BDA0003994631270000152
wherein N' (i) is an initial gaussian stretched histogram of the source image histogram; k is a variable and takes the integer with the value range of [ -3 delta, 3 delta ], and F (3 delta + k) is used for replacing the discretization value dependent variable b in the Gaussian extension template F (b). Because the histogram pixel value range of the source image is [0,255], after the histogram is extended by the gaussian extension template, the pixel value range may be out of range, for example, when the original pixel value is 255, the pixel value after the extension may reach 259, because the present embodiment further needs to perform truncation processing on the convolved initial gaussian extension histogram to ensure that the pixel value does not exceed the range, specifically, the number of pixels N ' (i) is less than 0 is accumulated to N ' (0), the number of pixels N ' (i) is greater than 255 is accumulated to N ' (255), and the truncated initial gaussian extension histogram is used as the gaussian extension histogram of the source image and is marked as N ' (j).
The embodiment adopts the Gaussian expansion template to expand the histogram, and realizes weighting and increasing the contrast of the image without greatly changing the overall gray distribution and the gray mean value of the input image.
In the embodiment, the histogram of the source image is extended through the gaussian extension template, and the number of the pixels counted for different pixel values changes, so that the distribution of the gaussian extension histogram of the source image is also distinguished from the previous histogram, and therefore, in order to better distinguish the two histograms, the gaussian extension histogram of the source image is not easy to be confused, so that the gaussian extension histogram of the source image is marked as N' (j), where j is a gaussian extension histogram pixel value, N (i) is a histogram of the source image, and i is a histogram pixel value.
Fig. 3 is a schematic diagram of an exemplary gaussian stretched histogram of the source image provided in this embodiment, the histogram of the source image in fig. 2 is stretched by a gaussian stretching template, and the distribution of the histogram of the source image is not changed by the finally obtained gaussian stretched histogram of the source image, as shown in fig. 3. In the embodiment, after the histogram of the source image and the gaussian expansion histogram are respectively obtained, the cumulative probability of the histogram of the source image and the cumulative probability difference between the cumulative probabilities of the gaussian expansion histograms are obtained, and the enhanced pixel value corresponding to the pixel value of the source image is determined through the cumulative probability difference and the gray mapping function in the enhancement function.
In an embodiment of the present disclosure, calculating a cumulative probability difference between a histogram cumulative probability of a source image and a gaussian stretched histogram cumulative probability 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 to be used as the histogram cumulative probability of the source image; normalizing the Gaussian extension histogram of the source image, and calculating the cumulative probability based on the normalized Gaussian extension histogram of the source image to serve as the cumulative probability of the Gaussian extension histogram of the source image; based on each histogram pixel value of the histogram accumulation probability of the source image, a cumulative probability difference value is calculated with all gaussian spread histogram pixel values of the gaussian spread histogram accumulation probability of the source image.
Specifically, the histogram of the source image is normalized by the following formula:
Figure BDA0003994631270000171
and h (i) is a histogram of the normalized source image, and the cumulative probability is calculated based on the histogram of the normalized source image and is used as the histogram cumulative probability of the source image.
In the embodiment of the present disclosure, normalizing the histogram of the source image, and calculating a cumulative probability based on the histogram of the normalized source image, as the histogram cumulative probability of the source image, includes: normalizing the histogram of the source image, and determining the histogram cumulative probability of the source image by calculating the mean value of the histogram cumulative probability of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000172
Figure BDA0003994631270000173
h (i) is the histogram cumulative probability of the source image, H (i) is the histogram of the normalized source image, and i is the histogram pixel value.
Specifically, in this embodiment, a special pixel point with a histogram pixel value of 0 is separately calculated by using a formula (10), and a pixel point with a histogram pixel value range of [1,255] is calculated by using a formula (11), so as to determine the histogram accumulation probability of the source image. Compared with the prior art, the method for calculating the histogram cumulative probability of the source image is more reasonable.
Similarly, in this embodiment, the gaussian spread histogram of the source image is normalized, and the formula is as follows:
Figure BDA0003994631270000174
and h' (j) is a Gaussian extension histogram of the normalized source image, and the cumulative probability is calculated based on the Gaussian extension histogram of the normalized source image and is used as the Gaussian extension histogram cumulative probability of the source image.
In the embodiment of the present disclosure, normalizing the gaussian expansion histogram of the source image, and calculating a cumulative probability based on the normalized gaussian expansion histogram of the source image, as the cumulative probability of the gaussian expansion histogram of the source image, includes: normalizing the Gaussian extension histogram of the source image, and determining the Gaussian extension histogram cumulative probability of the source image by calculating the mean value of the Gaussian extension histogram cumulative probability of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000181
Figure BDA0003994631270000182
h '(j) is the Gaussian extension histogram accumulation probability of the source image, H' (j) is the normalized Gaussian extension histogram of the source image, and j is the Gaussian extension histogram pixel value.
Specifically, in this embodiment, a special pixel point with a gaussian expansion histogram pixel value of 0 is separately calculated by using a formula (13), and a pixel point with a gaussian expansion histogram pixel value range of [1,255] is calculated by using a formula (14), so as to determine the gaussian expansion histogram cumulative probability of the source image. Compared with the prior art, the method for calculating the Gaussian extension histogram cumulative probability of the source image is more reasonable.
While the jump unevenness may have a great influence on the post-processing cumulative probability difference D (i, j), and an optimal value may not be found, the present embodiment can be well improved by using the above equations (9) - (14), especially for the case of the jump unevenness of the pixel value (gray scale), and the cumulative probability with uniform change is obtained by calculating the average value between the gray scale cumulative probabilities.
In this embodiment, after the histogram accumulation probability and the gaussian spread histogram accumulation probability of the source image are respectively obtained, the cumulative probability difference value between each histogram pixel value based on the histogram accumulation probability of the source image and all gaussian spread histogram pixel values based on the gaussian spread histogram accumulation probability has a calculation formula as follows:
D(i,j)=|H(i)-H'(j)|, i,j∈[0,255] (15)
wherein 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 spread histogram cumulative probability of the source image.
Specifically, the present embodiment calculates the cumulative probability difference between each histogram pixel value and all gaussian spread histogram pixel values, for example, when the histogram pixel value i is 1, the difference between the corresponding cumulative probability value and the cumulative probability value corresponding to each gaussian spread histogram pixel value in the gaussian spread histogram pixel value range j ∈ [0,255] is calculated.
In the disclosed embodiments, determining an enhanced pixel value corresponding to a pixel value of a source image by accumulating the probability difference value and a gray scale mapping function within the enhancement function comprises: determining the minimum value of the cumulative probability difference value of each histogram pixel value in the cumulative probability difference values of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian spread histogram pixel values of the Gaussian spread histogram cumulative probability of the source image; and taking the Gaussian extension histogram pixel value corresponding to the minimum value of the cumulative probability difference value of each histogram pixel value as an enhanced pixel value corresponding to each pixel value of the source image, wherein the calculation formula is as follows:
l(i)=j, if minD(i,j),j∈[0,255] (16)
wherein l (i) is a gray mapping function, i.e. a mapping function for converting each histogram pixel value i in the source image into a gaussian spread histogram pixel value j.
Specifically, in this embodiment, the gaussian expansion histogram pixel value corresponding to the minimum cumulative probability difference value of each histogram pixel value is used as the enhanced pixel value corresponding to each pixel value of the final source image, and the minimum cumulative probability difference value is selected by using the histogram conversion method, which indicates that the enhanced histogram distribution is closest to the original histogram distribution. For example, when the value of the histogram pixel value i is 15, the difference between the corresponding cumulative probability value and the cumulative probability value corresponding to each gaussian extension histogram pixel value in the gaussian extension histogram pixel value range j ∈ [0,255] is calculated, and in the obtained 256 cumulative probability difference values according to the formula (16), if the gaussian extension histogram pixel value j corresponding to the minimum cumulative probability difference value is determined to be 16, the gaussian extension histogram pixel value 16 is used as the enhanced pixel value corresponding to the pixel value 15 in the source image.
In the method for enhancing image contrast provided by this embodiment, pixel values of a source image are obtained; presetting an enhancement factor, and inputting the enhancement factor and a pixel value of a source image into an enhancement function to obtain an enhancement pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian extension template and a gray mapping function between the pixel value of the source image and the enhancement pixel value, so that the purpose of rapidly enhancing the image can be realized, and the whole gray distribution and the gray average value of the source image can be changed less.
Fig. 4 is a detailed schematic diagram of an image contrast enhancement method provided in an embodiment of the present disclosure, which includes the following specific steps:
step (1): inputting a source image, wherein the source image can be a gray image, a color image or a transformed image, such as an HSV channel image;
step (2): generating a one-dimensional continuous Gaussian extension template, namely a one-dimensional continuous Gaussian function; generating a one-dimensional Gaussian extension template, namely a Gaussian extension template, through the parameter delta;
and (3): counting a histogram of the source image;
and (4): performing Gaussian extension on the statistical histogram through the generated one-dimensional Gaussian extension template to obtain the Gaussian extension of the histogram, namely the Gaussian extension histogram of the source image;
and (5): calculating the cumulative probability of each gray scale (histogram pixel value) of the statistical histogram;
and (6): calculating the cumulative probability of each gray scale (Gaussian extension histogram pixel value) of the Gaussian extension of the histogram;
and (7): calculating the difference value of the cumulative probability, and calculating the difference value of the cumulative probability of each gray scale of the histogram and the Gaussian extension of the histogram;
and (8): constructing a gray mapping table (gray mapping function) and constructing a gray change mapping relation from a source image to an enhanced image;
and (9): and (4) image enhancement operation, namely enhancing the source image through a gray mapping table.
Fig. 5 is a schematic diagram of a source image provided by an embodiment of the present disclosure, fig. 6 is a schematic diagram of a source image after performing an image contrast enhancement operation, and fig. 5 and fig. 6 are partial images of the same display screen with defects, as shown in fig. 5 and fig. 6, which are circled by a dashed frame.
In the method for enhancing the image contrast provided by the embodiment, gaussian stretching is adopted instead of linear stretching, so that the mean distribution of the original histogram and the distribution of the whole pixels are not changed, only a limited range around the original pixels is stretched, and for a background area in the image, because the pixel value is near the mean value, the stretching has little influence on the background area, and the change is small; however, for the abnormal pixel point, the extended abnormal point can be extended faster, so the contrast ratio is more obvious.
EXAMPLE III
Fig. 7 is a schematic structural diagram of an apparatus for enhancing image contrast provided in an embodiment of the present disclosure, where the apparatus specifically includes:
a pixel value obtaining module 310, configured to obtain a pixel value of a source image;
the enhancement module 320 is configured to preset an enhancement factor, and input the enhancement factor and a pixel value of the source image into an enhancement function to obtain an enhancement pixel value corresponding to the pixel value of the source image, where the enhancement function includes a pre-constructed gaussian expansion template and a gray mapping function between the pixel value of the source image and the enhancement pixel value.
In an implementation, the enhancement module 320 is specifically configured to:
inputting the enhancement factor into a Gaussian expansion template in the enhancement function; counting a histogram of the source image based on pixel values of the source image; stretching the histogram of the source image through a Gaussian stretching template to obtain a Gaussian stretched histogram of the source image; calculating the cumulative probability of the histogram of the source image and the cumulative probability difference value between the Gaussian extension histogram cumulative probabilities of the source image; an enhanced pixel value corresponding to the pixel value of the source image is determined by accumulating the probability difference and a gray scale mapping function within the enhancement function.
In an implementation, the enhancement module 320 is specifically configured to: normalizing the histogram of the source image, and calculating the cumulative probability based on the normalized histogram of the source image to be used as the histogram cumulative probability of the source image; normalizing the Gaussian extension histogram of the source image, and calculating the cumulative probability based on the normalized Gaussian extension histogram of the source image to serve as the cumulative probability of the Gaussian extension histogram of the source image; based on each histogram pixel value of the histogram accumulation probability of the source image, a cumulative probability difference value is calculated with all gaussian spread histogram pixel values of the gaussian spread histogram accumulation probability of the source image.
In an implementation, the enhancement module 320 is specifically configured to: determining the minimum value of the cumulative probability difference value of each histogram pixel value in the cumulative probability difference values of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian spread histogram pixel values of the Gaussian spread histogram cumulative probability of the source image; and taking the Gaussian expansion histogram pixel value corresponding to the minimum value of the cumulative probability difference value of each histogram pixel value as an enhanced pixel value corresponding to each pixel value of the source image.
In an implementation, the enhancement module 320 is specifically configured to: normalizing the histogram of the source image, and determining the histogram cumulative probability of the source image by calculating the mean value of the histogram cumulative probability of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000221
Figure BDA0003994631270000222
h (i) is the histogram cumulative probability of the source image, H (i) is the histogram of the normalized source image, and i is the histogram pixel value.
In an implementation, the enhancement module 320 is specifically configured to: normalizing the Gaussian extension histogram of the source image, and determining the Gaussian extension histogram cumulative probability of the source image by calculating the mean value of the Gaussian extension histogram cumulative probability of the normalized source image, wherein the calculation formula is as follows:
Figure BDA0003994631270000223
Figure BDA0003994631270000224
h '(j) is the Gaussian extension histogram accumulation probability of the source image, H' (j) is the normalized Gaussian extension histogram of the source image, and j is the Gaussian extension histogram pixel value.
In one embodiment, the method further comprises: a template building module for building a template,
the template construction module is used for discretizing the one-dimensional continuous Gaussian function according to the 3 delta principle before the pixel value of the source image is obtained to obtain the one-dimensional discretized Gaussian function; and summing the one-dimensional discretization Gaussian functions, and carrying out normalization processing to obtain the Gaussian extension template.
In an implementation manner, the pixel value obtaining module is specifically configured to: acquiring a source image; and determining the pixel value of the source image according to the image type of the source image.
In an implementation manner, the pixel value obtaining module is specifically configured to: if the image type of the source image is judged to be the first gray image, taking the gray value of the first gray image as the pixel value of the source image; or if the image type of the source image is judged to be a color image or an HSV image, converting the color image or the HSV image into a second gray image, and taking the gray value of the second gray image as the pixel value of the source image.
In an implementation manner, the pixel value obtaining module is specifically configured to: if the image type of the source image is judged to be a color image, extracting an R channel image, a G channel image and a B channel image from the color image, and acquiring gray values of the R channel image, the G channel image and the B channel image as pixel values of the source image; or if the image type of the source image is judged to be an HSV image, extracting an H-channel image, an S-channel image and a V-channel image through the HSV image, and obtaining gray values of the H-channel image, the S-channel image and the V-channel image as pixel values of the source image.
In an embodiment, the enhancement module is specifically configured to: inputting the enhancement factor into an enhancement function; if the image type of the source image is judged to be a color image, inputting the gray values of the R channel image, the G channel image and the B channel image into an enhancement function respectively to obtain enhanced pixel values corresponding to the gray values of the R channel image, the G channel image and the B channel image respectively, and synthesizing the enhanced pixel values into the color image through a first image conversion formula; or if the image type of the source image is judged to be the 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, enhancement 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 enhancement pixel values are synthesized into a color image through a second image conversion formula.
The present disclosure also provides an electronic device and a readable storage medium according to an embodiment of the present disclosure.
FIG. 8 shows a schematic block diagram of an example electronic device 400 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 8, the device 400 comprises a computing unit 401 which may perform various suitable actions and processes according to a computer program stored in a Read Only Memory (ROM) 402 or a computer program loaded from a storage unit 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
A number of components in device 400 are connected to I/O interface 405, including: an input unit 406 such as a keyboard, a mouse, or the like; an output unit 407 such as various types of displays, speakers, and the like; a storage unit 408 such as a magnetic disk, optical disk, or the like; and a communication unit 409 such as a network card, modem, wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
Computing unit 401 may be a variety of general 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 dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The calculation unit 401 executes the respective methods and processes described above, such as the enhancement method of image contrast. For example, in some embodiments, the method of image contrast enhancement may be implemented as a computer software program tangibly embodied 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 onto the device 400 via the ROM 402 and/or the communication unit 409. When the computer program is loaded into RAM 403 and executed by computing unit 401, one or more steps of the method of enhancing image contrast described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured by any other suitable means (e.g. by means of firmware) to perform the method of enhancement of image contrast.
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems on a chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user may provide input to the computer. Other kinds of devices may also be used to provide for interaction with a 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 may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server with a combined blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, and the present disclosure is not limited herein.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present disclosure, "a plurality" means two or more unless specifically limited otherwise.
The above description is only for the specific embodiments of the present disclosure, but the scope of the present disclosure is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present disclosure, and all the changes or substitutions should be covered within the scope of the present disclosure. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.

Claims (11)

1. A method for enhancing image contrast, the method comprising:
acquiring 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 enhancement pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian extension template and a gray mapping function between the pixel value of the source image and the enhancement pixel value.
2. The method of claim 1, wherein inputting the enhancement factor and the pixel value of the source image into an enhancement function resulting in an enhanced pixel value corresponding to the pixel value of the source image comprises:
inputting the enhancement factor into a gaussian stretch template within the enhancement function;
counting a histogram of the source image based on pixel values 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 the histogram cumulative probability of the source image and the Gaussian stretched histogram cumulative probability of the source image;
and determining an enhanced pixel value corresponding to the pixel value of the source image through the accumulated probability difference value and a gray mapping function in the enhanced function.
3. The method of claim 2, wherein calculating a cumulative probability difference between the histogram cumulative probability of the source image and the gaussian stretched histogram cumulative probability of the source image comprises:
normalizing the histogram of the source image, and calculating a cumulative probability based on the histogram of the normalized source image, wherein the cumulative probability is used as the histogram cumulative probability of the source image;
normalizing the Gaussian extension histogram of the source image, and calculating a cumulative probability based on the normalized Gaussian extension histogram of the source image, wherein the cumulative probability is used as the cumulative probability of the Gaussian extension histogram of the source image;
and calculating the cumulative probability difference value of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian stretching histogram pixel values of the Gaussian stretching histogram cumulative probability of the source image.
4. The method of claim 3, wherein determining enhanced pixel values corresponding to pixel values of the source image from the cumulative probability difference values and a gray scale mapping function within the enhancement function comprises:
determining a cumulative probability difference minimum value of each histogram pixel value in the cumulative probability difference values of each histogram pixel value of the histogram cumulative probability of the source image and all Gaussian spread histogram pixel values of the Gaussian spread histogram cumulative probability of the source image;
and taking the Gaussian expansion histogram pixel value corresponding to the minimum value of the cumulative probability difference value of each histogram pixel value as an enhanced pixel value corresponding to each pixel value of the source image.
5. The method according to claim 4, wherein the normalizing the histogram of the source image and the calculating a cumulative probability based on the histogram of the normalized source image as the histogram cumulative probability of the source image comprises:
normalizing the histogram of the source image, and determining the histogram cumulative probability of the source image by calculating the average value of the histogram cumulative probability of the normalized source image, wherein the calculation formula is as follows:
Figure FDA0003994631260000021
Figure FDA0003994631260000022
h (i) is the histogram cumulative probability of the source image, H (i) is the histogram of the normalized source image, and i is the histogram pixel value.
6. The method of claim 5, wherein 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 Gaussian stretched histogram cumulative probability of the source image comprises:
normalizing the Gaussian extension histogram of the source image, and determining the Gaussian extension histogram cumulative probability of the source image by calculating the mean value of the Gaussian extension histogram cumulative probabilities of the normalized source image, wherein the calculation formula is as follows:
Figure FDA0003994631260000023
Figure FDA0003994631260000031
h '(j) is the Gaussian extension histogram accumulation probability of the source image, H' (j) is the normalized Gaussian extension histogram of the source image, and j is the Gaussian extension histogram pixel value.
7. The method of claim 6, further comprising, prior to said obtaining pixel values of a source image:
discretizing the one-dimensional continuous Gaussian function according to a 3 delta principle to obtain a one-dimensional discretized Gaussian function;
and summing the one-dimensional discretization Gaussian functions, and performing normalization processing to obtain the Gaussian extension template.
8. The method of claim 7, wherein the obtaining pixel values of a source image comprises:
acquiring the source image;
and determining the pixel value of the source image according to the image type of the source image.
9. An apparatus for enhancing image contrast, the apparatus comprising:
the pixel value acquisition module is used for acquiring the pixel value of the source image;
and the enhancement module is used for presetting an enhancement factor, inputting the enhancement factor and the pixel value of the source image into an enhancement function, and obtaining an enhancement pixel value corresponding to the pixel value of the source image, wherein the enhancement function comprises a pre-constructed Gaussian extension template and a gray mapping function between the pixel value of the source image and the enhancement pixel value.
10. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.
11. A non-transitory computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method of any one of claims 1-8.
CN202211591466.4A 2022-12-12 2022-12-12 Method, device and equipment for enhancing image contrast and storage medium Pending CN115829872A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211591466.4A CN115829872A (en) 2022-12-12 2022-12-12 Method, device and equipment for enhancing image contrast and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211591466.4A CN115829872A (en) 2022-12-12 2022-12-12 Method, device and equipment for enhancing image contrast and storage medium

Publications (1)

Publication Number Publication Date
CN115829872A true CN115829872A (en) 2023-03-21

Family

ID=85546561

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211591466.4A Pending CN115829872A (en) 2022-12-12 2022-12-12 Method, device and equipment for enhancing image contrast and storage medium

Country Status (1)

Country Link
CN (1) CN115829872A (en)

Similar Documents

Publication Publication Date Title
WO2022199583A1 (en) Image processing method and apparatus, computer device, and storage medium
CN111709428B (en) Method and device for identifying positions of key points in image, electronic equipment and medium
CN113327193A (en) Image processing method, image processing apparatus, electronic device, and medium
CN113222921A (en) Image processing method and system
CN114862897A (en) Image background processing method and device and electronic equipment
CN113837965B (en) Image definition identification method and device, electronic equipment and storage medium
CN113516697B (en) Image registration method, device, electronic equipment and computer readable storage medium
CN113705380B (en) Target detection method and device for foggy days, electronic equipment and storage medium
CN114495101A (en) Text detection method, and training method and device of text detection network
CN112651953B (en) Picture similarity calculation method and device, computer equipment and storage medium
CN116503370A (en) Tobacco shred width determining method and device, electronic equipment and storage medium
CN115829872A (en) Method, device and equipment for enhancing image contrast and storage medium
CN115760578A (en) Image processing method and device, electronic equipment and storage medium
CN116167912A (en) Anti-sample generation method, anti-attack detection device and electronic equipment
CN115049713A (en) Image registration method, device, equipment and readable storage medium
CN114037630A (en) Model training and image defogging method, device, equipment and storage medium
CN113903071A (en) Face recognition method and device, electronic equipment and storage medium
CN113610856A (en) Method and device for training image segmentation model and image segmentation
CN118015311A (en) Image matching method, device, equipment and medium
CN117764913A (en) Image detection method, device, electronic equipment and storage medium
CN113658294B (en) Image processing method, device and storage medium
CN117558018A (en) Method and device for extracting configuration parameters of chart, electronic equipment and storage medium
CN115171225A (en) Image detection method and training method of image detection model
CN117274588A (en) Image processing method, device, electronic equipment and storage medium
CN116957983A (en) Image enhancement method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination