(19)
(11)EP 3 686 845 A1

(12)EUROPEAN PATENT APPLICATION
published in accordance with Art. 153(4) EPC

(43)Date of publication:
29.07.2020 Bulletin 2020/31

(21)Application number: 18866515.2

(22)Date of filing:  12.10.2018
(51)International Patent Classification (IPC): 
G06T 7/30(2017.01)
(86)International application number:
PCT/CN2018/109951
(87)International publication number:
WO 2019/072222 (18.04.2019 Gazette  2019/16)
(84)Designated Contracting States:
AL AT BE BG CH CY CZ DE DK EE ES FI FR GB GR HR HU IE IS IT LI LT LU LV MC MK MT NL NO PL PT RO RS SE SI SK SM TR
Designated Extension States:
BA ME
Designated Validation States:
KH MA MD TN

(30)Priority: 13.10.2017 CN 201710954301
16.10.2017 CN 201710959936

(71)Applicant: Huawei Technologies Co., Ltd.
Longgang District Shenzhen, Guangdong 518129 (CN)

(72)Inventors:
  • WANG, Yinting
    Shenzhen Guangdong 518129 (CN)
  • HU, Biying
    Shenzhen Guangdong 518129 (CN)
  • ZHANG, Xi
    Shenzhen Guangdong 518129 (CN)

(74)Representative: Gill Jennings & Every LLP 
The Broadgate Tower 20 Primrose Street
London EC2A 2ES
London EC2A 2ES (GB)

  


(54)IMAGE PROCESSING METHOD AND DEVICE AND APPARATUS


(57) The present invention discloses an image processing method and apparatus, and a device. The method includes: obtaining N frames of images; determining one of the N frames of images as a reference image, where the other N-1 frames of images are to-be-processed images; obtaining N-1 frames of ghost-free images based on the N-1 frames of to-be-processed images; and performing an averaging operation on the reference image and the N-1 frames of ghost-free images, to obtain a first target image. The method can provide a snapshot mode for a camera, so that a user can snap a sharp image in different scenes, thereby improving user experience.




Description

TECHNICAL FIELD



[0001] The present invention relates to the field of terminal technologies, and in particular, to an image processing method and apparatus, and a device.

BACKGROUND



[0002] In real life, motion blur occurs more or less when a moving object is photographed, and streaking becomes even worse when a fast-moving target such as a playing child or a running pet is photographed. During an exposure after a shutter button is pressed, unsteady hands may cause an image to be blurrier.

[0003] To improve sharpness of a photographed image of a moving object and mitigate impact of unsteady hands, professional photographers often arm themselves with an expensive lens with a wide aperture and optical image stabilization, a tripod, and other equipment to aid photography. However, for mobile phone users who may take a photo anytime and anywhere, such methods are difficult to be prevalent because they are expensive, not portable, or the like.

[0004] To resolve the motion blur and accompanying common problems concerning luminance, noise, and the like that may exist during photographing, the present invention provides a set of photographing methods for snapping a moving scene.

SUMMARY



[0005] Embodiments of the present invention provide an image processing method and apparatus, and a device, to provide a snapshot mechanism for a user. When a moving scene is processed, an image with high sharpness can be snapped, thereby improving photographing experience of the user.

[0006] Specific technical solutions provided in the embodiments of the present invention are as follows:

[0007] According to a first aspect, an embodiment of the present invention provides an image processing method. The method includes: obtaining N frames of images; determining one of the N frames of images as a reference image, where the other N-1 frames of images are to-be-processed images; obtaining N-1 frames of ghost-free images based on the N-1 frames of to-be-processed images; and performing an averaging operation on the reference image and the N-1 frames of ghost-free images, to obtain a first target image, where the obtaining N-1 frames of ghost-free images based on the N-1 frames of to-be-processed images includes: performing step 1 to step 4 on an ith frame of image in the N-1 frames of to-be-processed images, where values of i are all positive integers that are not greater than N-1, and
step 1: perform registration on the ith frame of image and the reference image, to obtain an ith registered image; step 2: obtain an ith difference image based on the ith registered image and the reference image; step 3: obtain an ith ghost weight image based on the ith difference image; and step 4: perform fusion on the ith registered image and the reference image based on the ith ghost weight image, to obtain an ith frame of ghost-free image.

[0008] According to a second aspect, an embodiment of the present invention provides an image processing apparatus. The apparatus includes: an obtaining module, configured to obtain N frames of images; a determining module, configured to determine one of the N frames of images as a reference image, where the other N-1 frames of images are to-be-processed images; a ghost-removal module, configured perform step 1 to step 4 on an ith frame of image in the N-1 frames of to-be-processed images, to obtain N-1 frames of ghost-free images, where values of i are all positive integers that are not greater than N-1, and step 1: perform registration on the ith frame of image and the reference image, to obtain an ith registered image; step 2: obtain an ith difference image based on the ith registered image and the reference image; step 3: obtain an ith ghost weight image based on the ith difference image; and step 4: perform fusion on the ith registered image and the reference image based on the ith ghost weight image, to obtain an ith frame of ghost-free image; and an averaging operation module, configured to perform an averaging operation on the reference image and the N-1 frames of ghost-free images, to obtain a first target image.

[0009] According to the technical solutions of the foregoing method and apparatus provided in the embodiments of the present invention, in a moving scene, a user can still snap a moving image and obtain an image with high sharpness.

[0010] According to the first aspect or the second aspect, in a possible design, before the obtaining N frames of images, the method further includes: when it is detected that the following three cases exist at the same time, generating a control signal, where the control signal is used to instruct to obtain the N frames of images; and case 1: it is detected that a to-be-photographed image of a camera is a moving image; case 2: it is detected that a current exposure time of the camera exceeds a safe time; and case 3: it is detected that the camera is in an extreme high-light scene, and correspondingly, current ISO sensitivity of the camera is less than a first preset threshold and the current exposure time is less than a second preset threshold. As a supplement to this embodiment, a corresponding control signal may be generated once at least one of the foregoing three cases is detected. For example, if the case 3 is detected, which indicates extreme high-light conditions, the camera intelligently switches to a first snapshot mode mentioned below, and generates the control signal to obtain the N frames of images in the first snapshot mode. A method of detecting the foregoing case may be performed by a detection module.

[0011] According to the first aspect or the second aspect, in a possible design, the obtaining N frames of images includes: with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a first exposure time and first ISO sensitivity; and setting the current exposure time and the current ISO sensitivity of the camera to the first exposure time and the first ISO sensitivity respectively, and photographing the N frames of images.

[0012] According to the first aspect or the second aspect, in a possible design, before the obtaining N frames of images, the method further includes: when it is detected that the following three cases exist at the same time, generating a control signal, where the control signal is used to instruct to obtain the N frames of images; and case 1: it is detected that a to-be-photographed image of a camera is a moving image; case 2: it is detected that a current exposure time of the camera exceeds a safe time; and case 3: it is detected that the camera is in a moderate high-light scene, and correspondingly, current ISO sensitivity of the camera is in a first preset threshold interval and the current exposure time is in a second preset threshold interval. As a supplement to this embodiment, a corresponding control signal may be generated once at least one of the foregoing three cases is detected. For example, if the case 3 is detected, which indicates moderate high-light conditions, the camera intelligently switches to a second snapshot mode or a third snapshot mode mentioned below, and generates the control signal to obtain the N frames of images in the second snapshot mode or the third snapshot mode. A method of detecting the foregoing case may be performed by a detection module.

[0013] According to the first aspect or the second aspect, in a possible design, namely, the second snapshot mode, the obtaining N frames of images includes: with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a second exposure time and second ISO sensitivity; and setting the current exposure time and the current ISO sensitivity of the camera to the second exposure time and the second ISO sensitivity respectively, and photographing the N frames of images. The method further includes: photographing one frame of first new image based on the current ISO sensitivity and the exposure time of the camera; and obtaining a second target image based on the first target image and the first new image. This technical solution may be used for a pure snapshot mode, in which there is no need to decide on a current photographing environment.

[0014] According to the first aspect or the second aspect, in a possible design, namely, the second snapshot mode, the obtaining a second target image based on the first target image and the first new image includes: performing registration on the first new image and the reference image or the first target image, to obtain a first (second) registered image; obtaining a first (second) difference image based on the first (second) registered image and the first target image; obtaining a first (second) ghost weight image based on the first (second) difference image; performing fusion on the first (second) registered image and the first target image based on the first (second) ghost weight image, to obtain a first (second) ghost-free image; and performing pixel-value weighted fusion based on the first (second) ghost-free image and the first target image, to obtain the second target image.

[0015] According to the first aspect or the second aspect, in a possible design, namely, the third snapshot mode, the obtaining N frames of images includes: with the current ISO sensitivity of the camera unchanged, setting the current exposure time to a third exposure time that is shorter, and photographing the N frames of images; and the method further includes: photographing one frame of second new image based on the current ISO sensitivity and the current exposure time of the camera; and obtaining a third target image based on the first target image and the second new image. This technical solution may be used for a pure snapshot mode, in which there is no need to decide on a current photographing environment.

[0016] According to the first aspect or the second aspect, in a possible design, namely, the third snapshot mode, the obtaining a third target image based on the first target image and the second new image includes: processing the first target image based on the second new image according to a preset luminance correction algorithm, to obtain a fourth target image; performing registration on the second new image and the reference image or the fourth target image, to obtain a third (fourth) registered image; obtaining a third (fourth) difference image based on the third (fourth) registered image and the fourth target image; obtaining a third (fourth) ghost weight image based on the third (fourth) difference image; performing fusion on the third (fourth) registered image and the fourth target image based on the third (fourth) ghost weight image, to obtain a third (fourth) ghost-free image; performing pixel-value weighted fusion based on the third (fourth) ghost-free image and the fourth target image, to obtain a fifth (sixth) target image; and performing pyramid fusion on the fifth (sixth) target image and the first target image, to obtain the third target image.

[0017] More specifically, the foregoing possible technical implementations may be implemented by a processor invoking a program and instruction in a memory to perform corresponding computing processing.

[0018] According to the first aspect or the second aspect, in a possible design, according to a choice of a user, the terminal directly enters a snapshot mode, for example, the first snapshot mode, the second snapshot mode, or the third snapshot mode that is mentioned above. In this case, the terminal does not need to detect an environment of a to-be-photographed scene, because there is a preset parameter rule (prestored locally in the terminal or a cloud server) for each snapshot mode. To be specific, each snapshot mode has corresponding ISO sensitivity and a corresponding exposure time, and certainly, there may be other performance parameters or the like. Upon entering a particular snapshot mode, the camera automatically adjusts to corresponding ISO sensitivity and a corresponding exposure time to photograph. Therefore, if the user directly uses the snapshot mode, the obtaining N frames of images may be photographing the N images by using the corresponding ISO sensitivity and the corresponding exposure time, to perform subsequent image processing in a corresponding mode.

[0019] In the first snapshot mode, in a possible design, a photographing action may be triggered by the user pressing a shutter button. In one case, before the user presses the shutter button, the current exposure time and the current ISO sensitivity of the camera are already adjusted to the first exposure time and the first ISO sensitivity; and when the user presses the shutter button, the camera photographs the N images by using the first exposure time and the first ISO sensitivity, for subsequent processing. In another case, before the user presses the shutter button, the camera still maintains the current ISO sensitivity and the current exposure time; and when the user presses the shutter button, the current exposure time and the current ISO sensitivity of the camera are adjusted to the first exposure time and the first ISO sensitivity, and the camera photographs the N images by using the first exposure time and the first ISO sensitivity, for subsequent processing. In addition, in a preview image data stream, the image may be displayed with the current ISO sensitivity and the current exposure time, or may be displayed with the first exposure time and the first ISO sensitivity.

[0020] In the second snapshot mode, in a possible design, a photographing action may be triggered by the user pressing a shutter button. In one case, when the user presses the shutter button, one frame of first new image is obtained by using the current ISO sensitivity and the current exposure time; the current exposure time and the current ISO sensitivity are adjusted to the second exposure time and the second ISO sensitivity, and the N images are photographed in this condition; and N+1 images are obtained in total, for subsequent processing. In another case, when the user presses the shutter button, the current exposure time and the current ISO sensitivity are set to the second exposure time and the second ISO sensitivity, and the N images are photographed in this condition; then one frame of first new image is obtained still by using the current ISO sensitivity and the current exposure time; and N+1 images are obtained in total, for subsequent processing. In addition, in a preview image data stream, the image may be displayed with the current ISO sensitivity and the current exposure time, or may be displayed with the second exposure time and the second ISO sensitivity.

[0021] In the third snapshot mode, in a possible design, a photographing action may be triggered by the user pressing a shutter button. In one case, when the user presses the shutter button, one frame of second new image is obtained by using the current ISO sensitivity and the current exposure time; with the current ISO sensitivity of the camera unchanged, the current exposure time is set to the third exposure time that is shorter, and the N images are photographed in this condition; and N+1 images are obtained in total, for subsequent processing. In another case, when the user presses the shutter button, the current exposure time is set to the third exposure time that is shorter, and the N images are photographed in this condition; then one frame of second new image is obtained still by using the current ISO sensitivity and the current exposure time; and N+1 images are obtained in total, for subsequent processing. In addition, in a preview image data stream, the image may be displayed with the current ISO sensitivity and the current exposure time, or may be displayed with the third exposure time and the current ISO sensitivity.

[0022] According to a third aspect, an embodiment of the present invention provides a terminal device. The terminal device includes a memory, a processor, a bus, a camera lens, and the memory, the camera lens, and the processor are connected by using the bus, where the camera lens is configured to collect an image signal under control of the processor; the memory is configured to store a computer program and instruction; and the processor is configured to invoke the computer program and instruction stored in the memory, so that the terminal device performs the method according to any one of the foregoing possible designs.

[0023] According to the third aspect, in a possible design, the terminal device further includes an antenna system, and under control of the processor, the antenna system sends and receives a radio communication signal to implement radio communication with a mobile communications network, where the mobile communications network includes one or more of the following: a GSM network, a CDMA network, a 3G network, a 4G network, FDMA, TDMA, PDC, TACS, AMPS, WCDMA, TDSCDMA, WIFI, and an LTE network.

[0024] The foregoing method, apparatus, and device can not only be applied to a photographing scenario using camera software that comes with a terminal, but also be applied to a photographing scenario using third-party camera software running in the terminal. Photographing includes normal photographing, selfie photographing, and other photographing modes such as a video call, a video conference, VR photography, and aerial photography.

[0025] According to the foregoing solutions, the terminal in the embodiments of the present invention may include a plurality of photographing modes, for example, a pure snapshot mode, or a smart photographing mode that determines, depending on a result of scene detection, whether to snap an image. When a terminal is in a snapshot mode, for a moving scene or a scene with a relatively high signal-to-noise ratio in which a sharp image is not easy to photograph, a photo with high sharpness can be photographed by using the solutions, thereby improving a user's photographing experience.

BRIEF DESCRIPTION OF DRAWINGS



[0026] 

FIG 1 is a schematic structural diagram of a terminal;

FIG. 2 is a flowchart of an image processing method according to an embodiment of the present invention;

FIG. 3 is a flowchart of a ghost removal method for an image according to an embodiment of the present invention;

FIG. 4 is a flowchart of a snapshot system according to an embodiment of the present invention;

FIG. 5 is a schematic diagram of another image processing method according to an embodiment of the present invention;

FIG. 6 is a schematic diagram of another image processing method according to an embodiment of the present invention; and

FIG. 7 is a schematic structural diagram of an image processing apparatus according to an embodiment of the present invention.


DESCRIPTION OF EMBODIMENTS



[0027] The following clearly and completely describes the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Apparently, the described embodiments are merely some but not all of the embodiments of the present invention. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.

[0028] In the embodiments of the present invention, a terminal may be a device that provides photographing and/or data connectivity for a user, a handheld device with a wireless connection function, or another processing device connected to a wireless modem, such as a digital camera, a single-lens reflex camera, a mobile phone (or referred to as a "cellular" phone), or may be a portable, pocket-sized, handheld, or wearable device (such as a smartwatch), a tablet computer, a personal computer (PC, Personal Computer), a PDA (Personal Digital Assistant, personal digital assistant), a POS (Point of Sale, point of sale), an in-vehicle computer, an unmanned aerial vehicle, a camera drone, or the like.

[0029] FIG. 1 is a schematic diagram of an optional hardware structure of a terminal 100.

[0030] As shown in FIG. 1, the terminal 100 may include components such as a radio frequency unit 110, a memory 120, an input unit 130, a display unit 140, a camera lens 150, an audio frequency circuit 160, a speaker 161, a microphone 162, a processor 170, an external interface 180, and a power supply 190. In this embodiment of the present invention, there are at least two camera lenses 150.

[0031] The camera lens 150 is configured to collect an image or a video and may be enabled through a trigger of an application program instruction, to implement a photo or video photographing function. The camera lens may include components such as an imaging lens, a light filter, an image sensor, and a motor for focusing and optical image stabilization. Light rays emitted or reflected by an object enter the imaging lens and finally converge on the image sensor through the light filter. The imaging lens is mainly configured to converge light emitted or reflected by all objects in a photographing view (which may also be referred to as subjects to be photographed) for imaging. The light filter is mainly configured to filter out redundant light waves (for example, a light wave other than visible light, such as infrared) from light rays. The image sensor is mainly configured to: perform optical-to-electrical conversion on a received optical signal to obtain an electrical signal, and input the electrical signal to the processor 170 for subsequent processing.

[0032] A person skilled in the art may understand that FIG. 2 is merely an example of a portable multifunctional apparatus and constitutes no limitation on the portable multifunctional apparatus. The terminal may include more or fewer components than shown in the figure, or combine some components, or have different components.

[0033] The input unit 130 may be configured to: receive entered digit or character information, and generate a key signal input related to user settings and function control of the portable multifunctional apparatus. Specifically, the input unit 130 may include a touchscreen 131 and another input device 132. The touchscreen 131 may collect a touch operation (for example, an operation performed by a user on the touchscreen or near the touchscreen by using any proper object such as a finger, a joint, or a stylus) of the user on or near the touchscreen, and drive a corresponding connection apparatus according to a preset program. The touchscreen may detect a touch action of the user on the touchscreen, convert the touch action into a touch signal, send the touch signal to the processor 170, and can receive and execute a command sent by the processor 170. The touch signal includes at least touch point coordinate information. The touchscreen 131 may provide an input interface and an output interface between the terminal 100 and the user. In addition, the touchscreen may be implemented in various types such as a resistive type, a capacitive type, an infrared type, and a surface acoustic wave type. In addition to the touchscreen 131, the input unit 130 may further include the another input device. Specifically, the another input device 132 may include but is not limited to one or more of a physical keyboard, a function key (such as a volume control key or a power on/off key), a trackball, a mouse, a joystick, and the like.

[0034] The display unit 140 may be configured to display information entered by the user or information provided for the user, and various menus of the terminal 100. In this embodiment of the present invention, the display unit is further configured to display an image obtained by the terminal by using the camera lens 150, including a preview image, an initial image that is photographed, and a target image that is obtained after being photographed and processed by using a specific algorithm.

[0035] Further, the touchscreen 131 may cover a display panel 141. After detecting a touch operation on or near the touchscreen 131, the touchscreen 131 transfers the touch operation to the processor 170 to determine a type of a touch event. Then the processor 170 provides a corresponding visual output on the display panel 141 based on the type of the touch event. In this embodiment, the touchscreen and the display unit may be integrated into one component to implement input, output, and display functions of the terminal 100. For ease of description, in this embodiment of the present invention, a touch display screen represents a function set of the touchscreen and the display unit. In some embodiments, the touchscreen and the display unit may alternatively be used as two independent components.

[0036] The memory 120 may be configured to store an instruction and data. The memory 120 may mainly include an instruction storage area and a data storage area. The data storage area may store an association relationship between a joint touch gesture and an application program function. The instruction storage area may store software units such as an operating system, an application, and an instruction required by at least one function, or a subset and an extension set of the software units. The memory 120 may further include a non-volatile random access memory, and provide the processor 170 with hardware, software, and data resources for managing a computing processing device, to support control of software and an application. The memory 120 is further configured to store a multimedia file, and store an execution program and an application.

[0037] The processor 170 is a control center of the terminal 100, and is connected to various parts of an entire mobile phone through various interfaces and lines. The processor 170 performs various functions of the terminal 100 and processes data by running or executing the instruction stored in the memory 120 and invoking the data stored in the memory 120, to perform overall monitoring on the mobile phone. Optionally, the processor 170 may include one or more processing units. Preferably, the processor 170 may be integrated with an application processor and a modem processor. The application processor mainly processes an operating system, a user interface, an application program, and the like. The modem processor mainly processes wireless communication. It may be understood that alternatively, the modem processor may not be integrated into the processor 170. In some embodiments, the processor and the memory may be implemented on a single chip. In some embodiments, the processor and the memory may be separately implemented on independent chips. The processor 170 may be further configured to: generate a corresponding operation control signal; send the operation control signal to a corresponding component of the computing processing device; and read and process data in software, especially the data and program in the memory 120, so that each function module in the computing processing device performs a corresponding function, to control the corresponding component to perform an action as required by an instruction.

[0038] The radio frequency unit 110 may be configured to: receive and send information, or receive and send a signal during a call, and particularly, receive downlink information of a base station and then send the downlink information to the processor 170 for processing. In addition, the radio frequency unit 110 is configured to send uplink data of the mobile phone to the base station. Generally, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, or the like. In addition, the radio frequency unit 110 may further communicate with a network device and another device through wireless communication. The wireless communication may use any communications standard or protocol, including but not limited to a global system for mobile communications (Global System for Mobile communication, GSM), a general packet radio service (General Packet Radio Service, GPRS), code division multiple access (Code Division Multiple Access, CDMA), wideband code division multiple access (Wideband Code Division Multiple Access, WCDMA), long term evolution (Long Term Evolution, LTE), email, a short message service (Short Message Service, SMS), or the like.

[0039] The audio frequency circuit 160, the speaker 161, and the microphone 162 may provide an audio interface between the user and the terminal 100. The audio frequency circuit 160 may transmit, to the speaker 161, an electrical signal converted from received audio data, and the speaker 161 converts the electrical signal into a sound signal for outputting. On the other hand, the microphone 162 is configured to collect a sound signal, and may further convert the collected sound signal into an electrical signal. The audio frequency circuit 160 receives the electrical signal, converts the electrical signal into audio data, outputs the audio data to the processor 170 for processing, and then sends the audio data to, for example, another terminal through the radio frequency unit 110, or the audio data is output to the memory 120 for further processing. The audio frequency circuit may also include a headphone jack 163, configured to provide a connection interface between the audio frequency circuit and a headset.

[0040] The terminal 100 further includes the power supply 190 (such as a battery) that supplies power to each component. Preferably, the power supply may be logically connected to the processor 170 by using a power supply management system, to implement functions such as charging and discharging management and power consumption management by using the power supply management system.

[0041] The terminal 100 further includes the external interface 180. The external interface may be a standard micro-USB port, or may be a multi-pin connector. The external interface may be configured to connect the terminal 100 to another apparatus for communication, or may be configured to connect to a charger to charge the terminal 100.

[0042] Although not shown, the terminal 100 may further include a flash, a wireless fidelity (wireless fidelity, Wi-Fi) module, a Bluetooth module, various sensors, and the like. Details are not described herein. All of the methods described below may be applied to the terminal shown in FIG. 1.

[0043] As shown in FIG. 2, an embodiment of the present invention provides an image processing method. A specific processing method procedure includes the following steps.

[0044] Step 31: Obtain N frames of images, where N is a positive integer greater than 2.

[0045] Step 32: Determine one of the N frames of images as a reference image, where the other N-1 frames of images are to-be-processed images. For example, N is 20, the first frame of image is a reference image, the other 19 frames of images are to-be-processed images, and i in step 33 may be any one of 1 to 19.

[0046] Step 33: Obtain N-1 frames of ghost-free images based on the N-1 frames of to-be-processed images. Specifically, steps s331 to s334 may be performed on an ith frame in the N-1 frames, where values of i may be all positive integers that are not greater than N-1. In some embodiments, alternatively, only M frames of to-be-processed images may be used to obtain M frames of ghost-free images, where M is a positive integer less than N-1. Still using N-1 for description, refer to FIG. 3.

[0047] s331: Perform registration on the ith frame of image and the reference image, to obtain an ith registered image.

[0048] s332: Obtain an ith difference image based on the ith registered image and the reference image.

[0049] s333: Obtain an ith ghost weight image based on the ith difference image.

[0050] s334: Perform fusion on the ith registered image and the reference image based on the ith ghost weight image, to obtain an ith frame of ghost-free image.

[0051] Step 34: Obtain a first target image based on the reference image and the N-1 frames of ghost-free images. Specifically, an averaging operation is performed on the reference image and the N-1 frames of ghost-free images, to obtain the first target image, and the averaging operation may also include some modifications to an average value, or include an average value of absolute values, or the like.

[0052] If a camera of a terminal is directly in a snapshot mode, in step 31, N images are photographed consecutively in current parameter settings after a photographing instruction is received, and this may be used as a replacement for step 31 in the following first snapshot mode, second snapshot mode, and third snapshot mode. Specifically, according to a choice of a user, the terminal directly enters a snapshot mode, for example, the first snapshot mode, the second snapshot mode, or the third snapshot mode that is to be mentioned below. In this case, the terminal does not need to detect an environment of a to-be-photographed scene, because there is a preset parameter rule (prestored locally in the terminal or a cloud server) for each snapshot mode. To be specific, each snapshot mode has corresponding ISO sensitivity and a corresponding exposure time, and certainly, there may be other performance parameters or the like. Upon entering a particular snapshot mode, the camera automatically adjusts to corresponding ISO sensitivity and a corresponding exposure time to photograph. Therefore, if the user directly uses the snapshot mode, the obtaining N images may be photographing the N images by using the ISO sensitivity and the exposure time corresponding to the snapshot mode, to perform subsequent image processing of the corresponding mode.

[0053] If the camera of the terminal is in an auto mode or a smart mode, the camera needs to detect an environment of a to-be-photographed scene. If it is detected that a to-be-photographed image of the camera is a moving image, and that a current exposure time of the camera exceeds a safe time, and that the environment of the to-be-photographed scene is an extreme high-light environment, the first snapshot mode provided in the present invention is used. If it is detected that a to-be-photographed image of the camera is a moving image, and that a current exposure time of the camera exceeds a safe time, and that the environment of the to-be-photographed scene is a moderate high-light environment, the second snapshot mode or the third snapshot mode provided in the present invention is used. If none of the foregoing cases are detected, any one of the photographing modes supported by the terminal may be used to photograph. For a specific photographing procedure, refer to FIG. 4.

[0054] The "camera" in this specification generally refers to a system in a terminal device capable of implementing a photographing function, and the system includes a camera lens and a necessary processing module and storage module to obtain and transfer an image, and may further include some processing function modules.

[0055] The "current exposure time" and "current ISO sensitivity" are respectively a corresponding exposure time and corresponding ISO sensitivity when the camera previews a data stream of the to-be-photographed image in initial conditions, and usually are related to properties and initial settings of the camera. In a possible design, if the terminal does not detect the environment of the to-be-photographed scene of the camera, or detects none of the following three cases when detecting the environment of the to-be-photographed scene, a corresponding exposure time and corresponding ISO sensitivity when the camera previews a data stream of the to-be-photographed image are also considered as the "current exposure time" and "current ISO sensitivity"; and case 1: the to-be-photographed image of the camera is a moving image; case 2: it is detected that the current exposure time of the camera exceeds a safe time; and case 3: it is detected that the environment of the to-be-photographed scene is an extreme high-light environment or a moderate high-light environment.

[0056] There are many manners of detecting whether the to-be-photographed image is a moving image. For example, motion detection is performed on a preview data stream to analyze a photographing preview stream, detection is performed every x frames (a quantity x of interval frames is variable, and x is a positive integer), and a difference between a current frame of image detected and a previous frame of image detected is analyzed during each time of detection. Specifically, the two frames of images each may be divided into areas in a same division manner, for example, 64 areas per frame of image. If a relatively big difference exists in one or more than one area, the image is considered as a moving image.

[0057] The current exposure time and a safe shutter speed may be obtained by obtaining camera parameters. The safe shutter speed is a property of a terminal camera. Generally, a snapshot mode is considered only when the current exposure time is greater than the safe shutter speed.

[0058] It is highly required to detect light intensity in a photographing environment. In an environment with higher light, sharpness of an image is higher and subsequent processing required is simpler. An extreme high-light scene is defined as follows: ISO sensitivity (denoted as ISO) and an exposure time (denoted as expo) of a preview image are less than a threshold each, that is, ISO < iso_th1 and expo < expo_th1. ISO and expo of the preview image may be obtained by obtaining camera parameters, and iso_th1 and expo thl may be determined based on the user's specific requirements. A moderate high-light scene is defined as follows: iso_th1 ≤ ISO < iso_th2 and expo_th1 ≤ expo < expo_th2. Likewise, iso_th2 and expo_th2 may also be determined based on the user's specific requirements. A low-light scene is defined as follows: iso_th2 ≤ ISO and expo_th2 ≤ expo. It should be understood that division of the intervals is determined based on a user requirement, and it is allowable that the value intervals are discontinuous or overlap.

[0059] The following describes the first snapshot mode, the second snapshot mode, and the third snapshot mode in detail.

First snapshot mode



[0060] For a flowchart of the first snapshot mode, refer to FIG. 2 and FIG. 3.

[0061] Step 31 is specifically: obtaining parameters such as current ISO sensitivity and a current exposure time of a camera; with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a first exposure time and first ISO sensitivity, for example, the first exposure time being 1/2 or 1/4 of the original exposure time and the first ISO sensitivity being two or four times of the original ISO sensitivity, where a specific ratio may be adjusted according to a requirement of a user or a specified rule; and setting the exposure time and the ISO sensitivity of the camera to the first exposure time and the first ISO sensitivity respectively, and photographing N frames of images. The following step is performing noise reduction on the N frames of images.

[0062] In a possible design, a photographing action may be triggered by the user pressing a shutter button. In one case, before the user presses the shutter button, the current exposure time and the current ISO sensitivity of the camera are already adjusted to the first exposure time and the first ISO sensitivity; and when the user presses the shutter button, the camera photographs the N images by using the first exposure time and the first ISO sensitivity, for subsequent processing. In another case, before the user presses the shutter button, the camera still maintains the current ISO sensitivity and the current exposure time; and when the user presses the shutter button, the current exposure time and the current ISO sensitivity of the camera are adjusted to the first exposure time and the first ISO sensitivity, and the camera photographs the N images by using the first exposure time and the first ISO sensitivity, for subsequent processing. In addition, in a preview image data stream, the image may be displayed with the current ISO sensitivity and the current exposure time, or may be displayed with the first exposure time and the first ISO sensitivity.

[0063] Step 32 is specifically: determining one of the N frames of images as a reference image, where the other N-1 frames of images are to-be-processed images. For example, the first frame of image or a frame of image in the middle of the N frames of images is used as the reference image. The first frame of image is used as an example for description of the following steps.

[0064] Step 33 is specifically: obtaining N-1 frames of ghost-free images based on the N-1 frames of to-be-processed images. This step may be further divided into many sub-steps. Steps s331 to s334 may be performed on an ith frame in the other N-1 frames, where values of i may be all positive integers that are not greater than N-1. In a specific implementation process, alternatively, some of the N-1 frames may be selected to obtain some frames of ghost-free images. For ease of description, all of the N-1 frames are selected to obtain ghost-free images in this embodiment.

[0065] s331 is specifically: performing registration on the ith frame of image and the reference image, to obtain an ith registered image. A specific registration method may be: (1) performing feature extraction on the ith frame of image and the reference image in a same manner, to obtain a series of feature points, and making a feature description for each feature point; (2) matching feature points of the ith frame of image and the reference image, to obtain a series of feature point pairs, and eliminating outliers by using a RANSAC algorithm (the prior art); and (3) solving for a transformation matrix (for example, a homography matrix or an affine matrix) of the two images from the matched feature point pairs, and performing registration and alignment, based on the transformation matrix, on the ith frame image and the reference image to obtain the ith frame of registered image. For this step, there is already a mature open-source algorithm available for invocation at the present stage, and therefore details are not described herein.

[0066] s332 is specifically: obtaining an ith difference image based on the ith registered image and the reference image. Specifically, differences between the ith frame of registered image and the reference image are calculated pixel by pixel, and a difference image of the two images is obtained by taking an absolute value of each value.

[0067] s333 is specifically: obtaining an ith ghost weight image based on the ith difference image. Specifically, a pixel exceeding a preset threshold in the difference image is set to M (for example, 255), a pixel not exceeding the preset threshold is set to N (for example, 0), and Gaussian smoothing is performed on the difference image after reassignment, to obtain the ith ghost weight image.

[0068] s334 is specifically: performing fusion on the ith registered image and the reference image based on the ith ghost weight image, to obtain an ith frame of ghost-free image. Specifically, based on the ghost weight image (ghost_mask in the following formula), pixel-by-pixel fusion is performed on the ith frame of registered image (image_i in the following formula) and the reference image (image_1 in the following formula), to obtain the ith frame of ghost-free image (no_ghost_mask). A fusion formula is as follows, where m and n represent pixel coordinates:



[0069] Step 34 is specifically: performing an averaging operation on the reference image and the N-1 frames of ghost-free images, to obtain a first target image. For example, a pixel averaging algorithm or the like in the industry may be used. The first target image is a final image obtained when the terminal executes the photographing mode.

Second snapshot mode



[0070] The second snapshot mode is more complex than the first snapshot mode. Some steps are the same as the method of the snapshot mode 1. For a flowchart of the second snapshot mode, refer to FIG. 5.

[0071] Step 41: Photograph one frame of first new image based on current ISO sensitivity and a current exposure time of a camera; with a product of the current ISO sensitivity and the current exposure time, reduce the exposure time and increase the ISO sensitivity at a preset ratio, to obtain a second exposure time and second ISO sensitivity; and set the exposure time and the ISO sensitivity of the camera to the second exposure time and the second ISO sensitivity respectively, and photograph N frames of images.

[0072] In a possible design, a photographing action may be triggered by a user pressing a shutter button. In one case, when the user presses the shutter button, one frame of first new image is obtained by using the current ISO sensitivity and the current exposure time; the current exposure time and the current ISO sensitivity are adjusted to the second exposure time and the second ISO sensitivity, and the N images are photographed in this condition; and N+1 images are obtained in total, for subsequent processing. In another case, when the user presses the shutter button, the current exposure time and the current ISO sensitivity are set to the second exposure time and the second ISO sensitivity, and the N images are photographed in this condition; then one frame of first new image is obtained still by using the current ISO sensitivity and the current exposure time; and N+1 images are obtained in total, for subsequent processing. In addition, in a preview image data stream, the image may be displayed with the current ISO sensitivity and the current exposure time, or may be displayed with the second exposure time and the second ISO sensitivity.

[0073] Step 42: Obtain a first target image by using the solution of the first snapshot mode (step 31 to step 34) for the N frames of images obtained in the previous step. It should be understood that the second ISO sensitivity, the second exposure time, and some of the foregoing adjustable thresholds may vary accordingly with a scene.

[0074] Step 43: Obtain a second target image based on the first target image and the first new image. In a specific implementation process, step 43 may include but is not limited to the following two implementations:

Manner (1) for step 43:



[0075] s4311: Perform registration on the first new image and a reference image (the same as the reference image selected when the first target image is obtained), to obtain a first registered image.

[0076] s4312: Obtain a first difference image based on the first registered image and the first target image.

[0077] s4313: Obtain a first ghost weight image based on the first difference image.

[0078] s4314: Perform fusion on the first registered image and the first target image based on the first ghost weight image, to obtain a first ghost-free image.

[0079] s4315: Perform pixel-value weighted fusion based on the first ghost-free image and the first target image, to obtain the second target image. Specifically, the fusion may include four implementations: time domain fusion s4315(1), time domain fusion s4315(3), frequency domain fusion s4315(2), and frequency domain fusion s4315(4).

[0080] Time domain fusion s4315(1): Guided filtering is separately performed on the first target image and the first ghost-free image, to filter out short-frame information (an existing mature algorithm), where the first target image and the first ghost-free image after the guided filtering is performed are denoted as fusion_gf and noghost_gf. Pixel-value weighted fusion is performed on fusion_gf and noghost_gf. A specific fusion formula is as follows:



where v is magnitude of corresponding noise specified according to a current ISO stop, and is a constant, W is a weight, and a value range of W is [0, 1).

[0081] Target details are added back to a fused image pixel by pixel. For any pixel, a target detail is a larger value of details that are filtered out from the first target image and the first ghost-free image during guided filtering at the pixel, to add more image details, thereby obtaining the second target image.

[0082] Time domain fusion s4315(3): Downsampling is separately performed on the first target image (denoted as fusion) and the first ghost-free image (denoted as noghost), and both a width and a height are downsampled by two times, to separately obtain a downsampled image of the first target image and a downsampled image of the first ghost-free image, where the two downsampled images are denoted as fusionx4 and noghostx4 respectively. Then upsampling is performed on fusionx4 and noghostx4, and both a width and a height are upsampled by two times, to separately obtain two images that are consistent in size with those before sampling is performed, where the two images are denoted as fusion' and noghost'. Differences between fusion and fusion' are calculated pixel by pixel, to obtain a sampling error image of the first target image, where the sampling error image is denoted as fusion_se. Differences between noghost and noghost' are calculated pixel by pixel, to obtain a sampling error image of the first ghost-free image, where the sampling error image is denoted as noghost_se. Guided filtering (an existing mature algorithm) is separately performed on fusionx4 and noghostx4, to obtain two filtered images, where the two filtered images are denoted as fusion_gf and noghost_gf. A pixel-value weighted fusion is performed on fusion_gf and noghost_gf to obtain a fused image, which is denoted as Fusion. A specific fusion formula is the same as the formula in s4315(1). Details that are filtered out from the first target image during guided filtering are added back to the fused image pixel by pixel, upsampling is performed on the image, and both a width and a height are upsampled by two times, where the upsampled image is denoted as FusionUp. A larger value is selected pixel by pixel from the two sampling error images fusion _se and noghost se, and is added pixel by pixel to FusionUp, to add more image details, thereby obtaining the second target image.

[0083] Frequency domain fusion s4315(2): Guided filtering (an existing mature algorithm) is separately performed on the first target image and the first ghost-free image. Fourier transform is separately performed on the two filtered images, and corresponding amplitudes are calculated. A ratio of the amplitudes is used as a weight, and Fourier spectrums corresponding to the two images are fused. A specific fusion formula is similar to that for time domain fusion. Inverse Fourier transform is performed on the fused spectrum to obtain a fused image. Target details are added back to a fused image pixel by pixel. For any pixel, a target detail is a larger value of details that are filtered out from the first target image and the first ghost-free image during guided filtering at the pixel, to add more image details, thereby obtaining the second target image.

[0084] Frequency domain fusion s4315(4): Downsampling is separately performed on the first target image (denoted as fusion) and the first ghost-free image (denoted as noghost), and both a width and a height are downsampled by two times, to separately obtain a downsampled image of the first target image and a downsampled image of the first ghost-free image, where the two downsampled images are denoted as fusionx4 and noghostx4 respectively. Then upsampling is performed on fusionx4 and noghostx4, and both a width and a height are upsampled by two times, to separately obtain two images that are consistent in size with those before sampling is performed, where the two images are denoted as fusion' and noghost'. Differences between fusion and fusion' are calculated pixel by pixel, to obtain a sampling error image of the first target image, where the sampling error image is denoted as fusion_se. Differences between noghost and noghost' are calculated pixel by pixel, to obtain a sampling error image of the first ghost-free image, where the sampling error image is denoted as noghost_se. Guided filtering (an existing mature algorithm) is separately performed on fusionx4 and noghostx4, and two filtered images are denoted as fusion_gf and noghost_gf. Fourier transform is separately performed on the two filtered images, and corresponding amplitudes are calculated. A ratio of the amplitudes is used as a weight, and Fourier spectrums corresponding to the two images are fused. A specific fusion formula is similar to that for time domain fusion. Inverse Fourier transform is performed on the fused spectrum to obtain a fused image. Details that are filtered out from the first target image during guided filtering are added back to the fused image pixel by pixel, and upsampling of two times in both a width and a height is performed on the image to which details are added back, where the upsampled image is denoted as FusionUp. A larger value is selected pixel by pixel from the two sampling error images fusion _se and noghost se, and is added pixel by pixel to FusionUp, to add more image details, thereby obtaining the second target image.

[0085] A specific algorithm used in s4311 to s4314 is the same as that used in s331 to s334, and a difference mainly lies in a replacement of an input image. Details are not described herein again.

Manner (2) for step 43:



[0086] s4321: Perform registration on the first new image and the first target image, to obtain a second registered image.

[0087] s4322: Obtain a second difference image based on the second registered image and the first target image.

[0088] s4323: Obtain a second ghost weight image based on the second difference image.

[0089] s4324: Perform fusion on the second registered image and the first target image based on the second ghost weight image, to obtain a second ghost-free image.

[0090] s4325: Perform pixel-value weighted fusion based on the second ghost-free image and the first target image, to obtain the second target image. Specifically, the fusion may include two implementations: time domain fusion and frequency domain fusion, and refer to any one of the foregoing time domain fusion s4315(1) and s4315(3), and frequency domain fusion s4315(2) and s4315(4). An algorithm is the same except for a replacement of an input image, and details are not described herein again.

Third snapshot mode



[0091] The third snapshot mode is more complex than the first snapshot mode, and may be understood as a replacement for the second snapshot mode in a sense. The second and the third snapshot modes are usually used in a moderate high-light scene. For a flowchart of the third snapshot mode, refer to FIG 6.

[0092] Step 51: Photograph one frame of second new image based on current ISO sensitivity and current exposure time of a camera; and with the current ISO sensitivity of the camera unchanged, set the current exposure time to a third exposure time that is shorter, and photograph N frames of images.

[0093] In a possible design, a photographing action may be triggered by a user pressing a shutter button. In one case, when the user presses the shutter button, one frame of second new image is obtained by using the current ISO sensitivity and the current exposure time; with the current ISO sensitivity of the camera unchanged, the current exposure time is set to the third exposure time that is shorter, and the N images are photographed in this condition; and N+1 images are obtained in total, for subsequent processing. In another case, when the user presses the shutter button, the current exposure time is set to the third exposure time that is shorter, and the N images are photographed in this condition; then one frame of second new image is obtained still by using the current ISO sensitivity and the current exposure time; and N+1 images are obtained in total, for subsequent processing. In addition, in a preview image data stream, the image may be displayed with the current ISO sensitivity and the current exposure time, or may be displayed with the third exposure time and the current ISO sensitivity.

[0094] Step 52: Obtain a first target image by using the solution of the first snapshot mode (step 31 to step 34) for the N frames of images obtained in the previous step. It should be understood that the third exposure time and some adjustable thresholds may vary accordingly with a scene.

[0095] Step 53: Obtain a third target image based on the first target image and the second new image. In a specific implementation process, step 53 may include but is not limited to the following two implementations:

Manner (1) for step 53:



[0096] s5311: Perform luminance correction on the first target image based on the second new image, to obtain a fourth target image. Specifically, statistics about histograms of the second new image and the first target image are separately collected, and statistics about cumulative histograms are collected based on the histograms; the cumulative histogram of the first target image is mapped to the cumulative histogram of the second new image, to obtain a mapping relationship curve; smoothing is performed on the mapping relationship curve, to prevent the curve from being convex or concave with a relatively large slope; and luminance of the first target image is increased based on the mapping curve. The luminance correction algorithm is an existing mature algorithm, and details are not described.

[0097] s5312: Perform registration on the second new image and a reference image (the same as the reference image selected when the first target image is obtained), to obtain a third registered image.

[0098] s5313: Obtain a third difference image based on the third registered image and the fourth target image.

[0099] s5314: Obtain a third ghost weight image based on the third difference image.

[0100] s5315: Perform fusion on the third registered image and the fourth target image based on the third ghost weight image, to obtain a third ghost-free image.

[0101] s5316: Perform pixel-value weighted fusion based on the third ghost-free image and the fourth target image, to obtain a fifth target image. For a fusion algorithm, refer to any one of time domain fusion s4315(1), time domain fusion s4315(3), frequency domain fusion s4315(2), or frequency domain fusion s4315(4).

[0102] s5317: Perform pyramid fusion on the fifth target image and the first target image, to obtain the third target image. Specifically, Laplacian pyramids of the fifth target image and the first target image are separately built, a weight image of the image fusion is built, normalization and smoothing are performed on the weight image, and a Gaussian pyramid is built for the normalized and smoothed weight image; based on a weight setting of each level of pyramids, the pyramids of all the images are fused at the corresponding level to obtain a synthetic pyramid; starting from a top level of the Laplacian pyramid, the synthetic pyramid is rebuilt according to a reverse process of pyramid generation, and each level of information is added back one by one, to restore the fused image. Pyramid fusion processing is an existing mature algorithm, and details are not described.

[0103] For algorithms in s5312 to s5316, refer to corresponding s4311 to s4315. Details are not described herein.

Manner (2) for step 53:



[0104] s5321: Perform luminance correction on the first target image based on the second new image, to obtain a fourth target image. Specifically, statistics about histograms of the second new image and the first target image are separately collected, and statistics about cumulative histograms are collected based on the histograms; the cumulative histogram of the first target image is mapped to the cumulative histogram of the second new image, to obtain a mapping relationship curve; smoothing is performed on the mapping relationship curve, to prevent the curve from being convex or concave with a relatively large slope; and luminance of the first target image is increased based on the mapping curve. The luminance correction algorithm is an existing mature algorithm, and details are not described.

[0105] s5322: Perform registration on the second new image and a reference image (the same as the reference image selected when the first target image is obtained), to obtain a third registered image.

[0106] s5323: Obtain a third difference image based on the third registered image and the fourth target image.

[0107] s5324: Obtain a third ghost weight image based on the third difference image.

[0108] s5325: Perform fusion on the third registered image and the fourth target image based on the third ghost weight image, to obtain a third ghost-free image.

[0109] s5326: Perform pixel-value weighted fusion based on the third ghost-free image and the fourth target image, to obtain a fifth target image. For a fusion algorithm, refer to one of time domain fusion s4315(1), time domain fusion s4315(3), frequency domain fusion s4315(2), and frequency domain fusion s4315(4).

[0110] s5327: Perform pyramid fusion on the fifth target image and the first target image, to obtain the third target image. Specifically, Laplacian pyramids of the fifth target image and the first target image are separately built, a weight image of the image fusion is built, normalization and smoothing are performed on the weight image, and a Gaussian pyramid is built for the normalized and smoothed weight image; based on a weight setting of each level of pyramids, the pyramids of all the images are fused at the corresponding level to obtain a synthetic pyramid; starting from a top level of the Laplacian pyramid, the synthetic pyramid is rebuilt according to a reverse process of pyramid generation, and each level of information is added back one by one, to restore the fused image. Pyramid fusion processing is an existing mature algorithm, and details are not described.

[0111] For algorithms in s5322 to s5326, refer to corresponding s4321 to s4325. Details are not described herein.

[0112] The present invention provides an image processing method, and the method can provide a snapshot mode for the camera. By using the method, the user can snap a sharp image in different scenes, catering to the user's psychology of taking a snapshot; and the user can take a snapshot to record daily life anytime and anywhere, thereby greatly improving user experience.

[0113] Based on the image processing methods provided in the foregoing embodiments, an embodiment of the present invention provides an image processing apparatus 700. The apparatus 700 may be applied to various photographing devices. As shown in FIG. 7, the apparatus 700 includes an obtaining module 701, a determining module 702, a ghost removal module 703, and an averaging operation module 704.

[0114] The obtaining module 701 is configured to obtain N frames of images. The obtaining module 701 may be implemented by a processor invoking a program instruction in a memory to control a camera lens to obtain the images.

[0115] The determining module 702 is configured to determine one of the N frames of images as a reference image, where the other N-1 frames of images are to-be-processed images. The determining module 702 may be implemented by the processor invoking a program instruction in the memory or an externally entered program instruction.

[0116] The ghost removal module 703 is configured to perform the following step 1 to step 4 on an ith frame of image in the N-1 frames of to-be-processed images, to obtain N-1 frames of ghost-free images, where values of i are all positive integers that are not greater than N-1, and

step 1: perform registration on the ith frame of image and the reference image, to obtain an ith registered image;

step 2: obtain an ith difference image based on the ith registered image and the reference image;

step 3: obtain an ith ghost weight image based on the ith difference image; and

step 4: perform fusion on the ith registered image and the reference image based on the ith ghost weight image, to obtain an ith frame of ghost-free image.



[0117] The ghost removal module 703 may be implemented by the processor, and may perform corresponding computing by invoking data and an algorithm in a local memory or a cloud server.

[0118] The averaging operation module 704 is configured to perform an averaging operation on the reference image and the N-1 frames of ghost-free images, to obtain a first target image. The averaging operation module 704 may be implemented by the processor, and may perform corresponding computing by invoking data and an algorithm in the local memory or the cloud server.

[0119] In a specific implementation process, the obtaining module 701 is specifically configured to perform the method mentioned in step 31 and a method that can be equivalently replaced; the determining module 702 is specifically configured to perform the method mentioned in step 32 and a method that can be equivalently replaced; the ghost removal module 703 is specifically configured to perform the method mentioned in step 33 and a method that can be equivalently replaced; and the averaging operation module 704 is specifically configured to perform the method mentioned in step 34 and a method that can be equivalently replaced. The foregoing specific method embodiments and explanations and descriptions in the embodiments are also applicable to method execution in the apparatus.

[0120] In a specific implementation process, the apparatus 700 further includes a detection module 705. The detection module 705 is configured to: when it is detected that the following three cases exist at the same time, control the obtaining module to obtain the N frames of images according to the following first obtaining manner, where

case 1: it is detected that a to-be-photographed image of a camera is a moving image;

case 2: it is detected that current exposure time of the camera exceeds a safe time; and

case 3: it is detected that the camera is in an extreme high-light environment, that is, current ISO sensitivity is less than a first preset threshold and the current exposure time is less than a second preset threshold.



[0121] The first obtaining manner is: with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a first exposure time and first ISO sensitivity; and setting the current exposure time and the current ISO sensitivity of the camera to the first exposure time and the first ISO sensitivity respectively, and photographing the N frames of images.

[0122] In a specific implementation process, the detection module 705 is configured to: when it is detected that the following three cases exist at the same time, control the obtaining module to obtain the N frames of images according to the following second or third obtaining manner, where

case 1: it is detected that a to-be-photographed image of a camera is a moving image;

case 2: it is detected that current exposure time of the camera exceeds a safe time; or

case 3: it is detected that the camera is in a moderate high-light environment, that is, current ISO sensitivity is in a first preset threshold interval and the current exposure time is in a second preset threshold interval.



[0123] The second obtaining manner is: with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a second exposure time and second ISO sensitivity; and setting the current exposure time and the current ISO sensitivity of the camera to the second exposure time and the second ISO sensitivity respectively, and photographing the N frames of images.

[0124] The third obtaining manner is: photographing one frame of second new image based on the current ISO sensitivity and the current exposure time of the camera; and with the current ISO sensitivity of the camera unchanged, setting the current exposure time to a third exposure time that is shorter, and photographing the N frames of images.

[0125] The apparatus 700 may further include a fusion module 706, configured to obtain a second target image based on a first target image and the first new image; or configured to obtain a third target image based on the first target image and the second new image.

[0126] For example, the fusion module 706 is specifically configured to: perform registration on the first new image and the reference image, to obtain a first registered image; obtain a first difference image based on the first registered image and the first target image; obtain a first ghost weight image based on the first difference image; perform fusion on the first registered image and the first target image based on the first ghost weight image, to obtain a first ghost-free image; and perform pixel-value weighted fusion based on the first ghost-free image and the first target image, to obtain the second target image. The fusion module 706 is specifically configured to perform the method mentioned in manner (1) for step 43 and a method that can be equivalently replaced.

[0127] Alternatively, the fusion module 706 is specifically configured to: perform registration on the first new image and the first target image, to obtain a second registered image; obtain a second difference image based on the second registered image and the first target image; obtain a second ghost weight image based on the second difference image; perform fusion on the second registered image and the first target image based on the second ghost weight image, to obtain a second ghost-free image; and perform pixel-value weighted fusion based on the second ghost-free image and the first target image, to obtain the second target image. The fusion module 706 is specifically configured to perform the method mentioned in manner (2) for step 43 and a method that can be equivalently replaced.

[0128] Alternatively, the fusion module 706 is specifically configured to: perform luminance correction on the first target image based on the second new image, to obtain a fourth target image; perform registration on the second new image and the reference image, to obtain a third registered image; obtain a third difference image based on the third registered image and the fourth target image; obtain a third ghost weight image based on the third difference image; perform fusion on the third registered image and the fourth target image based on the third ghost weight image, to obtain a third ghost-free image; perform pixel-value weighted fusion based on the third ghost-free image and the fourth target image, to obtain a fifth target image; and perform pyramid fusion on the fifth target image and the first target image, to obtain the third target image. The fusion module 706 is specifically configured to perform the method mentioned in manner (1) for step 53 and a method that can be equivalently replaced.

[0129] Alternatively, the fusion module 706 is specifically configured to: perform luminance correction on the first target image based on the second new image, to obtain a fourth target image; perform registration on the second new image and the fourth target image, to obtain a fourth registered image; obtain a fourth difference image based on the fourth registered image and the fourth target image; obtain a fourth ghost weight image based on the fourth difference image; perform fusion on the fourth registered image and the fourth target image based on the fourth ghost weight image, to obtain a fourth ghost-free image; perform pixel-value weighted fusion based on the fourth ghost-free image and the fourth target image, to obtain a sixth target image; and perform pyramid fusion on the sixth target image and the first target image, to obtain the third target image. The fusion module 706 is specifically configured to perform the method mentioned in manner (2) for step 53 and a method that can be equivalently replaced.

[0130] According to a choice of a user, the terminal directly enters a snapshot mode, for example, the first snapshot mode, the second snapshot mode, or the third snapshot mode that is mentioned above. In this case, the terminal does not need to detect an environment of a to-be-photographed scene, because there is a preset parameter rule (prestored locally in the terminal or a cloud server) for each snapshot mode. To be specific, each snapshot mode has corresponding ISO sensitivity and a corresponding exposure time, and certainly, there may be other performance parameters or the like. Upon entering a particular snapshot mode, the obtaining module automatically adjusts to corresponding ISO sensitivity and a corresponding exposure time to photograph. Therefore, if the user directly uses the snapshot mode, the obtaining module photographs the N images by using the corresponding ISO sensitivity and the corresponding exposure time, to perform subsequent image processing in a corresponding mode.

[0131] The foregoing detection module 705 and fusion module 706 may be implemented by the processor invoking a program instruction in the memory or a program instruction on a cloud.

[0132] The present invention provides the image processing apparatus 700. By using the apparatus or a terminal including the apparatus, the user can snap a sharp image in different scenes, catering to the user's psychology of taking a snapshot; and the user can take a snapshot to record daily life anytime and anywhere, thereby greatly improving user experience.

[0133] It should be understood that division of the modules in the foregoing apparatus 700 is merely division of logical functions, some or all of which may be integrated, during actual implementation, into one physical entity, or may be physically separated. For example, each of the foregoing modules may be a separate processing element, or may be integrated on a chip of a terminal, or may be stored in a storage element of a controller in a form of program code, and a processing element of the processor invokes and executes a function of each of the foregoing modules. In addition, the modules may be integrated or may be implemented independently. The processing element may be an integrated circuit chip and has a signal processing capability. In an implementation process, steps in the foregoing methods or the foregoing modules may be implemented by using a hardware integrated logical circuit in the processor element, or by using instructions in a form of software. The processing element may be a general-purpose processor, such as a central processing unit (English: central processing unit, CPU for short), or may be one or more integrated circuits configured to implement the foregoing methods, for example, one or more application-specific integrated circuits (English: application-specific integrated circuit, ASIC for short), or one or more microprocessors (English: digital signal processor, DSP for short), or one or more field programmable gate arrays (English: field-programmable gate array, FPGA for short).

[0134] A person skilled in the art should understand that the embodiments of the present invention may be provided as a method, a system, or a computer program product. Therefore, the present invention may use a form of hardware only embodiments, software only embodiments, or embodiments with a combination of software and hardware. Moreover, the present invention may use a form of a computer program product that is implemented on one or more computer-usable storage media (including but not limited to a disk memory, a CD-ROM, an optical memory, and the like) that include computer-usable program code.

[0135] The present invention is described with reference to the flowcharts and/or block diagrams of the method, the device (system), and the computer program product according to the embodiments of the present invention. It should be understood that computer program instructions may be used to implement each process and/or each block in the flowcharts and/or the block diagrams and a combination of a process and/or a block in the flowcharts and/or the block diagrams. These computer program instructions may be provided for a general-purpose computer, a dedicated computer, an embedded processor, or a processor of any other programmable data processing device to generate a machine, so that the instructions executed by a computer or a processor of any other programmable data processing device generate an apparatus for implementing a specific function in one or more processes in the flowcharts and/or in one or more blocks in the block diagrams.

[0136] These computer program instructions may be stored in a computer readable memory that can instruct the computer or any other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory generate an artifact that includes an instruction apparatus. The instruction apparatus implements a specific function in one or more processes in the flowcharts and/or in one or more blocks in the block diagrams.

[0137] These computer program instructions may be loaded onto a computer or another programmable data processing device, so that a series of operations and steps are performed on the computer or the another programmable device, thereby generating computer-implemented processing. Therefore, the instructions executed on the computer or the another programmable device provide steps for implementing a specific function in one or more processes in the flowcharts and/or in one or more blocks in the block diagrams.

[0138] Although embodiments of the present invention have been described, a person skilled in the art can make changes and modifications to these embodiments once they learn the basic inventive concept. Therefore, the following claims are intended to be construed as to cover the embodiments and all changes and modifications falling within the scope of the present invention. Apparently, a person skilled in the art can make various modifications and variations to the embodiments of the present invention without departing from the spirit and scope of the embodiments of the present invention. The present invention is intended to cover these modifications and variations provided that they fall within the scope of protection defined by the following claims and their equivalent technologies.


Claims

1. An image processing method, wherein the method comprises:

obtaining N frames of images;

determining one of the N frames of images as a reference image, wherein the other N-1 frames of images are to-be-processed images;

obtaining N-1 frames of ghost-free images based on the N-1 frames of to-be-processed images; and

performing an averaging operation on the reference image and the N-1 frames of ghost-free images, to obtain a first target image, wherein

the obtaining N-1 frames of ghost-free images based on the N-1 frames of to-be-processed images comprises:
performing step 1 to step 4 on an ith frame of image in the N-1 frames of to-be-processed images, wherein values of i are all positive integers that are not greater than N-1, and

step 1: perform registration on the ith frame of image and the reference image, to obtain an ith registered image;

step 2: obtain an ith difference image based on the ith registered image and the reference image;

step 3: obtain an ith ghost weight image based on the ith difference image; and

step 4: perform fusion on the ith registered image and the reference image based on the ith ghost weight image, to obtain an ith frame of ghost-free image.


 
2. The method according to claim 1, wherein before the obtaining N frames of images, the method further comprises: when it is detected that the following three cases exist at the same time, generating a control signal, wherein the control signal is used to instruct to obtain the N frames of images; and

case 1: it is detected that a to-be-photographed image of a camera is a moving image;

case 2: it is detected that a current exposure time of the camera exceeds a safe time; and

case 3: it is detected that current ISO sensitivity of the camera is less than a first preset threshold and the current exposure time is less than a second preset threshold.


 
3. The method according to claim 1 or 2, wherein the obtaining N frames of images comprises:

with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a first exposure time and first ISO sensitivity; and

setting the current exposure time and the current ISO sensitivity of the camera to the first exposure time and the first ISO sensitivity respectively, and photographing the N frames of images.


 
4. The method according to claim 1, wherein before the obtaining N frames of images, the method further comprises: when it is detected that all following three cases exist at the same time, generating a control signal, wherein the control signal is used to instruct to obtain the N frames of images; and

case 1: it is detected that a to-be-photographed image of a camera is a moving image;

case 2: it is detected that a current exposure time of the camera exceeds a safe time; and

case 3: it is detected that current ISO sensitivity of the camera is in a first preset threshold interval and the current exposure time is in a second preset threshold interval.


 
5. The method according to claim 1 or 4, wherein the obtaining N frames of images comprises:

with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a second exposure time and second ISO sensitivity; and

setting the current exposure time and the current ISO sensitivity of the camera to the second exposure time and the second ISO sensitivity respectively, and photographing the N frames of images; and

the method further comprises:

photographing one frame of first new image based on the current ISO sensitivity and the current exposure time of the camera; and

obtaining a second target image based on the first target image and the first new image.


 
6. The method according to claim 5, wherein the obtaining a second target image based on the first target image and the first new image comprises:

performing registration on the first new image and the reference image, to obtain a first registered image;

obtaining a first difference image based on the first registered image and the first target image;

obtaining a first ghost weight image based on the first difference image;

performing fusion on the first registered image and the first target image based on the first ghost weight image, to obtain a first ghost-free image; and

performing pixel-value weighted fusion based on the first ghost-free image and the first target image, to obtain the second target image.


 
7. The method according to claim 5, wherein the obtaining a second target image based on the first target image and the first new image comprises:

performing registration on the first new image and the first target image, to obtain a second registered image;

obtaining a second difference image based on the second registered image and the first target image;

obtaining a second ghost weight image based on the second difference image;

performing fusion on the second registered image and the first target image based on the second ghost weight image, to obtain a second ghost-free image; and

performing pixel-value weighted fusion based on the second ghost-free image and the first target image, to obtain the second target image.


 
8. The method according to claim 1 or 4, wherein the obtaining N frames of images comprises:

with the current ISO sensitivity of the camera unchanged, setting the current exposure time to a third exposure time that is shorter, and photographing the N frames of images; and

the method further comprises:

photographing one frame of second new image based on the current ISO sensitivity and the current exposure time of the camera; and

obtaining a third target image based on the first target image and the second new image.


 
9. The method according to claim 8, wherein the obtaining a third target image based on the first target image and the second new image comprises:

performing luminance correction on the first target image based on the second new image, to obtain a fourth target image;

performing registration on the second new image and the reference image, to obtain a third registered image;

obtaining a third difference image based on the third registered image and the fourth target image;

obtaining a third ghost weight image based on the third difference image;

performing fusion on the third registered image and the fourth target image based on the third ghost weight image, to obtain a third ghost-free image;

performing pixel-value weighted fusion based on the third ghost-free image and the fourth target image, to obtain a fifth target image; and

performing pyramid fusion on the fifth target image and the first target image, to obtain the third target image.


 
10. The method according to claim 8, wherein the obtaining a third target image based on the first target image and the second new image comprises:

performing luminance correction on the first target image based on the second new image, to obtain a fourth target image;

performing registration on the second new image and the fourth target image, to obtain a fourth registered image;

obtaining a fourth difference image based on the fourth registered image and the fourth target image;

obtaining a fourth ghost weight image based on the fourth difference image;

performing fusion on the fourth registered image and the fourth target image based on the fourth ghost weight image, to obtain a fourth ghost-free image;

performing pixel-value weighted fusion based on the fourth ghost-free image and the fourth target image, to obtain a sixth target image; and

performing pyramid fusion on the sixth target image and the first target image, to obtain the third target image.


 
11. The method according to claim 1, wherein the obtaining N frames of images comprises: when a photographing instruction is received and it is detected that the following three cases exist at the same time, with a product of current ISO sensitivity and a current exposure time of a camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a first exposure time and first ISO sensitivity; and
photographing the N frames of images based on the first exposure time and the first ISO sensitivity, wherein

case 1: it is detected that a to-be-photographed image of the camera is a moving image;

case 2: it is detected that the current exposure time of the camera exceeds a safe time; and

case 3: it is detected that the current ISO sensitivity of the camera is less than a first preset threshold and the current exposure time is less than a second preset threshold.


 
12. The method according to claim 1, wherein the obtaining N frames of images comprises: when it is detected that the following three cases exist at the same time, with a product of current ISO sensitivity and a current exposure time of a camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a first exposure time and first ISO sensitivity; and
receiving a photographing instruction, and photographing the N frames of images based on the first exposure time and the first ISO sensitivity, wherein

case 1: it is detected that a to-be-photographed image of the camera is a moving image;

case 2: it is detected that the current exposure time of the camera exceeds a safe time; and

case 3: it is detected that the current ISO sensitivity of the camera is less than a first preset threshold and the current exposure time is less than a second preset threshold.


 
13. The method according to claim 1, wherein the obtaining N frames of images comprises: when a photographing instruction is received and it is detected that the following three cases exist at the same time, with a product of current ISO sensitivity and a current exposure time of a camera unchanged, reducing the exposure time and increasing the ISO sensitivity at a preset ratio, to obtain a second exposure time and second ISO sensitivity; and
photographing the N frames of images based on the second exposure time and the second ISO sensitivity, wherein

case 1: it is detected that a to-be-photographed image of the camera is a moving image;

case 2: it is detected that the current exposure time of the camera exceeds a safe time; and

case 3: it is detected that the current ISO sensitivity of the camera is in a first preset threshold interval and the current exposure time is in a second preset threshold interval.


 
14. The method according to claim 1, wherein the method further comprises:

photographing one frame of first new image based on current ISO sensitivity and the current exposure time of a camera;

performing registration on the first new image and the first target image or the reference image, to obtain a first registered image;

obtaining a first difference image based on the first registered image and the first target image;

obtaining a first ghost weight image based on the first difference image;

performing fusion on the first registered image and the first target image based on the first ghost weight image, to obtain a first ghost-free image; and

performing pixel-value weighted fusion based on the first ghost-free image and the first target image, to obtain the second target image.


 
15. The method according to claim 13 or 14, wherein the method further comprises:

photographing one frame of first new image based on the current ISO sensitivity and the current exposure time of the camera;

performing registration on the first new image and the first target image or the reference image, to obtain a first registered image;

obtaining a first difference image based on the first registered image and the first target image;

obtaining a first ghost weight image based on the first difference image;

performing fusion on the first registered image and the first target image based on the first ghost weight image, to obtain a first ghost-free image; and

performing pixel-value weighted fusion based on the first ghost-free image and the first target image, to obtain the second target image.


 
16. The method according to claim 1, wherein the obtaining N frames of images comprises: when it is detected that the following three cases exist at the same time, with current ISO sensitivity of a camera unchanged, setting a current exposure time to a third exposure time that is shorter; and
receiving a photographing instruction, and photographing the N frames of images based on the third exposure time and the second ISO sensitivity, wherein

case 1: it is detected that a to-be-photographed image of the camera is a moving image;

case 2: it is detected that the current exposure time of the camera exceeds a safe time; and

case 3: it is detected that the current ISO sensitivity of the camera is in a first preset threshold interval and the current exposure time is in a second preset threshold interval.


 
17. The method according to claim 1, wherein the obtaining N frames of images comprises: when a photographing instruction is received and it is detected that the following three cases exist at the same time, with current ISO sensitivity of a camera unchanged, setting a current exposure time to a third exposure time that is shorter; and
photographing the N frames of images based on the third exposure time and the second ISO sensitivity, wherein

case 1: it is detected that a to-be-photographed image of the camera is a moving image;

case 2: it is detected that the current exposure time of the camera exceeds a safe time; and

case 3: it is detected that the current ISO sensitivity of the camera is in a first preset threshold interval and the current exposure time is in a second preset threshold interval.


 
18. The method according to claim 16 or 17, wherein the method further comprises:

photographing one frame of second new image based on the current ISO sensitivity and the current exposure time of the camera;

performing luminance correction on the first target image based on the second new image, to obtain a fourth target image;

performing registration on the second new image and the fourth target image or the reference image, to obtain a third registered image;

obtaining a third difference image based on the third registered image and the fourth target image;

obtaining a third ghost weight image based on the third difference image;

performing fusion on the third registered image and the fourth target image based on the third ghost weight image, to obtain a third ghost-free image;

performing pixel-value weighted fusion based on the third ghost-free image and the fourth target image, to obtain a fifth target image; and

performing pyramid fusion on the fifth target image and the first target image, to obtain the third target image.


 
19. An image processing apparatus, wherein the apparatus comprises:

an obtaining module, configured to obtain N frames of images;

a determining module, configured to determine one of the N frames of images as a reference image, wherein the other N-1 frames of images are to-be-processed images;

a ghost removal module, configured to perform the following step 1 to step 4 on an ith frame of image in the N-1 frames of to-be-processed images, to obtain N-1 frames of ghost-free images, wherein values of i are all positive integers that are not greater than N-1, and

step 1: perform registration on the ith frame of image and the reference image, to obtain an ith registered image;

step 2: obtain an ith difference image based on the ith registered image and the reference image;

step 3: obtain an ith ghost weight image based on the ith difference image; and

step 4: perform fusion on the ith registered image and the reference image based on the ith ghost weight image, to obtain an ith frame of ghost-free image; and

an averaging operation module, configured to perform an averaging operation on the reference image and the N-1 frames of ghost-free images, to obtain a first target image.


 
20. The apparatus according to claim 19, wherein the apparatus further comprises a detection module, and the detection module is configured to: when it is detected that the following three cases exist at the same time, control the obtaining module to obtain the N frames of images;

case 1: it is detected that a to-be-photographed image of a camera is a moving image;

case 2: it is detected that current exposure time of the camera exceeds a safe time; and

case 3: it is detected that current ISO sensitivity of the camera is less than a first preset threshold and the current exposure time is less than a second preset threshold.


 
21. The apparatus according to claim 19 or 20, wherein the obtaining module is configured to:

with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reduce the exposure time and increase the ISO sensitivity at a preset ratio, to obtain a first exposure time and first ISO sensitivity; and

set the current exposure time and the current ISO sensitivity of the camera to the first exposure time and the first ISO sensitivity respectively, and photograph the N frames of images.


 
22. The apparatus according to claim 19, wherein the apparatus further comprises a detection module, and the detection module is configured to: when it is detected that the following three cases exist at the same time, control the obtaining module to obtain the N frames of images;

case 1: it is detected that a to-be-photographed image of a camera is a moving image;

case 2: it is detected that current exposure time of the camera exceeds a safe time; and

case 3: it is detected that current ISO sensitivity of the camera is in a first preset threshold interval and the current exposure time is in a second preset threshold interval.


 
23. The apparatus according to claim 19 or 22, wherein the obtaining module is configured to:

with a product of the current ISO sensitivity and the current exposure time of the camera unchanged, reduce the exposure time and increase the ISO sensitivity at a preset ratio, to obtain a second exposure time and second ISO sensitivity; and

set the current exposure time and the current ISO sensitivity of the camera to the second exposure time and the second ISO sensitivity respectively, and photograph the N frames of images; and

the obtaining module is further configured to photograph one frame of first new image based on the current ISO sensitivity and the current exposure time of the camera; and

the apparatus further comprises:
a fusion module, configured to obtain a second target image based on the first target image and the first new image.


 
24. The apparatus according to claim 23, wherein the fusion module is configured to:

perform registration on the first new image and the reference image, to obtain a first registered image;

obtain a first difference image based on the first registered image and the first target image;

obtain a first ghost weight image based on the first difference image;

perform fusion on the first registered image and the first target image based on the first ghost weight image, to obtain a first ghost-free image; and

perform pixel-value weighted fusion based on the first ghost-free image and the first target image, to obtain the second target image.


 
25. The apparatus according to claim 24, wherein the fusion module is configured to:

perform registration on the first new image and the first target image, to obtain a second registered image;

obtain a second difference image based on the second registered image and the first target image;

obtain a second ghost weight image based on the second difference image;

perform fusion on the second registered image and the first target image based on the second ghost weight image, to obtain a second ghost-free image; and

perform pixel-value weighted fusion based on the second ghost-free image and the first target image, to obtain the second target image.


 
26. The apparatus according to claim 19 or 22, wherein the obtaining module is configured to:

with the current ISO sensitivity of the camera unchanged, set the current exposure time to a third exposure time that is shorter, and photograph the N frames of images; and

photograph one frame of second new image based on the current ISO sensitivity and the current exposure time of the camera; and

the apparatus further comprises:
a fusion module, configured to obtain a third target image based on the first target image and the second new image.


 
27. The apparatus according to claim 26, wherein the fusion module is configured to:

perform luminance correction on the first target image based on the second new image, to obtain a fourth target image;

perform registration on the second new image and the reference image, to obtain a third registered image;

obtain a third difference image based on the third registered image and the fourth target image;

obtain a third ghost weight image based on the third difference image;

perform fusion on the third registered image and the fourth target image based on the third ghost weight image, to obtain a third ghost-free image;

perform pixel-value weighted fusion based on the third ghost-free image and the fourth target image, to obtain a fifth target image; and

perform pyramid fusion on the fifth target image and the first target image, to obtain the third target image.


 
28. The apparatus according to claim 26, wherein the fusion module is configured to:

perform luminance correction on the first target image based on the second new image, to obtain a fourth target image;

perform registration on the second new image and the fourth target image, to obtain a fourth registered image;

obtain a fourth difference image based on the fourth registered image and the fourth target image;

obtain a fourth ghost weight image based on the fourth difference image;

perform fusion on the fourth registered image and the fourth target image based on the fourth ghost weight image, to obtain a fourth ghost-free image;

perform pixel-value weighted fusion based on the fourth ghost-free image and the fourth target image, to obtain a sixth target image; and

perform pyramid fusion on the sixth target image and the first target image, to obtain the third target image.


 
29. A terminal device, wherein the terminal device comprises a memory, a processor, a bus, a camera lens, and the memory, the camera lens, and the processor are connected by using the bus, wherein
the camera lens is configured to collect an image signal under control of the processor;
the memory is configured to store a computer program and instruction; and
the processor is configured to invoke the computer program and instruction stored in the memory, so that the terminal device performs the method according to any one of claims 1 to 18.
 
30. The terminal device according to claim 29, wherein the terminal device further comprises an antenna system, and under control of the processor, the antenna system sends and receives a radio communication signal to implement radio communication with a mobile communications network, wherein the mobile communications network comprises one or more of the following: a GSM network, a CDMA network, a 3G network, a 4G network, FDMA, TDMA, PDC, TACS, AMPS, WCDMA, TDSCDMA, WIFI, and an LTE network.
 




Drawing
















Search report