Image processing method and electronic device
By detecting and processing the glare area of the light source area in the night scene image captured by the mobile phone, the contrast is enhanced, which solves the problem of glare affecting the shooting effect, and the cost is lower than that of lens improvement.
Patent Information
- Application Number
- CN202310207609.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-24
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2043-02-24
AI Technical Summary
When shooting night scene images with a mobile phone, glare effects are likely to occur around the light source, which reduces local contrast and affects the shooting effect. Moreover, the cost of improving the existing technology through the lens is relatively high.
By detecting the glare area in the light source area, performing morphological expansion processing and contrast enhancement processing to improve the contrast of the glare area, and using software to improve the shooting effect, the cost is lower.
It effectively improves the local contrast of night scene images and improves the shooting effect, and the cost is lower than lens improvement.
Smart Images

Figure CN117132511B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image processing method and electronic equipment. Background Art
[0002] Currently, in night scene images captured by mobile phones, a glare effect may be generated around the light source, which reduces the local contrast of the night scene images and affects the shooting effect of the night scene.
[0003] In the prior art, the design of the mobile phone lens can be improved to reduce the glare effect around the light source in the captured image, but the cost of improving the lens design is relatively high. Summary of the invention
[0004] The embodiments of the present application provide an image processing method and an electronic device, which can detect a glare area corresponding to a light source area, enhance the contrast of the glare area, improve the shooting effect, and have a low cost.
[0005] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0006] In a first aspect, an image processing method is provided, which can be applied to an electronic device. The electronic device can acquire at least one frame of a first image of a target object, wherein the first image includes a light source area, and the brightness of the pixels in the light source area exceeds a preset brightness threshold. The electronic device can acquire a first mask MASK image, and perform morphological dilation processing on the first MASK image to obtain a second MASK image; wherein the first MASK image is a MASK image of the light source area in the first image. The electronic device calculates the difference between the second MASK image and the first MASK image to obtain a third MASK image; wherein the third MASK image corresponds to a glare area in the first image, and the glare area is an edge area of the light source area. Contrast enhancement processing is performed on the glare area corresponding to the third MASK image in the first image to obtain a processed first image.
[0007] By adopting this technical solution, the glare area where glare occurs at the edge of the light source area can be detected, and contrast enhancement processing can be performed on the glare area, which can improve the shooting effect.
[0008] In a possible design manner of the first aspect, the brightness of the pixel points in the above-mentioned light source area exceeds the preset brightness threshold, including: the red pixel value, green pixel value and blue pixel value of the pixel points in the light source area are greater than the preset pixel threshold.
[0009] In a possible design of the first aspect, the first image is a normally exposed image of the target object. That is, when the first image acquired is a single-frame image, a normally exposed image is generally acquired. Alternatively, a low-exposure image or a high-exposure image may be acquired.
[0010] In a possible design of the first aspect, the at least one first image frame includes at least two first images, and the at least two first images include a low-exposure image and a normal-exposure image of the target object. That is, the first image may include images with different exposure levels, and the images with different exposure levels may be a single frame or multiple frames.
[0011] The above-mentioned contrast enhancement processing is performed on the glare area corresponding to the third MASK image in the first image to obtain the processed first image, including: image fusion of the first area image corresponding to the third MASK image in the low-exposure image and the second area image corresponding to the fourth MASK image in the normal-exposure image to obtain the second image; wherein the fourth MASK image corresponds to the non-glare area in the normal-exposure image, and the non-glare area includes all other areas except the glare area in the normal-exposure image. The contrast enhancement processing is performed on the glare area corresponding to the third MASK image in the second image to obtain the processed first image. That is to say, when fusion is performed, the image content corresponding to the glare area is selected from the low-exposure image, and the image content corresponding to the non-glare area is selected from the normal-exposure image, and the brightness of the glare area can be dimmed after fusion.
[0012] Therefore, when the first image includes images with different exposure levels, it is necessary to first fuse the images with different exposure levels to reduce the brightness of the glare area, and then enhance the contrast of the corresponding glare area in the fused image, so that the processed image can be displayed more clearly.
[0013] In a possible design of the first aspect, before the contrast enhancement processing is performed on the glare area corresponding to the third MASK image in the first image to obtain the processed first image, the method also includes: calculating the information entropy of the third area image corresponding to the third MASK image in the normal exposure image and the information entropy of the first area image; determining that the information entropy of the third area image is greater than the information entropy of the first area image. In other words, the information entropy of the image corresponding to the third MASK image in the normal exposure image is greater than the information entropy of the image corresponding to the third MASK image in the low exposure image. In other words, the contrast of the image corresponding to the third MASK image in the normal exposure image is less than the contrast of the image corresponding to the third MASK image in the low exposure image. If the above conditions are met, it means that the area corresponding to the third MASK image is very likely to be the area where glare or halo is generated.
[0014] In a possible design of the first aspect, the at least two frames of first images also include a high-exposure image of the target object. Before the contrast enhancement processing is performed on the glare area corresponding to the third MASK image in the first image to obtain the processed first image, the method also includes: calculating the information entropy of the fourth area image corresponding to the third MASK image in the high-exposure image; determining that the information entropy of the third area image is less than the information entropy of the fourth area image. That is, for images with different degrees of exposure, the information entropy of the image corresponding to the third MASK image in the image with a lower exposure degree is smaller. That is, the contrast of the image corresponding to the third MASK image in the high-exposure image is smaller than the contrast of the image corresponding to the third MASK image in the normal exposure image, and the contrast of the image corresponding to the third MASK image in the normal exposure image is smaller than the contrast of the image corresponding to the third MASK image in the low-exposure image.
[0015] Therefore, when there are high-exposure images, normal-exposure images, and low-exposure images, if the above-mentioned information entropy conditions are met, it means that the area corresponding to the third MASK image is very likely to be the area where glare or halo is generated.
[0016] In a possible design of the first aspect, the method further includes: acquiring a first MASK image based on the normal exposure image, so that the final image fusion result can be better.
[0017] In a possible design of the first aspect, before performing contrast enhancement processing on the glare area corresponding to the third MASK image in the first image to obtain the processed first image, the method further includes: calculating the information entropy of the third area image corresponding to the third MASK image in the normal exposure image; and determining whether the information entropy of the third area image is within a preset threshold interval. In other words, if there is only one frame of image, a preset information entropy threshold interval can be set. If the information entropy of the image corresponding to the third MASK image in the normal exposure image is within the preset threshold interval, it means that the area corresponding to the third MASK image is very likely to be an area where glare or halo is generated.
[0018] In a second aspect, the present application provides an electronic device, which includes a memory, a display screen, one or more cameras, and one or more processors. The memory, the display screen, and the camera are coupled to the processor. The memory stores a computer program code, and the computer program code includes computer instructions. When the computer instructions are executed by the processor, the electronic device executes the method described in the first aspect and any possible design thereof.
[0019] In a third aspect, the present application provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect and any possible design thereof.
[0020] In a fourth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect and any possible design manner. The computer may be the electronic device described above.
[0021] It can be understood that the beneficial effects that can be achieved by the electronic device described in the second aspect, the computer storage medium described in the third aspect, and the computer program product described in the fourth aspect provided above can be referred to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 A schematic diagram of the display effect of the same image before and after image processing provided by an embodiment of the present application;
[0023] Figure 2 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0024] Figure 3 A flowchart of an image processing method provided in an embodiment of the present application;
[0025] Figure 4 A schematic diagram of a display interface of a mobile phone provided in an embodiment of the present application;
[0026] Figure 5 A schematic diagram of a display interface of another mobile phone provided in an embodiment of the present application;
[0027] Figure 6 A schematic diagram of a display interface of another mobile phone provided in an embodiment of the present application;
[0028] Figure 7 A schematic diagram of a display interface of another mobile phone provided in an embodiment of the present application;
[0029] Figure 8 A schematic diagram of a display interface of another mobile phone provided in an embodiment of the present application;
[0030] Fig. 9 A schematic diagram of the effect of a MASK image of a target object provided in an embodiment of the present application;
[0031] Fig.10 A schematic diagram of the effect of a MASK image corresponding to different areas of a target object provided in an embodiment of the present application;
[0032] Fig.11 A schematic diagram of the display effect of a glare area before and after image processing provided in an embodiment of the present application;
[0033] Fig.12 is a flowchart of another image processing method provided in an embodiment of the present application;
[0034] Fig.13 is a schematic diagram of an implementation of an image processing method provided in an embodiment of the present application;
[0035] Fig.14 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The following terms "first", "second", etc. are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, features defined as "first", "second", etc. may explicitly or implicitly include one or more of the features. In the description of the present embodiment, unless otherwise specified, "multiple" means two or more.
[0037] For ease of understanding, the following terms are introduced in this application:
[0038] (1) Exposure Values (EV): Exposure index, a measurement system for exposure. It can be divided into normal exposure (EV0), low exposure (EV-), and high exposure (EV+).
[0039] Among them, normal exposure means that both the highlights and shadows of the picture have clear details; low exposure means that the light is too dark, resulting in a dark picture and underexposure; high exposure means that the light is too bright, resulting in a bright picture and overexposure.
[0040] If the photo is too dark, the EV value base of the camera's light meter needs to be corrected. Every increase of 1.0 in the EV value is equivalent to doubling the amount of light intake. If the photo is too bright, the EV value needs to be reduced. Every decrease of 1.0 in the EV value is equivalent to halving the amount of light intake. The compensation interval can be adjusted in units of 1 / 2 (0.5) or 1 / 3 (0.3) according to different cameras.
[0041] (2) Mask: Also known as an image mask, it is used to block the processed image (all or part) with a selected image, graphic or object to control the image processing area or processing process. The specific image or object used for covering is called a mask.
[0042] In digital image processing, a mask is a binary image consisting of 0s and 1s. When a mask is applied to a function, the 1-valued areas are processed and the masked 0-valued areas are not included in the calculation. Image masks are defined by specifying data values, data ranges, finite or infinite values, regions of interest, and annotation files. Masks can also be created by applying any combination of the above options as input.
[0043] (3) Morphological dilation: Morphology is a series of image processing operations based on shape. The two most basic morphological operations are dilation and erosion. Generally, operations on binary images / grayscale images require two inputs, one is the original image or binary image, and the other is called a structuring element or kernel, which is used to determine the nature of the operation.
[0044] Dilation is for the white part (highlight part), not the black part. Dilation is to expand the highlight area or white part in the image. The result is larger than the highlight area of the original image, and the lines become thicker. It is mainly used for denoising. Among them, image dilation can be divided into three types: horizontal dilation, vertical dilation, and omnidirectional dilation.
[0045] When an electronic device is shooting, the subject may include light sources, such as advertising billboards, street lamps, etc. Since the lens of the electronic device may have design defects, when the light passes through the lens and then reaches the image sensor, there may be unexpected reflection or refraction, which may cause glare around the light source in the image presented by the electronic device, reducing the contrast around the light source and affecting the shooting effect.
[0046] See also Figure 1 , Figure 1 Schematic diagram of the display effect of the same image before and after image processing. Figure 1 1a is the image 101 before image processing. Figure 1 1b is the image 102 after image processing. It can be seen from 1a and 1b that the local contrast of image 101 around the light-emitting area of the street lamp is lower than the local contrast of image 102 around the light-emitting area of the street lamp, and image 102 is clearer and more eye-catching than image 101.
[0047] In some existing solutions, the above problem can be solved by improving the lens of the electronic device. However, the cost of improving the lens is relatively high.
[0048] Therefore, the embodiment of the present application provides an image processing method, which can obtain a first MASK image corresponding to the light source area in the image, and a second MASK image after the first MASK image is morphologically expanded, and then obtain a third MASK image corresponding to the glare area according to the first MASK image and the second MASK image. Finally, by performing contrast enhancement processing on the glare area, the local contrast of the image is improved, the glare effect of the image is improved, and then the shooting effect is improved. And the shooting effect is improved by software, which is more cost-effective.
[0049] Exemplarily, the electronic device in the embodiments of the present application may be a portable computer (such as a mobile phone), a tablet computer, a laptop computer, a personal computer (PC), a wearable electronic device (such as a smart watch), an augmented reality (AR) device, a virtual reality (VR) device, a car computer, etc. The following embodiments do not impose any special restrictions on the specific form of the electronic device.
[0050] The following will describe the implementation of the embodiment of the present application in detail with reference to the accompanying drawings. Taking the above-mentioned electronic device as a mobile phone as an example, the hardware structure of the electronic device 100 is introduced. Figure 2 , Figure 2 A schematic diagram of the structure of an electronic device is shown. Figure 2 As shown, the electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a USB interface 110, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone, an earphone interface, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.
[0051] Among them, the above-mentioned sensor module 180 may include sensors such as pressure sensor, gyroscope sensor, air pressure sensor, magnetic sensor, acceleration sensor, distance sensor, proximity light sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor and bone conduction sensor.
[0052] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the mobile phone 100. In other embodiments, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0053] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0054] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0055] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0056] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0057] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0058] The charging management module 140 is used to receive charging input from the charger. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0059] The wireless communication function of the electronic device 100 can be implemented by antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modulation and demodulation processor and baseband processor. Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antenna. For example, antenna 1 can be reused as a diversity antenna of a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0060] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
[0061] The wireless communication module 160 can provide wireless communication solutions for application in the mobile phone 100, 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 technology (NFC), infrared technology (IR), etc.
[0062] The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 may also receive a signal to be sent from the processor 110, modulate the signal, amplify the signal, and convert it into an electromagnetic wave for radiation via the antenna 2.
[0063] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0064] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0065] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc.
[0066] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor. ISP is used to process the data fed back by camera 193. Camera 193 is used to capture static images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1. The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 is in frequency selection, the digital signal processor is used to perform Fourier transform on the frequency energy. The video codec is used to compress or decompress digital video. NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, speech recognition, text understanding, etc.
[0067] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0068] The internal memory 121 may be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the mobile phone 100 by running the instructions stored in the internal memory 121. For example, in an embodiment of the present application, the processor 110 may execute the instructions stored in the internal memory 121, and the internal memory 121 may include a program storage area and a data storage area.
[0069] The program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0070] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone, the headphone interface, and the application processor.
[0071] The fingerprint sensor 180A is used to collect fingerprint information. The electronic device 100 can use the fingerprint characteristics of the collected fingerprint information to perform user identity verification (i.e. fingerprint recognition) to achieve fingerprint unlocking, access application locks, fingerprint photography, fingerprint answering calls, etc.
[0072] The touch sensor 180B is also called a "touch panel (TP)". The touch sensor 180B can be set on the display screen 194, and the touch sensor 180B and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180B is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180B can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0073] The button 190 includes a power button, a volume button, etc. The button 190 can be a mechanical button. It can also be a touch button. The motor 191 can generate a vibration prompt. The motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power changes, messages, missed calls, notifications, etc. The SIM card interface 195 is used to connect the SIM card. The SIM card can be inserted into the SIM card interface 195, or pulled out from the SIM card interface 195 to achieve contact and separation with the mobile phone 100. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc.
[0074] The methods in the following embodiments can all be implemented in the electronic device 100 having the above hardware structure.
[0075] The present application embodiment provides an image processing method, which can be applied to an electronic device including a camera. In the following embodiment, the electronic device is a mobile phone as an example to introduce the method of the present application embodiment. Figure 3 , Figure 3 FIG. 1 is a schematic diagram of an implementation flow of an image processing method provided in an embodiment of the present application. Figure 3 As shown, the image processing method may include S301-S304.
[0076] S301. A mobile phone acquires at least one first image frame of a target object, wherein the first image includes a light source area, and the brightness of pixels in the light source area exceeds a preset brightness threshold.
[0077] For example, the method of the embodiment of the present application can be applied to the scene of mobile phone taking pictures, previewing pictures, recording videos, and previewing videos. Alternatively, the method of the embodiment of the present application can also be applied to the scene of the mobile phone performing image processing on photos or videos in the mobile phone gallery (or album).
[0078] In some embodiments, the method of the embodiment of the present application can be applied to the scene of mobile phone photography (referred to as: photography scene). Among them, the above-mentioned photography scene may include: night scenes with light sources, such as advertising billboards, street lights, etc. in night scenes. Alternatively, it may not be for night scenes, for example, when there is a very bright light source in the scene and the surroundings are very dark, it is for scenes with obvious light and dark. Or, it is an ordinary high dynamic range imaging (High Dynamic Range Imaging, HDRI or HDR for short) scene in backlight. Or, in a scene without a light source, for example, facing the sunset at sunset, or standing next to a window, there may also be glare areas when shooting at a specific angle.
[0079] In the photo-taking scenario, the phone can display a Figure 4 The preview interface 401 of the photo taking as shown in (b) of FIG. 4 is shown in FIG. 4. For example, the operation of opening the camera application may be a user's Figure 4 The click operation of the application icon of the camera application shown in (a) in the figure. The preview interface 401 for taking photos may include a preview image 402. Among them, the preview image 402 may be the first image after the processing described in S304 obtained by the mobile phone executing S301-S304 to process the image (i.e., the first image) captured by the camera. The first image may be the original (RAW) image captured by the camera. Specifically, the mobile phone may execute S301-S304 in response to the user's operation of turning on the camera application. That is, the mobile phone may execute S301 to capture the first image in response to the user's operation of turning on the camera application.
[0080] Alternatively, in a photo-taking scenario, the mobile phone may display a Figure 5 The preview interface 501 for taking a photo as shown in (a) of FIG. 5 . The preview image 502 displayed in the preview interface 501 for taking a photo may be a preview image captured by the camera of the mobile phone. The preview image 502 (i.e., the first image) may be a RAW image captured by the camera and has not been processed by the mobile phone. In response to the user clicking the "shoot shutter" 503 in the preview interface 501, the mobile phone may execute the method of the embodiment of the present application to process the preview image (i.e., the first image) captured by the camera to obtain Figure 5 The processed first image 504 shown in (b) of FIG. 3 is shown in FIG. 3. Specifically, the mobile phone can execute S301-S304 in response to the user's click operation on the "shoot shutter" 503. In other words, the mobile phone can execute S301 to obtain the first image in response to the user's click operation on the "shoot shutter" 503, and then execute S302-S304 to display the processed first image.
[0081] In other embodiments, the method of the embodiments of the present application can be applied to a scenario in which a mobile phone performs image processing on photos or videos in a mobile phone gallery (or album) (referred to as: post-shooting image processing scenario).
[0082] In the post-photographing image processing scenario, the mobile phone can execute S301 - S304 in response to a user clicking operation on any photo in the album, and obtain and display the processed first image.
[0083] For example, a mobile phone can display Figure 6The album list interface 601 shown in (a) of FIG. 1 includes preview items of multiple photos. Generally speaking, the mobile phone can respond to the user's click operation on the preview item 602 of the street light photo (equivalent to the first image) in the album list interface 601, and can directly display the street light photo (equivalent to the first image) corresponding to the preview item 602. In the embodiment of the present application, the mobile phone can respond to the user's click operation on the preview item 602 of the street light photo (equivalent to the first image) and can execute S301-S304 to obtain and display Figure 6 The processed first image 603 is shown in (b) in FIG. Figure 6 The photo details page shown in (b) includes not only the processed first image 603, but also an edit button 604. The edit button 604 is used to trigger the mobile phone to edit the processed first image 603.
[0084] Alternatively, in a post-photography image processing scenario, the user may trigger the mobile phone to execute S301 - S304 in a photo editing interface to obtain and display a processed first image.
[0085] For example, a mobile phone can display Figure 7 The mobile phone responds to the user's response to the photo 701 (i.e., the first image) shown in (a) of FIG. Figure 7 Clicking the edit button 702 shown in (a) of FIG. Figure 7 The editing interface 703 shown in (b) of FIG. The editing interface 703 includes an “intelligent AI” button 705, a “crop” button, a “filter” button, and an “adjust” button. The “intelligent AI” button 705 is used to trigger the mobile phone to improve the glare effect of the first image 704. The “crop” button is used to trigger the mobile phone to crop the first image. The “filter” button is used to trigger the mobile phone to add a filter effect to the first image. The “adjust” button is used to trigger the mobile phone to adjust the contrast, saturation, brightness and other parameters of the first image.
[0086] In response to the user clicking the "Smart AI" button 705, the mobile phone can execute S301-S304 to obtain and display Figure 7 The processed first image 707 is shown in (c) in FIG. Figure 7 The editing interface shown in (c) of FIG. 7 includes not only the processed first image 707, but also a save button 706. The save button 706 is used to trigger the mobile phone to save the processed first image 707. In response to the user clicking the save button 706, the mobile phone can save the processed first image 707 and display it. Figure 8 The photo details page of the processed first image 707 is shown.
[0087] In other embodiments, the method of the embodiments of the present application can also be applied to the scenario of mobile phone recording. The mobile phone can execute S301-S304 in response to the user's operation of turning on the recording mode, or the mobile phone can execute S301-S304 in response to the user's clicking operation on the "recording shutter".
[0088] It should be noted that the method of image processing of a video in a mobile phone gallery (or album) is similar to the method of image processing of a photo in a mobile phone gallery, and the present application embodiment will not be described in detail here. The difference is that the mobile phone needs to process each frame of the video.
[0089] The image obtained by the above shooting is the first image, and the first image can be a single frame or multiple frames. Among them, the target object can be a portrait, a landscape, a delicacy, a building, etc.
[0090] In the embodiment of the present application, the at least one first image frame obtained may be at least one image frame with the same exposure level, such as one normal exposure image frame, or multiple normal exposure images. It may also be at least one image frame with different exposure levels, such as one or more low exposure images and one or more normal exposure images, or one or more low exposure images, one or more high exposure images, and one or more normal exposure images.
[0091] In the embodiment of the present application, the acquired first image includes a light source area, wherein the brightness of a pixel in the first image can be detected to determine whether the image has a light source area. If the brightness of a pixel exceeds a preset brightness threshold, the pixel is a pixel of the light source area.
[0092] The first image captured by the mobile phone lens is composed of pixels, each of which includes three sub-pixels: red (Red, R), green (Green, G), and blue (Blue, B). The brightness value of the pixel is between 0 and 255, and the brightness of the pixel close to 255 is higher, and the brightness of the pixel close to 0 is lower.
[0093] In the embodiment of the present application, the brightness of the pixel point in the light source area exceeds the preset brightness threshold, that is, the red pixel value, green pixel value and blue pixel value of the pixel point in the light source area are greater than the preset pixel threshold. Wherein, the preset pixel threshold can be set by user, for example, the preset pixel threshold is 200, then the red pixel value, green pixel value and blue pixel value of the pixel point in the light source area are greater than 200. That is to say, when the red pixel value, green pixel value and blue pixel value of the pixel point of the first image are detected, if the red pixel value, green pixel value and blue pixel value of the pixel point are all greater than 200, the pixel point is a pixel point in the light source area. Alternatively, a preset ratio value of the pixel interval can also be set, for example, the pixel interval is 0 to 255, and the preset ratio value is 0.8, then if the red pixel value, green pixel value and blue pixel value of the pixel point in the pixel value interval The ratio value is greater than 0.8, that is, the red pixel value, green pixel value and blue pixel value of the pixel point are all greater than 204 (255*0.8=204), the pixel point is a pixel point in the light source area.
[0094] S302: The mobile phone obtains a first mask image, and performs morphological dilation processing on the first mask image to obtain a second mask image. The first mask image is a mask image of the light source area in the first image.
[0095] In the embodiment of the present application, after detecting the light source area in the first image, the mobile phone obtains a MASK image of the light source area and sets it as the first MASK image.
[0096] Among them, if the mobile phone performs the image processing of the present application on images with different exposure levels, at least one frame of the first image obtained by the mobile phone includes a normal exposure image, and of course, may also include a low exposure image and / or a high exposure image. Generally, the mobile phone can obtain the first MASK image of the light source area based on the normal exposure image.
[0097] For example, if the first image acquired by the mobile phone includes a low-exposure image and a normal-exposure image of the target object, then based on the normal-exposure image, a first MASK image of the light source area is acquired. For another example, if the first image acquired by the mobile phone includes a low-exposure image, a normal-exposure image, and a high-exposure image of the target object, then based on the normal-exposure image, a first MASK image of the light source area is acquired. It is understandable that, in other embodiments, the first image acquired by the mobile phone may also be a low-exposure image and a high-exposure image of the target object, or a normal-exposure image and a high-exposure image of the target object. Relatively speaking, if there is a low-exposure image, the effect presented when performing image fusion is better.
[0098] In some embodiments, when the mobile phone performs the image processing of the present application on a single-frame image or an image with the same exposure level, a normal exposure image is generally obtained, and the first image is also a normal exposure image. In other embodiments, the first image may also be a low exposure image or a high exposure image.
[0099] In the embodiment of the present application, compared with the case where the first image only includes a single-frame image or images with the same exposure level, if the first image includes images with different exposure levels, the image processing effect is better.
[0100] For example, the first MASK image described above is used as an example in the present embodiment to introduce the MASK image described in the present embodiment. For example, assuming that the target object is a street lamp, the first MASK image may be a MASK image of the light source area of the street lamp. Fig. 9 As shown, the mobile phone can obtain the first MASK image 902 of the first image 901.
[0101] For example, in the first MASK image described in the embodiment of the present application, the pixel value of the pixel in the image of the light source area may be a first value, and the pixel value of the pixel in the image other than the image of the light source area in the first MASK image may be a second value. The first value is different from the second value and is used to distinguish the image of the first photographed object from other images in the second image. For example, the first value may be 1 and the second value may be 0.
[0102] For example, Fig. 9 In the figure, the light source area is the portion filled with white in the first MASK image 902, and its pixel value may be 1. Fig. 9 In the figure, other images outside the light source area are the parts filled with black in the first MASK image 902, and their pixel values may be 0.
[0103] In the embodiment of the present application, after obtaining the first MASK image of the light source area, the first MASK image is subjected to morphological dilation processing to obtain the second MASK image. The first MASK image can be subjected to omnidirectional dilation processing.
[0104] Specifically, traverse each pixel of the first MASK image, take the pixel value of the pixel and all the adjacent pixels corresponding to the pixel, and take the maximum value of all the pixel values as the pixel value of the pixel. In the first MASK image, if the pixel values of a certain pixel and all the adjacent pixels corresponding to the pixel are 0, the maximum value is 0, and the pixel value of the pixel is determined to be 0; if the pixel value of the pixel is 0, and the pixel values of all the adjacent pixels corresponding to the pixel are 1 or 0, the pixel value of the pixel is set to 1, and so on. After processing each pixel, the expansion operation of the first MASK image is completed.
[0105] The size of the sliding window may be determined first, and each pixel of the first MASK image is traversed through the preset sliding window to assign values to the pixels in the sliding window. The larger the preset sliding window is, the larger the white area will be.
[0106] like Fig.10 As shown, the mobile phone performs a morphological dilation operation on the first mask image 1001 to obtain a second mask image 1002. After the dilation process, the light source area 1004 corresponding to the first mask image 1001 becomes the dilated light source area 1005. Fig.10 It can be seen that the white area in the first MASK image 1001 is significantly larger in the second MASK image 1002 .
[0107] S303: The mobile phone calculates the difference between the second MASK image and the first MASK image to obtain a third MASK image.
[0108] In the present application embodiment, Fig.10 As shown, by calculating the difference between the second mask image 1002 and the first mask image 1001, a third mask image 1003 is obtained. The third mask image corresponds to the glare area in the first image, and the glare area is the edge area of the light source area.
[0109] like Fig.10 As shown, the difference between the second MASK image 1002 and the first MASK image 1001 is calculated, that is, the difference between the expanded light source area 1005 and the light source area 1004 is calculated to obtain the glare area 1006, which is the white area in the third MASK image 1003.
[0110] S304: The mobile phone performs contrast enhancement processing on the glare area corresponding to the third MASK image in the first image to obtain a processed first image.
[0111] In the embodiment of the present application, before contrast enhancement processing is performed on the glare area, it can be determined whether the contrast of the first image meets the preset contrast condition. If the contrast of the first image meets the preset contrast condition, it means that there is glare at the edge of the light source area in the first image, and contrast enhancement processing needs to be performed on the glare area.
[0112] In some embodiments, if the first image acquired by the mobile phone is a single frame or has the same exposure level, and the first image is assumed to be a normally exposed image, then before contrast enhancement processing is performed on the glare area, it is necessary to first determine whether the contrast of the normally exposed image meets a preset contrast condition.
[0113] Specifically, the information entropy of the third area image corresponding to the third MASK image in the normal exposure image is calculated, and it is determined whether the information entropy of the third area image is within a preset threshold range. Among them, information entropy can represent contrast in a certain sense. Therefore, it is determined whether the information entropy of the third area image is within the preset threshold range of information entropy, that is, it is determined whether the contrast of the third area image is within the preset threshold range of contrast. If the information entropy of the third area image is within the preset threshold range of information entropy, that is, the contrast of the third area image is within the preset threshold range of contrast, then it means that the contrast of the normal exposure image meets the preset contrast condition.
[0114] After determining that the contrast of the normal exposure image meets the preset contrast condition, that is, determining that there is a glare area behind the normal exposure image, the contrast enhancement process can be directly performed on the glare area determined in the normal exposure image to obtain a processed normal exposure image to improve the display effect of the normal exposure image. The "display effect" of the image described in the embodiment of the present application refers to the image effect that can be observed by the human eye after the image is displayed on the display screen.
[0115] In some embodiments, if the first image acquired by the mobile phone is an image with different exposure levels, and the first image includes a low-exposure image and a normal-exposure image, then before contrast enhancement processing is performed on the glare area, it is necessary to first determine whether the contrast of the normal-exposure image and the contrast of the low-exposure image meet the preset contrast condition. That is, in order to further confirm whether there is glare or halo in the area corresponding to the third MASK image, and whether this glare or halo meets the conditions of higher contrast and smaller area in the image frame with a smaller EV value in terms of area and contrast. The above-mentioned preset contrast condition means that the contrast of the glare area in the image with a lower exposure value is greater.
[0116] Specifically, the information entropy of the third region image corresponding to the third MASK image in the normal exposure image and the information entropy of the first region image corresponding to the third MASK image in the low exposure image can be calculated, and it is determined whether the information entropy of the third region image is greater than the information entropy of the first region image. Since the information entropy can represent the contrast in a certain sense, within the preset threshold range of the information entropy, the smaller the information entropy, the greater the contrast.
[0117] It can be known that the exposure value of the third region image is higher than the exposure value of the first region image, therefore, it is necessary to determine whether the information entropy of the third region image is greater than the information entropy of the first region image, that is, to determine whether the contrast of the third region image is less than the contrast of the first region image. If the information entropy of the third region image is greater than the information entropy of the first region image, that is, the contrast of the third region image is less than the contrast of the first region image, then it means that the contrast of the normal exposure image and the contrast of the low exposure image meet the preset contrast condition.
[0118] In the embodiment of the present application, if the first image acquired by the mobile phone is an image with different exposure levels, the images with different exposure levels are first fused, and then the glare area in the fused image is subjected to contrast enhancement processing, so as to obtain the processed first image to improve the display effect of the first image. Assuming that the first image is a low-exposure image and a normal-exposure image of the target object, when performing image fusion, the image content of the glare area can be determined from the low-exposure image, and the image content of the non-glare area can be determined from the normal-exposure image, and the non-glare area includes all other areas in the normal-exposure image except the glare area.
[0119] Specifically, the first area image corresponding to the third MASK image in the low-exposure image and the second area image corresponding to the fourth MASK image in the normal exposure image are fused to obtain a second image. The fourth MASK image corresponds to the non-glare area in the normal exposure image. Then, the glare area corresponding to the third MASK image in the second image is contrast enhanced to obtain the processed first image. It can be understood that the fusion algorithm in the prior art can be used in the embodiment of the present application to achieve image fusion, which will not be described in detail here.
[0120] In some embodiments, if the first image includes a high exposure image in addition to a low exposure image and a normal exposure image, then before performing contrast enhancement processing on the glare area, it is necessary to first determine whether the contrast of the normal exposure image, the contrast of the low exposure image, and the contrast of the high exposure image meet preset contrast conditions.
[0121] Specifically, the information entropy of the fourth region image corresponding to the third MASK image in the high exposure image, the information entropy of the third region image corresponding to the third MASK image in the normal exposure image, and the information entropy of the first region image corresponding to the third MASK image in the low exposure image are calculated. Then, it is determined whether the information entropy of the third region image is greater than the information entropy of the first region image, and less than the information entropy of the fourth region image. If the information entropy of the third region image is greater than the information entropy of the first region image, and less than the information entropy of the fourth region image, that is, the contrast of the third region image is less than the contrast of the first region image, and greater than the contrast of the fourth region image. Then, it means that the contrast of the normal exposure image, the contrast of the low exposure image, and the contrast of the high exposure image meet the preset contrast conditions.
[0122] Among them, the information of the above-mentioned high-exposure image is only used for contrast judgment before image fusion, and is not used for image fusion. Therefore, if the first image includes a low-exposure image, a normal-exposure image, and a high-exposure image, only the image content in the low-exposure image and the normal-exposure image is needed for image fusion. Then, the glare area in the fused image is contrast enhanced to obtain the processed first image. Generally speaking, the image processing effect after multi-exposure fusion of the glare area is better than the effect of contrast enhancement of the glare area of a single frame image.
[0123] In some embodiments, if the first image includes multiple frames of images with the same exposure level and the corresponding exposure values are different, then the information entropy of the images in the corresponding areas of the third MASK image of these images are arranged in order from small to large, which is the same as the arrangement order of these images from low to high according to the exposure values.
[0124] For example, the first image includes a low-exposure image EV-, a normal-exposure image EV0, and high-exposure images EV+1 and EV+2. Then, before image fusion, the information entropy A of the image corresponding to the area of the third MASK image of the low-exposure image EV-, the information entropy B of the image corresponding to the area of the third MASK image of the normal-exposure image EV0, the information entropy C of the image corresponding to the area of the third MASK image of the high-exposure image EV+1, and the information entropy D of the image corresponding to the area of the third MASK image of the high-exposure image EV+2 are calculated respectively. Then, if information entropy A<information entropy B<information entropy C<information entropy D, it means that the area corresponding to the third MASK image is a glare area. Then, image fusion is performed based on the above images, and the contrast of the glare area is enhanced.
[0125] In other embodiments, the first image acquired by the mobile phone may not include the low-exposure image, for example, the first image only includes the normal-exposure image and the high-exposure image. However, the image processing effect when the graphics processing method described in the present application is used when the low-exposure image is included is better than the image processing effect when the low-exposure image is not included.
[0126] In the embodiment of the present application, contrast enhancement processing is performed only on the glare area in the first image or the second image. Among them, the contrast enhancement method includes histogram equalization, local tone mapping, bilateral grid high frequency enhancement, etc. It can be understood that the present application can use the contrast enhancement method in the prior art to perform contrast enhancement processing on the glare area, which will not be repeated here.
[0127] like Fig.11 As shown, Fig.11 11a is the image 1101 before the above image processing, Fig.11 11b is the image 1102 after the above image processing. The light emitting area 1103 of the street lamp in the image 1101 is the above light source area, and the edge area 1104 of the light emitting area 1103 of the street lamp in the image 1101 is the above glare area. After the image processing method described in the present application, the contrast of the glare area 1105 in the image 1102 is enhanced, and the image 1102 is clearer than the image 1101.
[0128] It is understandable that the light source area of the image 1101 is determined by detecting the brightness of each pixel in the image 1101. In this example, only the pixel points of the light-emitting area 1103 of the street lamp in the image 1101 are detected to meet the preset brightness threshold, so only the edge area 1104 of the light-emitting area 1103 is considered to be the glare area. However, in other examples, there may be multiple light source areas in the image, and the above image processing method can be performed together, and it is not necessary to process the glare area of only one light source area.
[0129] In some embodiments, please refer to the flowchart of another image processing method provided in the embodiment of the present application. Fig.12 In the following embodiments, the electronic device is still taken as an example to describe the method of the embodiment of the present application. Fig.12 As shown, the image processing method may include S1201-S1206.
[0130] S1201. A mobile phone obtains at least two first image frames of a target object, where the at least two first image frames include a low-exposure image and a normal-exposure image of the target object, and the first image includes a light source area.
[0131] In the embodiment of the present application, it is possible to determine whether there is a light source area in the first image by detecting the brightness of a pixel in the first image. If the brightness of a pixel exceeds a preset brightness threshold, the pixel is a pixel in the light source area. The brightness of a pixel in the light source area exceeds the preset brightness threshold, that is, the red pixel value, green pixel value, and blue pixel value of the pixel in the light source area are greater than the preset pixel threshold.
[0132] For example, the preset pixel threshold is 200, and the red pixel value, green pixel value, and blue pixel value of the pixel point in the light source area are greater than 200. In other words, each pixel point of the first image is detected, and if the red pixel value, green pixel value, and blue pixel value of the pixel point are all greater than 200, the pixel point is a pixel point in the light source area.
[0133] S1202: The mobile phone obtains a first mask image, and performs morphological dilation processing on the first mask image to obtain a second mask image. The first mask image is a mask image of the light source area in the first image.
[0134] In the embodiment of the present application, the mobile phone obtains a first MASK image of the light source area based on the above-mentioned normal exposure image.
[0135] Among them, the step of "obtaining a first MASK image of the light source area, and performing morphological dilation processing on the first MASK image to obtain a second MASK image" please refer to step S302, and this application will not elaborate on it here.
[0136] S1203: The mobile phone calculates the difference between the second MASK image and the first MASK image to obtain a third MASK image.
[0137] The step of "calculating the difference between the second MASK image and the first MASK image to obtain the third MASK image" refers to step S303, which is not described in detail in this application. The third MASK image corresponds to the glare area in the first image, and the glare area is the edge area of the light source area.
[0138] S1204. The mobile phone calculates the information entropy of the third area image corresponding to the third MASK image in the normal exposure image and the information entropy of the first area image corresponding to the third MASK image in the low exposure image, and determines that the information entropy of the third area image is greater than the information entropy of the first area image.
[0139] In the embodiment of the present application, it is possible to determine whether there is glare at the edge of the light source area in the first image by judging whether the normal exposure image and the low exposure image meet the preset contrast condition. If the normal exposure image and the low exposure image meet the preset contrast condition, it means that there is glare at the edge of the light source area in the first image, and the glare area needs to be contrast enhanced.
[0140] Specifically, calculate whether the information entropy a of the third area image corresponding to the third MASK image in the normal exposure image is greater than the calculated information entropy b of the first area image corresponding to the third MASK image in the low exposure image. If the information entropy a is greater than the information entropy b, that is, it is determined that the contrast of the third area image is less than the contrast of the first area image, then the area corresponding to the third MASK image in the first image is a glare area.
[0141] Since the first image includes two frames of images with different exposure levels, before executing the local contrast enhancement process in step S1206 , the two images with different exposure levels must be fused first.
[0142] S1205. The mobile phone performs image fusion on the first area image and the second area image corresponding to the fourth MASK image in the normal exposure image to obtain a second image; wherein the fourth MASK image corresponds to the non-glare area in the normal exposure image, and the non-glare area includes all other areas in the normal exposure image except the glare area.
[0143] In the embodiment of the present application, when image fusion is performed, the image content of the glare area can be determined from the low-exposure image, and the image content of the non-glare area can be determined from the normal-exposure image, and then a fused second image is obtained. It can be understood that the fusion algorithm in the prior art can be used to achieve image fusion in the embodiment of the present application, which will not be described in detail here.
[0144] S1206: The mobile phone performs contrast enhancement processing on the glare area corresponding to the third MASK image in the second image to obtain a processed first image.
[0145] In the embodiment of the present application, a contrast enhancement method in the prior art can be used to perform contrast enhancement processing on the glare area of the fused image, which will not be described in detail here.
[0146] In the embodiment of the present application, the above-mentioned image processing method can enhance the contrast of the glare area and improve the display effect of the image.
[0147] See also Fig.13 , Fig.13 The following is a schematic diagram of an implementation of an image processing method provided in an embodiment of the present application. Fig.13 As shown, the image processing method includes a glare area detection module, a glare area fusion module and a glare area local contrast enhancement module.
[0148] First, obtain the low-exposure image EV-, the normal-exposure image EV0, and the high-exposure image EV+ for the target object. Then, detect the flare regions in the images. Among them, the flare region detection module includes a light source region detection module, a morphological dilation module, a flare region mask initialization module, a flare region contrast judgment module, and a flare region mask determination module.
[0149] In the embodiment of the present application, the light source region detection module is used to detect the light source region in the image. Then, the first MASK image MASK1 corresponding to the light source region can be obtained.
[0150] Specifically, it can be determined whether there is a light source region in the first image by detecting the brightness of the pixel points in the first image. For example, the pixel values of the pixel points in the light source region satisfy the following condition: MASK1 = where img(R) && img(G) && img(B) > th1. That is, if the red (R), green (G), and blue (B) pixel values of the pixel points in the light source region are all greater than the preset pixel threshold th1, the pixel point is a pixel point in the light source region.
[0151] The morphological dilation module is used to perform morphological dilation processing on the first MASK image MASK1 to obtain the second MASK image MASK2.
[0152] The flare region mask initialization module is used to determine the third MASK image MASK3 according to the first MASK image MASK1 and the second MASK image MASK2, corresponding to the initial flare region in the first image. Among them, the initial flare region determined here is not necessarily the final flare region that needs to be fused and contrast-enhanced, and further contrast judgment is required. The calculation formula of the third MASK image MASK3 is as follows: MASK3 = MASK2 - MASK1.
[0153] The flare region contrast judgment module is used to determine whether the initial flare region is the flare region to be processed according to the contrast of the initial flare region of each exposure-degree image. Among them, the contrast can be represented by information entropy (entropy), and the information entropy of the initial flare region of each exposure-degree image satisfies the following condition: if entropy(img_EV-.*MASK3) < entropy(img_EV0.*MASK3) < entropy(img_EV+.*MASK3). That is, the information entropy of the image corresponding to the third MASK image in the low-exposure image is less than the information entropy of the image corresponding to the third MASK image in the normal-exposure image, and the information entropy of the image corresponding to the third MASK image in the normal-exposure image is less than the information entropy of the image corresponding to the third MASK image in the high-exposure image. When the above information entropy condition is satisfied, it can be determined that the above initial flare region is the flare region to be processed.
[0154] The calculation formula of information entropy is: information entropy = ∑-p(x)log(p(x)). In the above formula, x is the pixel value in the pixel value sequence selected for the first image when the pixel value of the pixel point in MASK3 is 1, and p(x) is the number of times the pixel value x appears in the pixel value sequence selected for the first image when the pixel value of the pixel point in MASK3 is 1.
[0155] When the glare is lower (i.e., the contrast is greater), the pixel values of the glare area are closer, and the calculated information entropy is smaller. Generally speaking, the contrast of the glare area in the image with lower exposure value should be greater, that is, the corresponding information entropy is smaller. Therefore, if the initial glare area corresponding to MASK3 is the glare area to be processed, then the information entropy corresponding to MASK3 in the image with lower exposure value is smaller.
[0156] The glare area mask determination module is used to obtain a MASK image MASK4 corresponding to the glare area to be processed. When the information entropy of the initial glare area satisfies the above information entropy condition, the MASK image MASK4 corresponding to the glare area to be processed = MASK3.
[0157] In the embodiment of the present application, the glare area fusion module is used to perform image fusion on images with different exposure levels. The image fusion formula is as follows: img_fusion = MASK3.*img_EV-*EV-+(1-MASK3).*img_EV0. In the above formula, (1-MASK3) represents the non-glare area in the normal exposure image, and the non-glare area includes all other areas in the normal exposure image except the glare area.
[0158] From the image fusion formula, it can be seen that the image corresponding to the MASK3 image in the low-exposure image and the image corresponding to the (1-MASK3) image in the normal-exposure image are fused to obtain a fused image.
[0159] In an embodiment of the present application, the glare area local contrast enhancement module is used to perform contrast enhancement processing on the glare area to be processed in the fused image. The local contrast enhancement formula is as follows: img_result = LCE (img_fusion.*MASK4) + img_fusion.* (1-MASK4). In the above formula, (1-MASK4) represents the non-glare area in the fused image. It can be seen from the above formula that only the glare area to be processed in the fused image is contrast enhanced, and the non-glare area in the fused image is not contrast enhanced.
[0160] In an embodiment of the present application, by detecting the glare area where glare occurs at the edge of the light source area, performing multi-exposure image fusion on the glare area, and then performing contrast enhancement processing on the glare area, the local brightness of the glare area can be improved and reduced, the contrast of the glare area can be improved, and then the display effect of the image can be improved.
[0161] Some other embodiments of the present application provide an electronic device, which may include: a memory, a display screen, one or more cameras, and one or more processors.
[0162] The memory, display screen, and camera are coupled to a processor. The memory stores a computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device executes the functions or steps executed by the mobile phone in the above method embodiment. The structure of the electronic device can refer to Figure 2 The structure of the electronic device 100 is shown.
[0163] The present application also provides a chip system, such as Fig.14 As shown, the chip system 1400 includes at least one processor 1401 and at least one interface circuit 1402. The processor 1401 and the interface circuit 1402 can be interconnected via lines. For example, the interface circuit 1402 can be used to receive signals from other devices (such as a memory of an electronic device). For another example, the interface circuit 1402 can be used to send signals to other devices (such as processor 1401). Exemplarily, the interface circuit 1402 can read instructions stored in the memory and send the instructions to the processor 1401. When the instructions are executed by the processor 1401, the electronic device can execute the various steps in the above embodiments. Of course, the chip system may also include other discrete devices, which are not specifically limited in the embodiments of the present application.
[0164] An embodiment of the present application also provides a computer storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned electronic device, the electronic device executes each function or step executed by the mobile phone in the above-mentioned method embodiment.
[0165] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute each function or step executed by the mobile phone in the above method embodiment.
[0166] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0167] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units 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 device, 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, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0168] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0169] 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.
[0170] If the 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 readable storage medium. Based on this understanding, the technical solution of the embodiment 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, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0171] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. An image processing method, characterized in that: include: Acquire at least one first image of the target object, wherein the first image includes a light source area, and the brightness of the pixels in the light source area exceeds a preset brightness threshold; the at least one first image includes at least two first images, and the at least two first images include a low-exposure image and a normal-exposure image of the target object; Acquire a first MASK image, and perform morphological dilation processing on the first MASK image to obtain a second MASK image; wherein the first MASK image is a MASK image of the light source area in the first image; Calculate the difference between the second MASK image and the first MASK image to obtain a third MASK image; wherein the third MASK image corresponds to the glare area in the first image, and the glare area is the edge area of the light source area; perform contrast enhancement processing on the glare area corresponding to the third MASK image in the first image to obtain a processed first image, including: perform image fusion on the first area image corresponding to the third MASK image in the low-exposure image and the second area image corresponding to the fourth MASK image in the normal exposure image to obtain a second image; wherein the fourth MASK image corresponds to the non-glare area in the normal exposure image, and the non-glare area includes other areas in the normal exposure image except the glare area; perform contrast enhancement processing on the glare area corresponding to the third MASK image in the second image to obtain a processed first image.
2. The image processing method according to claim 1, characterized in that: The brightness of the pixel point in the light source area exceeds a preset brightness threshold, including: The red pixel value, green pixel value and blue pixel value of the pixel point in the light source area are greater than the preset pixel threshold value.
3. The image processing method according to claim 1, characterized in that: Before performing contrast enhancement processing on the glare area corresponding to the third MASK image in the first image to obtain the processed first image, the method further includes: Calculating the information entropy of the third region image corresponding to the third MASK image and the information entropy of the first region image in the normal exposure image; It is determined that the information entropy of the third region image is greater than the information entropy of the first region image.
4. The image processing method according to claim 3, characterized in that: The at least two frames of first images also include a high exposure image of the target object; Before performing contrast enhancement processing on the glare area corresponding to the third MASK image in the first image to obtain the processed first image, the method further includes: Calculating the information entropy of the fourth area image corresponding to the third MASK image in the high exposure image; It is determined that the information entropy of the third region image is less than the information entropy of the fourth region image.
5. The image processing method according to claim 3 or 4, characterized in that: The step of acquiring a first MASK image comprises: Based on the normal exposure image, the first MASK image is acquired.
6. The image processing method according to claim 1 or 2, characterized in that: The first image is a normally exposed image of the target object.
7. The image processing method according to claim 6, characterized in that: Before performing contrast enhancement processing on the glare area corresponding to the third MASK image in the first image to obtain the processed first image, the method further includes: Calculating the information entropy of a third area image corresponding to a third MASK image in the normal exposure image; It is determined that the information entropy of the third region image is within a preset threshold range.
8. An electronic device, characterized in that: The electronic device includes a memory, a display screen, one or more cameras and one or more processors; the memory, the display screen, and the camera are coupled to the processor; wherein the camera is used to capture images, and the display screen is used to display images captured by the camera or images generated by the processor, and the memory stores computer program code, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed in an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 7.
