Image processing method and device, electronic equipment and computer program product
By adjusting pixel values based on image information, the problem of inaccurate defog treatment in the prior art is solved, and a more accurate defog removal effect is achieved, excessive or insufficient, and the accuracy of image processing is improved.
Patent Information
- Application Number
- CN202510453798.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-07-22
AI Technical Summary
In the existing image processing technology, defog removal is prone to excessive or insufficient defog removal, which affects the image effect.
According to the image information of the first image, the pixel values of each pixel point of the second image are adjusted, including pixel distribution characteristics, color parameters and target object information, and the first image is defogged through the adjusted second image to accurately adjust the defogged intensity.
Improve the accuracy of the defog treatment, avoid excessive or insufficient defog removal, and obtain more natural defog removal images.
Smart Images

Figure CN120355619A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of image processing technology, and in particular, to an image processing method, apparatus, electronic device, and computer program product. Background Art
[0002] With the development of science and technology, various electronic devices have emerged in people's daily lives, and people can use electronic devices for entertainment, learning, etc.
[0003] Currently, in various electronic devices, most of them have image processing functions, and users can use various application programs to process images to obtain the images they want. Among them, haze removal processing is a relatively common processing method. Usually, the haze removal processing scheme is to perform a one-time processing on the image based on the dark channel prior, and the obtained haze-removed image is prone to over-haze removal or under-haze removal, affecting the effect of the haze-removed image. Summary of the Invention
[0004] In order to solve the problems of related technologies, avoid over-haze removal or under-haze removal of images, and improve the effect of haze removal processing. Embodiments of the present application provide an image processing method, apparatus, electronic device, and computer program product. The technical solutions are as follows:
[0005] On the one hand, an embodiment of the present application provides an image processing method, which is applied to an electronic device. The method includes:
[0006] Adjust the pixel values of each pixel point of the second image according to the image information of the first image. The image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the haze removal intensity values for performing haze removal processing on each pixel point of the first image;
[0007] Perform haze removal processing on the first image according to the adjusted second image to obtain a haze-removed image.
[0008] On the other hand, an embodiment of the present application provides an image processing apparatus, which is applied to an electronic device. The apparatus includes:
[0009] A first adjustment module, configured to adjust the pixel values of each pixel point of the second image according to the image information of the first image. The image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the haze removal intensity values for performing haze removal processing on each pixel point of the first image;
[0010] A first acquisition module, configured to perform haze removal processing on the first image according to the adjusted second image to obtain a haze-removed image.
[0011] On the other hand, the present application provides an electronic device, which includes a processor and a memory. The memory stores a computer program that can run on the processor. When the processor executes the computer program, the image processing method described in the above aspect is implemented.
[0012] On the other hand, the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the image processing method described in the above aspect is implemented.
[0013] On the other hand, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the image processing method described in the above aspect is implemented.
[0014] On the other hand, an embodiment of the present application provides an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer is caused to execute to implement the image processing method described in the above aspect.
[0015] The beneficial effects brought by the technical solution provided by the embodiment of the present application at least include:
[0016] The electronic device of this solution can adjust the pixel values of each pixel point of the second image according to the image information of the first image, and perform haze removal processing on the first image according to the adjusted second image to obtain a haze-removed image. Among them, the image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the haze removal intensity value for performing haze removal processing on each pixel point of the first image. During the haze removal process, for the second image obtained by the electronic device, the electronic device can flexibly adjust the pixel values of the second image based on the image information of the first image, and can timely optimize the unreasonable haze removal intensity values in the second image, more accurately adjust the haze removal intensity required by the first image, avoid the situation of over-haze removal or insufficient haze removal, and improve the accuracy of haze removal processing on the first image. Description of the Drawings
[0017] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.
[0018] Figure 1 Schematic structural diagram of an electronic device provided in an exemplary embodiment of the present application;
[0019] Figure 2 Schematic diagram of an image before and after dehazing involved in an exemplary embodiment of the present application;
[0020] Figure 3 Method flowchart of an image processing method provided in an exemplary embodiment of the present application;
[0021] Figure 4 Method flowchart of an image processing method provided in an exemplary embodiment of the present application;
[0022] Figure 5 Schematic diagram of the process architecture for dehazing a first image in an electronic device involved in an exemplary embodiment of the present application;
[0023] Figure 6 Method flowchart of an image processing method provided in an exemplary embodiment of the present application;
[0024] Figure 7 Schematic diagram of an image of a first image involved in an exemplary embodiment of the present application;
[0025] Figure 8 Block diagram of the structure of an image processing apparatus provided in an exemplary embodiment of the present application;
[0026] Figure 9 Schematic diagram of another example of the structure of the image processing apparatus provided in the embodiments of the present application. Detailed implementation manners
[0027] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different accompanying drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are only examples of the devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0028] As used herein, "a plurality of" means two or more. "And / or" describes the relationship between associated objects and indicates that there can be three relationships. For example, A and / or B can represent three cases: A exists alone, both A and B exist simultaneously, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0029] It should be noted that the terms "first / second / third" involved in the embodiments of the present application are used to distinguish similar or different objects and do not represent a specific order for the objects. Understandably, "first / second / third" can be interchanged in a specific order or sequence when permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0030] The solution provided by the present application can be used in the real scenario where people use an electronic device with an image processing function to perform image dehazing processing in their daily lives. For the convenience of understanding, the application scenarios involved in the embodiments of the present application will be briefly introduced below.
[0031] With the development of science and technology, various electronic devices have emerged in people's daily lives, and people can use the electronic devices for entertainment, learning, etc. Among them, the image processing function has been applied in most electronic devices, and users can start the corresponding application program in the electronic device to enable the electronic device to process images.
[0032] Please refer to Figure 1 , which shows a schematic structural diagram of an electronic device provided by an exemplary embodiment of the present application. As Figure 1 shown, the electronic device includes components such as a processor 110, a memory 120, a transceiver 130, a display unit 140, an input unit 150, a sensor 160, an audio circuit 170, and a power module 180.
[0033] The processor 110 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 120, and by calling the data stored in the memory 120, the processor 110 executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 110 may include one or more processing units; optionally, the processor 110 may integrate an application processor, and the application processor mainly processes operating systems, user interfaces, and application programs, etc. Of course, other processors may also be included, which will not be listed one by one here.
[0034] The memory 120 can be used to store software programs and modules. The processor 110 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 120. The memory 120 may mainly include a program storage area and a data storage area. Among them, the program storage area can store the operating device, application programs required for at least one function (such as the sound playback function, the image playback function, etc.); the data storage area can store data created according to the use of the electronic device (such as audio data, phone book, etc.). In addition, the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
[0035] The transceiver 130 can provide solutions for wireless communications applied to the electronic device, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. The transceiver 130 can be one or more devices integrating at least one communication processing module. For example, integrating the antenna with the baseband processor as the transceiver 130, or integrating the antenna and the modulation and demodulation processor as the transceiver 130, etc., which is not limited here.
[0036] The display unit 140 can be used to display information input by the user or information provided to the user, as well as various menus of the electronic device. The display unit 140 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc., which is not limited here.
[0037] The input unit 150 can be used to receive input digital or character information and generate key signal inputs related to the user settings and function controls of the electronic device. Specifically, the input unit 150 can collect operations performed on or near it and drive the corresponding connection devices according to a preset program. In addition, the input unit 150 may include a touch panel, which can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel, the input unit 150 may further include other input devices. Specifically, the other input devices may include, but are not limited to, one or more of function keys (such as volume control buttons, power on / off buttons, etc.), trackballs, joysticks, etc.
[0038] The electronic device may further include at least one sensor 160, such as a gyroscope sensor, a motion sensor, and other sensors. The motion sensor may include an acceleration sensor for detecting the magnitude of acceleration in various directions. When stationary, it can detect the magnitude and direction of gravity and can be used in applications for identifying the posture of the electronic device, such as horizontal / vertical screen switching, related games, magnetometer posture calibration, etc. As for other sensors such as a pressure gauge, a barometer, a hygrometer, a thermometer, an infrared sensor, etc. that the electronic device may also be configured with, they will not be elaborated here.
[0039] The audio circuit 170 may include a speaker and a microphone, which can provide an audio interface between the user and the electronic device. The audio circuit 170 can transmit the electrical signal converted from the received audio data to the speaker, and the speaker converts it into a sound signal for output. On the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 170 and then converted into audio data. After the audio data is output to the processor 110 for processing, it is sent through the video circuit to, for example, another electronic device, or the audio data is output to the memory 120 for further processing.
[0040] The electronic device further includes a power module 180 for supplying power to each component. Optionally, the power module 180 can be logically connected to the processor 110 through a power management device, so as to implement functions such as management of charging, discharging, and power consumption management through the power management device.
[0041] Although not shown, the electronic device may further include a camera. Optionally, the position of the camera on the electronic device can be front-facing or rear-facing, and the embodiments of the present application do not limit this.
[0042] It can be understood that the structure schematically shown in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or combine certain components, or split certain components, or have different component arrangements. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0043] Optionally, the above-mentioned electronic device may include, but is not limited to, wearable devices (such as smart bracelets, smart watches, smart glasses, etc.), mobile phones, tablet computers, laptop computers, smart glasses, smart watches, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, desktop computers, laptop portable computers, etc.
[0044] Under normal circumstances, the above-mentioned Figure 1 shown electronic device needs to be equipped with a corresponding operating system and run based on the operating system. For example, the operating system of the electronic device can be the Android system, the iOS system, the Linux system, etc.
[0045] Optionally, for the above-mentioned Figure 1 shown electronic device, if the user needs to perform defogging on a certain foggy image in the electronic device, the user can use methods such as dark channel prior, image contrast enhancement, or a defogging processing model based on deep learning to perform defogging, so as to obtain an image with a clearer visual effect. Please refer to Figure 2 which shows a schematic diagram of an image before and after defogging involved in an exemplary embodiment of the present application. As Figure 2 shown, the user can perform defogging on the pre-defogging image 201 to obtain the post-defogging image 202.
[0046] Currently, the above-mentioned several defogging methods are basically one-time processing of images. In the whole process, the finally defogged image is often directly calculated based on their respective conventional calculation methods. These technologies often have poor adaptability to the surrounding environment. For example, in different lighting conditions or diverse color distributions, the processing methods used are the same. Therefore, the defogging effects obtained by these methods may not be ideal, resulting in over-defogging in some defogged images and under-defogging in some defogged images. In addition, for overexposed or near-saturated areas in the image, they usually turn gray or change color after defogging, and the highlight details are lost. The dark areas in the image may cause the pixel values to be subtracted to less than 0, resulting in problems of dead black and detail loss, affecting the overall defogging effect.
[0047] To solve the above problems existing in the related art, avoid over-dehazing or under-dehazing of images, and improve the effect of dehazing processing, an image processing method is provided in an embodiment of the present application. The dehazing intensity value of the dehazing processing can be adjusted based on the image information of the first image, so that the current image information of the first image is considered during dehazing, and the dehazing intensity required for the first image can be adjusted more accurately to obtain a more natural dehazed image.
[0048] Please refer to Figure 3 , which shows a flowchart of an image processing method provided by an exemplary embodiment of the present application. The image processing method can be applied to an electronic device. As Figure 3 shown, the image processing method may include the following steps:
[0049] Step 301, adjust the pixel values of each pixel point of the second image according to the image information of the first image. The image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the dehazing intensity value for dehazing each pixel point of the first image.
[0050] Optionally, the first image is an image to be dehazed, and the second image is generated by the electronic device based on the first image. For example, the second image is an image generated by the electronic device according to the dehazing intensity value required for each pixel point after calculating the dehazing intensity of the first image. It should be noted that in practical applications, the electronic device can calculate the dehazing intensity value according to various preset algorithms, and the present solution does not limit the specific process of generating the second image.
[0051] Optionally, the image information of the first image includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. Among them, the pixel distribution characteristics of the first image can be information such as the brightness and black level of each pixel point obtained by the electronic device through histogram statistics of the pixel points of the first image. The color parameters of the first image can be directly obtained by the electronic device for parameters such as the color, saturation, and contrast of the first image. The target object information is used to indicate the target object in the first image and can be obtained by the electronic device based on a machine learning model for recognizing the first image. For example, the machine learning model can recognize the target object in any image. By inputting the first image into the machine learning model, the target object information of the target object in the first image can be obtained accordingly.
[0052] Optionally, after the electronic device obtains the image information of the first image, it can adjust the second image corresponding to the first image based on the image information, and re-change the pixel values of each pixel point in the second image, which is equivalent to flexibly changing the defogging intensity value based on the image information.
[0053] Step 302, perform defogging processing on the first image according to the adjusted second image to obtain a defogged image.
[0054] Optionally, the process by which the electronic device performs defogging processing on the first image according to the adjusted second image can be as follows: The pixel values of each pixel point in the target image are defogged through the following formula:
[0055]
[0056] where the transmittance t = 1 - w * haze, and the above formula can be transformed into:
[0057]
[0058] where J represents the obtained defogged image, I is the first image, haze is the second image, A is the global atmospheric light component, and w is a constant factor within the range of [0, 1] used in a calculation process.
[0059] In summary, the electronic device in this solution can adjust the pixel values of each pixel point of the second image according to the image information of the first image, and perform defogging processing on the first image according to the adjusted second image to obtain a defogged image. Among them, the image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the defogging intensity value for defogging each pixel point of the first image. During the defogging process, for the second image obtained by the electronic device, the electronic device can flexibly adjust the pixel values of the second image based on the image information of the first image, can timely optimize the unreasonable defogging intensity values in the second image, more accurately adjust the defogging intensity required by the first image, avoid the situation of over-defogging or under-defogging, and improve the accuracy of defogging processing on the first image.
[0060] In a possible implementation manner, different preset adjustment relationships are set in advance in the electronic device for different color parameters. The electronic device obtains the corresponding required adjustment parameters for the pixel points based on various color parameters and the corresponding preset adjustment relationships, and then adjusts the pixel values of each pixel point of the second image to improve the accuracy of adjusting the pixel points of the second image.
[0061] Please refer to Figure 4, which shows a flowchart of an image processing method provided by an exemplary embodiment of the present application. The image processing method can be applied to an electronic device. As Figure 4 shown, the image processing method may include the following steps:
[0062] Step 401, obtain a first image.
[0063] Optionally, the first image refers to the image before dehazing, similar to the Figure 2 image 201 above. The electronic device may pre-store various images before dehazing. When it is necessary to perform dehazing processing on a certain image before dehazing, the image is obtained from the corresponding storage location, and this image is the first image.
[0064] Step 402, obtain the image information of the first image. The image information includes the pixel distribution characteristics and / or color parameters of the first image.
[0065] Optionally, the electronic device may obtain the image information of the first image based on the first image. In this embodiment, taking the image information including the pixel distribution characteristics and / or color parameters of the first image as an example, where the pixel distribution characteristics of the first image include any one of brightness or black level, and the color parameters of the first image include saturation.
[0066] Optionally, for the brightness of the first image, the electronic device may calculate the brightness of each pixel point of the first image based on a preset brightness calculation method to obtain the brightness value of each pixel point, or the electronic device may also calculate the brightness of the entire image to obtain the overall brightness value. For the saturation of the first image, the electronic device may calculate the saturation of the first image based on a preset saturation calculation method to obtain the saturation of the entire image. For example, the electronic device may convert the first image to the HSV (Hue, Saturation, Value) color space and extract the data of the second channel for calculation to obtain the saturation of the image. For the black level of the first image, the electronic device may perform histogram statistics, calculate the histogram quantile, and obtain the black level of the first image, thereby reflecting the degree of fog in the first image. Among them, the larger the black level, the greater the fog, and the smaller the black level, the smaller the fog, which can effectively reflect the true black area in the first image and the blurred area caused by fog.
[0067] Optionally, the present solution does not limit how the electronic device specifically obtains brightness, saturation, and black level. Moreover, the above several color parameters are exemplary. In practical applications, more color parameters may also be obtained, such as contrast, hue, color phase, sharpness, etc., which will not be elaborated one by one here.
[0068] Step 403: Obtain a second image. The pixel values of each pixel point in the second image are used to indicate the defogging intensity value for defogging each pixel point in the first image.
[0069] Optionally, the second image can be generated by the electronic device itself based on the above-mentioned first image, or can be sent to the electronic device by other devices after generating the first image.
[0070] Optionally, in this solution, the second image can be generated in the following manner: The electronic device performs an operation on the defogging intensity of each pixel point in the first image to obtain the defogging intensity value for defogging each pixel point. In this way, the second image has the same size as the first image, and each pixel point corresponds.
[0071] Optionally, in order to save the power consumption of the electronic device for obtaining the second image and reduce the time consumption of the electronic device, the electronic device can also downsample the first image to obtain a thumbnail, perform an operation on the defogging intensity based on the thumbnail to obtain the defogging intensity value required for each pixel point corresponding to the thumbnail, and then upsample to obtain the second image with the same size as the original image. For example, for a first image with an M*N size, downsampling by S times can obtain a thumbnail with an (M / S)*(N / S) size. Here, M and N can represent the number of pixels in the length and width of the first image. Optionally, the obtained thumbnail is much smaller than the first image, that is, the (M / S)*(N / S) size is much smaller than the M*N size, and finally, the second image with the same size as the original image (i.e., the first image) is obtained through upsampling.
[0072] Of course, the above steps 401 to 403 can also be executed by other devices to obtain the actions and sent to the electronic device through the network, and it is also possible for the electronic device to receive this information.
[0073] Step 404: According to the image information of the first image and the preset adjustment relationship, obtain the adjustment parameters required for each pixel point of the second image. The preset adjustment relationship is the corresponding relationship between each information value of the image information and the required adjustment parameters.
[0074] Optionally, the preset adjustment relationship is stored in the electronic device in advance. After obtaining the second image from the first image, the adjustment parameters required for each pixel point of the second image can be obtained according to the image information of the first image and the preset adjustment relationship. Among them, different image information corresponds to different preset adjustment relationships.
[0075] Optionally, the adjustment parameter can be a specific adjustment value or an adjustment ratio. The adjustment ratio is a ratio value greater than 0 and less than or equal to 1. For example, if the adjustment parameter is a specific adjustment value, the adjustment value required for each pixel point of the second image can indicate that the pixel value of each pixel point of the second image is increased or decreased by a certain value. If the adjustment parameter is an adjustment ratio, the adjustment value required for each pixel point of the second image can indicate that the pixel value of each pixel point of the second image is adjusted according to the adjustment ratio.
[0076] Optionally, in this embodiment, the image information includes the pixel distribution characteristics of the first image and / or the color parameters of the first image as an example. When the image information includes the pixel distribution characteristics of the first image, and the pixel distribution characteristics include the brightness of each pixel point of the first image, the process for the electronic device to obtain the adjustment parameter required for each pixel point of the second image according to the image information of the first image and the preset adjustment relationship can be as follows: According to the brightness of each pixel point in the first image and the first adjustment relationship, obtain the adjustment parameter corresponding to the brightness of each pixel point of the second image. The first adjustment relationship is the corresponding relationship between each brightness value and the required adjustment parameter. That is, when the color parameter includes the brightness of the first image, the electronic device can query the first adjustment relationship according to the brightness of each pixel point in the first image to obtain the adjustment parameter corresponding to the brightness of each pixel point. That is, in this case, the preset adjustment relationship is the first adjustment relationship, and each information value of the image information is the brightness value of each pixel point in the first image.
[0077] Taking the adjustment parameter as an adjustment ratio as an example, please refer to Table 1, which shows a corresponding relationship table of a first adjustment relationship.
[0078] Table 1
[0079] Brightness value Adjustment ratio First brightness range 0.6 Second brightness range 0.8 Third brightness range 1 …… ……
[0080] As shown in Table 1, if the brightness of a certain pixel point in the first image is within the first brightness range, the obtained adjustment parameter is 0.6. If the brightness of a certain pixel point in the first image is within the second brightness range, the obtained adjustment parameter is 0.8. Optionally, the corresponding relationship shown in Table 1 is exemplary. In practical applications, a curve obtained by fitting can also be used to replace the first adjustment relationship. That is, the curve represents the change of the adjustment parameter required for the pixel value of the pixel point corresponding to the second image with the change of the brightness value. Substitute the brightness value of each pixel point of the first image into the curve to obtain the corresponding adjustment parameter.
[0081] Optionally, the black level is the dark region quantile of the histogram of the first image, indicating the missing situation of the pixel values in the dark region of the image, and can reflect the most critical information about the fogginess degree of the image. When the image information includes the pixel distribution characteristics of the first image, and the pixel distribution characteristics include the black level of the first image, the process for the electronic device to obtain the adjustment parameters required for each pixel point of the second image according to the image information of the first image and the preset adjustment relationship can be as follows: Obtain the adjustment parameter corresponding to the black level according to the black level of the first image and the second adjustment relationship, where the second adjustment relationship is used to indicate the corresponding relationship between each black level value and the required adjustment parameter; Determine the adjustment parameter corresponding to the black level as the adjustment parameter required for each pixel point of the second image. That is, in this case, the preset adjustment relationship is the second adjustment relationship, and each information value of the image information is each black level value of the black level of the first image.
[0082] Among them, the electronic device can perform histogram statistics on the first image (that is, count the distribution of the pixel values of all pixel points). Generally speaking, the distribution of pixel values is 0 to 255, but the proportions of different brightness levels are different. After the electronic device performs statistics on the first image, the 10% quantile of the dark region is the black level statistical result, and 10% is an adjustable parameter. For example, if the pixel value distribution in the first image from 0 to 80 is less, then the 10% position is at 80, and the black level is 80. The electronic device obtains the adjustment parameter corresponding to the black level according to the black level (80) of the first image obtained by statistics and the second adjustment relationship.
[0083] Still taking the adjustment parameter as the adjustment ratio as an example, please refer to Table 2, which shows a correspondence table of a second adjustment relationship.
[0084] Table 2
[0085] Black level Adjustment ratio First black level range 0.2 Second black level range 0.6 …… ……
[0086] Among them, in the correspondence shown in Table 2, as the black level increases, the adjustment ratio weakens accordingly, that is, the higher the black level of the image, the smaller the ratio that needs to be adjusted. If the black level of the first image is within the first black level range, the obtained adjustment parameter is 0.2. If the black level of the first image is within the second black level range, the obtained adjustment parameter is 0.6.
[0087] Of course, for the second adjustment relationship, it can also be characterized in a similar way to the curve corresponding to the first adjustment relationship above. That is, in practical applications, a fitted curve can be used to represent the change in the adjustment parameter required for the pixel value of the pixel point in the second image corresponding to the black level as the black level changes.
[0088] Optionally, when the image information includes the color parameters of the first image and the color parameters include the saturation of the first image, the process for the electronic device to obtain the adjustment parameters required for each pixel of the second image according to the image information of the first image and the preset adjustment relationship can be as follows: According to the saturation of the first image and the third adjustment relationship, obtain the adjustment parameters corresponding to the saturation. The third adjustment relationship is the corresponding relationship between each saturation value and the required adjustment parameters; determine the adjustment parameters corresponding to the saturation as the adjustment parameters required for each pixel of the second image. That is, for the case where the above color parameters include the saturation of the first image, the electronic device can query the third adjustment relationship according to the saturation of the first image to obtain the adjustment parameters corresponding to the current saturation of the first image. That is, in this case, the preset adjustment relationship is the third adjustment relationship, and each information value of the image information is each saturation value of the saturation of the first image.
[0089] Still taking the adjustment parameter as a specific adjustment value as an example, please refer to Table 3, which shows a corresponding relationship table of a third adjustment relationship.
[0090] Table 3
[0091] Saturation Adjustment value First saturation range -X Second saturation range -Y Third saturation range -Z …… ……
[0092] Among them, X, Y, and Z respectively represent numerical values, and the specific numerical values can be flexibly set by developers and are not limited here. As shown in Table 3, if the saturation of a certain pixel in the first image is within saturation range one, the obtained adjustment parameter is -X. If the saturation of a certain pixel in the first image is within saturation range two, the obtained adjustment parameter is -Y. Optionally, in this implementation, -X means that X needs to be lowered. If the adjustment value is a positive number, it means that the corresponding adjustment value needs to be raised.
[0093] Of course, Table 3 can also be a corresponding relationship established in the form of an adjustment ratio similar to Table 1. It should be noted that in this solution, as the saturation increases, the adjustment ratio needs to be correspondingly reduced, that is, the higher the image saturation, the smaller the amplitude by which the pixel values of the pixels in the second image need to be lowered, and try to achieve less defogging effect. Similarly, for the third adjustment relationship, it can also be characterized by a curve similar to the curve corresponding to the above first adjustment relationship. That is, in practical applications, a fitted curve can be used to represent the change in the adjustment parameters required for the pixel values of the pixels in the second image corresponding to this pixel as the saturation changes, and it is not limited here.
[0094] It should be noted that the method for obtaining the adjustment parameters required for each pixel of the second image for the above other color parameters can also refer to the example of saturation and will not be elaborated here.
[0095] Step 405: Adjust the pixel values of each pixel point in the second image according to the adjustment parameters required for each pixel point in the second image.
[0096] Optionally, after obtaining the adjustment parameters required for each pixel point in the second image, the pixel values of each pixel point in the second image can be adjusted. Taking the adjustment parameter as an adjustment ratio as an example, the manner in which the electronic device adjusts the pixel values of each pixel point in the second image can be as follows: Multiply the pixel value of each pixel point in the second image by the corresponding adjustment parameter to obtain the adjusted pixel value of each pixel point.
[0097] For example, taking the color parameter as brightness as an example, if the adjustment ratio corresponding to pixel point one is 0.6, then multiply the pixel value of pixel point one in the second image by 0.6. In the above manner where the size of the second image is much smaller than that of the first image, obtaining the color parameters of the first image can be replaced by obtaining the color parameters of the thumbnail of the first image, so as to ensure that each pixel point in the color parameters corresponds one-to-one with each pixel point in the second image. This solution is not limited thereto.
[0098] It should be noted that the above several methods can also be superimposed, that is, the electronic device can obtain two or more color parameters, and obtain the corresponding adjustment parameters based on the respective preset adjustment relationships of various color parameters. When making adjustments, the pixel values of each pixel point in the second image can also be adjusted in sequence according to the adjustment parameters corresponding to each color parameter. Here, the order of adjusting the pixel values of each pixel point in the second image can be arbitrary.
[0099] For example, in the case where the color parameters include the above-mentioned brightness, saturation, and black level, and the adjustment parameters are all adjustment ratios, for any pixel point in the second image, the adjustment parameters required for this pixel point that can be obtained through this step include: adjustment parameter one (0.6) corresponding to brightness, adjustment parameter two (0.8) corresponding to saturation, and adjustment parameter three (0.9) corresponding to black level. The electronic device can adjust the pixel value of this pixel point in the manner of multiplying the pixel value of this pixel point by adjustment parameter one (0.6) * adjustment parameter two (0.8) * adjustment parameter three (0.9) to calculate the final pixel value.
[0100] Step 406: Perform defogging processing on the first image according to the adjusted second image to obtain a defogged image.
[0101] Optionally, the process of the electronic device using the adjusted second image to perform defogging processing on the first image can be calculated according to the above formula, which will not be elaborated here. Among them, if the number of pixel points in the second image is the same as that in the first image, they can be directly subtracted correspondingly. If the size of the second image is much smaller than that of the first image, the second image can be upsampled first, enlarged back to the same size as the first image, and then substituted into the above formula for calculation to obtain the defogged image.
[0102] For example, in the case where the size of the second image obtained above is much smaller than that of the first image, the current size of the second image is (M / S)*(N / S), which contains 600 pixel points (such as a resolution of 100*60). The electronic device upsamples the second image and enlarges it back to the same size as the first image (M*N size), which contains more than 4K pixel points (such as a resolution of 3840×2160). For the enlarged second image, since the first image is also more than 4K (such as a resolution of 3840×2160), in this way, each pixel point in the first image can correspond to each pixel point in the second image. Subtract the pixel value of the corresponding pixel point on the second image from the pixel value of each pixel point in the first image to obtain the defogged image.
[0103] In a possible implementation manner, after the electronic device performs defogging processing on the first image according to the adjusted second image to obtain a defogged image, it can also obtain a color change threshold value according to the color parameters of the first image. The color change threshold value is used to indicate the maximum color change degree between the first image and the defogged image; obtain the color change degree between the first image and the defogged image according to the first image and the defogged image; if the color change degree between the first image and the defogged image exceeds the color change threshold value, perform fusion processing on the first image and the defogged image to generate a new defogged image, and the color change degree between the first image and the new defogged image is lower than the color change threshold value. Among them, the color change threshold value can be preset by developers.
[0104] For example, when the color parameter is saturation, the color change degree is the saturation change degree between the first image before and after defogging and the defogged image. In this solution, by setting the color change threshold value, it is possible to prevent the gap between the first image and the defogged image before and after defogging from being too large (the saturation of the defogged image is too high compared to the saturation of the original first image), thereby realizing the limitation of the image saturation.
[0105] When the color parameter is saturation, the electronic device will obtain the corresponding saturation change threshold value according to the saturation of the first image, and calculate the difference between the saturation of the defogged image and the saturation of the first image (i.e., the degree of color change). If the difference between the saturation of the defogged image and the saturation of the first image is greater than the above saturation change threshold value, it means that the saturation of the defogged image has increased too much, the image is oversaturated, and the defogging is excessive. Therefore, the first image and the defogged image can be fused to generate a new defogged image, so that the difference between the saturation of the new defogged image and the saturation of the first image is lower than the set saturation change threshold value.
[0106] It should be noted that in addition to using the saturation here for limitation, brightness can also be used for limitation, that is, the electronic device can also obtain the degree of brightness change between the first image and the defogged image before and after defogging, and compare it with the corresponding brightness threshold value, so as to prevent the brightness of the defogged image from being too high compared with the brightness of the original first image. For other color parameters, a similar principle can also be applied, which will not be elaborated here.
[0107] Optionally, the electronic device can fuse the first image and the defogged image to generate a new defogged image as follows: obtain the target weight according to the degree of color change between the first image and the defogged image. The target weight includes the weight of the first image and the weight of the defogged image. The weight of the first image is proportional to the degree of color change; fuse the first image and the defogged image according to the target weight to generate a new defogged image.
[0108] For example, the electronic device also stores the correspondence between different degrees of color change and different target weights. Please refer to Table 4, which shows the correspondence between different degrees of color change and different target weights involved in an exemplary embodiment of the present application.
[0109] Table 4
[0110]
[0111]
[0112] As shown in Table 4, in the case where a new dehazed image needs to be generated, the above-obtained color change degree can be used to query Table 4 to obtain the corresponding target weight, and then the target weight is used to fuse the first image and the dehazed image. For example, in the case where the color change degree between the first image and the dehazed image exceeds the color change threshold, if the color change degree is the second color change degree, the target weight can be obtained as the second weight based on Table 4. For example, the second weight is as follows: the weight of the first image is 0.2, and the weight of the dehazed image is 0.8. According to the target weight, the first image and the dehazed image can be fused by multiplying each pixel of the first image by 0.2 and adding 0.8 times each pixel of the dehazed image, so that the new dehazed image retains the details of the original image and improves the dehazing effect.
[0113] Please refer to Figure 5 , which shows a schematic flowchart of dehazing a first image in an electronic device according to an exemplary embodiment of the present application. As Figure 5 shown, it includes a first image input unit 501, a brightness and saturation calculation unit 502, a black level statistics unit 503, a second image input unit 504, a dehazing processing unit 505, a protection unit 506, and an output unit 507. Among them, the first image input unit 501 is used to input the first image to be processed, which is equivalent to the electronic device obtaining the first image. The brightness and saturation calculation unit 502 is used to calculate the brightness and saturation of the first image, the black level statistics unit 503 is used to perform black level statistics on the first image, the second image input unit 504 is used to input the second image corresponding to the obtained first image into the dehazing process, and the electronic device obtains corresponding adjustment parameters based on the brightness and saturation calculation unit 502 and the black level statistics unit 503, and adjusts the pixel values of each pixel in the second image. The dehazing processing unit 505 calculates the dehazed image using the first image and the adjusted second image. After obtaining the dehazed image, the electronic device uses the protection unit 506 to protect the brightness and / or saturation, so that the dehazed image is prevented from being over-saturated or having too high brightness or over-exposure or the pixel value being subtracted to less than 0 (appearing black or gray). The output unit 507 is used to output the final dehazed image to complete the entire dehazing process.
[0114] In summary, the electronic device of the present solution can adjust the pixel values of each pixel point of the second image according to the image information of the first image, and perform defogging processing on the first image based on the adjusted second image to obtain a defogged image. Among them, the image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the defogging intensity value for defogging each pixel point of the first image. During the defogging process, for the second image obtained by the electronic device, the electronic device can flexibly adjust the pixel values of the second image based on the image information of the first image, can timely optimize the unreasonable defogging intensity values in the second image, and more accurately adjust the defogging intensity required by the first image, avoiding the situation of over-defogging or under-defogging, and improving the accuracy of defogging the first image.
[0115] In a possible implementation manner, different preset adjustment relationships can also be set in advance for different target objects in the electronic device. Among them, the target object can be a person, an animal, etc. The electronic device also sets corresponding adjustment parameters based on different target objects included in the first image, and then adjusts the pixel values of each pixel point of the second image to improve the accuracy of adjusting the pixel points of the second image.
[0116] Please refer to Figure 6 , which shows a flowchart of a method for an image processing method provided by an exemplary embodiment of the present application. This image processing method can be applied to an electronic device. As Figure 6 shown, this image processing method can include the following steps:
[0117] Step 601, obtain a first image.
[0118] Optionally, this step can refer to the content of obtaining the first image in the above step 401, and will not be elaborated here.
[0119] Step 602, obtain the target object information of the first image, where the target object information is used to indicate the target object in the first image.
[0120] Optionally, for the first image obtained by the electronic device, the electronic device can obtain the target object information of the first image by means of image recognition. Among them, in addition to indicating the target object, the target object information can also indicate the position of the target object, that is, in which area of the first image the target object is located. For example, if the target object is a human face and a face recognition model is configured in the electronic device, by recognizing the first image, the face information of the human face in the first image can be obtained, and the face information includes the position coordinates of the human face in the first image.
[0121] For example, by inputting a first image into a pre-trained face recognition model, an electronic device can obtain target object information, which includes each face in the first image and its corresponding position coordinates. Please refer to Figure 7 , which shows an image schematic diagram of a first image according to an exemplary embodiment of the present application. As Figure 7 shown, by using the face recognition model to recognize the first image 701, each face 702 therein is obtained. The face information may include the position coordinates of the face frame determined for the face during the recognition process by the face recognition model, and this position coordinate is the position coordinate of the face in the first image.
[0122] Of course, the target object can also be other special objects, and the specific recognition process is not limited in this solution.
[0123] Step 603: Obtain a second image, where the pixel values of each pixel point of the second image are used to indicate the defogging intensity value for defogging each pixel point of the first image.
[0124] Optionally, this step can refer to the content of obtaining the second image in step 403 above, and will not be elaborated here.
[0125] Step 604: According to the target object indicated by the target object information, obtain an adjustment parameter corresponding to the target object.
[0126] Optionally, the electronic device can obtain an adjustment parameter corresponding to the target object according to the target object indicated by the target object information. Please refer to Table 5, which shows the corresponding relationship between different target objects and different adjustment parameters according to an exemplary embodiment of the present application.
[0127] Table 5
[0128] Target object Adjustment parameter First target object First adjustment parameter Second target object Second adjustment parameter Third target object Third adjustment parameter …… ……
[0129] As shown in Table 5, if the target object indicated by the target object information in the first image is target object one, the obtained adjustment parameter is adjustment parameter one (for example, 0.6). If the target object indicated by the target object information in the first image is target object two, the obtained adjustment parameter is adjustment parameter two (for example, 0.8). Optionally, the adjustment parameter can also be a specific adjustment value or adjustment ratio, and the actual setting can be determined by the developer independently.
[0130] Step 605: According to the adjustment parameter corresponding to the target object, adjust the pixel values of each pixel point in the area where the target object is located in the second image.
[0131] Optionally, in the electronic device, based on the adjustment parameter corresponding to the target object, the pixel values of each pixel in the area where the target object is located in the second image can be adjusted. That is, in this solution, for each pixel in the area where the target object is located in the second image, the pixel value can be adjusted according to the adjustment parameter corresponding to the target object, and for the pixel values of the pixels outside the area where the target object is located, they can be left unprocessed, or processed according to the process described above Figure 4 shown in the figure.
[0132] Still taking the target object as a human face as an example, after the electronic device obtains the face information of each human face, based on the position coordinates of each human face, it determines the area where each human face is located in the second image, and uses the corresponding adjustment parameter to adjust the pixel values of each pixel in the area where these human faces are located, and temporarily does not process the other pixel values, completing the adjustment process of the pixel values of each pixel in the second image, thereby preventing the situation of over-dehazing when dehazing the human face area.
[0133] It should be noted that this solution can also be combined with the solution described above Figure 4 shown in the figure, and combined with various color parameters and pixel distribution characteristics to superimpose the adjustment of the second image. Specifically, the combination is similar to the way of adjusting the pixel values of each pixel in the second image in the case where the above-mentioned image information includes the pixel distribution characteristics of the first image and various color parameters of the first image, which will not be elaborated here.
[0134] Step 606: Perform dehazing processing on the first image according to the adjusted second image to obtain a dehazed image.
[0135] Optionally, this step can refer to the content of obtaining the second image in the above step 406 and will not be elaborated here.
[0136] It should be noted that in the above implementation manner with a color change threshold set, in this embodiment, it can be set based on the color change degree of the target object in the first image before dehazing and the dehazed image after dehazing. That is, according to the first image and the dehazed image, obtain the color change degree between the target object in the first image and the dehazed image, so as to more accurately identify the color change degree of the target object in the first image after dehazing, and prevent the situation of over-dehazing when dehazing the target object.
[0137] In summary, the electronic device of the present solution can adjust the pixel values of each pixel point of the second image according to the image information of the first image, and perform defogging processing on the first image based on the adjusted second image to obtain a defogged image. Among them, the image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the defogging intensity value for defogging each pixel point of the first image. During the defogging process, for the second image obtained by the electronic device, the electronic device can flexibly adjust the pixel values of the second image based on the image information of the first image, optimize the unreasonable defogging intensity values in the second image in a timely manner, more accurately adjust the defogging intensity required for the first image, avoid the situation of over-defogging or under-defogging, and improve the accuracy of defogging the first image.
[0138] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For the details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0139] Please refer to Figure 8 , which shows a structural block diagram of an image processing device provided by an exemplary embodiment of the present application. The image processing device 800 can be used in an electronic device to execute all or part of the steps executed by the electronic device in the methods provided by the above various illustrated embodiments. The image processing device 800 includes:
[0140] A first adjustment module 801, configured to adjust the pixel values of each pixel point of the second image according to the image information of the first image, where the image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image, and the pixel values of each pixel point of the second image are used to indicate the defogging intensity value for defogging each pixel point of the first image;
[0141] A first acquisition module 802, configured to perform defogging processing on the first image according to the adjusted second image to obtain a defogged image.
[0142] In summary, the electronic device of the present solution can adjust the pixel values of each pixel point of the second image according to the image information of the first image, and perform haze removal processing on the first image according to the adjusted second image to obtain a haze-removed image. Among them, the image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image. The pixel values of each pixel point of the second image are used to indicate the haze removal intensity values for performing haze removal processing on each pixel point of the first image. During the haze removal process, for the second image obtained by the electronic device, the electronic device can flexibly adjust the pixel values of the second image based on the image information of the first image, can timely optimize the unreasonable haze removal intensity values in the second image, more accurately adjust the haze removal intensity required by the first image, avoid the situation of over-haze removal or insufficient haze removal, and improve the accuracy of haze removal processing on the first image.
[0143] Optionally, the image information includes the pixel distribution characteristics of the first image and / or the color parameters of the first image. The first adjustment module 801 includes a first acquisition unit and a first adjustment unit;
[0144] The first acquisition unit is used to obtain the adjustment parameters required for each pixel point of the second image according to the image information of the first image and a preset adjustment relationship. The preset adjustment relationship is the corresponding relationship between each information value of the image information and the required adjustment parameters;
[0145] The first adjustment unit is used to adjust the pixel values of each pixel point of the second image according to the adjustment parameters required for each pixel point of the second image.
[0146] Optionally, the image information includes the pixel distribution characteristics of the first image. The pixel distribution characteristics include the brightness of each pixel point of the first image. The first acquisition unit is further used for:
[0147] According to the brightness of each pixel point in the first image and a first adjustment relationship, obtain the adjustment parameters corresponding to the brightness of each pixel point of the second image. The first adjustment relationship is the corresponding relationship between each brightness value and the required adjustment parameters.
[0148] Optionally, the image information includes the pixel distribution characteristics of the first image. The pixel distribution characteristics include the black level of the first image. The black level is the dark region quantile point of the histogram of the first image. The first acquisition unit is further used for:
[0149] According to the black level of the first image and a second adjustment relationship, obtain the adjustment parameters corresponding to the black level. The second adjustment relationship is used to indicate the corresponding relationship between each black level value and the required adjustment parameters;
[0150] Determine the adjustment parameters corresponding to the black level as the adjustment parameters required for each pixel point of the second image.
[0151] Optionally, the image information includes the color parameters of the first image, the color parameters include the saturation of the first image, and the first acquisition unit is further configured to:
[0152] Obtain the adjustment parameters corresponding to the saturation according to the saturation of the first image and a third adjustment relationship, where the third adjustment relationship is the corresponding relationship between each saturation value and the required adjustment parameters;
[0153] Determine the adjustment parameters corresponding to the saturation as the adjustment parameters required for each pixel point of the second image.
[0154] Optionally, the image information includes the target object information of the first image, the target object information is used to indicate the target object in the first image, and the first adjustment module 801 includes a second acquisition unit and a second adjustment unit;
[0155] The second acquisition unit is configured to obtain the adjustment parameters corresponding to the target object according to the target object indicated by the target object information;
[0156] The second adjustment unit is configured to adjust the pixel values of each pixel point in the area where the target object is located in the second image according to the adjustment parameters corresponding to the target object.
[0157] Optionally, the device further includes:
[0158] A second acquisition module, configured to obtain a color change threshold value according to the color parameters of the first image after performing defogging processing on the first image according to the adjusted second image, where the color change threshold value is used to indicate the maximum color change degree between the first image and the defogged image;
[0159] A third acquisition module, configured to obtain the color change degree between the first image and the defogged image according to the first image and the defogged image;
[0160] A first generation module, configured to perform a fusion process on the first image and the defogged image to generate a new defogged image if the color change degree between the first image and the defogged image exceeds the color change threshold value, and the color change degree between the first image and the new defogged image is lower than the color change threshold value.
[0161] Optionally, the first generation module is further configured to:
[0162] Obtain the target weight according to the degree of color change between the first image and the dehazed image. The target weight includes the weight of the first image and the weight of the dehazed image, and the weight of the first image is proportional to the degree of color change.
[0163] Fuse the first image and the dehazed image according to the target weight to generate a new dehazed image.
[0164] Please refer to Figure 9 , which is a schematic structural diagram of another example of the image processing apparatus provided in the embodiments of the present application. Among them, the image processing apparatus 900 may be an electronic device, and the electronic device can implement the functions in the method provided in the embodiments of the present application. Among them, the image processing apparatus 900 may be a chip system. In the embodiments of the present application, the chip system may be composed of chips, or may include chips and other discrete devices.
[0165] In terms of hardware implementation, the above communication module may be a transceiver, and the transceiver is integrated in the image processing apparatus 900 to form a communication interface 903.
[0166] The image processing apparatus 900 includes at least one processor 901, which is used to implement or support the image processing apparatus 900 to implement the functions of the electronic device in the method provided in the embodiments of the present application. Exemplarily, the processor 901 may execute steps such as adjusting the pixel values of each pixel point of the second image according to the image information of the first image, and performing dehazing processing on the first image according to the adjusted second image to obtain a dehazed image. For specific details, please refer to the detailed description in the method example, and details are not described here.
[0167] The image processing apparatus 900 may further include at least one memory 902, which is used to store program instructions and / or data. The memory 902 is coupled to the processor 901. The coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units or modules, which may be electrical, mechanical or other forms, and is used for information interaction between devices, units or modules. The processor 901 may cooperate with the memory 902. The processor 901 may execute the program instructions stored in the memory 902. At least one of the at least one memories may be included in the processor.
[0168] The image processing apparatus 900 may further include a communication interface 903, which is used to communicate with other devices through a transmission medium, so that the devices in the image processing apparatus 900 can communicate with other devices. Exemplarily, the other device may be a network-side device. The processor 901 may use the communication interface 903 to send and receive data. The communication interface 903 may specifically be a transceiver.
[0169] In the embodiments of the present application, the specific connection medium between the communication interface 903, the processor 901, and the memory 902 is not limited. In the embodiments of the present application, Figure 9 it is shown that the memory 902, the processor 901, and the communication interface 903 are connected through a bus 904. The bus is represented by a thick line in Figure 9 which. The connection manners between other components are only for illustrative purposes and are not to be construed as limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, Figure 9 it is only represented by a thick line in which, but it does not mean that there is only one bus or one type of bus.
[0170] In the embodiments of the present application, the processor 901 can be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field-programmable gate array, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
[0171] In the embodiments of the present application, the memory 902 can be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD), etc., or can also be a volatile memory, such as a random-access memory (RAM). The memory is any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory in the embodiments of the present application can also be a circuit or any other device capable of implementing a storage function, for storing program instructions and / or data.
[0172] Optionally, the embodiments of the present application further provide an electronic device, which includes a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the computer program, all or part of the steps performed by the electronic device in the image processing methods of the above various embodiments are implemented.
[0173] Optionally, the embodiments of the present application further provide a computer-readable medium, on which a computer program is stored. When the computer program is executed by a processor, all or part of the steps performed by the electronic device in the image processing methods of the above various embodiments are implemented.
[0174] Optionally, an embodiment of the present application further provides a chip, on which there is a computer program that can run. When the chip executes the computer program, all or part of the steps performed by the electronic device in the image processing methods of the above various embodiments are implemented.
[0175] Optionally, an embodiment of the present application further provides a computer program product, including a computer program, which implements the image processing methods of the above various embodiments when the computer program is processed and executed.
[0176] Optionally, an embodiment of the present application further provides an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer is enabled to execute all or part of the steps performed by the electronic device in the image processing methods of the above various embodiments.
[0177] It should be noted that when the device provided in the above embodiment executes the control of the electronic device, only the above-mentioned division of each functional module is used for illustration. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device provided in the above embodiment and the method embodiment belong to the same concept, and the specific implementation process can be seen in the method embodiment, which will not be repeated here.
[0178] The serial numbers of the embodiments of the present application above are only for description and do not represent the advantages or disadvantages of the embodiments.
[0179] Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, or can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium, and the above-mentioned storage medium can be a read-only memory, a magnetic disk or an optical disc, etc.
[0180] The above are only optional embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. An image processing method, characterized in that, Applied to an electronic device, the method includes: Adjust the pixel values of each pixel point of a second image according to the image information of a first image, where the image information includes one or more of the pixel distribution characteristics of the first image, the color parameters of the first image, and the target object information of the first image, and the pixel values of each pixel point of the second image are used to indicate the defogging intensity values for defogging each pixel point of the first image; Perform defogging processing on the first image according to the adjusted second image to obtain a defogged image.
2. The method according to claim 1, wherein The image information includes the pixel distribution characteristics of the first image and / or the color parameters of the first image. The adjusting the pixel values of each pixel point of the second image according to the image information of the first image includes: Obtain the adjustment parameters required for each pixel point of the second image according to the image information of the first image and a preset adjustment relationship, where the preset adjustment relationship is the corresponding relationship between each information value of the image information and the required adjustment parameters; Adjust the pixel values of each pixel point of the second image according to the adjustment parameters required for each pixel point of the second image.
3. The method according to claim 2, characterized in that The image information includes the pixel distribution characteristics of the first image, and the pixel distribution characteristics include the brightness of each pixel point of the first image. The obtaining the adjustment parameters required for each pixel point of the second image according to the image information of the first image and a preset adjustment relationship includes: Obtain the adjustment parameters corresponding to the brightness of each pixel point of the second image according to the brightness of each pixel point in the first image and a first adjustment relationship, where the first adjustment relationship is the corresponding relationship between each brightness value and the required adjustment parameters.
4. The method according to claim 2, wherein The image information includes the pixel distribution characteristics of the first image, and the pixel distribution characteristics include the black level of the first image, where the black level is the dark region quantile of the histogram of the first image. The obtaining the adjustment parameters required for each pixel point of the second image according to the image information of the first image and a preset adjustment relationship includes: Obtain the adjustment parameters corresponding to the black level according to the black level of the first image and a second adjustment relationship, where the second adjustment relationship is used to indicate the corresponding relationship between each black level value and the required adjustment parameters; Determine the adjustment parameters corresponding to the black level as the adjustment parameters required for each pixel point of the second image.
5. The method according to claim 2, characterized in that, The image information includes the color parameters of the first image, and the color parameters include the saturation of the first image. The obtaining the adjustment parameters required for each pixel point of the second image according to the image information of the first image and a preset adjustment relationship includes: Obtain the adjustment parameters corresponding to the saturation according to the saturation of the first image and a third adjustment relationship, where the third adjustment relationship is the corresponding relationship between each saturation value and the required adjustment parameters; Determine the adjustment parameters corresponding to the saturation as the adjustment parameters required for each pixel point of the second image.
6. The method according to claim 1, characterized in that, The image information includes the target object information of the first image, and the target object information is used to indicate the target object in the first image. Adjusting the pixel values of each pixel point of the second image according to the image information of the first image includes: Obtaining an adjustment parameter corresponding to the target object according to the target object indicated by the target object information; Adjusting the pixel values of each pixel point in the area where the target object is located in the second image according to the adjustment parameter corresponding to the target object.
7. According to the method of any one of claims 1 to 6, characterized in that After performing defogging processing on the first image according to the adjusted second image to obtain a defogged image, the method further includes: Obtaining a color change threshold according to the color parameter of the first image, and the color change threshold is used to indicate the maximum color change degree between the first image and the defogged image; Obtaining the color change degree between the first image and the defogged image according to the first image and the defogged image; If the color change degree between the first image and the defogged image exceeds the color change threshold, performing fusion processing on the first image and the defogged image to generate a new defogged image, and the color change degree between the first image and the new defogged image is lower than the color change threshold.
8. The method according to claim 7, characterized in that The performing fusion processing on the first image and the defogged image to generate a new defogged image includes: Obtaining a target weight according to the color change degree between the first image and the defogged image, where the target weight includes the weight of the first image and the weight of the defogged image, and the weight of the first image is proportional to the color change degree; Performing fusion processing on the first image and the defogged image according to the target weight to generate a new defogged image.
9. An image processing apparatus, characterized in that, Applied to an electronic device, the device includes: A first adjustment module, configured to adjust the pixel values of each pixel point of a second image according to the image information of a first image, where the image information includes one or more of the pixel distribution characteristics of the first image, the color parameter of the first image, and the target object information of the first image, and the pixel values of each pixel point of the second image are used to indicate the defogging intensity value for defogging each pixel point of the first image; A first obtaining module, configured to perform defogging processing on the first image according to the adjusted second image to obtain a defogged image.
10. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory stores a computer program that can run on the processor, and when the processor executes the computer program, the image processing method according to any one of claims 1 to 8 is implemented.
11. A computer program product, characterized in that, Including a computer program, when the computer program is executed by a processor, the image processing method according to any one of claims 1 to 8 is implemented.