A method, device and storage medium for optimizing low-light images
By performing grayscale processing, polynomial conversion and Gaussian convolution kernel processing on low-light images, the channel sub-image of the color image is optimized, which solves the problem of low-light image quality and achieves high image quality without increasing hardware costs. promote.
Patent Information
- Application Number
- CN202011311042.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-20
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-11-20
AI Technical Summary
Low-illumination images have low image quality when shot in low-light environments. Existing fill-light methods increase hardware costs and are not suitable for all scenes, and cannot effectively improve image quality.
By performing grayscale processing, polynomial conversion, and Gaussian convolution kernel processing on the original color image, the channel sub-images of the color image are extracted and optimized, and merged to improve image quality and optimize low-light images.
Significantly improves the quality of low-light images without increasing hardware costs and is suitable for a variety of scenarios.
Smart Images

Figure CN112508805B
Abstract
Description
Technical Field
[0001] The present invention relates to image optimization, and in particular to a method, device and storage medium for optimizing low-illuminance images. Background Art
[0002] Low-light images refer to images produced by taking photos in a low-light environment. For example, during 24-hour monitoring, the images taken by the camera are usually low-light images due to the weak light at night. Due to the low image quality of low-light images, such as low image clarity, they cannot be used later. Usually, the quality of the captured images is improved by adding a fill light to the camera to supplement the light for the camera shooting, but this method will greatly increase the hardware cost; at the same time, since the light used by the fill light is generally visible light or infrared light, for some special scenes, it is not allowed to use visible light as the light source for shooting, and this method is not available. Therefore, there is an urgent need for a method to optimize low-light images to improve the quality of low-light images. Summary of the invention
[0003] In order to overcome the deficiencies of the prior art, one of the objectives of the present invention is to provide a method for optimizing low-illumination images, which can solve the problems of low quality of images captured in a weak light environment in the prior art.
[0004] A second object of the present invention is to provide a low-light image optimization device, which can solve the problems of low quality of images taken in low-light environments in the prior art.
[0005] A third object of the present invention is to provide a storage medium that can solve the problems of low quality of images taken in a low-light environment in the prior art.
[0006] One of the purposes of the present invention is achieved by the following technical solution:
[0007] A low-illumination image optimization method, comprising:
[0008] Grayscale step: obtain the original color image, and perform grayscale processing on the original color image to obtain a grayscale image;
[0009] Polynomial transformation step: perform polynomial transformation on the grayscale image to obtain the polynomial transformation result;
[0010] Grayscale ratio image calculation steps: taking multiple different Gaussian convolution kernel functions in sequence, and processing the grayscale image according to the Gaussian convolution kernel function to obtain the corresponding grayscale ratio image;
[0011] Grayscale coefficient image calculation steps: obtaining a corresponding intermediate grayscale image according to the polynomial transformation result and each grayscale ratio image, and obtaining a grayscale coefficient image according to a plurality of intermediate grayscale images;
[0012] Sub-image extraction step: processing the original color image to obtain multiple channel sub-images;
[0013] Channel sub-image calculation steps: deriving each channel contrast image according to each channel sub-image and the grayscale image, and deriving the corresponding channel optimized image according to each channel contrast image and the grayscale coefficient image;
[0014] Merging step: Merge multiple channel optimized sub-images to obtain the optimized image.
[0015] Furthermore, the multiple channel sub-images include a red channel sub-image, a green channel sub-image and a blue channel sub-image; the multiple channel contrast images include a red channel contrast image, a green channel contrast image and a blue channel contrast image; and the multiple channel optimized sub-images include a red channel optimized sub-image, a green channel optimized sub-image and a blue channel optimized sub-image.
[0016] Furthermore, the channel sub-image calculation step includes:
[0017] The corresponding channel contrast image is obtained by dividing each channel sub-image by the grayscale image;
[0018] Each channel contrast image is multiplied by the gamma image to produce the corresponding channel-optimized sub-image.
[0019] Furthermore, the intermediate result image of the grayscale ratio image calculation step is obtained according to formula (2):
[0020] I Gauss =I gray *G(2); where G is the Gaussian convolution kernel function, I gray is a grayscale image, I Gauss is the intermediate result image;
[0021] Each grayscale ratio image is obtained according to formula (3):
[0022] Among them, I gray_contrast is the grayscale ratio image.
[0023] Furthermore, each intermediate grayscale image in the grayscale coefficient image calculation step is obtained according to formula (4):
[0024] I gray_mid =I ploy ∧I gray_contrast (4); where Igray_mid is the intermediate grayscale image, I ploy The result of polynomial conversion.
[0025] Furthermore, the polynomial conversion step includes: performing polynomial conversion on the grayscale image according to formula (1) to obtain a polynomial conversion result;
[0026] in, m and n are both positive numbers less than 1, p is an integer greater than 1, I ploy is the polynomial conversion result, I gray is a grayscale image.
[0027] Furthermore, the different Gaussian convolution kernel functions in the grayscale ratio image calculation step are Gaussian convolution kernel functions of different sizes.
[0028] Furthermore, obtaining the grayscale coefficient image based on the multiple intermediate result grayscale images in the grayscale coefficient image calculation step includes summing the multiple intermediate result grayscale images and calculating the average value to obtain the grayscale coefficient image.
[0029] The second object of the present invention is achieved by adopting the following technical solution:
[0030] A low-light image optimization device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the computer program is a low-light image optimization program, and when the processor executes the low-light image optimization program, the processor implements the steps of a low-light image optimization method adopted as one of the purposes of the present invention.
[0031] The third object of the present invention is achieved by adopting the following technical solution:
[0032] A storage medium, which is a computer-readable storage medium and stores a computer program, wherein the computer program is an optimization program for low-light images, and when the optimization program for low-light images is executed by a processor, the steps of optimizing a low-light image as adopted in one of the purposes of the present invention are implemented.
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] The present invention optimizes the original color image by optimizing the sub-images of multiple channels of the original color image respectively, and then merges the optimized sub-images of multiple channels to achieve the optimization of the original color image, thereby greatly improving the quality of the low-illuminance image while ensuring that the hardware cost remains unchanged. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A flow chart of a low-illumination image optimization method provided by the present invention;
[0036] Figure 2 A module diagram of a low-illumination image optimization device provided by the present invention.
[0037] In the figure: 11, memory; 12, processor; 13, communication bus; 14, network interface. DETAILED DESCRIPTION
[0038] The present invention is further described below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that, under the premise of no conflict, the various embodiments or technical features described below can be arbitrarily combined to form a new embodiment.
[0039] Embodiment 1
[0040] The present invention provides a method for optimizing low-light images, which extracts sub-images of multiple channels in a color image, optimizes the sub-images of each channel respectively, and then merges the sub-images of three channels to obtain an optimized image, thereby optimizing the original image and improving the image quality without changing the hardware cost. Figure 1 As shown, this embodiment includes the following steps:
[0041] Step S1, obtain the original color image. Set the original color image as I RGB .
[0042] The original color image is obtained by a camera device or other storage device. Preferably, the original color image in this embodiment is a low-light image, which is obtained by shooting in a weak light environment.
[0043] Step S2: grayscale the original color image to obtain a grayscale image.
[0044] By transforming the original color image I RGB Grayscale processing is performed to facilitate the next step of image processing.
[0045] Step S3: Perform polynomial transformation on the grayscale image to obtain a polynomial transformation result.
[0046] Preferably, the grayscale image is polynomially transformed according to formula (1) to obtain a polynomial transformation result I ploy :
[0047]
[0048] Among them, I gray is a grayscale image, I ploy is the result of polynomial conversion. Among them, ∧ is the logical operation symbol:
[0049] Both m and n are positive numbers less than 1, and p is an integer greater than 1. m, n, and p can select corresponding values according to the actual image effect. These parameters are related to the program that controls the darkening of the bright area and the brightening of the dark area after the original image is processed. In the actual calculation process, these parameters are set according to the brightness or darkness of the original image.
[0050] Step S4: Process the grayscale image according to the Gaussian convolution kernel function to obtain a grayscale ratio image.
[0051] Preferably, a Gaussian convolution kernel function is used to perform a convolution operation on the grayscale image to obtain an intermediate result image, as shown in formula (2):
[0052] I Gauss =I gray *G(2). Where G is the Gaussian convolution kernel function, I Gauss is the intermediate result image, and * is the convolution operation symbol.
[0053] The grayscale ratio image is obtained based on the intermediate result image and the grayscale image:
[0054] Among them, I gray_contrast is the grayscale ratio image.
[0055] Step S5, obtaining an intermediate grayscale image according to the polynomial conversion result and the grayscale ratio image.
[0056] Among them, I gray_mid =I ploy ∧I gray_contrast (4) Among them, I gray_mid is the intermediate grayscale image.
[0057] Step S6, respectively taking a plurality of Gaussian convolution kernel functions of different sizes, and respectively executing step S4 and step S5 to obtain a plurality of different intermediate grayscale images.
[0058] Step S7, summing up the multiple intermediate grayscale images and calculating the average value to obtain a grayscale coefficient image.
[0059] Among them, I gray_coef grayscale image, h is the number of Gaussian convolution kernel functions.
[0060] Among them, the Gaussian convolution kernel function is essentially a matrix. Each value in the matrix obeys a two-dimensional Gaussian distribution. Therefore, taking multiple Gaussian convolution kernel functions of different sizes means taking multiple matrices that obey a two-dimensional Gaussian distribution; at the same time, the sizes of these matrices (that is, the number of rows and columns of the matrix) are not equal. Preferably, the Gaussian convolution kernel function can manually construct a matrix, or use a matrix generated by a function interface provided by a third party.
[0061] Step S8: Process the original color image to obtain multiple channel sub-images.
[0062] Since a color image is generally composed of red, green, and blue, in this embodiment, the plurality of channel sub-images are respectively a red channel sub-image I R , Green channel sub-image I G , blue channel sub-image I B .
[0063] Step S9: Obtain each channel contrast image according to each channel sub-image and the grayscale image.
[0064] Among them, the channel contrast images are: red channel contrast image I R_contrast , Green channel contrast image I G_contrast , blue channel contrast image I B_contrast .
[0065] That is, the contrast image of each channel is obtained according to formulas (6), (7) and (8), specifically:
[0066]
[0067]
[0068]
[0069] Step S10, obtaining each channel optimized sub-image according to the grayscale coefficient image and each channel contrast image.
[0070] According to formulas (9), (10) and (11), the optimized sub-image of each channel is obtained respectively, which is:
[0071] I R_result =I gray_coef ×I R_contrast (9)
[0072] I G_result =I gray_coef ×I G_contrast (10)
[0073] I B_result =I gray_coef ×I B_contrast (11).
[0074] Among them, I R_result Optimize sub-image for red channel, I G_result Green channel optimized sub-image, I B_result Blue channel optimized sub-image.
[0075] This embodiment first extracts channel sub-images from the original color image, and then performs optimization processing on each extracted channel sub-image.
[0076] Step S11, obtaining an optimized color image according to the multiple channel optimization sub-images.
[0077] Preferably, the three channel optimized sub-images are merged to generate an RGB image, that is, an optimized image.
[0078] The present invention processes the original color image to obtain three-channel sub-images, then optimizes the sub-images of each channel respectively, and finally merges the optimized sub-images of the three channels into a new color image, that is, the optimized color image, thereby improving the quality of the original color image. The present invention greatly improves the effect of low-light images without increasing hardware costs, and is suitable for applications in various fields.
[0079] Embodiment 2
[0080] The present invention provides a low-light image optimization device. Figure 2 As shown, a schematic diagram of the internal structure of a low-illumination image optimization device provided by an embodiment of the present invention.
[0081] In this embodiment, a low-light image optimization device can be a PC (Personal Computer), or a terminal device such as a smart phone, a tablet computer, a portable computer, etc. The low-light image optimization device at least includes: a processor 12, a communication bus 13, a network interface 14, and a memory 11.
[0082] Among them, the memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of a low-light image optimization device, such as a hard disk of the low-light image optimization device. In other embodiments, the memory 11 can also be an external storage device of a low-light image optimization device, such as a plug-in hard disk equipped on a low-light image optimization device, a smart memory card (SmartMedia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Further, the memory 11 can also include both an internal storage unit of a low-light image optimization device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in a low-light image optimization device, such as the code of the low-light image optimization program, but also can be used to temporarily store data that has been output or is to be output.
[0083] In some embodiments, the processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor or other data processing chip, and is used to run program codes or process data stored in the memory 11, such as executing a low-light image optimization program.
[0084] The communication bus 13 is used to realize the connection and communication between these components.
[0085] The network interface 14 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), and is generally used to establish a communication connection between the low-light image optimization device and other electronic devices.
[0086] Optionally, the low-light image optimization device may further include a user interface, which may include a display (Display), an input unit such as a keyboard (Keyboard), and the optional user interface may also include a standard wired interface and a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in a low-light image optimization device and to display a visual user interface.
[0087] Figure 2Only one low-light image optimization device having components 11-14 and a low-light image optimization program is shown. It can be understood by those skilled in the art that Figure 2 The structure shown does not constitute a limitation on a low-light image optimization device, and may include fewer or more components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0088] exist Figure 2 In the embodiment of the low-light image optimization device shown, the memory 11 stores a low-light image optimization program; when the processor 12 executes the low-light image optimization program stored in the memory 11, the following steps are implemented:
[0089] Grayscale step: obtain the original color image, and perform grayscale processing on the original color image to obtain a grayscale image;
[0090] Polynomial transformation step: perform polynomial transformation on the grayscale image to obtain the polynomial transformation result;
[0091] Grayscale ratio image calculation steps: taking multiple different Gaussian convolution kernel functions in sequence, and processing the grayscale image according to the Gaussian convolution kernel function to obtain the corresponding grayscale ratio image;
[0092] Grayscale coefficient image calculation steps: obtaining a corresponding intermediate grayscale image according to the polynomial transformation result and each grayscale ratio image, and obtaining a grayscale coefficient image according to a plurality of intermediate grayscale images;
[0093] Sub-image extraction step: processing the original color image to obtain multiple channel sub-images;
[0094] Channel sub-image calculation steps: deriving each channel contrast image according to each channel sub-image and the grayscale image, and deriving the corresponding channel optimized image according to each channel contrast image and the grayscale coefficient image;
[0095] Merging step: Merge multiple channel optimized sub-images to obtain the optimized image.
[0096] Furthermore, the multiple channel sub-images include a red channel sub-image, a green channel sub-image and a blue channel sub-image; the multiple channel contrast images include a red channel contrast image, a green channel contrast image and a blue channel contrast image; and the multiple channel optimized sub-images include a red channel optimized sub-image, a green channel optimized sub-image and a blue channel optimized sub-image.
[0097] Furthermore, the channel sub-image calculation step includes:
[0098] The corresponding channel contrast image is obtained by dividing each channel sub-image by the grayscale image;
[0099] Each channel contrast image is multiplied by the gamma image to produce the corresponding channel-optimized sub-image.
[0100] Furthermore, the intermediate result image of the grayscale ratio image calculation step is obtained according to formula (2):
[0101] I Gauss =I gray *G(2); where G is the Gaussian convolution kernel function, I gray is a grayscale image, I Gauss is the intermediate result image;
[0102] Each grayscale ratio image is obtained according to formula (3):
[0103] Among them, I gray_contrast is the grayscale ratio image.
[0104] Furthermore, each intermediate grayscale image in the grayscale coefficient image calculation step is obtained according to formula (4):
[0105] I gray_mid =I ploy ∧I gray_contrast (4); where I gray_mid is the intermediate grayscale image, I ploy The result of polynomial conversion.
[0106] Furthermore, the polynomial conversion step includes: performing polynomial conversion on the grayscale image according to formula (1) to obtain a polynomial conversion result;
[0107] in, m and n are both positive numbers less than 1, p is an integer greater than 1, I ploy is the polynomial conversion result, I gray is a grayscale image.
[0108] Furthermore, the different Gaussian convolution kernel functions in the grayscale ratio image calculation step are Gaussian convolution kernel functions of different sizes.
[0109] Furthermore, obtaining the grayscale coefficient image based on the multiple intermediate result grayscale images in the grayscale coefficient image calculation step includes summing the multiple intermediate result grayscale images and calculating the average value to obtain the grayscale coefficient image.
[0110] Embodiment 3
[0111] The present invention also provides a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and the computer program is a low-illumination image optimization program; when the low-illumination image optimization program is executed by a processor, the following steps are implemented:
[0112] Grayscale step: obtain the original color image, and perform grayscale processing on the original color image to obtain a grayscale image;
[0113] Polynomial transformation step: perform polynomial transformation on the grayscale image to obtain the polynomial transformation result;
[0114] Grayscale ratio image calculation steps: taking multiple different Gaussian convolution kernel functions in sequence, and processing the grayscale image according to the Gaussian convolution kernel function to obtain the corresponding grayscale ratio image;
[0115] Grayscale coefficient image calculation steps: obtaining a corresponding intermediate grayscale image according to the polynomial transformation result and each grayscale ratio image, and obtaining a grayscale coefficient image according to a plurality of intermediate grayscale images;
[0116] Sub-image extraction step: processing the original color image to obtain multiple channel sub-images;
[0117] Channel sub-image calculation steps: deriving each channel contrast image according to each channel sub-image and the grayscale image, and deriving the corresponding channel optimized image according to each channel contrast image and the grayscale coefficient image;
[0118] Merging step: Merge multiple channel optimized sub-images to obtain the optimized image.
[0119] Furthermore, the multiple channel sub-images include a red channel sub-image, a green channel sub-image and a blue channel sub-image; the multiple channel contrast images include a red channel contrast image, a green channel contrast image and a blue channel contrast image; and the multiple channel optimized sub-images include a red channel optimized sub-image, a green channel optimized sub-image and a blue channel optimized sub-image.
[0120] Furthermore, the channel sub-image calculation step includes:
[0121] The corresponding channel contrast image is obtained by dividing each channel sub-image by the grayscale image;
[0122] Each channel contrast image is multiplied by the gamma image to produce the corresponding channel-optimized sub-image.
[0123] Furthermore, the intermediate result image of the grayscale ratio image calculation step is obtained according to formula (2):
[0124] I Gauss =I gray *G(2); where G is the Gaussian convolution kernel function, I gray is a grayscale image, I Gauss is the intermediate result image;
[0125] Each grayscale ratio image is obtained according to formula (3):
[0126] Among them, I gray_contrast is the grayscale ratio image.
[0127] Furthermore, each intermediate grayscale image in the grayscale coefficient image calculation step is obtained according to formula (4):
[0128] I gray_mid =I ploy ∧I gray_contrast (4); where I gray_mid is the intermediate grayscale image, I ploy The result of polynomial conversion.
[0129] Furthermore, the polynomial conversion step includes: performing polynomial conversion on the grayscale image according to formula (1) to obtain a polynomial conversion result;
[0130] in, m and n are both positive numbers less than 1, p is an integer greater than 1, I ploy is the polynomial conversion result, I gray is a grayscale image.
[0131] Furthermore, the different Gaussian convolution kernel functions in the grayscale ratio image calculation step are Gaussian convolution kernel functions of different sizes.
[0132] Furthermore, obtaining the grayscale coefficient image based on the multiple intermediate result grayscale images in the grayscale coefficient image calculation step includes summing the multiple intermediate result grayscale images and calculating the average value to obtain the grayscale coefficient image.
[0133] The above-mentioned embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and substitutions made by technicians in this field on the basis of the present invention shall fall within the scope of protection required by the present invention.
Claims
1. A method for optimizing low-light images, characterized in that: include: Grayscale step: obtain the original color image, and perform grayscale processing on the original color image to obtain a grayscale image; Polynomial transformation step: perform polynomial transformation on the grayscale image to obtain the polynomial transformation result; Grayscale ratio image calculation steps: taking multiple different Gaussian convolution kernel functions in sequence, and processing the grayscale image according to the Gaussian convolution kernel function to obtain the corresponding grayscale ratio image; Grayscale coefficient image calculation steps: obtaining a corresponding intermediate grayscale image according to the polynomial transformation result and each grayscale ratio image, and obtaining a grayscale coefficient image according to a plurality of intermediate grayscale images; Sub-image extraction step: processing the original color image to obtain multiple channel sub-images; Channel sub-image calculation steps: deriving each channel contrast image according to each channel sub-image and the grayscale image, and deriving the corresponding channel optimized image according to each channel contrast image and the grayscale coefficient image; Merging step: merging multiple channel optimized sub-images to obtain an optimized image; The intermediate result image of the grayscale ratio image calculation step is obtained according to formula (2): IGauss = Igray*G(2); where G is the Gaussian convolution kernel function, Igray is the grayscale image, and IGauss is the intermediate result image; Each grayscale ratio image is obtained according to formula (3): Among them, Igray_contrast is the grayscale ratio image; Among them, each intermediate result grayscale image in the grayscale coefficient image calculation step is obtained according to formula (4): Igray_mid=Iploy∧Igray_contrast(4); wherein Igray_mid is the intermediate grayscale image, and Iploy is the polynomial conversion result; The polynomial conversion step includes: performing polynomial conversion on the grayscale image according to formula (1) to obtain a polynomial conversion result; in, m and n are both positive numbers less than 1, p is an integer greater than 1, Iploy is the polynomial transformation result, and Igray is the grayscale image.
2. The low-light image optimization method according to claim 1, characterized in that: The plurality of channel sub-images include a red channel sub-image, a green channel sub-image, and a blue channel sub-image; The plurality of channel contrast images include a red channel contrast image, a green channel contrast image, and a blue channel contrast image; The multiple channel-optimized sub-images include a red channel-optimized sub-image, a green channel-optimized sub-image, and a blue channel-optimized sub-image.
3. The method for optimizing low-light images according to claim 2, characterized in that: The channel sub-image calculation step comprises: The corresponding channel contrast image is obtained by dividing each channel sub-image by the grayscale image; Each channel contrast image is multiplied by the gamma image to produce the corresponding channel-optimized sub-image.
4. The method for optimizing low-light images according to claim 1, characterized in that: The different Gaussian convolution kernel functions in the grayscale ratio image calculation step are Gaussian convolution kernel functions of different sizes.
5. The method for optimizing low-light images according to claim 1, characterized in that: The gamma image The step of calculating the grayscale coefficient image according to the plurality of intermediate grayscale images includes: Summing and averaging the values yields a gamma image.
6. A low-light image optimization device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is a low-light image optimization program, characterized in that: When the processor executes the low-illumination image optimization program, the steps of a low-illumination image optimization method according to any one of claims 1 to 5 are implemented.
7. A storage medium, wherein the storage medium is a computer-readable storage medium, and a computer program is stored thereon, wherein the computer program is a low-light image optimization program, characterized in that: When the low-illumination image optimization program is executed by a processor, the steps of optimizing a low-illumination image according to any one of claims 1 to 5 are implemented.
