Image Enhancement Method, Device and Equipment Based on Retinex Theory
Through the image enhancement method of Retinex theory, the image quality problem under the influence of light is solved and the image clarity and contrast is improved.
Patent Information
- Application Number
- CN201810686408.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-06-28
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2038-06-28
AI Technical Summary
The image is affected by lighting conditions during the acquisition process, resulting in poor image quality.
Using the image enhancement method based on Retinex theory, we use the incident component of the loss function to obtain the optimized image using the activation function and optimization algorithm, including image processing using the Adam optimization algorithm and the Scharr operator.
This improves the image quality, especially image clarity and contrast in low light conditions, reduces memory consumption and improves computing efficiency.
Smart Images

Figure CN110211049B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular, to an image enhancement method, apparatus, and device based on the Retinex theory. Background Art
[0002] Images are important carriers for humans to obtain and transmit information, and images are required in many scenarios, such as: daily life, public security criminal investigation, biomedical, or animation games, etc. However, during the process of image acquisition, it is inevitably affected by lighting conditions, resulting in color deviation and poor image quality. Summary of the Invention
[0003] Embodiments of the present invention provide an image enhancement method, apparatus, and device based on the Retinex theory to solve the problem of poor image quality.
[0004] Embodiments of the present invention provide an image enhancement method based on the Retinex theory, including:
[0005] Obtaining an input image;
[0006] Solving for the incident component of the input image that minimizes the loss function;
[0007] Obtaining an optimized image of the input image according to the incident component;
[0008] Wherein, the loss function includes an activation function.
[0009] Optionally, the loss function is the following function:
[0010]
[0011] Wherein, c1, c2, and c3 are preset weight values, l is the logarithm of the incident component, s is the logarithm of the input image, ▽l is the first-order partial derivative of l, and ▽(s - l) is the first-order partial derivative of s - l.
[0012] Optionally, the loss function is the following function:
[0013]
[0014] Optionally, the Scharr operator is used to solve ▽l and ▽(s - l).
[0015] Optionally, the step of solving for the incident component of the input image that minimizes the loss function includes:
[0016] Using the Adam optimization algorithm to solve for the incident component of the input image that minimizes the loss function.
[0017] Optionally, obtaining the optimized image of the input image according to the incident component includes:
[0018] Removing the incident component in the input image to obtain the reflection component of the input image;
[0019] Performing gamma correction on the incident component to obtain a corrected component;
[0020] Taking the product of the reflection component and the corrected component as the optimized image.
[0021] Optionally, before obtaining the optimized image of the input image according to the incident component, the method further includes:
[0022] Obtaining the image information of the H channel, the image information of the S channel, and the image information of the V channel in the hue saturation value (HSV) space of the input image, where the incident component is the incident component of the image information of the V channel;
[0023] Obtaining the optimized image of the input image according to the incident component includes:
[0024] Obtaining the image information of the optimized V channel of the input image according to the incident component;
[0025] Converting the image information of the H channel, the image information of the S channel, and the image information of the optimized V channel into the optimized image in the red green blue (RGB) space.
[0026] An embodiment of the present invention further provides an image enhancement device based on the Retinex theory, including:
[0027] A first acquisition module, configured to acquire an input image;
[0028] A solution module, configured to solve the incident component of the input image that minimizes the loss function;
[0029] A processing module, configured to obtain the optimized image of the input image according to the incident component;
[0030] Wherein, the loss function includes an activation function.
[0031] Optionally, the loss function is the following function:
[0032]
[0033] Wherein, c1, c2, and c3 are preset weight values, l is the logarithm of the incident component, s is the logarithm of the input image, ▽l is the first-order partial derivative of l, and ▽(s - l) is the first-order partial derivative of s - l.
[0034] Optionally, the loss function is the following function:
[0035]
[0036] Optionally, the Scharr operator is used to solve for ▽l and ▽(s - l).
[0037] Optionally, the solving module is used to solve for the incident component of the input image that minimizes the loss function using the Adam optimization algorithm.
[0038] Optionally, the processing module includes:
[0039] A removal unit, configured to remove the incident component from the input image to obtain the reflected component of the input image;
[0040] A correction unit, configured to perform gamma correction on the incident component to obtain a corrected component;
[0041] An operation unit, configured to use the product of the reflected component and the corrected component as the optimized image.
[0042] Optionally, the device further includes:
[0043] A second acquisition module, configured to acquire the image information of the H channel, the image information of the S channel, and the image information of the V channel in the HSV space of the input image, where the incident component is the incident component of the image information of the V channel;
[0044] The processing module includes:
[0045] A processing unit, configured to obtain the optimized image information of the V channel of the input image according to the incident component;
[0046] A conversion unit, configured to convert the image information of the H channel, the image information of the S channel, and the optimized image information of the V channel into the optimized image in the RGB space.
[0047] An embodiment of the present invention further provides an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the computer program is executed by the processor, the steps in the image enhancement method based on the Retinex theory provided by the embodiment of the present invention are implemented.
[0048] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where when the computer program is executed by a processor, the steps in the image enhancement method based on the Retinex theory provided by the embodiment of the present invention are implemented.
[0049] In an embodiment of the present invention, an input image is obtained; the input image is obtained; the incident component of the input image that minimizes the loss function is solved; and an optimized image of the input image is obtained according to the incident component; wherein the loss function includes an activation function. This can improve the image quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is a schematic diagram of the Retinex theory provided by an embodiment of the present invention;
[0051] Figure 2 is a flowchart of an image enhancement method based on the Retinex theory provided by an embodiment of the present invention;
[0052] Figure 3 is a schematic diagram of an optimization solution provided by an embodiment of the present invention;
[0053] Figure 4 is a schematic diagram of another image enhancement method based on the Retinex theory provided by an embodiment of the present invention;
[0054] Figure 5 is a structural diagram of an image enhancement device based on the Retinex theory provided by an embodiment of the present invention;
[0055] Figure 6 is a structural diagram of another image enhancement device based on the Retinex theory provided by an embodiment of the present invention;
[0056] Figure 7 is a structural diagram of another image enhancement device based on the Retinex theory provided by an embodiment of the present invention;
[0057] Figure 8 is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0058] To make the technical problems, technical solutions and advantages to be solved by the present invention clearer, the following will be described in detail with reference to the accompanying drawings and specific embodiments.
[0059] Please refer to Figure 1 , Figure 1 which is a schematic diagram of the Retinex theory provided by an embodiment of the present invention. As Figure 1 shown, in the Retinex theory, an image mainly consists of two parts, namely an incident component and a reflection component, which are expressed as:
[0060] S = L × R
[0061] Among them, L represents the incident component, R represents the reflection component, and S is the image received by the observer or camera. Among them, the incident component L determines the dynamic range that the pixels in an image can reach, and the reflection component R determines the inherent properties of the image. As Figure 1 shown, the purpose in the Retinex theory is to discard the properties of the incident component from the image S, so as to obtain the original appearance of the image, and then realize image enhancement.
[0062] Please refer to Figure 2 , Figure 2 which is a flowchart of an image enhancement method based on the Retinex theory provided by an embodiment of the present invention. As Figure 2 shown, it includes the following steps:
[0063] 201. Obtain an input image;
[0064] 202. Solve the incident component of the input image that minimizes the loss function;
[0065] 203. Obtain an optimized image of the input image according to the incident component;
[0066] Among them, the loss function includes an activation function.
[0067] The above input image can be an image collected by an image acquisition device, for example: an image collected by the camera of devices such as mobile phones and cameras. And the above input image can be a static image or a dynamic image, such as a video.
[0068] Among them, the above loss function can be pre-configured, for example: received from other devices, or configured by the user, etc., or the above loss function can be obtained by pre-optimization.
[0069] The above solution of the incident component of the input image that minimizes the loss function can be to solve the minimum of the loss function through an optimization algorithm to obtain the incident component of the above input image. For example: initialize l (l is the logarithm of the incident component) in the above loss function, and then continuously optimize l in the loss function through the optimization algorithm until the minimum value of the loss function is solved, and take l at this time as the logarithm of the incident component of the above input image, and then obtain the incident component of the above input image. It should be noted that the minimum of the above loss function can mean that the loss function satisfies specific conditions. For example: when the value of the loss function is less than the target threshold, it is determined that the loss function is the minimum at this time. Among them, the above target threshold can be a threshold determined according to the theoretical minimum value (for example: 0), such as 0.001, 0.0001 or 0.002, etc. Preferably, the above target threshold can be set according to the theoretical minimum value and combined with the actual situation of image enhancement.
[0070] The activation function included in the above loss function is used to ensure the above loss function. For example, the activation function is used to ensure that the constraint condition is L≥S or l≥s, where L is the incident component, S is the input image, l is the logarithm of the incident component, and s is the logarithm of the input image.
[0071] The above-mentioned obtaining the optimized image of the input image according to the incident component means realizing it based on the Retinex theory. Because in the Retinex theory, S = L×R, so when the incident component is determined, the optimized image of the input image can be obtained.
[0072] In the above steps, because the activation function included in the loss function, during the image enhancement process, there is no need to separately judge the constraint conditions, thus the operation efficiency during the image enhancement process can be improved.
[0073] It should be noted that in the embodiments of the present invention, based on S = L×R in the Retinex theory, in order to simplify the operation, the multiplication relationship can be transformed into an addition relationship in the logarithmic domain, that is:
[0074] s = logS(x,y), l = logL(x,y), r = logR(x,y)
[0075] It can be obtained that: s = l + r, where x and y are the pixel point coordinates in the input image. Among them, the base of the above logarithm can be other values such as e, 2, 10, etc., and no limitation is made in this regard.
[0076] In the embodiments of the present invention, it is assumed that the incident component and the reflection component satisfy the following assumptions:
[0077] 1. Assume that the incident component is sufficiently uniform in space;
[0078] 2. The value of the reflection component R is limited to 0 to 1. Therefore, L≥S. And because the base of the logarithm in the embodiments of the present invention is a value greater than 1, the logarithmic domain is monotonically increasing. Therefore, l≥s;
[0079] 3. Assume that the incident component is a constant C, and C is greater than any point in S. Then C is a trivial solution that satisfies the above two assumptions. Therefore, it can be assumed that L is infinitely close to S but greater than S;
[0080] 4. Assume that r = s - l has a relatively high prior probability.
[0081] In this way, according to the above 4 assumptions combined into an expression, the following penalty function can be obtained:
[0082]
[0083] Among them, c1, c2, and c3 are their respective weights, and these weights can be pre-configured. For example, they can be set according to experience or requirements, and l ≥ s. It should be noted that in the embodiments of the present invention, the loss function can also be called the penalty function.
[0084] In addition, since When L is very small, the derivative of log(L) is very dependent on 1 / L. To solve this problem, the penalty function can be modified as follows:
[0085]
[0086] From the content of this formula, it can be seen that this formula modifies the first term to That is, it multiplies by the coefficient e l , without changing the function of the original formula. Assuming l = log(L) and the base is e, it can be known that e l = L, that is Substituting gives: In this way, it only relates to ▽L, thus eliminating the influence of 1 / L. Similarly, the third term in the above penalty function can be obtained.
[0087] Through the above formula, it can be achieved that when L is very small, the quality of the image can also be improved.
[0088] Since in the embodiments of the present invention, the above loss function includes an activation function, and the activation function can adopt the Relu activation function. Among them, the Relu activation function is an activation function in deep learning, defined as: Relu(x) = max(0, x)
[0089] In this way, through the above penalty function, using Relu(s - l) = 0 to ensure l ≥ s. Therefore, in an alternative embodiment, the above loss function is the following function:
[0090]
[0091] Among them, c1, c2, and c3 are preset weight values, l is the logarithm of the incident component, s is the logarithm of the input image, ▽l is the first-order partial derivative of l, and ▽(s - l) is the first-order partial derivative of s - l.
[0092] The above first term represents that the incident component space is sufficiently smooth, while the second term represents that the incident component is infinitely close to and greater than the captured image. The third term ||e (s-l) ▽(s - l)||1 indicates that the reflection component has a large prior probability, and the Relu activation function realizes the integration of the constraint condition l ≥ s into a part of the loss function, and no longer separately serves as a constraint condition for solving the loss function.
[0093] In the embodiments of the present invention, a first-order differential operator can be used to calculate the first-order partial derivatives of an image. Preferably, the Scharr operator is used to solve for ▽l and ▽(s - l). Specifically, the Scharr operator can be defined as follows:
[0094]
[0095] In this way, when solving for the derivative of image A, we have: Thus, we can obtain
[0096] Of course, in the embodiments of the present invention, the above operator elements 0, 3, -3, 10, -10 are not limited. For example, they can also be replaced with other constants, such as 0, 4, -4, 10, -10, etc.
[0097] By using the Scharr operator for solution in this way, the zero gradient during backpropagation can be avoided, which is beneficial to the spatial smoothing of the incident component, and thus improves the quality of the optimized image.
[0098] By using different loss functions as described above, the operation processing efficiency can be improved, the memory consumption can be reduced, and the quality of the optimized image can also be improved. For example, by using the above loss function, the quality of pictures taken at night can be effectively improved, making the picture content clearer, effectively improving the blurring of image details, increasing the image contrast, restoring distorted colors, and performing gain compensation, etc.
[0099] Of course, in the embodiments of the present invention, the loss function is not limited to the function represented by the above formula. For example, in some scenarios, the above loss function can also be the following function:
[0100]
[0101] It's just that when using this loss function, the problem that when L is very small, the derivative of log(L) is very dependent on 1 / L is not considered, resulting in the quality of the optimized image being worse than that obtained by using this loss function, but it can still improve the operation efficiency during the image enhancement process. Or, it can be understood as is a further limitation of
[0102] As an alternative embodiment, the above method of obtaining the incident component of the input image by solving the minimum value of the loss function includes:
[0103] Using the Adam optimization algorithm to solve for the minimum of the loss function to obtain the incident component of the input image.
[0104] For example: such asFigure 3 As shown, input s, initialize l, calculate the above loss function, and determine whether the loss function meets the condition (i.e., determine whether the loss function is minimized). If not, update l and calculate the above loss function again, and determine whether the loss function meets the condition until the loss function meets the condition (i.e., determine that the loss function is minimized), then output l. Among them, the above update of l is continuously optimized through the Adam optimization algorithm.
[0105] In this embodiment, it is possible to use l as the parameter to be optimized, and continuously optimize l using the Adam optimization algorithm to minimize the loss function and obtain the optimal solution of l. After that, an exponential solution is performed on l to obtain L = e l . Then, the optimized image can be obtained through the reflection component R = S / L. Using the Adam optimization algorithm can improve the computational efficiency of the algorithm, reduce memory consumption, and is easy to implement in engineering.
[0106] The following is an example to illustrate the Adam optimization algorithm:
[0107] Adam is a first-order optimization algorithm that can replace the traditional stochastic gradient descent process. It dynamically adjusts the learning rate of each parameter using the first-order moment estimate and second-order moment estimate of the gradient. Among them, the main advantage of Adam is that after bias correction, the learning rate has a definite range for each iteration, making the parameters relatively stable. The formula can be as follows:
[0108] m t = μ * m t-1 +(1 - μ) * g t
[0109]
[0110]
[0111]
[0112]
[0113] Among them, η is the learning rate, t is the number of iterations, g t is the gradient of the image, m t and n t are respectively the
[0114] first-order moment estimate and second-order moment estimate of the gradient, and can be regarded as the estimation of the expectations E[g t , E[g t 2 ;
[0115] and are for m t and nt Calibration can be approximated as an unbiased estimate of the expectation. The parameters μ and v can be manually set parameters used to estimate and Generally, μ = 0.9 and v = 0.99 or other values are taken.
[0116] It can be seen that Adam's direct moment estimation of the gradient has no additional requirements for memory and can be dynamically adjusted according to the gradient. It forms a dynamic constraint on the learning rate and has a clear range. ε is the error to ensure that the denominator is not zero. Generally, ε = 1e - 8 is taken.
[0117] During the optimization process, the above g t is the gradient of the current image. Here, the so - called current image actually refers to the incident component l obtained in the current iteration. That is to say, g t is the gradient of the incident component l, that is, g t =▽l.
[0118] Through the above description, it can be summarized that the Adam algorithm has the following advantages:
[0119] Efficient calculation, less memory required, invariance to diagonal scaling of the gradient, suitable for solving optimization problems with large - scale data and parameters, applicable to non - stationary objectives, applicable to solving problems containing high noise or sparse gradients, and the hyperparameters can be intuitively explained and basically only require very little tuning.
[0120] It should be noted that the above formula is only an example of the Adam optimization algorithm. In the embodiments of the present invention, the Adam optimization algorithm is not limited.
[0121] As an optional implementation manner, obtaining the optimized image of the input image according to the incident component includes:
[0122] Removing the incident component from the input image to obtain the reflection component of the input image;
[0123] Performing gamma correction on the incident component to obtain a corrected component;
[0124] Taking the product of the reflection component and the corrected component as the optimized image.
[0125] Among them, removing the incident component from the input image to obtain the reflection component of the input image can be obtained according to the formula S = L×R in the Retinex theory, where S represents the input image, L represents the incident component, and R represents the reflection component.
[0126] Among them, the above gamma correction of the incident component can be to edit the gamma curve of the incident component to perform non-linear tone editing on the incident component, so as to obtain the above correction component. Of course, the above gamma correction of the incident component can also be performed by the following formula:
[0127]
[0128] Among them, L' is the correction component, W = 2 b -1, b is the number of bits of the image. For example, for an 8-bit image, W = 255.
[0129] After obtaining the correction component through the above gamma correction, the above optimized image S' can be obtained through the formula S' = L' × R.
[0130] In this embodiment, the optimized image is obtained according to the above correction component, so that it is possible to appropriately adjust the image according to the illumination information included in the incident component to produce the visual effect of a dark image, which is closer to the real image and achieves the effect of improving the image quality.
[0131] As an alternative embodiment, before obtaining the optimized image of the input image according to the incident component, the method further includes:
[0132] Obtaining the image information of the H channel, the image information of the S channel, and the image information of the V channel in the Hue Saturation Value (HSV) space of the input image, where the incident component is the incident component of the image information of the V channel;
[0133] The obtaining of the optimized image of the input image according to the incident component includes:
[0134] Obtaining the optimized image information of the V channel of the input image according to the incident component;
[0135] Converting the image information of the H channel, the image information of the S channel, and the optimized image information of the V channel into the optimized image in the Red Green Blue (RGB) space.
[0136] Among them, the image information of the H channel represents the chromaticity of the image, the image information of the S channel represents the saturation of the image, and the image information of the V channel represents the brightness of the image.
[0137] In general, the above input image is an RGB image. First, the RGB image needs to be converted into an HSV space image. In this way, the image information of the H channel, the S channel, and the V channel in the HSV space of the above input image can be obtained through the following formulas:
[0138]
[0139]
[0140] v = max
[0141] Among them, h, s, and v respectively represent the image information of the H channel, the S channel, and the V channel in the HSV space, and r, g, and b respectively represent the image information of the R channel, the G channel, and the B channel in the RGB space. max is equal to the maximum value among r, g, and b, and min is equal to the minimum value among r, g, and b.
[0142] Of course, in the embodiments of the present invention, it is not limited that the above input image is an RGB image. For example, the above input image is an HSV image, so that the image information of the H channel, the S channel, and the V channel in the HSV space of the input image can be directly obtained.
[0143] In this embodiment, during the image enhancement process, the image information in the HSV space can be obtained. The HSV space can very intuitively express the brightness, hue, and vividness of colors, which is convenient for color comparison and also convenient for emotional communication. It is a color space based on users. In this embodiment, since the image information of the H channel represents the chromaticity of the image and the image information of the S channel represents the saturation of the image, and the chromaticity and saturation correspond to the colors of the image. In order to ensure that the color of the image remains unchanged, in this embodiment, only the image information of the V channel is enhanced, that is, only the brightness of the image is enhanced, and the image information of the H channel and the S channel is not changed, thereby improving the quality of the image.
[0144] It should be noted that the image enhancement method based on the Retinex theory provided by the embodiments of the present invention can be applied to any device capable of enhancing images, such as, but not limited to, mobile phones, cameras, video cameras, computers, servers, etc., and there is no limitation in this regard. And the application fields include, but are not limited to, video, image processing, public security criminal investigation, biomedical, and animation games and other fields.
[0145] In an embodiment of the present invention, an input image is obtained; the input image is obtained; the incident component of the input image that minimizes the loss function is solved; an optimized image of the input image is obtained according to the incident component; wherein the loss function includes an activation function. This can improve the image quality.
[0146] The following refers to Figure 4 , and an image enhancement method based on the Retinex theory provided by the embodiment of the present invention will be illustrated by way of example:
[0147] As Figure 4 shown, an input image S is obtained, the input image S is logarithmically transformed to obtain the logarithm s of the input image S, and then light estimation is performed. Among them, the above light estimation can be understood as solving the logarithm l of the incident component provided by the above embodiment, and then performing exp (exponential solution) to obtain the incident component L; in this way, the reflection component R of the input image can be obtained based on the Retinex theory (R = S / L), and after obtaining L, image correction (for example: gamma correction) can be performed on L to obtain the corrected component L', and finally, the final optimized image S' is obtained through S' = L' × R.
[0148] Figure 4 The image enhancement scheme shown can achieve beneficial effects such as high operation efficiency, low memory loss, better preservation of image color, and easy engineering implementation.
[0149] Please refer to Figure 5 , Figure 5 which is a structural diagram of an image enhancement device based on the Retinex theory provided by an embodiment of the present invention. As Figure 5 shown, the image enhancement device 500 based on the Retinex theory includes:
[0150] A first acquisition module 501, configured to acquire an input image;
[0151] A solution module 502, configured to obtain the incident component of the input image by solving the minimum value of the loss function;
[0152] A processing module 503, configured to obtain an optimized image of the input image according to the incident component;
[0153] wherein the loss function includes an activation function.
[0154] Optionally, the loss function is the following function:
[0155]
[0156] Among them, c1, c2, and c3 are preset weight values, l is the logarithm of the incident component, s is the logarithm of the input image, ▽l is the first-order derivative of l, and ▽(s - l) is the first-order derivative of s - l.
[0157] Optionally, the loss function is the following function:
[0158]
[0159] Optionally, the Scharr operator is used to solve ▽l and ▽(s - l).
[0160] Optionally, the solving module 502 is used to solve the minimum of the loss function using the Adam optimization algorithm to obtain the incident component of the input image.
[0161] Optionally, as Figure 6 shown, the processing module 503 includes:
[0162] The removal unit 5031 is used to remove the incident component in the input image to obtain the reflection component of the input image;
[0163] The correction unit 5032 is used to perform gamma correction on the incident component to obtain a corrected component;
[0164] The operation unit 5033 is used to use the product of the reflection component and the corrected component as the optimized image.
[0165] Optionally, as Figure 7 shown, the device further includes:
[0166] The second acquisition module 504 is used to acquire the image information of the H channel, the image information of the S channel, and the image information of the V channel in the HSV space of the input image, where the incident component is the incident component of the image information of the V channel;
[0167] The processing module 503 includes:
[0168] The processing unit 5034 is used to obtain the optimized image information of the V channel of the input image according to the incident component;
[0169] The conversion unit 5035 is used to convert the image information of the H channel, the image information of the S channel, and the optimized image information of the V channel into the optimized image in the RGB space.
[0170] It should be noted that the above-mentioned image enhancement device 500 based on the Retinex theory in this embodiment can implement any implementation manner in the image enhancement method embodiment based on the Retinex theory in the embodiments of the present invention. That is to say, any implementation manner in the image enhancement method embodiment based on the Retinex theory in the embodiments of the present invention can be implemented by the above-mentioned image enhancement device 500 based on the Retinex theory in this embodiment, and the same beneficial effects can be achieved, which will not be elaborated here.
[0171] Please refer to Figure 8 , Figure 8 which is a structural diagram of an electronic device provided by an embodiment of the present invention. As Figure 8 shown, the electronic device 800 includes: a memory 801, a processor 802, and a computer program stored on the memory 801 and executable on the processor 802. Among them,
[0172] the processor 802 is used to read the calculation program in the memory 801 and execute the following processes:
[0173] Obtain an input image;
[0174] Obtain the incident component of the input image by solving the minimum value of the loss function;
[0175] Obtain the optimized image of the input image according to the incident component;
[0176] Among them, the loss function includes an activation function.
[0177] Optionally, the loss function is the following function:
[0178]
[0179] where c1, c2, and c3 are preset weight values, l is the logarithm of the incident component, s is the logarithm of the input image, ▽l is the first-order partial derivative of l, and ▽(s - l) is the first-order partial derivative of s - l.
[0180] Optionally, the loss function is the following function:
[0181]
[0182] Optionally, the Scharr operator is used to solve ▽l and ▽(s - l).
[0183] Optionally, the obtaining the incident component of the input image by solving the minimum value of the loss function executed by the processor 802 includes:
[0184] Use the Adam optimization algorithm to solve for the minimum of the loss function to obtain the incident component of the input image.
[0185] Optionally, the obtaining of the optimized image of the input image according to the incident component executed by the processor 802 includes:
[0186] Remove the incident component from the input image to obtain the reflection component of the input image;
[0187] Perform gamma correction on the incident component to obtain a corrected component;
[0188] Use the product of the reflection component and the corrected component as the optimized image.
[0189] Optionally, before obtaining the optimized image of the input image according to the incident component, the processor 802 is further configured to:
[0190] Obtain the image information of the H channel, the image information of the S channel, and the image information of the V channel in the hue saturation value (HSV) space of the input image, where the incident component is the incident component of the image information of the V channel;
[0191] The obtaining of the optimized image of the input image according to the incident component executed by the processor 802 includes:
[0192] Obtain the image information of the optimized V channel of the input image according to the incident component;
[0193] Convert the image information of the H channel, the image information of the S channel, and the image information of the optimized V channel into the optimized image in the red green blue (RGB) space.
[0194] It should be noted that the above electronic device 800 in this embodiment can implement any implementation manner in the image enhancement method embodiment based on the Retinex theory in the embodiments of the present invention. That is to say, any implementation manner in the image enhancement method embodiment based on the Retinex theory in the embodiments of the present invention can be implemented by the above electronic device 800 in this embodiment, and the same beneficial effects can be achieved, which will not be elaborated here.
[0195] The embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the steps in the image enhancement method based on the Retinex theory provided by the embodiments of the present invention, or when the computer program is executed by a processor, it implements the steps in the image enhancement method based on the Retinex theory provided by the embodiments of the present invention.
[0196] The above are the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. An image enhancement method based on the Retinex theory, characterized in that Including: Obtain the input image; Solve for the incident component of the input image that minimizes the loss function; Obtain the optimized image of the input image based on the incident component; Wherein, the loss function includes an activation function; The loss function is the following function: wherein, c1, c2, and c3 are preset weight values, l is the logarithm of the incident component, s is the logarithm of the input image, is the first-order partial derivative of l, is the first-order partial derivative of s - l; The obtaining the optimized image of the input image based on the incident component includes: Remove the incident component from the input image to obtain the reflected component of the input image, where the value of the reflected component is limited to 0 to 1, ensuring that the incident component ≥ the input image; Perform gamma correction on the incident component to obtain a corrected component; Use the product of the reflected component and the corrected component as the optimized image; Before obtaining the optimized image of the input image based on the incident component, the method further includes: Obtain the image information of the H channel, the image information of the S channel, and the image information of the V channel in the Hue-Saturation-Value (HSV) space of the input image, wherein the incident component is the incident component of the image information of the V channel; The obtaining the optimized image of the input image based on the incident component includes: Obtain the optimized image information of the V channel of the input image based on the incident component; Convert the image information of the H channel, the image information of the S channel, and the optimized image information of the V channel into the optimized image in the Red-Green-Blue (RGB) space.
2. The method according to claim 1, wherein The loss function is the following function:
3. The method according to claim 2, wherein Solve using the Scharr operator and 4. The method according to any one of claims 1 to 3, characterized in that, The solving for the incident component of the input image that minimizes the loss function includes: Use the Adam optimization algorithm to solve for the incident component of the input image that minimizes the loss function.
5. An image enhancement device based on the Retinex theory, characterized in that Including: A first obtaining module for obtaining the input image; A solving module for solving for the incident component of the input image that minimizes the loss function; A processing module for obtaining the optimized image of the input image based on the incident component; Wherein, the loss function includes an activation function; The loss function is the following function: wherein, c1, c2, and c3 are preset weight values, l is the logarithm of the incident component, and s is the logarithm of the input image, is the first-order partial derivative of l, is the first-order partial derivative of s - l; The processing module includes: A removing unit for removing the incident component from the input image to obtain the reflected component of the input image, where the value of the reflected component is limited to 0 to 1, ensuring that the incident component ≥ the input image; A correcting unit for performing gamma correction on the incident component to obtain a corrected component; An operating unit for using the product of the reflected component and the corrected component as the optimized image; The apparatus further includes: A second obtaining module for obtaining the image information of the H channel, the image information of the S channel, and the image information of the V channel in the HSV space of the input image, wherein the incident component is the incident component of the image information of the V channel; The processing module includes: A processing unit for obtaining the optimized image information of the V channel of the input image based on the incident component; A converting unit for converting the image information of the H channel, the image information of the S channel, and the optimized image information of the V channel into the optimized image in the RGB space.
6. The device according to claim 5, characterized in that, The loss function is the following function:
7. The device according to claim 6, characterized in that, Solve using the Scharr operator and 8. The device according to any one of claims 5 to 7, characterized in that, The solving module is used to solve the incident component of the input image that minimizes the loss function by using the Adam optimization algorithm.
9. An electronic device, characterized in that, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implements the steps in the Retinex theory-based image enhancement method according to any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps in the Retinex theory-based image enhancement method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Sharpness processing method for foggy-day images
CN105513015A
Haze weather image enhancement method
CN106997584A
Image enhancement method, device and equipment
CN107358586A
Enhancement method for low-illumination image
CN105654437A