Image processing method and electronic device
By collecting and adjusting the exposure time of long and short exposure images in electronic equipment, the problem of image blur when shooting moving objects is solved, high signal-to-noise ratio and high-definition image fusion are achieved, and the image quality is improved.
Patent Information
- Application Number
- CN202310151718.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-14
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-02-14
AI Technical Summary
When shooting moving objects or equipment moving, it is difficult to obtain clear images with a high signal-to-noise ratio using existing technology, resulting in poor image quality.
By collecting alternating long-exposure images and short-exposure images in electronic equipment, adjusting the exposure time of the short-exposure image according to motion blur, reducing the exposure time to improve clarity, and obtaining high signal-to-noise ratio images through fusion image technology.
This enables clear images with high signal-to-noise ratio to be obtained when there is relative motion between the device and the subject, improving the image quality.
Smart Images

Figure CN117135455B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image technology, and in particular to an image processing method and electronic equipment. Background Art
[0002] With the development of electronic devices and semiconductor technology, mobile phones, tablet computers and other electronic devices are generally equipped with cameras. Users often get blurry images when shooting images or videos (including multiple image frames). In particular, when shooting moving objects or when the shooting device is moving (for example, hand shaking), the relative motion between the subject and the shooting device makes it easier for the captured image to be blurred and the image quality to be poor. Summary of the invention
[0003] The embodiments of the present application provide an image processing method and an electronic device, which can obtain a clear image with a high signal-to-noise ratio and good image quality when a subject and the electronic device are in relative motion.
[0004] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:
[0005] In a first aspect, the present application provides an image processing method, which is applied to an electronic device, wherein the electronic device includes a camera, and the method includes: in response to a user's operation of turning on the camera, using the camera to capture an image sequence, the image sequence including alternating long exposure images and short exposure images, and the exposure time of the short exposure image is less than the exposure time of the long exposure image; when it is determined that there is motion blur in a first image captured by the camera, reducing the exposure time used for capturing the short exposure image, the first image being a frame of long exposure image or a frame of short exposure image captured most recently by the camera; re-capturing the first short exposure image based on the reduced exposure time used for capturing the short exposure image, and re-capturing the first long exposure image; synthesizing the first short exposure image and the first long exposure image to obtain a fused image; and displaying the fused image.
[0006] It can be understood that since the first short exposure image acquired by a shorter exposure time has higher clarity, and the fused image is obtained by fusing the first short exposure image and the first long exposure image, the fused image has both the high signal-to-noise ratio of the long exposure image and the high clarity of the short exposure image.
[0007] In an implementation provided in the first aspect, reducing the exposure time used for acquiring a short exposure image includes: determining an exposure time adjustment amount; and reducing the exposure time used for acquiring the short exposure image from a first exposure time to a target exposure time according to the exposure time adjustment amount, wherein the first exposure time is the exposure time used for a frame of short exposure image most recently acquired by the camera.
[0008] In an implementation manner provided in the first aspect, the image sequence further includes a second image, and the second image and the first image are two consecutive long-exposure images, or two consecutive short-exposure images, and determining the exposure time adjustment amount includes: determining the optical flow of at least one connected area in the first image according to the first image and the second image; determining the first speed according to the first depth, the first focal length, and the maximum optical flow of the optical flow of at least one connected area; wherein the first depth is the distance between the subject and the electronic device, the first speed is the movement speed of the subject, and the first focal length is the focal length corresponding to the first image; querying in a preset first correspondence table with the first depth, the first focal length, the first speed, and the maximum optical flow as reference parameters to obtain a first target exposure time; wherein the preset first correspondence table includes multiple groups of parameters and their corresponding theoretical exposure times, each group of parameters includes distance, focal length, optical flow, and speed, and the first target exposure time is the exposure time required for the electronic device to obtain a clear short-exposure image under the conditions of the first depth, the first focal length, the first speed, and the maximum optical flow; and determining the difference between the first exposure time and the first target exposure time as the exposure time adjustment amount.
[0009] In an implementation manner provided in the first aspect, determining the exposure time adjustment amount further includes: querying a preset exposure ratio query table to determine a maximum exposure ratio; wherein the preset exposure ratio query table includes exposure ratios that can be used by the electronic device in different scenarios, and the exposure ratio is the ratio of the exposure time of the short exposure image to the exposure time of the long exposure image; determining a second target exposure time according to the second exposure time and the maximum exposure ratio, the second exposure time being the exposure time used for a frame of long exposure image most recently acquired by the camera, and the second target exposure time being the minimum exposure time used for acquiring the short exposure image when the electronic device adjusts the exposure time used for acquiring the short exposure image according to the exposure ratio; determining the difference between the first exposure time and the first target exposure time as the exposure time adjustment amount, including: when the first target exposure time is less than the second target exposure time, determining the difference between the first exposure time and the first target exposure time as the exposure time adjustment amount.
[0010] It can be understood that the first target exposure time refers to the exposure time required to obtain a clear short exposure image, and the second target exposure time refers to the exposure time required to ensure that the signal-to-noise ratio and clarity of the short exposure image are relatively balanced. When the first target exposure time is less than the second target exposure time, the difference between the first exposure time and the first target exposure time is determined as the exposure time adjustment amount, which can ensure the clarity of the next frame of short exposure image.
[0011] In an implementation manner provided in the first aspect, determining the exposure time adjustment amount further includes: when the first target exposure time is greater than the second target exposure time, determining the difference between the first exposure time and the second target exposure time as the exposure time adjustment amount.
[0012] It can be understood that when the second target exposure time is less than the first target exposure time, the difference between the first exposure time and the second target exposure time is determined as the exposure time adjustment amount, which can not only ensure the clarity of the next frame of short exposure image, but also make its signal-to-noise ratio and clarity more balanced.
[0013] In an implementation manner provided by the first aspect, the first ratio is equal to the second ratio, the first ratio is the ratio of the first depth to the first focal length, and the second ratio is the ratio of the first depth to the maximum optical flow.
[0014] In an implementation provided in the first aspect, a query is performed in a preset first correspondence table using the first depth, the first focal length, the first speed, and the maximum optical flow as reference parameters to obtain a first target exposure time, including: a query is performed in a preset first correspondence table using the first depth, the first focal length, the first speed, and the maximum optical flow as reference parameters; if the reference parameters exist in the preset first correspondence table, the theoretical exposure time corresponding to the reference parameters is determined as the first target exposure time.
[0015] In an implementation manner provided in the first aspect, a query is performed in a preset first correspondence table using the first depth, the first focal length, the first speed, and the maximum optical flow as reference parameters to obtain a first target exposure time, and further includes: if the reference parameters do not exist in the preset first correspondence table, respectively calculating the similarity between multiple groups of parameters in the first correspondence table and the reference parameters; and determining the theoretical exposure time corresponding to a group of parameters in the first correspondence table that has the highest similarity to the reference parameters as the first target exposure time. In this way, the corresponding exposure time can always be determined according to the first correspondence table.
[0016] In an implementation manner provided in the first aspect, respectively calculating the similarities between multiple groups of parameters in the first correspondence table and the reference parameters includes: for any group of parameters, the any group of parameters includes a second depth, a second focal length, a second speed, and a second optical flow; determining a first difference between the second depth and the first depth, determining a first similarity according to the first difference, and the first similarity is negatively correlated with the first difference; determining a second difference between the second focal length and the first focal length, determining a second similarity according to the second difference, and the second similarity is negatively correlated with the second difference; determining a third difference between the second speed and the first speed, determining a third similarity according to the third difference, and the third similarity is negatively correlated with the third difference; determining a fourth difference between the second optical flow and the maximum optical flow, determining a fourth similarity according to the fourth difference, and the fourth similarity is negatively correlated with the fourth difference; and taking the sum of the first similarity, the second similarity, the third similarity, and the fourth similarity as the similarity between any group of parameters and the reference parameters.
[0017] In an implementation provided in the first aspect, an optical flow of at least one connected area in the first image is determined according to the first image and the second image, including: dividing the first image and the second image into multiple areas, respectively; determining the optical flow of each area in the first image according to the multiple areas of the second image and the multiple areas of the first image; and merging the multiple areas of the first image based on the optical flow of each area to obtain the optical flow of at least one connected area.
[0018] In an implementation provided in the first aspect, multiple regions of the first image are merged based on the optical flow of each region to obtain the optical flow of at least one connected region, including: for any region, merging regions adjacent to any region and satisfying a merging condition to obtain at least one connected region; for any connected region, determining the optical flow of any connected region based on synthesizing the optical flows of multiple regions of any connected region.
[0019] In an embodiment provided in the first aspect, satisfying the merging condition includes: the optical flow of region Ri and region Rj satisfy |L1-L2|≤S1, and |α1-α2|≤S2; wherein L1 is the length of the optical flow of region Ri, α1 is the angle between the optical flow of region Ri and the x-axis, L2 is the length of the optical flow of region Rj, α2 is the angle between the optical flow of region Rj and the x-axis, the x-axis is the straight line on which the upper edge of the first image is located, S1 is a preset first threshold, and S2 is a preset second threshold.
[0020] In a second aspect, the present application also provides an exposure time adjustment method, which is applied to an electronic device, the electronic device including a camera, the method including: in response to a user's operation of turning on the camera, using the camera to capture an image sequence, the image sequence including alternating long exposure images and short exposure images, the exposure time of the short exposure image being shorter than the exposure time of the long exposure image; when it is determined that there is motion blur in a first image captured by the camera, reducing the exposure time used for capturing the short exposure image, the first image being a latest frame of long exposure image captured by the camera or a latest frame of short exposure image captured by the camera.
[0021] In a third aspect, the present application also provides an electronic device, comprising: a memory and a processor; the processor is coupled to the memory; wherein the memory is used to store computer program code, and the computer program code comprises computer instructions; when the computer instructions are executed by the processor, the electronic device executes a method as in any one of the embodiments of the first aspect and the second aspect.
[0022] In a fourth aspect, the present application further provides a computer-readable storage medium, comprising computer instructions; when the computer instructions are executed on an electronic device, the electronic device executes a method as in any one of the embodiments of the first aspect or the second aspect.
[0023] In a fifth aspect, the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the method of the first aspect, the second aspect, and any possible design thereof.
[0024] In a sixth aspect, the present application provides a chip system, which includes one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected by lines. The above chip system can be applied to a terminal device including a communication module and a memory. The interface circuit is used to receive a signal from the memory of the terminal device and send the received signal to the processor, where the signal includes a computer instruction stored in the memory. When the processor executes the computer instruction, the terminal device can execute the method of the first aspect, the second aspect and any possible design thereof.
[0025] Among them, the technical effects brought about by any design method in the second to sixth aspects can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A schematic diagram of a shooting scene provided in an embodiment of the present application;
[0027] Figure 2 A schematic diagram of HDR fusion provided in an embodiment of the present application;
[0028] Figure 3 A schematic diagram of a HDR frame output method;
[0029] Figure 4 This is a schematic diagram of a stagger HDR frame output method;
[0030] Figure 5 This is a schematic diagram of another stagger HDR frame output method;
[0031] Figure 6 A schematic diagram of a pixel array provided in an embodiment of the present application;
[0032] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0033] Figure 8 A flowchart of an image processing method provided in an embodiment of the present application;
[0034] Fig. 9 A flowchart of another image processing method provided in an embodiment of the present application;
[0035] Fig.10 A schematic diagram of an optical flow provided in an embodiment of the present application;
[0036] Fig.11 A schematic diagram of a process of merging regions provided in an embodiment of the present application;
[0037] Fig.12 A schematic diagram of imaging of an electronic device provided in an embodiment of the present application;
[0038] Fig.13 A comparison diagram of imaging effects provided in an embodiment of the present application;
[0039] Fig.14 A schematic diagram of the structure of a chip system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0040] The technical solutions in the embodiments of the present application are described below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "a", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear indication to the contrary in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two). The term "and / or" is used to describe the association relationship of associated objects, indicating that three relationships can exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in a "or" relationship.
[0041] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0042] In the embodiments of the present application, the words "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0043] Before specifically introducing the embodiments of the present application, a brief introduction to the technical terms involved in the present application is given:
[0044] 1. Motion Blur
[0045] It is understandable that when photographing a moving object or person, if the object or person moves too fast and the exposure time of the photographing device is too long, the photographed image is prone to motion blur. Motion blur is a moving effect in a scene image, which is generally caused by the relative movement between the photographing device and the subject. Motion blur will cause obvious blur and dragging marks in the acquired image. It is understandable that the photographing device can refer to electronic devices such as digital cameras and mobile phones; the subject is the object photographed by the photographing device.
[0046] For example, Figure 1 As shown, the subject is walking, and the user will find that the subject displayed on the electronic device is relatively blurry when shooting with the electronic device. In this case, it is impossible to obtain a clear image or video by shooting.
[0047] It should be noted that the motion blur may also be referred to as "smear", "ghosting", etc., without any specific limitation here.
[0048] 2. Optical flow
[0049] Generally speaking, optical flow is generated when there is relative motion between the subject and the shooting device (for example, mobile phones, tablets and other electronic devices), which includes the following three situations:
[0050] Case 1: The subject is moving. For example, use a mobile phone to shoot a scene of an athlete running.
[0051] Case 2: The camera is in motion during the shooting process, for example, when the hands are shaking.
[0052] Case 3: Case 1 and Case 2 above work together. For example, when an athlete is running, the user's hands shake when taking a photo.
[0053] In the above three cases, during the shooting process, with the relative movement of the subject and the shooting equipment, the subject will form a series of continuously changing images on the imaging plane. This series of continuously changing information continuously "flows" through the imaging plane, like a "flow" of light, so it is called optical flow.
[0054] Optical flow is specifically the instantaneous speed of the pixel motion of the object on the imaging plane. When the time interval is very small (such as between two consecutive frames of a video), the optical flow is also equivalent to the displacement of the pixel motion.
[0055] In the embodiments of the present application, the optical flow is mainly represented by displacement. In addition, the optical flow can be calculated by algorithms such as calcOpticalFlowPyrLK, calcOpticalFlowFarneback, CalcOpticalFlowBM, CalcOpticalFlowHS, and calcOpticalFlowSF in OpenCV, which are not specifically limited in the present application.
[0056] 3. High-dynamic range (HDR)
[0057] HDR can be understood as a technology that fuses multiple low-dynamic range (LDR) images of various exposure levels into one HDR image, which can include more picture details.
[0058] For example, Figure 2 This is a schematic diagram of taking photos of sea level scenery, where Figure 2 (a) is an LDR image with a larger exposure. Figure 2 (b) is an LDR image with a smaller exposure. Figure 2 In (a), due to the high exposure, the highlight area in the picture is distorted due to overexposure, while the dark area can clearly see the details and contours due to the compensation of the exposure value; Figure 2 In (b), due to the low exposure, the highlight area in the picture has a clearer outline, but the dark area is blurred due to lack of exposure. Figure 2 The fusion of (a) and (b) is Figure 2 (c), we can see Figure 2 (c) can show the outline and details of both the highlight area and the dark area.
[0059] Specifically, Figure 3 A timing diagram of a photographing process provided in an embodiment of the present application. The timing diagram includes two time axes, the upper time axis is used to reflect the time when the photosensitive element in the camera performs image exposure, and the lower time axis is used to reflect the time when the camera reads the photosensitive data.
[0060] The electronic device receives the user's photo operation at time t1. After receiving the photo operation, the electronic device needs a period of time to generate exposure parameters, send the exposure parameters to the camera, and make the camera execute the exposure parameters. Specifically, assuming that the time taken by the electronic device to generate the exposure parameters, send the exposure parameters to the camera, and make the camera execute the exposure parameters is one acquisition cycle T, then Figure 3The electronic device shown collects 4 frames of EV0 images, one frame of EV-2 image, and one frame of EV-4 image in the 6 collection cycles in the dotted frame. Afterwards, the electronic device synthesizes an HDR image based on the collected 6 frames of images.
[0061] It should be noted that, for the sake of simplicity, in the embodiments of the present application, the exposure of normal exposure is represented as EV0, and the exposure EV0×2n is represented as EVn. For example, EV-1 represents an exposure of half of EV0, and EV-2 represents an exposure of half of EV-1; for another example, EV1 represents an exposure of twice EV0, and EV2 represents an exposure of twice EV1. An EVn image is an image with an exposure of EVn.
[0062] 4. Stagger high-dynamic range (stagger HDR)
[0063] Stagger HDR is a technology that can collect multiple frames of images with different exposures in one acquisition cycle by increasing the frame rate of the sensor. For example, stagger HDR can generate long-exposure images and short-exposure images in one acquisition cycle. Figure 4 As shown, the electronic device can collect two frames of images at EV0 and EV-4 in one acquisition cycle T. For another example, stagger HDR can generate a long exposure image, a medium exposure image, and a short exposure image in one acquisition cycle, for example Figure 5 As shown, the electronic device can collect three frames of images, EV0, EV-2 and EV-4, in one collection period T. In comparison, in the stagger HDR scenario, since images with multiple exposure parameters need to be collected, the interval time between two adjacent frames of images (which can be called the frame interval) is shorter than the frame interval in the non-stagger HDR scenario. Among them, the exposure time of the long exposure image is greater than the exposure time of the medium exposure image, and the exposure time of the medium exposure image is greater than the exposure time of the short exposure image.
[0064] Generally speaking, the electronic device can reduce the exposure time to reduce motion blur. For example, Figure 6 Schematic diagram of sampling of a pixel array when photographing a subject (a triangle indicates the subject). Figure 6 (a) in the figure shows the sampling of the pixel array when the exposure time is long. Figure 6 (b) in the figure shows the sampling of the pixel array when the exposure time is short. Figure 6 In (a), due to the long exposure time, 4 pixels are used to sample the object (pixels filled with black in the figure); Figure 6In (b), due to the short exposure time, two pixels are used to sample the object. That is, the shorter the exposure time for capturing a frame of image, the smaller the displacement of the object during the capture of the frame of image. This can reduce the blur and drag traces caused by the movement of the object in the captured frame of image, thereby obtaining a clearer image.
[0065] In a technical solution provided by the related art, for HDR mode or stagger HDR mode, the device can reduce the blurring of the image by reducing the exposure time of the long exposure image. Figure 3 exposure time for EV0 images, or Figure 4 , Figure 5 The exposure time of the EV0 image is reduced. However, this method will reduce the signal-to-noise ratio of the image and affect the image quality.
[0066] The present application provides an image processing method, which is applied to an electronic device including a camera. The method can use a camera to capture an image sequence, which includes alternating long-exposure images and short-exposure images, and the exposure time of the short-exposure image is less than the exposure time of the long-exposure image; if it is determined that the first image captured by the camera (a frame of long-exposure image captured most recently or a frame of short-exposure image captured most recently) has motion blur, the electronic device can reduce the exposure time used to capture the short-exposure image. Among them, by reducing the exposure time used to capture the short-exposure image, the clarity of the short-exposure image to be captured can be improved.
[0067] Furthermore, the electronic device can also re-acquire the first short exposure image based on the reduced exposure time used for acquiring the short exposure image, re-acquire the first long exposure image, synthesize the first short exposure image and the first long exposure image to obtain a fused image, and display the fused image. Since the first short exposure image acquired with a shorter exposure time has a higher definition than the already acquired short exposure image, and the fused image is obtained by fusing the first short exposure image and the first long exposure image, the fused image has both the high signal-to-noise ratio of the long exposure image and the high definition of the short exposure image.
[0068] Among them, the electronic device provided in the embodiments of the present application can be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device, etc., or a device with a shooting function such as a camera and a camcorder. The embodiments of the present application do not impose any special restrictions on the specific type of the electronic device.
[0069] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, 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 170C, an earphone interface 170D, 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.
[0070] 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.
[0071] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more or fewer components than shown in the figure, or combine some components, or split 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.
[0072] 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.
[0073] The controller can be the nerve center and command center of the electronic device. The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching and executing instructions.
[0074] 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.
[0075] 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.
[0076] It is understandable that the interface connection relationship between the modules illustrated in this embodiment is only a schematic illustration and does not constitute a structural limitation of the electronic device. In other embodiments, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0077] The charging management module 140 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger. While the charging management module 140 charges the battery 142, it can also power the electronic device through the power management module 141.
[0078] 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 supplies 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. In some embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0079] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc. In some embodiments, the antenna 1 of the electronic device is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device can communicate with the network and other devices through wireless communication technology.
[0080] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0081] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to electronic devices. 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.
[0082] The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 can be set in the same device as at least some modules of the processor 110.
[0083] The wireless communication module 160 can provide wireless communication solutions for electronic devices including WLAN (such as wireless fidelity, Wi-Fi) network, Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), nearfield communication technology (NFC), infrared technology (IR), etc.
[0084] 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.
[0085] The electronic device 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.
[0086] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel.
[0087] The electronic device 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 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0088] 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. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos can be stored in the external memory card.
[0089] 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 electronic device 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.
[0090] 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 (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.
[0091] The electronic device can implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, and an application processor. For example, music playback, recording, etc. 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, or 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 electronic device. The electronic device 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.
[0092] The present application provides an image processing method, which can be applied to shooting preview scenes, photo shooting scenes, and video recording scenes. The following takes the shooting preview scene as an example for explanation. For example, Figure 8As shown, in response to the user turning on the camera, the electronic device uses the camera to capture an image sequence, wherein the image sequence includes alternating long exposure images and short exposure images, and the exposure time of the long exposure image is greater than the exposure time of the short exposure image. If there is motion blur in a frame of long exposure image or a frame of short exposure image (which may be referred to as the first image) captured by the camera, the electronic device may reduce the exposure time used to capture the short exposure image; and the electronic device re-captures the first short exposure image according to the reduced exposure time used for the short exposure image, and re-captures the first long exposure image, and synthesizes the first short exposure image and the first long exposure image to obtain a fused image.
[0093] Among them, the operation of turning on the camera may include the operation of the user turning on the camera application, the operation of making the camera start shooting or recording, etc., and no specific limitation is made here.
[0094] There are many ways for the electronic device to identify whether there is motion blur in the first image.
[0095] In an optional implementation, the electronic device may input the first image into a recognition model, and the recognition model may be used to identify the blur level of the image. Exemplarily, the server or electronic device may use a large number of images with motion blur as training samples, and train with blur labels (labels for identifying blur levels) corresponding to each training sample to obtain the recognition model. In this way, after the first image is input into the recognition model, it is possible to determine whether the first image has motion blur.
[0096] In another optional embodiment, the electronic device may divide the first image into multiple regions, and calculate the optical flow of each region in the first image, where the optical flow is used to reflect the displacement of pixels in the region; and determine whether there is motion blur in the first image based on the optical flows of the multiple regions.
[0097] Among them, the optical flow of each area in the first image needs to be determined with reference to the second image in the image sequence. The second image and the first image are two consecutive long-exposure images, or two consecutive short-exposure images. Specifically, the electronic device can divide the second image into multiple corresponding areas, and the multiple areas of the second image correspond one-to-one to the multiple areas of the first image. The electronic device can calculate the optical flow of the multiple areas in the second image moving to the corresponding areas in the first image, and the optical flow can be represented by (u, v).
[0098] It should be noted that, for the specific calculation of optical flow, the sparse optical flow (Lucas-kanade) algorithm can be used, and it can be implemented using functions such as calcOpticalFlowPyrLK, calcOpticalFlowFarneback, CalcOpticalFlowBM, CalcOpticalFlowHS, and calcOpticalFlowSF in OpenCV. This application does not make any specific limitations on this.
[0099] In an optional embodiment, the electronic device may divide the first image and the second image into a plurality of regions according to a preset size [H, W]. H is the length of each region, and W is the width of each region. For example, if the resolution of the first image and the second image is 3840×2160, and the preset size is [160,90], the electronic device may divide the first image into 24 regions, and the second image into 24 regions. It should be noted that H and W may also be other positive integers, and no specific limitation is made here. In particular, when H and W are both 1, each pixel is a region. In this case, the number of regions is the number of pixels in the first image.
[0100] Among them, the optical flows of multiple regions can be (u1,v1), (u2,v2)...(ui,vi)...(u m ,v m ). Wherein, (ui,vi) represents the optical flow of the ith region among multiple regions moving from the second image to the first image, m is the number of regions, and m is a positive integer.
[0101] If u and v in the optical flow (u,v) are both close to 0, it indicates that the motion amplitude of the pixel point is small. If the motion amplitude of most of the multiple region points is small, it indicates that during the image acquisition process, the relative motion amplitude between the subject and the electronic device is small, so the blur degree of the first image is also small, and it can be considered that there is no motion blur in the first image. Conversely, if the motion amplitude of most of the multiple regions is large, it indicates that during the image acquisition process, the relative motion amplitude between the subject and the electronic device is large, so the blur degree of the first image is also large, and it can be considered that there is motion blur in the first image.
[0102] In some embodiments, the electronic device can count the number of optical flows (u, v) where both u and v are close to 0. The smaller the number, the lower the blur; the larger the number, the higher the blur. The electronic device can use u+v, |u|+|v|, or equivalent values to measure whether u and v in the optical flow (u, v) are close to 0. Then, in the multiple optical flows (u, v), u+v, |u|+|v|, or equivalent values The more the number of equal values equal to or approximately equal to 0 (denoted as sum, the same below), the lower the blur; in multiple optical flows (u, v), u+v, |u|+|v| or The fewer the values that are equal to or approximately equal to 0, the greater the blur.
[0103] Taking the blur degree including clear and blurry as an example, if sum≥M1, the electronic device determines that the first image is relatively clear (ie, there is no motion blur); if sum<M1, the electronic device determines that there is motion blur in the first image.
[0104] After determining that the first image has motion blur, in order to reduce the blur of the image, the electronic device can reduce the exposure time used to collect the short exposure image. Specifically, the electronic device can determine the exposure time adjustment amount, and according to the exposure time adjustment amount, reduce the exposure time used to collect the short exposure image from the first exposure time to the target exposure time. The first exposure time is the exposure time used for a frame of short exposure image recently collected by the camera.
[0105] In an optional implementation, the electronic device may use an automatic exposure algorithm to adjust the exposure time used for capturing the long exposure image based on the ambient brightness, and re-capture the first long exposure image based on the adjusted exposure time used for capturing the long exposure image.
[0106] In an optional implementation, after re-capturing the first long exposure image and the first short exposure image, the electronic device can still determine whether there is motion blur in the first short exposure image or the first long exposure image. If there is still motion blur in the first short exposure image or the first long exposure image, the electronic device can further reduce the exposure time used to capture the short exposure image.
[0107] Optional, still as Figure 8 As shown, when it is determined that there is motion blur in a frame of long exposure image or a frame of short exposure image recently captured by the camera, the electronic device can also deblur the long exposure image and the short exposure image; and display the deblurred image.
[0108] The specific process of the electronic device determining the exposure time adjustment amount will be described in detail below with reference to the accompanying drawings.
[0109] exist Figure 8 Based on the image processing method provided, the following is combined Fig. 9 The process of determining the exposure time adjustment amount by the electronic device is specifically described. Fig. 9 As shown, the image processing method also includes:
[0110] S901: Divide the first image and the second image into a plurality of regions according to preset sizes.
[0111] S902: Determine an optical flow of each region in the first image according to the multiple regions of the first image and the multiple regions of the second image.
[0112] The specific contents of S901 to S902 refer to the above-mentioned contents related to the electronic device determining whether the first image has motion blur, which will not be described in detail here.
[0113] S903: Merge multiple regions of the first image based on the optical flow of each region to obtain an optical flow of at least one connected region.
[0114] The merged regions mainly merge regions with similar optical flows and adjacent positions. It can be understood that the optical flow of a region represents the size and direction of the displacement of the pixels in the region. When the optical flows of two regions are similar, it can be considered that the size and direction of the displacement of the pixels in the two regions are similar.
[0115] In this embodiment, the electronic device may use a depth-first search method to merge adjacent areas. For any area, the areas adjacent to the any area and satisfying the merging conditions are merged to obtain at least one connected area. Specifically, the electronic device may first use an area as a connected area, analyze its adjacent areas one by one, merge the adjacent areas satisfying the merging conditions into the connected area to form a new connected area, and then analyze the adjacent areas of the new connected area, merge the adjacent areas satisfying the merging conditions into the new connected area, and repeat the above steps until no adjacent areas can be merged into the connected area; then the electronic device selects a new area as the new connected area, and repeats the above steps; when no area can be used as a connected area, the merger is completed.
[0116] Among them, for two adjacent regions, the electronic device can decide whether to merge the two regions by comparing the closeness of the optical flows of the two regions. Taking region Ri and region Rj as two adjacent regions, and the optical flow of region Ri is (ui, vi), and the optical flow of region Rj is (uj, vj) as an example, several methods for comparing the closeness of the optical flows of two regions are described below.
[0117] In an optional implementation, the electronic device may calculate the size L1 of the optical flow (ui, vi), the angle α1 between the optical flow (ui, vi) and the x-axis, the size L2 of the optical flow (uj, vj), and the angle α2 between the optical flow (uj, vj) and the x-axis.
[0118]
[0119] α1=arctan(vi / ui), α2=arctan(vj / uj)
[0120] Further, the electronic device may pre-set a first threshold S1 and a second threshold S2 (in degrees). If |L1-L2|≤S1, and |α1-α2|≤S2, the electronic device may merge the region Ri and the region Rj. If |L1-L2|>S1, or |α1-α2| is greater than S2, the electronic device does not merge the region Ri and the region Rj.
[0121] For example, Fig.10 As shown, the light flow in area A is (1,1), and the light flow in area B is (1,-1). Then the electron can determine the length L1 of the light flow (1,1) as The length L2 of the optical flow (1,-1) is The angle α1 between the optical flow (1,1) and the x-axis is 45°, and the angle α2 between the optical flow (1,-1) and the x-axis is 135°. Taking the first threshold S1=1 and the second threshold S2=0.5° as an example, where |L1-L2|=0<1, |α1-α2|=90°>0.5°, it can be determined that region A and region B cannot be merged.
[0122] In another optional implementation, the electronic device may calculate du and dv, and determine whether to merge the region Ri and the region Rj according to du and dv. Wherein, du and dv satisfy the following formula:
[0123]
[0124] Wherein, du is the absolute value of the difference between the components of the optical flow in the x-axis direction, and dv is the absolute value of the difference between the components of the optical flow in the y-axis direction. In the embodiment of the present application, two segmentation thresholds Du and Dv can be pre-set, and when du≤Du and dv≤Dv are both established, regions Ri and Rj are merged; when du>Du, or dv≤Dv, regions Ri and Rj are not merged.
[0125] In another optional implementation, the electronic device may calculate the similarity of the two optical flows, and when the similarity is greater than or equal to a preset threshold, merge the regions Ri and Rj; when the similarity is less than the preset threshold, do not merge the regions Ri and Rj. The similarity may be measured by the cosine value of the two optical flows.
[0126] The optical flow of the connected area is related to the optical flows of multiple areas that synthesize the connected area. For example, the connected area is composed of n areas, and the optical flow of n areas is (uk, vk), where k = 1 to n, and n is a positive integer. The optical flow of the connected area L can be determined as:
[0127]
[0128] For example, Fig.11 As shown, the first image includes 12 regions R1 to R12. During the merging process, the electronic device may first use region R5 as the connected region, wherein the regions adjacent to region R5 include: region R2, region R4, region R6, and region R8. The electronic device may determine whether region R2 can be merged with region R5 based on the optical flow (u2, v2) of region R2 and the optical flow (u5, v5) of region R5, determine whether region R4 can be merged with region R5 based on the optical flow (u4, v4) of region R4 and the optical flow (u5, v5) of region R5, determine whether region R6 can be merged with region R5 based on the optical flow (u6, v6) of region R6 and the optical flow (u5, v5) of region R5, and determine whether region R8 can be merged with region R5 based on the optical flow (u8, v8) of region R8 and the optical flow (u5, v5) of region R5. If it is determined that regions R2 and R4 cannot be merged with region R5, and regions R6 and R8 can be merged with region R5, the electronic device can merge regions R5, R6, and R8 to obtain the connected region L1. Next, the electronic device can determine that the regions adjacent to the connected region L1 include: regions R2, R3, R4, R7, R9, and R11, and determine whether regions R2, R3, R4, R7, R9, and R11 can be merged with the connected region L1. And so on, until there are no regions that can be merged, the connected region L2, the connected region L3, and the connected region L4 can be obtained.
[0129] Among them, the connected area L2 is composed of areas R5, R6, R8, R9, R11 and R12. It can be determined that the optical flow of the connected area L2 is:
[0130]
[0131] The connected area L3 is composed of areas R1, R2, R3, R4 and R7. The optical flow of the connected area L3 can be determined as:
[0132]
[0133] The connected area L4 is the original area R10, and the optical flow of the connected area L4 is (u10, v10).
[0134] S904: Determine a maximum optical flow among the optical flows of at least one connected area.
[0135] Among them, the maximum optical flow refers to the optical flow with the largest length.
[0136] It can be understood that the area with the largest optical flow has the highest degree of motion blur. Therefore, by reducing the exposure time used to collect short-exposure images based on the maximum optical flow, the effect of reducing the motion blur in the area with the highest degree of blur can be achieved. At the same time, when the blur in the area with the highest degree of motion blur is alleviated, the blur in other areas with lower degrees of motion blur can also be alleviated.
[0137] In an optional embodiment, before determining the maximum optical flow, the electronic device may remove outliers from all optical flows. For example, the electronic device may calculate the mean μ1 and variance σ1 of the length of the optical flow of each connected area, as well as the mean μ2 and variance σ2 of the angle with the x-axis, and use the 3sigma (3σ) principle to remove outliers therefrom, and then determine the maximum optical flow therefrom. Among them, optical flows with lengths outside (μ1-3σ1, μ1+3σ1) can be removed as outliers, and optical flows with angles outside (μ2-3σ2, μ2+3σ2) can be removed as outliers. It can be understood that by removing outliers, the interference of obviously abnormal data on the exposure time adjustment process can be reduced.
[0138] S905: Acquire a first depth of the object.
[0139] The first depth is the distance between the object and the electronic device.
[0140] In an optional implementation, the electronic device includes a time of flight (TOF) camera, and the electronic device can determine the distance of the subject relative to the electronic device, that is, the first depth of the subject, through the TOF camera.
[0141] S906: Determine a first speed based on the first depth, the first focal length, and the maximum optical flow.
[0142] The first focal length refers to the focal length used by the electronic device when capturing the first image using a camera.
[0143] The first speed is the moving speed of the subject. Fig.12 FIG. 1 shows a schematic diagram of imaging of an electronic device. Fig.12 As shown, the speed v, depth l, focal length f of the camera and optical flow OF of the subject in the image satisfy the formula:
[0144]
[0145] That is, the ratio of velocity v to optical flow OF is equal to the ratio of depth l to focal length f.
[0146] In this way, when the first depth, the first focal length, and the maximum optical flow are determined, the first speed can be determined by the above formula.
[0147] S907 , query in a preset first correspondence table based on the first depth, the first focal length, the maximum optical flow, and the first speed to obtain a first target exposure time.
[0148] Among them, the first correspondence table includes multiple groups of parameters and their corresponding theoretical exposure times. Among them, one group of parameters includes depth, speed, focal length and optical flow. The theoretical exposure time refers to the exposure time theoretically required for the electronic device to obtain a clear short exposure image under the corresponding depth, speed, focal length and optical flow. In this embodiment, the electronic device can pre-generate multiple groups of parameters according to the formulas satisfied by the speed v, depth l, focal length f and optical flow OF, and use multiple experiments to determine the exposure time required to obtain a clear short exposure image under each group of parameters, thereby obtaining the first correspondence table.
[0149] Exemplarily, the first correspondence table may be as shown in Table 1:
[0150] Table 1
[0151] Depth(m) Speed (m / s) Focal length(mm) optical flow Theoretical exposure time (ms) 1 1 12 12 30 1 2 18 36 20 2 2 12 12 38 2 3 18 27 25 4 1 24 6 45 10 1 50 5 50 …… …… …… …… ……
[0152] It should be noted that Table 1 is only an example, and the first correspondence table may also include more or less data than Table 1, and no specific limitation is made here.
[0153] Furthermore, the electronic device may use the first depth, the first focal length, the maximum optical flow, and the first speed as basic parameters, and perform a query in the first correspondence table to obtain the first target exposure time.
[0154] In an optional implementation, the first correspondence table includes the basic parameter, and the electronic device can directly determine the theoretical exposure time corresponding to the basic parameter as the first target exposure time. For example, if the first depth is 1m, the first speed is 2m / s, the focal length is 18mm, and the length of the optical flow is 12, the first target exposure time can be 38ms.
[0155] In another optional implementation, the first correspondence table does not include the basic parameter. In this case, the electronic device can determine the similarity between the basic parameter and each group of parameters in the first correspondence table, and determine a group of parameters with the highest similarity to the basic parameter, and then use the theoretical exposure time corresponding to the group of parameters with the highest similarity to the basic parameter as the first target exposure time.
[0156] Exemplarily, taking the first correspondence table including a group of parameters: a second depth, a second speed, a second focal length and a second optical flow as an example, the process of the electronic device determining the similarity between the group of parameters and a group of parameters of the first depth, the first focal length, the maximum optical flow and the first speed is described.
[0157] The electronic device may calculate the similarity between the first depth and the second depth to obtain similarity 1 (i.e., the first similarity); calculate the similarity between the first focal length and the second focal length to obtain similarity 2 (i.e., the second similarity); calculate the similarity between the first speed and the second speed to obtain similarity 3 (i.e., the third similarity); and calculate the similarity between the maximum optical flow and the second optical flow (i.e., the fourth similarity) to obtain similarity 4. Then, similarity 1, similarity 2, similarity 3, and similarity 4 are added to obtain the similarity between the two sets of parameters. Optionally, similarity 1, similarity 2, similarity 3, and similarity 4 have different weights, and the product of each similarity and the corresponding weight may be superimposed to obtain the similarity between the two sets of parameters.
[0158] In an optional embodiment, the similarity of two parameters (such as depth, speed, focal length or optical flow) can be measured by the difference between the two parameters. For example, the electronic device can pre-set multiple threshold intervals for the difference, each threshold interval corresponds to a different similarity, and the similarity is negatively correlated with the difference, that is, the larger the difference, the lower the similarity; the lower the difference, the greater the similarity. It should be noted that different types of parameters may have different threshold intervals.
[0159] Exemplarily, the electronic device may calculate the first difference between the first depth and the second depth, determine the threshold interval in which the difference lies, and use the similarity corresponding to the threshold interval as similarity 1. For another example, the electronic device may calculate the second difference between the first focal length and the second focal length, determine the threshold interval in which the second difference lies, and use the similarity corresponding to the threshold interval as similarity 2. For another example, the electronic device may calculate the third difference between the first speed and the second speed, determine the threshold interval in which the third difference lies, and use the similarity corresponding to the threshold interval as similarity 3. For another example, the electronic device may calculate the fourth difference between the maximum optical flow and the second optical flow, determine the threshold interval in which the fourth difference lies, and use the similarity corresponding to the threshold interval as similarity 4.
[0160] S908, query a preset exposure ratio query table to determine the maximum exposure ratio.
[0161] The preset exposure ratio query table contains exposure ratios that can be used by the electronic device under different scene brightness and different ISO gains. The exposure ratio refers to the ratio of the exposure time of the short exposure image to the exposure time of the long exposure image. It should be noted that the exposure ratio query table is obtained by the staff in advance based on multiple experiments. It indicates that when the electronic device uses the camera to capture images with the exposure ratio in the exposure ratio query table, the captured images usually have good quality, such as a relatively balanced signal-to-noise ratio and clarity.
[0162] Exemplarily, the preset exposure ratio query table may be as shown in Table 2:
[0163] Table 2
[0164] Exposure ratio ISO Gain Scene brightness (LUX) 1:4 100 2000 1:5 260 3000 1:10 640 5000
[0165] For example, it can be determined according to Table 2 that the maximum exposure ratio is 1:10. Of course, the exposure ratio query table may also include more or less data than Table 2, and no specific limitation is made here.
[0166] It can be understood that the purpose of this application is to alleviate the motion blur caused by the relative motion between the subject and the electronic device. Figure 6 From the corresponding text content, it can be known that the shorter the exposure time for shooting a frame of image, the smaller the displacement of the subject during shooting of the frame of image, that is, the less motion blur. Therefore, in this embodiment, the maximum exposure ratio can be obtained from the exposure ratio query table to determine the minimum exposure time that can be supported by the short exposure image when the exposure time of the current long exposure image is constant and the exposure time of the short exposure image is adjusted according to the exposure ratio query table.
[0167] S909: Obtain a second target exposure time according to the exposure time of the latest long exposure image frame and the maximum exposure ratio.
[0168] The second target exposure time is the minimum exposure time of the short exposure image when the exposure time of the short exposure image is adjusted according to the exposure ratio lookup table.
[0169] For example, taking the exposure time of the latest long exposure image as the second exposure time, the electronic device can directly divide the second exposure time by the maximum exposure ratio to obtain the second target exposure time. For example, if the second exposure time is 70ms and the maximum exposure ratio is 1:10, the second target exposure time is 7ms.
[0170] S910: Taking the smaller value of the first target exposure time and the second target exposure time as the target exposure time.
[0171] It can be understood that the first target exposure time refers to the exposure time required to obtain a clear short exposure image, and the second target exposure time refers to the exposure time required to ensure that the signal-to-noise ratio and clarity of the short exposure image are relatively balanced. The purpose of the present application is to obtain a clear short exposure image, so the smaller value of the first target exposure time and the second target exposure time is used as the target exposure time. In this way, when the first target exposure time is less than the second target exposure time, the first target exposure time is determined as the target exposure time, which can ensure the clarity of the next frame of short exposure image; when the second target exposure time is less than the first target exposure time, the second target exposure time is determined as the target exposure time, which can ensure the clarity of the next frame of short exposure image and make its signal-to-noise ratio and clarity relatively balanced. That is, the smaller value of the first target exposure time and the second target exposure time is used as the target exposure time, which can ensure the clarity of the next frame of short exposure image while maximizing its signal-to-noise ratio.
[0172] S911, obtaining an exposure time adjustment amount according to the exposure time of the latest short-exposure image frame and the target exposure time.
[0173] That is to say, when the first target exposure time is less than the second target exposure time, the exposure time adjustment amount is the difference between the first exposure time and the first target exposure time; when the first target exposure time is greater than the second target exposure time, the exposure time adjustment amount is the difference between the first exposure time and the second target exposure time.
[0174] As described above, the exposure time of a frame of short-exposure image recently acquired by the camera is the first exposure time, and the electronic device uses the difference between the first exposure time and the target exposure time as the exposure time adjustment amount. In this way, the electronic device can adjust the exposure time of the short-exposure image from the first exposure time to the target exposure time based on the exposure time adjustment amount.
[0175] In an optional implementation, the electronic device may not execute S908 to S910, but directly use the first target exposure time as the target exposure time, and obtain the exposure time adjustment amount according to the first exposure time and the first target exposure time, which can also effectively ensure the clarity of the next short exposure image.
[0176] like Fig.13 As shown, an image obtained by reducing the exposure time in the related art and an image obtained by reducing the exposure time used for collecting short exposure images in the present application are shown. Fig.13 As shown in (a) in the figure, for the acquisition method that does not alternately acquire long exposure images and short exposure images, directly reducing the exposure time used for acquiring images will cause the images acquired by the camera to have more noise points, that is, the signal-to-noise ratio is reduced. Fig.13As shown in (b) in the figure, for the acquisition method of alternating long exposure images and short exposure images, by reducing the exposure time used to acquire long exposure images, the long exposure images acquired by the camera will have more noise points, but higher clarity; but since there are still many noise points in the short exposure images, the fused image has higher clarity, but the signal-to-noise ratio is poor (more noise points). Fig.13 As shown in (c) in the figure, for the acquisition method of alternately acquiring long exposure images and short exposure images, by reducing the exposure time used for acquiring short exposure images, although the acquired short exposure image will have more noise points, the short exposure image can have a clear image (that is, there is no motion blur); but since there are fewer noise points in the long exposure image and the signal-to-noise ratio is high, a clear fused image with a high signal-to-noise ratio can be obtained by fusing the long exposure image with a high signal-to-noise ratio and the relatively clear short exposure image.
[0177] In summary, the present application reduces the exposure time used to acquire the short exposure image, so that the short exposure image has higher clarity. In this way, a fused image with high signal-to-noise ratio and high clarity can be obtained without losing the signal-to-noise ratio of the long exposure image.
[0178] The present application also provides an electronic device, which may include: a memory and one or more processors. The memory and the processor are coupled. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can execute the various functions or steps executed by the mobile phone in the above method embodiment.
[0179] 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 or server can perform 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.
[0180] This embodiment also provides a computer-readable storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device or the server executes each function or step in the above method embodiment.
[0181] This embodiment also provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute each function or step in the above method embodiment.
[0182] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory so that the chip executes each function or step performed by the mobile phone in the above method embodiment.
[0183] Among them, the electronic device, communication system, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above and will not be repeated here.
[0184] 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.
[0185] 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.
[0186] The unit described as a separate component may or may not be physically separated, and the component shown as a unit may be one physical unit or multiple physical units, that is, it 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 embodiment.
[0187] 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.
[0188] 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 each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
[0189] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. An image processing method, characterized in that: Applied to an electronic device, the electronic device includes a camera, and the method includes: In response to a user turning on the camera, using the camera to capture an image sequence, the image sequence includes alternating long-exposure images and short-exposure images, and an exposure time of the short-exposure image is shorter than an exposure time of the long-exposure image; When it is determined that there is motion blur in the first image captured by the camera, a first short exposure image is acquired based on a target exposure time, where the first image is a latest long exposure image or a latest short exposure image captured by the camera; The target exposure time is less than the first exposure time, the first exposure time is the exposure time used for a frame of short exposure image most recently collected by the camera, the target exposure time is determined based on the first exposure time and the exposure time adjustment amount, the exposure time adjustment amount is the difference between the first exposure time and the smaller value of the first target exposure time and the second target exposure time, the first target exposure time is the exposure time required for the electronic device to obtain a clear short exposure image under the conditions of a first depth, a first focal length, a first speed, and a maximum optical flow among optical flows of at least one connected area in the first image, the first depth is the distance between the subject and the electronic device, the first speed is the moving speed of the subject, the first focal length is the focal length corresponding to the first image, and the connected area is obtained by merging multiple adjacent areas of the first image; the second target exposure time is the minimum exposure time used for collecting the short exposure image when the electronic device adjusts the exposure time used for collecting the short exposure image according to the exposure ratio; Acquire a first long exposure image; performing fusion processing on the first short-exposure image and the first long-exposure image to obtain a fused image; The fused image is displayed.
2. The method according to claim 1, characterized in that The method further comprises: Determine exposure time adjustment amount; According to the exposure time adjustment amount, the exposure time used for acquiring the short exposure image is reduced from the first exposure time to the target exposure time.
3. The method according to claim 2, characterized in that The image sequence further includes a second image, and the second image and the first image are two consecutive long-exposure images or two consecutive short-exposure images. The determining of the exposure time adjustment amount includes: Determine, according to the first image and the second image, an optical flow of at least one connected area in the first image; Determine a first speed according to the first depth, the first focal length, and a maximum optical flow among the optical flows of the at least one connected area; Taking the first depth, the first focal length, the first speed and the maximum optical flow as reference parameters, querying in a preset first correspondence table to obtain a first target exposure time; wherein the preset first correspondence table includes multiple groups of parameters and their corresponding theoretical exposure times, each group of parameters including distance, focal length, optical flow and speed; The difference between the first exposure time and the first target exposure time is determined as the exposure time adjustment amount.
4. The method according to claim 3, characterized in that The step of determining the exposure time adjustment amount further includes: Querying a preset exposure ratio query table to determine a maximum exposure ratio; wherein the preset exposure ratio query table includes exposure ratios that can be used by the electronic device in different scenarios, and the exposure ratio is a ratio of the exposure time of the short exposure image to the exposure time of the long exposure image; Determining a second target exposure time according to a second exposure time and the maximum exposure ratio, wherein the second exposure time is the exposure time used by a frame of long exposure image most recently acquired by the camera; The step of determining the difference between the first exposure time and the first target exposure time as the exposure time adjustment amount includes: When the first target exposure time is less than the second target exposure time, a difference between the first exposure time and the first target exposure time is determined as the exposure time adjustment amount.
5. The method according to claim 4, characterized in that The step of determining the exposure time adjustment amount further includes: When the first target exposure time is greater than the second target exposure time, a difference between the first exposure time and the second target exposure time is determined as the exposure time adjustment amount.
6. The method according to any one of claims 3 to 5, characterized in that: The first ratio is equal to the second ratio, the first ratio is a ratio of the first depth to the first focal length, and the second ratio is a ratio of the first depth to the maximum optical flow.
7. The method according to any one of claims 3 to 5, characterized in that: The querying in a preset first correspondence table using the first depth, the first focal length, the first speed, and the maximum optical flow as reference parameters to obtain a first target exposure time includes: The first depth, the first focal length, the first speed and the maximum optical flow are used as reference parameters to query in a preset first correspondence table. If the reference parameters exist in the preset first correspondence table, the theoretical exposure time corresponding to the reference parameters is determined as the first target exposure time.
8. The method according to claim 7, characterized in that The querying in a preset first correspondence table using the first depth, the first focal length, the first speed, and the maximum optical flow as reference parameters to obtain a first target exposure time also includes: If the reference parameter does not exist in the preset first correspondence table, respectively calculating the similarity between the plurality of groups of parameters in the first correspondence table and the reference parameter; The theoretical exposure time corresponding to a group of parameters having the highest similarity to the reference parameters in the first correspondence table is determined as the first target exposure time.
9. The method according to claim 8, characterized in that The respectively calculating the similarities between the plurality of groups of parameters in the first correspondence table and the reference parameters comprises: For any set of parameters, the any set of parameters includes a second depth, a second focal length, a second speed, and a second optical flow; determining a first difference between the second depth and the first depth, and determining a first similarity according to the first difference, wherein the first similarity is negatively correlated with the first difference; determining a second difference between the second focal length and the first focal length, and determining a second similarity according to the second difference, wherein the second similarity is negatively correlated with the second difference; determining a third difference between the second speed and the first speed, and determining a third similarity according to the third difference, wherein the third similarity is negatively correlated with the third difference; determining a fourth difference between the second optical flow and the maximum optical flow, and determining a fourth similarity according to the fourth difference, wherein the fourth similarity is negatively correlated with the fourth difference; The sum of the first similarity, the second similarity, the third similarity and the fourth similarity is taken as the similarity between the arbitrary group of parameters and the reference parameters.
10. The method according to any one of claims 3 to 5, characterized in that: The determining, according to the first image and the second image, an optical flow of at least one connected area in the first image includes: Dividing the first image and the second image into a plurality of regions respectively; Determining an optical flow of each of the regions in the first image according to the multiple regions of the second image and the multiple regions of the first image; The multiple regions of the first image are merged based on the optical flow of each of the regions to obtain the optical flow of the at least one connected region.
11. The method according to claim 10, characterized in that The step of merging the multiple regions of the first image based on the optical flow of each region to obtain the optical flow of at least one connected region includes: For any area, merge areas adjacent to the any area and satisfying the merging condition to obtain at least one connected area; For any connected area, the optical flow of the any connected area is determined according to the optical flows of multiple areas synthesized from the any connected area.
12. The method according to claim 11, characterized in that The conditions for meeting the merger include: The optical flow of region Ri and region Rj satisfy |L1-L2|≤S1, and |α1-α2|≤S2; wherein L1 is the length of the optical flow of region Ri, α1 is the angle between the optical flow of region Ri and the x-axis, L2 is the length of the optical flow of region Rj, α2 is the angle between the optical flow of region Rj and the x-axis, the x-axis is the straight line on which the upper edge of the first image is located, S1 is a preset first threshold, and S2 is a preset second threshold.
13. An electronic device, characterized in that: The electronic device comprises: a memory and a processor; the processor is coupled to the memory; wherein the memory is used to store computer program code, the computer program code comprises computer instructions; when the computer instructions are executed by the processor, the electronic device executes the method as described in any one of claims 1-12.
14. A computer-readable storage medium, characterized in that: The method comprises computer instructions; when the computer instructions are executed on an electronic device, the electronic device is caused to execute the method as claimed in any one of claims 1 to 12.
