Image processing method and related device
By using ambient light sensors and cameras in electronic devices, collecting ambient light brightness values and performing image segmentation and signal-to-noise ratio calculations, the problem of poor image quality when light is dark is solved, and the image quality is improved.
Patent Information
- Application Number
- CN202411995060.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-06-06
AI Technical Summary
In the case of dark light, the image quality is poor, and the prior art is difficult to effectively improve the image quality.
The ambient light brightness value is collected by the ambient light sensor, and the shooting is performed when the light is insufficient, a first image is obtained, and the target area and background area are obtained through image segmentation. Then, the signal-to-noise ratio of the target area and the background area is calculated, and the first image is subjected to image enhancement processing based on these signal-to-noise ratios to obtain a second image.
Through image enhancement processing, the image quality under darker light conditions is improved, so that the depth of the image enhancement effect is consistent with the image structure and characteristics.
Smart Images

Figure CN120107073A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology or computer technology, and in particular to an image processing method and related devices. Background Art
[0002] With the rapid development of electronic technology, electronic devices (such as mobile phones, tablet computers, etc.) are becoming more and more popular. Electronic devices have become a part of people's lives. At present, the image shooting effect is poor in dim light conditions. Therefore, how to improve the image quality in dim light conditions needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present application provide an image processing method and related devices, which are helpful to improve image quality in dim light conditions.
[0004] In a first aspect, an embodiment of the present application provides an image processing method, which is applied to an electronic device, wherein the electronic device includes an ambient light sensor and a camera; the method includes:
[0005] Collecting the ambient light brightness value by the ambient light sensor;
[0006] When the ambient light brightness value is less than a preset threshold, shooting is performed to obtain a first image;
[0007] Performing image segmentation on the first image to obtain a target area and a background area;
[0008] Determining a first signal-to-noise ratio of the target area and a second signal-to-noise ratio of the background area;
[0009] Perform image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image.
[0010] In a second aspect, an embodiment of the present application provides an image processing device, which is applied to an electronic device, wherein the electronic device includes an ambient light sensor and a camera; the device includes: a collection unit, a shooting unit, a segmentation unit, a determination unit, and an image enhancement unit, wherein:
[0011] The acquisition unit is used to acquire the ambient light brightness value through the ambient light sensor;
[0012] The shooting unit is used to shoot when the ambient light brightness value is less than a preset threshold value to obtain a first image;
[0013] The segmentation unit is used to perform image segmentation on the first image to obtain a target area and a background area;
[0014] The determining unit is used to determine a first signal-to-noise ratio of the target area and a second signal-to-noise ratio of the background area;
[0015] The image enhancement unit is used to perform image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program comprises instructions for executing some or all of the steps described in the method described in the first aspect of the embodiment of the present application.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, wherein the computer program is executed by a processor to implement part or all of the steps described in the method described in the first aspect of the embodiment of the present application.
[0018] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the method described in the first aspect of the embodiment of the present application. The computer program product may be a software installation package.
[0019] Implementing the embodiments of the present application has the following beneficial effects:
[0020] It can be seen that the image processing method and related devices described in the embodiments of the present application are applied to an electronic device, which includes an ambient light sensor and a camera. The ambient light brightness value is collected by the ambient light sensor. When the ambient light brightness value is less than a preset threshold, the camera is photographed to obtain a first image. The first image is segmented to obtain a target area and a background area. The first signal-to-noise ratio of the target area and the second signal-to-noise ratio of the background area are determined. The first image is image enhanced according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image. The first signal-to-noise ratio reflects the target quality, and the second signal-to-noise ratio reflects the background quality. The first signal-to-noise ratio and the second signal-to-noise ratio together reflect the image structure and image characteristics. The first image can be image enhanced based on the image structure and image characteristics. Therefore, in dim light conditions, the image enhancement effect depth is consistent with the image structure and image characteristics, which helps to improve the image quality in dim light conditions.
[0021] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a flowchart of an image processing method provided in an embodiment of the present application;
[0024] Figure 2 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0025] Figure 3 It is a structural schematic diagram of an image processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0027] The following are detailed descriptions of each.
[0028] The terms "first", "second", "third" and "fourth" etc. in the specification and claims of the present application and the drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0029] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0030] Below, some terms in this application are explained to facilitate understanding by those skilled in the art.
[0031] In an embodiment of the present application, the electronic device may include any computer device with a shooting function, the computer device may include an ambient light sensor and a camera, the computer device may include a smart phone, a tablet computer, a PDA, a driving recorder, a server, a laptop computer, a mobile Internet device or a wearable device (such as a smart watch, a Bluetooth headset, AI glasses), etc. The above are only examples and not exhaustive, including but not limited to the above electronic devices.
[0032] The following is a detailed description of the embodiments of the present application.
[0033] like Figure 1 As shown, Figure 1 1 is a flow chart of an image processing method provided in an embodiment of the present application, which is applied to an electronic device, wherein the electronic device includes an ambient light sensor and a camera; the method includes:
[0034] 101. Collect an ambient light brightness value through the ambient light sensor.
[0035] In an embodiment of the present application, the electronic device may include an ambient light sensor and a camera. The ambient light sensor may be used to detect the ambient light brightness to obtain the ambient light brightness value. The camera may include at least one of the following: a visible light camera, an infrared camera, etc., which are not limited here.
[0036] In a specific implementation, after receiving a shooting instruction, the shooting instruction is responded to and the ambient light brightness value is collected through the ambient light sensor.
[0037] 102. When the ambient light brightness value is less than a preset threshold, take a photo to obtain a first image.
[0038] The preset threshold value may be preset or set by system default.
[0039] In a specific implementation, when the ambient light brightness value is less than a preset threshold, it means that the image is in a dark visual environment or in a dark light condition, and then, the image can be taken to obtain the first image.
[0040] In an embodiment of the present application, a mapping relationship between preset ambient light brightness values and shooting parameters can be pre-stored, and then, based on the mapping relationship, the target shooting parameters corresponding to the ambient light brightness values collected by the ambient light sensor can be determined, and shooting can be performed according to the target shooting parameters to obtain a first image, and then, shooting can be performed based on the shooting parameters corresponding to the ambient light, so that the shooting effect is deeply adapted to the actual environment.
[0041] The shooting parameters may include at least one of the following: white balance parameters, sensitivity, exposure time, fill light parameters, etc., which are not limited here.
[0042] 103. Perform image segmentation on the first image to obtain a target area and a background area.
[0043] In a specific implementation, the first image may be segmented to obtain a target area and a background area, because the target area and the background area reflect image characteristics and the focus of user attention.
[0044] Optionally, the above step 103, performing image segmentation on the first image to obtain the target area and the background area, may include the following steps:
[0045] Performing multi-scale decomposition on the first image to obtain a low-frequency component part;
[0046] determining a first image quality evaluation value of the first image;
[0047] determining a first image segmentation algorithm corresponding to the first image quality evaluation value;
[0048] Determining a first information entropy of the low-frequency component part;
[0049] determining a second information entropy of the first image;
[0050] Determine a first information entropy ratio between the first information entropy and the second information entropy; determine a first algorithm control parameter of the first image segmentation algorithm corresponding to the first information entropy ratio;
[0051] The first image is segmented according to the first image segmentation algorithm and the first algorithm control parameters to obtain the target area and the background area.
[0052] In a specific implementation, a multi-scale decomposition algorithm may be used to perform multi-scale decomposition on the first image to obtain a low-frequency component part and a high-frequency component part. The multi-scale decomposition algorithm may include at least one of the following: a wavelet transform algorithm, a contourlet transform algorithm, a Laplace pyramid transform algorithm, a non-subsampled contourlet transform algorithm, a shearlet transform algorithm, a ridgelet transform algorithm, etc., which are not limited here. The low-frequency component part reflects the main body of the image, and the high-frequency component part reflects the detailed features of the image.
[0053] Next, at least one image quality evaluation index may be used to evaluate the image quality of the first image to obtain at least one evaluation result, each image quality evaluation index corresponds to an evaluation result and a weight, and then, a weighted operation may be performed on the at least one evaluation result and the corresponding weight to obtain a first image quality evaluation value. The image quality evaluation index may include at least one of the following: average gradient, clarity, information entropy, signal-to-noise ratio, contrast, etc., which are not limited here.
[0054] Among them, the mapping relationship between the preset image quality evaluation value and the image segmentation algorithm can also be pre-stored, and then, the first image segmentation algorithm corresponding to the first image quality evaluation value can be determined based on the mapping relationship. In this way, the image segmentation algorithm corresponding to the actual image quality can be obtained, so that the image segmentation effect is deeply adapted to the actual situation of the image.
[0055] Furthermore, the information entropy of the low-frequency component can be determined to obtain the first information entropy, and the second information entropy of the first image can be determined, and then the ratio between the first information entropy and the second information entropy can be determined to obtain the first information entropy ratio, where the first information entropy ratio = first information entropy / second information entropy.
[0056] Among them, since the low-frequency component part reflects the image subject, the high-frequency component part reflects the image detail features, and the information entropy ratio reflects the degree of masking of the image subject on the image detail features, and to a certain extent also reflects the image segmentation difficulty, therefore, the mapping relationship between the preset information entropy ratio and the algorithm control parameter of the first image segmentation algorithm can also be pre-stored, and the algorithm control parameter is used to control the image segmentation effect of the first image segmentation algorithm, and the image segmentation effect can include at least one of the following: image segmentation degree, image segmentation speed, image segmentation range, etc., which are not limited here. Then, the first algorithm control parameter of the first image segmentation algorithm corresponding to the first information entropy ratio can be determined based on the mapping relationship, and then the first image is segmented according to the first image segmentation algorithm and the first algorithm control parameter to obtain the target area and the background area. On the one hand, not only can an image segmentation algorithm corresponding to the actual image quality be obtained, so that the image segmentation effect is deeply adapted to the actual situation of the image, but on the other hand, the algorithm control parameters of the first image segmentation algorithm can also be deeply optimized based on the degree of masking of the image subject on the image detail features and the image segmentation difficulty, so that the image segmentation effect is adapted to the characteristics of the image itself, thereby improving the accuracy of image segmentation, which is helpful to improve the subsequent image enhancement effect and improve the image quality.
[0057] 104. Determine a first signal-to-noise ratio of the target area and a second signal-to-noise ratio of the background area.
[0058] In a specific implementation, the signal-to-noise ratio of the target area may be determined to obtain a first signal-to-noise ratio, and the signal-to-noise ratio of the background area may be determined to obtain a second signal-to-noise ratio.
[0059] 105. Perform image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image.
[0060] In a specific implementation, the first signal-to-noise ratio reflects the target quality, the second signal-to-noise ratio reflects the background quality, and the first signal-to-noise ratio and the second signal-to-noise ratio together reflect the image structure and image characteristics. Furthermore, the first image can be enhanced based on the image structure and image characteristics to obtain the second image, so that the image enhancement effect depth conforms to the image structure and image characteristics, which helps to improve the image quality in dim light conditions.
[0061] Optionally, the above step 105, performing image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain the second image, may include the following steps:
[0062] determining a first relative deviation between the first signal-to-noise ratio and the second signal-to-noise ratio;
[0063] Determining a first difference between the preset threshold and the ambient light brightness value;
[0064] determining a first image enhancement algorithm corresponding to the first difference;
[0065] Obtaining a first attribute parameter of the camera;
[0066] Determining a first control parameter of the first image enhancement algorithm corresponding to the first attribute parameter;
[0067] When the first relative deviation is within a preset range, image enhancement processing is performed on the first image according to the first image enhancement algorithm and the first control parameter to obtain the second image; the preset range includes an upper threshold and a lower threshold.
[0068] In a specific implementation, a first relative deviation between the first signal-to-noise ratio and the second signal-to-noise ratio may be determined, where the first relative deviation=(first signal-to-noise ratio−second signal-to-noise ratio) / (first signal-to-noise ratio+second signal-to-noise ratio).
[0069] Next, a first difference between the preset threshold and the ambient light brightness value can be determined, where the first difference = preset threshold - ambient light brightness value. A mapping relationship between the preset difference and the image enhancement algorithm can also be pre-stored. Then, a first image enhancement algorithm corresponding to the first difference can be determined based on the mapping relationship. Since the first difference reflects the difference between the actual light conditions and the critical light conditions (preset threshold), the corresponding image enhancement algorithm can be adapted based on the difference, so that the image enhancement algorithm depth conforms to the actual dark visual environment.
[0070] In an embodiment of the present application, a first attribute parameter of the camera can also be obtained. The first attribute parameter reflects the performance of the camera. The first attribute parameter may include at least one of the following: camera model, camera hardware configuration parameters, camera software configuration parameters, etc., which are not limited here.
[0071] Next, the mapping relationship between the preset attribute parameters of the camera and the control parameters of the first image enhancement algorithm can be pre-stored. The control parameters are used to control the image enhancement effect. The image enhancement effect can include at least one of the following: image enhancement degree, image enhancement area range, image enhancement speed, etc., which are not limited here. Furthermore, the first control parameter of the first image enhancement algorithm corresponding to the first attribute parameter can be determined based on the mapping relationship. In this way, an image enhancement effect corresponding to the performance of the camera can be obtained, so that the actual image enhancement effect depth further meets the performance of the camera.
[0072] The preset range may be preset or set by system default, and the preset range includes an upper threshold and a lower threshold, and the lower threshold is smaller than the upper threshold.
[0073] Furthermore, when the first relative deviation is within a preset range, it means that the quality difference between the background and the target of the image is not large, and the first image can be enhanced according to the first image enhancement algorithm and the first control parameter to obtain a second image. In this way, when the quality difference between the background and the target of the image is not large, image enhancement processing can be performed on the target area and the background area, that is, consistent image enhancement processing, which can ensure the image enhancement effect and make the image enhancement effect depth consistent with the image structure and image characteristics, which is helpful to improve the image quality in dim light conditions.
[0074] Optionally, the following steps may also be included:
[0075] determining a first area of the target region and a second area of the first image;
[0076] determining a target area ratio between the first area and the second area;
[0077] When the first relative deviation is greater than the upper threshold, determining a second difference between the first relative deviation and the upper threshold;
[0078] determining a first optimization parameter corresponding to the second difference;
[0079] Determine a second control parameter according to the first optimization parameter and the first control parameter;
[0080] Determining a second optimization parameter corresponding to the target area ratio;
[0081] Determine a third control parameter according to the second optimization parameter and the first control parameter;
[0082] Performing image enhancement processing on the target area according to the first image enhancement algorithm and the third control parameter to obtain a first target area;
[0083] Performing image enhancement processing on the background area according to the first image enhancement algorithm and the second control parameter to obtain a first background area;
[0084] The second image is determined according to the first target area and the first background area.
[0085] In a specific implementation, the area of the target region can be determined to obtain a first area, and the area of the first image can be determined to obtain a second area, and then the target area ratio between the first area and the second area can be determined, where the target area ratio = first area / second area. The target area ratio reflects the significance of the target to a certain extent.
[0086] Next, when the first relative deviation is greater than the upper limit threshold, it means that the quality of the target area is better than the quality of the background area, and then the second difference between the first relative deviation and the upper limit threshold is determined, the second difference = first relative deviation - upper limit threshold, the second difference reflects the degree to which the quality of the target area is better than the quality of the background area, and the first mapping relationship between the preset difference and the optimization parameter can be pre-stored, and then, the first optimization parameter corresponding to the second difference can be determined based on the first mapping relationship, that is, the corresponding optimization parameter can be determined based on the degree to which the quality of the target area is better than the quality of the background area, and then the second control parameter is determined according to the first optimization parameter and the first control parameter, the second control parameter = (1 + first optimization parameter) * first control parameter, which helps to reduce the difference between background quality and target quality while enhancing the image.
[0087] Next, a second mapping relationship between a preset area ratio and an optimization parameter can be pre-stored, and then a second optimization parameter corresponding to the target area ratio can be determined based on the second mapping relationship, and then a third control parameter can be determined based on the second optimization parameter and the first control parameter, where the third control parameter = (1 + second optimization parameter) * first control parameter.
[0088] Next, the target area is image enhanced according to the first image enhancement algorithm and the third control parameter to obtain the first target area, and the background area is image enhanced according to the first image enhancement algorithm and the second control parameter to obtain the first background area, and then the second image is determined according to the first target area and the first background area. On the one hand, when the quality of the target area is better than that of the background area, the first control parameter is optimized based on the second difference (the degree to which the quality of the target area is better than that of the background area) to obtain the second control parameter, and then the background area is enhanced based on the second control parameter and the first image enhancement algorithm, which can reduce the difference between the background quality and the target quality while enhancing the image. On the other hand, the first control parameter is optimized based on the target area ratio (the significance of the target) to obtain the third control parameter, and then the target area is enhanced based on the third control parameter and the first image enhancement algorithm, that is, while the target area is image enhanced, the target significance can also be moderately improved, which is more in line with the aesthetic characteristics of the human eye, thereby helping to improve image quality in dim light conditions.
[0089] Optionally, the following steps may also be included:
[0090] When the first relative deviation is less than the lower threshold, determining a third difference between the lower threshold and the first relative deviation;
[0091] determining a third optimization parameter corresponding to the third difference;
[0092] Determine a fourth control parameter according to the third optimization parameter and the first control parameter;
[0093] Determining a fourth optimization parameter corresponding to the target area ratio;
[0094] Determine a fifth control parameter according to the fourth optimization parameter and the fourth control parameter;
[0095] Performing image enhancement processing on the target area according to the first image enhancement algorithm and the fifth control parameter to obtain a second target area;
[0096] Performing image enhancement processing on the background area according to the first image enhancement algorithm and the first control parameter to obtain a second background area;
[0097] The second image is determined according to the second target area and the second background area.
[0098] In a specific implementation, when the first relative deviation is less than the lower limit threshold, it means that the quality of the background area is better than the quality of the target area. Then, the third difference between the lower limit threshold and the first relative deviation can be determined, and the third difference = the lower limit threshold - the first relative deviation. The third difference reflects the degree to which the quality of the background area is better than the quality of the target area. That is, the third mapping relationship between the preset difference and the optimization parameter can be pre-stored, and then, the third optimization parameter corresponding to the third difference can be determined based on the third mapping relationship, and then the fourth control parameter can be determined according to the third optimization parameter and the first control parameter, that is, the fourth control parameter = (1 + the third optimization parameter) * the first control parameter, which can reduce the difference between the target quality and the background quality while enhancing the image.
[0099] Next, a fourth mapping relationship between a preset area ratio and an optimization parameter can be pre-stored, and then, a fourth optimization parameter corresponding to the target area ratio can be determined based on the fourth mapping relationship, and then a fifth control parameter can be determined according to the fourth optimization parameter and the fourth control parameter, that is, the fifth control parameter = (1 + fourth optimization parameter) * fourth control parameter. This can not only reduce the difference between the target quality and the background quality while enhancing the image, but also improve the target significance.
[0100] Furthermore, the target area can be image enhanced according to the first image enhancement algorithm and the fifth control parameter to obtain a second target area, the background area can be image enhanced according to the first image enhancement algorithm and the first control parameter to obtain a second background area, and then the second image can be determined according to the second target area and the second background area. On the one hand, when the quality of the background area is better than that of the target area, the first control parameter is optimized based on the third difference (the degree to which the quality of the background area is better than that of the target area) to obtain a fourth control parameter, and then the target area is enhanced based on the fourth control parameter and the first image enhancement algorithm. This can reduce the difference between the target quality and the background quality while enhancing the image. On the other hand, the fourth control parameter is optimized based on the target area ratio (the significance of the target) to obtain the fifth control parameter, and then the target area is enhanced based on the fifth control parameter and the first image enhancement algorithm. That is, while the target area is image enhanced, the target significance can also be moderately improved, which is more in line with the aesthetic characteristics of the human eye, thereby helping to improve image quality in dim light conditions.
[0101] It can be seen that the image processing method described in the embodiment of the present application is applied to an electronic device, and the electronic device includes an ambient light sensor and a camera. The ambient light brightness value is collected by the ambient light sensor. When the ambient light brightness value is less than a preset threshold, the camera is taken to obtain a first image, and the first image is segmented to obtain a target area and a background area. The first signal-to-noise ratio of the target area and the second signal-to-noise ratio of the background area are determined. The first image is image enhanced according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image. The first signal-to-noise ratio reflects the target quality, and the second signal-to-noise ratio reflects the background quality. The first signal-to-noise ratio and the second signal-to-noise ratio together reflect the image structure and image characteristics. The first image can be image enhanced based on the image structure and image characteristics. Therefore, in dim light conditions, the image enhancement effect depth is consistent with the image structure and image characteristics, which helps to improve the image quality in dim light conditions.
[0102] In accordance with the above embodiment, please refer to Figure 2 , Figure 2 : is a structural schematic diagram of an electronic device provided in an embodiment of the present application. As shown in the figure, the electronic device includes a processor, a memory, a communication interface, and one or more programs. The one or more programs are stored in the memory and are configured to be executed by the processor. In the embodiment of the present application, the electronic device also includes an ambient light sensor and a camera; the program includes instructions for executing the following steps:
[0103] Collecting the ambient light brightness value by the ambient light sensor;
[0104] When the ambient light brightness value is less than a preset threshold, shooting is performed to obtain a first image;
[0105] Performing image segmentation on the first image to obtain a target area and a background area;
[0106] Determining a first signal-to-noise ratio of the target area and a second signal-to-noise ratio of the background area;
[0107] Perform image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image.
[0108] Optionally, in the aspect of performing image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain the second image, the program includes instructions for executing the following steps:
[0109] determining a first relative deviation between the first signal-to-noise ratio and the second signal-to-noise ratio;
[0110] Determining a first difference between the preset threshold and the ambient light brightness value;
[0111] determining a first image enhancement algorithm corresponding to the first difference;
[0112] Obtaining a first attribute parameter of the camera;
[0113] Determining a first control parameter of the first image enhancement algorithm corresponding to the first attribute parameter;
[0114] When the first relative deviation is within a preset range, image enhancement processing is performed on the first image according to the first image enhancement algorithm and the first control parameter to obtain the second image; the preset range includes an upper threshold and a lower threshold.
[0115] Optionally, the program further includes instructions for executing the following steps:
[0116] determining a first area of the target region and a second area of the first image;
[0117] determining a target area ratio between the first area and the second area;
[0118] When the first relative deviation is greater than the upper threshold, determining a second difference between the first relative deviation and the upper threshold;
[0119] determining a first optimization parameter corresponding to the second difference;
[0120] Determine a second control parameter according to the first optimization parameter and the first control parameter;
[0121] Determining a second optimization parameter corresponding to the target area ratio;
[0122] Determine a third control parameter according to the second optimization parameter and the first control parameter;
[0123] Performing image enhancement processing on the target area according to the first image enhancement algorithm and the third control parameter to obtain a first target area;
[0124] Performing image enhancement processing on the background area according to the first image enhancement algorithm and the second control parameter to obtain a first background area;
[0125] The second image is determined according to the first target area and the first background area.
[0126] Optionally, the program further includes instructions for executing the following steps:
[0127] When the first relative deviation is less than the lower threshold, determining a third difference between the lower threshold and the first relative deviation;
[0128] determining a third optimization parameter corresponding to the third difference;
[0129] Determine a fourth control parameter according to the third optimization parameter and the first control parameter;
[0130] Determining a fourth optimization parameter corresponding to the target area ratio;
[0131] Determine a fifth control parameter according to the fourth optimization parameter and the fourth control parameter;
[0132] Performing image enhancement processing on the target area according to the first image enhancement algorithm and the fifth control parameter to obtain a second target area;
[0133] Performing image enhancement processing on the background area according to the first image enhancement algorithm and the first control parameter to obtain a second background area;
[0134] The second image is determined according to the second target area and the second background area.
[0135] Optionally, in the aspect of performing image segmentation on the first image to obtain the target area and the background area, the program includes instructions for executing the following steps:
[0136] Performing multi-scale decomposition on the first image to obtain a low-frequency component part;
[0137] determining a first image quality evaluation value of the first image;
[0138] determining a first image segmentation algorithm corresponding to the first image quality evaluation value;
[0139] Determining a first information entropy of the low-frequency component part;
[0140] determining a second information entropy of the first image;
[0141] Determine a first information entropy ratio between the first information entropy and the second information entropy; determine a first algorithm control parameter of the first image segmentation algorithm corresponding to the first information entropy ratio;
[0142] The first image is segmented according to the first image segmentation algorithm and the first algorithm control parameters to obtain the target area and the background area.
[0143] It can be seen that the electronic device described in the embodiment of the present application includes an ambient light sensor and a camera. The ambient light brightness value is collected by the ambient light sensor. When the ambient light brightness value is less than a preset threshold, a photo is taken to obtain a first image. The first image is segmented to obtain a target area and a background area. The first signal-to-noise ratio of the target area and the second signal-to-noise ratio of the background area are determined. The first image is enhanced according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image. The first signal-to-noise ratio reflects the target quality, and the second signal-to-noise ratio reflects the background quality. The first signal-to-noise ratio and the second signal-to-noise ratio together reflect the image structure and image characteristics. The first image can be enhanced based on the image structure and image characteristics. Therefore, in dim light conditions, the image enhancement effect depth is consistent with the image structure and image characteristics, which helps to improve the image quality in dim light conditions.
[0144] Figure 3 : is a functional unit block diagram of an image processing device 300 involved in an embodiment of the present application. The image processing device 300 is applied to an electronic device, and the electronic device includes an ambient light sensor and a camera; the image processing device 300 includes: a collection unit 301, a shooting unit 302, a segmentation unit 303, a determination unit 304 and an image enhancement unit 305, wherein:
[0145] The acquisition unit 301 is used to acquire the ambient light brightness value through the ambient light sensor;
[0146] The shooting unit 302 is used to shoot when the ambient light brightness value is less than a preset threshold to obtain a first image;
[0147] The segmentation unit 303 is used to perform image segmentation on the first image to obtain a target area and a background area;
[0148] The determining unit 304 is used to determine a first signal-to-noise ratio of the target area and a second signal-to-noise ratio of the background area;
[0149] The image enhancement unit 305 is configured to perform image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image.
[0150] Optionally, in the aspect of performing image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain the second image, the image enhancement unit 305 is specifically used to:
[0151] determining a first relative deviation between the first signal-to-noise ratio and the second signal-to-noise ratio;
[0152] Determining a first difference between the preset threshold and the ambient light brightness value;
[0153] determining a first image enhancement algorithm corresponding to the first difference;
[0154] Obtaining a first attribute parameter of the camera;
[0155] Determining a first control parameter of the first image enhancement algorithm corresponding to the first attribute parameter;
[0156] When the first relative deviation is within a preset range, image enhancement processing is performed on the first image according to the first image enhancement algorithm and the first control parameter to obtain the second image; the preset range includes an upper threshold and a lower threshold.
[0157] Optionally, the image processing device 300 is further specifically configured to:
[0158] determining a first area of the target region and a second area of the first image;
[0159] determining a target area ratio between the first area and the second area;
[0160] When the first relative deviation is greater than the upper threshold, determining a second difference between the first relative deviation and the upper threshold;
[0161] determining a first optimization parameter corresponding to the second difference;
[0162] Determine a second control parameter according to the first optimization parameter and the first control parameter;
[0163] Determining a second optimization parameter corresponding to the target area ratio;
[0164] Determine a third control parameter according to the second optimization parameter and the first control parameter;
[0165] Performing image enhancement processing on the target area according to the first image enhancement algorithm and the third control parameter to obtain a first target area;
[0166] Performing image enhancement processing on the background area according to the first image enhancement algorithm and the second control parameter to obtain a first background area;
[0167] The second image is determined according to the first target area and the first background area.
[0168] Optionally, the image processing device 300 is further specifically configured to:
[0169] When the first relative deviation is less than the lower threshold, determining a third difference between the lower threshold and the first relative deviation;
[0170] determining a third optimization parameter corresponding to the third difference;
[0171] Determine a fourth control parameter according to the third optimization parameter and the first control parameter;
[0172] Determining a fourth optimization parameter corresponding to the target area ratio;
[0173] Determine a fifth control parameter according to the fourth optimization parameter and the fourth control parameter;
[0174] Performing image enhancement processing on the target area according to the first image enhancement algorithm and the fifth control parameter to obtain a second target area;
[0175] Performing image enhancement processing on the background area according to the first image enhancement algorithm and the first control parameter to obtain a second background area;
[0176] The second image is determined according to the second target area and the second background area.
[0177] Optionally, in the aspect of performing image segmentation on the first image to obtain the target area and the background area, the segmentation unit 303 is specifically used for:
[0178] Performing multi-scale decomposition on the first image to obtain a low-frequency component part;
[0179] determining a first image quality evaluation value of the first image;
[0180] determining a first image segmentation algorithm corresponding to the first image quality evaluation value;
[0181] Determining a first information entropy of the low-frequency component part;
[0182] determining a second information entropy of the first image;
[0183] Determine a first information entropy ratio between the first information entropy and the second information entropy; determine a first algorithm control parameter of the first image segmentation algorithm corresponding to the first information entropy ratio;
[0184] The first image is segmented according to the first image segmentation algorithm and the first algorithm control parameters to obtain the target area and the background area.
[0185] It can be seen that the image processing device described in the embodiment of the present application is applied to an electronic device, and the electronic device includes an ambient light sensor and a camera. The ambient light brightness value is collected by the ambient light sensor. When the ambient light brightness value is less than a preset threshold, the camera is taken to obtain a first image, and the first image is segmented to obtain a target area and a background area. The first signal-to-noise ratio of the target area and the second signal-to-noise ratio of the background area are determined. The first image is image enhanced according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image. The first signal-to-noise ratio reflects the target quality, and the second signal-to-noise ratio reflects the background quality. The first signal-to-noise ratio and the second signal-to-noise ratio together reflect the image structure and image characteristics. The first image can be image enhanced based on the image structure and image characteristics. Therefore, in dim light conditions, the image enhancement effect depth is consistent with the image structure and image characteristics, which helps to improve the image quality in dim light conditions.
[0186] It can be understood that the functions of each program module of the image processing device of this embodiment can be specifically implemented according to the method in the above method embodiment. The specific implementation process can refer to the relevant description of the above method embodiment, which will not be repeated here.
[0187] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0188] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.
[0189] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0190] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0191] In the several embodiments provided in the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0192] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0193] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0194] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0195] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0196] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. An image processing method, characterized in that: Applied to an electronic device, the electronic device includes an ambient light sensor and a camera; the method includes: Collecting the ambient light brightness value by the ambient light sensor; When the ambient light brightness value is less than a preset threshold, shooting is performed to obtain a first image; Performing image segmentation on the first image to obtain a target area and a background area; Determining a first signal-to-noise ratio of the target area and a second signal-to-noise ratio of the background area; Perform image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image.
2. The method according to claim 1, characterized in that: The performing image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image includes: determining a first relative deviation between the first signal-to-noise ratio and the second signal-to-noise ratio; Determining a first difference between the preset threshold and the ambient light brightness value; determining a first image enhancement algorithm corresponding to the first difference; Obtaining a first attribute parameter of the camera; Determining a first control parameter of the first image enhancement algorithm corresponding to the first attribute parameter; When the first relative deviation is within a preset range, image enhancement processing is performed on the first image according to the first image enhancement algorithm and the first control parameter to obtain the second image; the preset range includes an upper threshold and a lower threshold.
3. The method according to claim 2, characterized in that The method further comprises: determining a first area of the target region and a second area of the first image; determining a target area ratio between the first area and the second area; When the first relative deviation is greater than the upper threshold, determining a second difference between the first relative deviation and the upper threshold; determining a first optimization parameter corresponding to the second difference; Determine a second control parameter according to the first optimization parameter and the first control parameter; Determining a second optimization parameter corresponding to the target area ratio; Determine a third control parameter according to the second optimization parameter and the first control parameter; Performing image enhancement processing on the target area according to the first image enhancement algorithm and the third control parameter to obtain a first target area; Performing image enhancement processing on the background area according to the first image enhancement algorithm and the second control parameter to obtain a first background area; The second image is determined according to the first target area and the first background area.
4. The method according to claim 3, characterized in that The method further comprises: When the first relative deviation is less than the lower threshold, determining a third difference between the lower threshold and the first relative deviation; determining a third optimization parameter corresponding to the third difference; Determine a fourth control parameter according to the third optimization parameter and the first control parameter; Determining a fourth optimization parameter corresponding to the target area ratio; Determine a fifth control parameter according to the fourth optimization parameter and the fourth control parameter; Performing image enhancement processing on the target area according to the first image enhancement algorithm and the fifth control parameter to obtain a second target area; Performing image enhancement processing on the background area according to the first image enhancement algorithm and the first control parameter to obtain a second background area; The second image is determined according to the second target area and the second background area.
5. The method according to any one of claims 1 to 4, characterized in that: The performing image segmentation on the first image to obtain a target area and a background area includes: Performing multi-scale decomposition on the first image to obtain a low-frequency component part; determining a first image quality evaluation value of the first image; determining a first image segmentation algorithm corresponding to the first image quality evaluation value; Determining a first information entropy of the low-frequency component part; determining a second information entropy of the first image; Determine a first information entropy ratio between the first information entropy and the second information entropy; determine a first algorithm control parameter of the first image segmentation algorithm corresponding to the first information entropy ratio; The first image is segmented according to the first image segmentation algorithm and the first algorithm control parameters to obtain the target area and the background area.
6. An image processing device, characterized in that: Applied to electronic equipment, the electronic equipment includes an ambient light sensor and a camera; the device includes: a collection unit, a shooting unit, a segmentation unit, a determination unit and an image enhancement unit, wherein: The acquisition unit is used to acquire the ambient light brightness value through the ambient light sensor; The shooting unit is used to shoot when the ambient light brightness value is less than a preset threshold value to obtain a first image; The segmentation unit is used to perform image segmentation on the first image to obtain a target area and a background area; The determining unit is used to determine a first signal-to-noise ratio of the target area and a second signal-to-noise ratio of the background area; The image enhancement unit is used to perform image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain a second image.
7. The device according to claim 6, characterized in that In the aspect of performing image enhancement processing on the first image according to the first signal-to-noise ratio and the second signal-to-noise ratio to obtain the second image, the image enhancement unit is specifically used for: determining a first relative deviation between the first signal-to-noise ratio and the second signal-to-noise ratio; Determining a first difference between the preset threshold and the ambient light brightness value; determining a first image enhancement algorithm corresponding to the first difference; Obtaining a first attribute parameter of the camera; Determining a first control parameter of the first image enhancement algorithm corresponding to the first attribute parameter; When the first relative deviation is within a preset range, image enhancement processing is performed on the first image according to the first image enhancement algorithm and the first control parameter to obtain the second image; the preset range includes an upper threshold and a lower threshold.
8. The device according to claim 7, characterized in that The device is also specifically used for: determining a first area of the target region and a second area of the first image; determining a target area ratio between the first area and the second area; When the first relative deviation is greater than the upper threshold, determining a second difference between the first relative deviation and the upper threshold; determining a first optimization parameter corresponding to the second difference; Determine a second control parameter according to the first optimization parameter and the first control parameter; Determining a second optimization parameter corresponding to the target area ratio; Determine a third control parameter according to the second optimization parameter and the first control parameter; Performing image enhancement processing on the target area according to the first image enhancement algorithm and the third control parameter to obtain a first target area; Performing image enhancement processing on the background area according to the first image enhancement algorithm and the second control parameter to obtain a first background area; The second image is determined according to the first target area and the first background area.
9. An electronic device, characterized in that: The method comprises a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 5.