CN111612723B - Image restoration method and device - Google Patents

Image restoration method and device Download PDF

Info

Publication number
CN111612723B
CN111612723B CN202010472105.2A CN202010472105A CN111612723B CN 111612723 B CN111612723 B CN 111612723B CN 202010472105 A CN202010472105 A CN 202010472105A CN 111612723 B CN111612723 B CN 111612723B
Authority
CN
China
Prior art keywords
image
generator
images
processed
electronic device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010472105.2A
Other languages
Chinese (zh)
Other versions
CN111612723A (en
Inventor
颜海强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Oppo Chongqing Intelligent Technology Co Ltd
Original Assignee
Oppo Chongqing Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo Chongqing Intelligent Technology Co Ltd filed Critical Oppo Chongqing Intelligent Technology Co Ltd
Priority to CN202010472105.2A priority Critical patent/CN111612723B/en
Publication of CN111612723A publication Critical patent/CN111612723A/en
Application granted granted Critical
Publication of CN111612723B publication Critical patent/CN111612723B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • G06T5/77
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/50Image enhancement or restoration by the use of more than one image, e.g. averaging, subtraction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person

Abstract

The application discloses an image restoration method and device, which are applied to electronic equipment, wherein the method comprises the following steps: processing an image to be processed through first preprocessing; inputting the preprocessed image to be processed into a first generator; and obtaining a target image corresponding to the image to be processed output by the first generator, wherein the target image is the repaired image to be processed. By the adoption of the method and the device, convenience restoration of the low-quality image is facilitated, and intelligence and speed of image restoration are improved.

Description

Image restoration method and device
Technical Field
The present application relates to the field of electronic technologies, and in particular, to an image restoration method and apparatus.
Background
In daily life of people, old photos are often used for memory, but the old photos are mostly paper photos, and when the old photos are copied, the old photos are often limited by various factors such as shooting equipment, age and network stream compression distortion, and low-image quality problems such as low resolution, high noise and the like occur, so that how to repair the old photos with low image quality and how to improve the definition of the old photos become problems to be solved.
Disclosure of Invention
The embodiment of the application provides an image restoration method and device, which aim to realize convenience restoration of low-quality images and improve intelligence and speed of image restoration.
In a first aspect, an embodiment of the present application provides an image inpainting method, which is applied to an electronic device, and the method includes:
processing an image to be processed through first preprocessing;
inputting the preprocessed image to be processed into a first generator;
and obtaining a target image corresponding to the image to be processed output by the first generator, wherein the target image is the repaired image to be processed.
In a second aspect, an embodiment of the present application provides an image restoration apparatus applied to an electronic device, the image restoration apparatus including a processing unit, an input unit, and an acquisition unit, wherein:
the processing unit is used for processing the image to be processed through first preprocessing;
the input unit is used for inputting the preprocessed image to be processed into a first generator;
the acquisition unit is used for acquiring a target image corresponding to the image to be processed output by the first generator, wherein the target image is the repaired image to be processed.
In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing steps in any method of the first aspect of the embodiment of the present application.
In a fourth aspect, the present application provides a computer-readable storage medium, where the computer-readable storage medium stores a computer program for electronic data exchange, where the computer program makes a computer perform part or all of the steps described in any one of the methods of the first aspect of the present application.
In a fifth aspect, the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform some or all of the steps as described in any one of the methods of the first aspect of the embodiments of the present application. The computer program product may be a software installation package.
It can be seen that, in the embodiment of the present application, an electronic device processes an image to be processed through first preprocessing, and inputs the preprocessed image to be processed into a first generator, so as to obtain a target image corresponding to the image to be processed output by the first generator, where the target image is the repaired image to be processed. Therefore, the electronic equipment inputs the image to be processed into the first generator to obtain the repaired target image, convenience repair of the low-quality image is achieved, and the image is repaired only through the first generator without manual operation, so that the intelligence and the image repairing speed of image repair are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 2 is a schematic diagram of a software structure of an electronic device according to an embodiment of the present application;
fig. 3A is a schematic flowchart of an image restoration method according to an embodiment of the present application;
fig. 3B is a schematic structural diagram of a generative countermeasure network provided in an embodiment of the present application;
FIG. 4 is a schematic flowchart of another image restoration method provided in an embodiment of the present application;
fig. 5 is a block diagram of distributed functional units of an image restoration apparatus according to an embodiment of the present disclosure;
fig. 6 is a block diagram of an integrated functional unit of an image restoration device according to an embodiment of the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
In order to better understand the scheme of the embodiments of the present application, the following first introduces the related terms and concepts that may be involved in the embodiments of the present application.
1) The electronic device may be a portable electronic device, such as a cell phone, a tablet computer, a wearable electronic device with wireless communication capabilities (e.g., a smart watch), etc., that also contains other functionality, such as personal digital assistant and/or music player functionality. Exemplary embodiments of the portable electronic device include, but are not limited to, portable electronic devices that carry an IOS system, an Android system, a Microsoft system, or other operating system. The portable electronic device may also be other portable electronic devices such as a Laptop computer (Laptop) or the like. It should also be understood that in other embodiments, the electronic device may not be a portable electronic device, but may be a desktop computer.
2) The generative confrontation network is a deep learning model, and is one of the most promising methods for unsupervised learning in complex distribution in recent years. The model passes through (at least) two modules in the framework: the mutual game learning of the generative model and the discriminant model produces a fairly good output.
3) The generator, which is a network for generating pictures, receives a random noise from which the pictures are generated.
4) The discriminator is a discrimination network for discriminating whether a picture is "real". The input parameters of the method are x, wherein x represents a picture, and the output D (x) represents the probability that x is a real picture, if 1, 100 percent of the picture is real, and if 0, the picture cannot be real.
Fig. 1 shows a schematic structural diagram of an electronic device 100. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a Universal Serial Bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a compass 190, a motor 191, a pointer 192, a camera 193, a display screen 194, a Subscriber Identification Module (SIM) card interface 195, and the like.
It is to be understood that the illustrated structure of the embodiment of the present application does not specifically limit the electronic device 100. In other embodiments of the present application, electronic device 100 may include more or fewer components than shown, or some components may be combined, some components may be split, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
Processor 110 may include one or more processing units, such as: the processor 110 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and/or a neural-Network Processing Unit (NPU), etc. Wherein the different processing units may be separate components or may be integrated in one or more processors. In some embodiments, the electronic device 100 may also include one or more processors 110. The controller can generate an operation control signal according to the instruction operation code and the time sequence signal to complete the control of instruction fetching and instruction execution. In other embodiments, a memory may also be provided in processor 110 for storing instructions and data. Illustratively, the memory in the processor 110 may be a cache memory. The memory may hold instructions or data that have just been used or recycled by the processor 110. If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. This avoids repeated accesses, reduces the latency of the processor 110, and thus increases the efficiency with which the electronic device 100 processes data or executes instructions.
In some embodiments, processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit audio (I2S) interface, a Pulse Code Modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a general-purpose input/output (GPIO) interface, a SIM card interface, a USB interface, and/or the like. The USB interface 130 is an interface conforming to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 130 may be used to connect a charger to charge the electronic device 100, and may also be used to transmit data between the electronic device 100 and a peripheral device. The USB interface 130 may also be used to connect to a headset to play audio through the headset.
It should be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only an illustration, and does not limit the structure of the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners or a combination of multiple interface connection manners in the above embodiments.
The charging management module 140 is configured to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive a wireless charging input through a wireless charging coil of the electronic device 100. The charging management module 140 may also supply power to the electronic device through the power management module 141 while charging the battery 142.
The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, the wireless communication module 160, and the like. The power management module 141 may also be used to monitor parameters such as battery capacity, battery cycle count, battery state of health (leakage, impedance), etc. In some other embodiments, the power management module 141 may also be disposed in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be disposed in the same device.
The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication bands. Different antennas can also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed as a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The mobile communication module 150 may provide a solution including 2G/3G/4G/5G wireless communication applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a Low Noise Amplifier (LNA), and the like. The mobile communication module 150 may receive the electromagnetic wave from the antenna 1, filter, amplify, etc. the received electromagnetic wave, and transmit the electromagnetic wave to the modem processor for demodulation. The mobile communication module 150 may also amplify the signal modulated by the modem processor, and convert the signal into electromagnetic wave through the antenna 1 to radiate the electromagnetic wave. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 may be disposed in the same device as at least some of the modules of the processor 110.
The wireless communication module 160 may provide a solution for wireless communication applied to the electronic device 100, including Wireless Local Area Networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), bluetooth (bluetooth), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and the like. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, perform frequency modulation and amplification on the signal, and convert the signal into electromagnetic waves through the antenna 2 to radiate the electromagnetic waves.
The electronic device 100 implements display functions via the GPU, the display screen 194, and the application processor. The GPU is a microprocessor for image processing, and is connected to the display screen 194 and an application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
The display screen 194 is used to display images, videos, and the like. The display screen 194 includes a display panel. The display panel may be a Liquid Crystal Display (LCD), an organic light-emitting diode (OLED), an active matrix organic light-emitting diode (active-matrix organic light-emitting diode, AMOLED), a flexible light-emitting diode (FLED), a mini light-emitting diode (mini-light-emitting diode, mini), a Micro, a quantum dot light-emitting diode (QLED), or the like. In some embodiments, the electronic device 100 may include 1 or more display screens 194.
The electronic device 100 may implement a photographing function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, the application processor, and the like.
The ISP is used to process the data fed back by the camera 193. For example, when a photo is taken, the shutter is opened, light is transmitted to the camera photosensitive element through the lens, the optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converting into an image visible to naked eyes. The ISP can also carry out algorithm optimization on noise, brightness and skin color of the image. The ISP can also optimize parameters such as exposure, color temperature and the like of a shooting scene. In some embodiments, the ISP may be provided in camera 193.
The camera 193 is used to capture still images or video. The object generates an optical image through the lens and projects the optical image to the photosensitive element. The photosensitive element may be a Charge Coupled Device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The light sensing element converts the optical signal into an electrical signal, which is then passed to the ISP where it is converted into a digital image signal. And the ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into image signal in standard RGB, YUV and other formats. In some embodiments, the electronic device 100 may include 1 or more cameras 193.
The digital signal processor is used for processing digital signals, and can process digital image signals and other digital signals. For example, when the electronic device 100 selects a frequency bin, the digital signal processor is used to perform fourier transform or the like on the frequency bin energy.
Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 may play or record video in a variety of encoding formats, such as: moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, and the like.
The NPU is a neural-network (NN) computing processor that processes input information quickly by using a biological neural network structure, for example, by using a transfer mode between neurons of a human brain, and can also learn by itself continuously. Applications such as intelligent recognition of the electronic device 100 can be realized through the NPU, for example: image recognition, face recognition, speech recognition, text understanding, and the like.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to extend the memory capability of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music, video, etc. are saved in an external memory card.
Internal memory 121 may be used to store one or more computer programs, including instructions. The processor 110 may execute the above-mentioned instructions stored in the internal memory 121, so as to enable the electronic device 100 to execute the method for displaying page elements provided in some embodiments of the present application, and various applications and data processing. The internal memory 121 may include a program storage area and a data storage area. Wherein, the storage program area can store an operating system; the storage program area may also store one or more applications (e.g., gallery, contacts, etc.), and the like. The storage data area may store data (e.g., photos, contacts, etc.) created during use of the electronic device 100, and the like. Further, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic disk storage components, flash memory components, Universal Flash Storage (UFS), and the like. In some embodiments, the processor 110 may cause the electronic device 100 to execute the method for displaying page elements provided in the embodiments of the present application and other applications and data processing by executing instructions stored in the internal memory 121 and/or instructions stored in a memory provided in the processor 110. The electronic device 100 may implement audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor, etc. Such as music playing, recording, etc.
The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
The pressure sensor 180A is used for sensing a pressure signal, and converting the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display screen 194. The pressure sensor 180A can be of a wide variety, such as a resistive pressure sensor, an inductive pressure sensor, a capacitive pressure sensor, and the like. The capacitive pressure sensor may be a sensor comprising at least two parallel plates having an electrically conductive material. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the strength of the pressure from the change in capacitance. When a touch operation is applied to the display screen 194, the electronic apparatus 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic apparatus 100 may also calculate the touched position from the detection signal of the pressure sensor 180A. In some embodiments, the touch operations that are applied to the same touch position but different touch operation intensities may correspond to different operation instructions. For example: and when the touch operation with the touch operation intensity smaller than the first pressure threshold value acts on the short message application icon, executing an instruction for viewing the short message. And when the touch operation with the touch operation intensity larger than or equal to the first pressure threshold value acts on the short message application icon, executing an instruction of newly building the short message.
The gyro sensor 180B may be used to determine the motion attitude of the electronic device 100. In some embodiments, the angular velocity of electronic device 100 about three axes (i.e., X, Y and the Z-axis) may be determined by gyroscope sensor 180B. The gyro sensor 180B may be used for photographing anti-shake. For example, when the shutter is pressed, the gyro sensor 180B detects a shake angle of the electronic device 100, calculates a distance to be compensated for by the lens module according to the shake angle, and allows the lens to counteract the shake of the electronic device 100 through a reverse movement, thereby achieving anti-shake. The gyroscope sensor 180B may also be used for navigation, somatosensory gaming scenes.
The acceleration sensor 180E may detect the magnitude of acceleration of the electronic device 100 in various directions (typically three axes). The magnitude and direction of gravity can be detected when the electronic device 100 is stationary. The method can also be used for recognizing the posture of the electronic equipment, and is applied to horizontal and vertical screen switching, pedometers and other applications.
The ambient light sensor 180L is used to sense the ambient light level. Electronic device 100 may adaptively adjust the brightness of display screen 194 based on the perceived ambient light level. The ambient light sensor 180L may also be used to automatically adjust the white balance when taking a picture. The ambient light sensor 180L may also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
The fingerprint sensor 180H is used to collect a fingerprint. The electronic device 100 can utilize the collected fingerprint characteristics to unlock the fingerprint, access the application lock, photograph the fingerprint, answer an incoming call with the fingerprint, and so on.
The temperature sensor 180J is used to detect temperature. In some embodiments, electronic device 100 implements a temperature processing strategy using the temperature detected by temperature sensor 180J. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 performs a reduction in performance of a processor located near the temperature sensor 180J, so as to reduce power consumption and implement thermal protection. In other embodiments, the electronic device 100 heats the battery 142 when the temperature is below another threshold to avoid the low temperature causing the electronic device 100 to shut down abnormally. In other embodiments, when the temperature is lower than a further threshold, the electronic device 100 performs boosting on the output voltage of the battery 142 to avoid abnormal shutdown due to low temperature.
The touch sensor 180K is also referred to as a "touch panel". The touch sensor 180K may be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, which is also called a "touch screen". The touch sensor 180K is used to detect a touch operation acting thereon or nearby. The touch sensor can communicate the detected touch operation to the application processor to determine the touch event type. Visual output associated with the touch operation may be provided through the display screen 194. In other embodiments, the touch sensor 180K may be disposed on a surface of the electronic device 100, different from the position of the display screen 194.
Fig. 2 is a block diagram of a software structure of the electronic device 100 according to the embodiment of the present application. The layered architecture divides the software into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into four layers, an application layer, an application framework layer, an Android runtime (Android runtime) and system library, and a kernel layer from top to bottom. The application layer may include a series of application packages.
As shown in fig. 2, the application package may include applications such as camera, gallery, calendar, phone call, map, navigation, WLAN, bluetooth, music, video, short message, etc.
The application framework layer provides an Application Programming Interface (API) and a programming framework for the application program of the application layer. The application framework layer includes a number of predefined functions.
As shown in FIG. 2, the application framework layers may include a window manager, content provider, view system, phone manager, resource manager, notification manager, and the like.
The window manager is used for managing window programs. The window manager can obtain the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The content provider is used to store and retrieve data and make it accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
The view system includes visual controls such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
The phone manager is used to provide communication functions of the electronic device 100. Such as management of call status (including on, off, etc.).
The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and the like.
The notification manager enables the application to display notification information in the status bar, can be used to convey notification-type messages, can disappear automatically after a short dwell, and does not require user interaction. Such as a notification manager used to inform download completion, message alerts, etc. The notification manager may also be a notification that appears in the form of a chart or scroll bar text at the top status bar of the system, such as a notification of a background running application, or a notification that appears on the screen in the form of a dialog window. For example, prompting text information in the status bar, sounding a prompt tone, vibrating the electronic device, flashing an indicator light, etc.
The Android Runtime comprises a core library and a virtual machine. The Android runtime is responsible for scheduling and managing an Android system.
The core library comprises two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. And executing java files of the application program layer and the application program framework layer into a binary file by the virtual machine. The virtual machine is used for performing the functions of object life cycle management, stack management, thread management, safety and exception management, garbage collection and the like.
The system library may include a plurality of functional modules. For example: surface managers (surface managers), media libraries (media libraries), three-dimensional graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), and the like.
The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
The media library supports a variety of commonly used audio, video format playback and recording, and still image files, among others. The media library may support a variety of audio-video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like.
The 2D graphics engine is a drawing engine for 2D drawing.
The kernel layer is a layer between hardware and software. The inner core layer at least comprises a display driver, a camera driver, an audio driver and a sensor driver.
The following describes embodiments of the present application in detail.
Referring to fig. 3A, fig. 3A is a schematic flowchart of an image restoration method applied to an electronic device according to an embodiment of the present disclosure.
S301, the electronic equipment processes an image to be processed through first preprocessing;
wherein the first preprocessing mainly comprises a zooming operation, i.e. zooming the image to be processed to a preset size suitable for the first generator.
S302, inputting the preprocessed image to be processed into a first generator by the electronic equipment;
the image to be processed generates a basic feature map through an initial convolution layer in the first generator, the basic feature map is input into a basic neural network to obtain a target feature map through convolution and a nonlinear algorithm, and the target feature map performs semantic conversion through convolution processing to output the following target image.
And S303, the electronic equipment obtains a target image corresponding to the image to be processed output by the first generator, wherein the target image is the repaired image to be processed.
The target image is a high-quality image corresponding to the to-be-processed image, namely, the image noise is low and the resolution is high.
It can be seen that, in the embodiment of the present application, an electronic device processes an image to be processed through first preprocessing, and inputs the preprocessed image to be processed into a first generator, so as to obtain a target image corresponding to the image to be processed output by the first generator, where the target image is the repaired image to be processed. Therefore, the electronic equipment inputs the image to be processed into the first generator to obtain the repaired target image, convenience repair of the low-quality image is achieved, and the image is repaired only through the first generator without manual operation, so that the intelligence and the image repairing speed of image repair are improved.
In one possible example, the method further comprises:
establishing a generative confrontation network, wherein the generative confrontation network comprises a second generator and an arbiter;
and training the generative confrontation network through a preset data set to obtain the trained first generator.
The preset data set comprises a plurality of first images and corresponding second images, and the second images are high-quality first images.
And when the convergence of the objective function corresponding to the second generator and the discriminator meets the requirement, the first generator is obtained.
Therefore, in this example, the electronic device trains the established generation countermeasure network by using the preset data set to obtain the trained first generator and the first generator with better data enhancement effect, so that the first generator can effectively perform image restoration and improve the image restoration effect.
In this possible example, the preset data set includes a plurality of first images and a plurality of second images corresponding to the first images, the definition of the first images is smaller than a first threshold, the definition of the second images is greater than a second threshold, and the second images are images obtained by image processing of the first images.
For example, the first image may be an old photo image with low quality in the real world, and the second image may be a high quality image obtained by manually processing the first image.
As can be seen, in this example, the electronic device trains the generative confrontation network using the constructed real-world low-quality and high-quality old photo data set, and the obtained first generator better meets the requirement of image restoration, and the second image in the preset data set is obtained by performing data processing on the first image, instead of performing dimension reduction on the high-quality second image, and better meets the process of image restoration, which is beneficial to enhancing the restoration effect of the first generator.
In one possible example, the input of the second generator is the first image after passing the second pre-processing, the output of the second generator is a third image, and the definition of the third image is greater than the second threshold;
the input of the discriminator is the third image and the second image, and the output of the discriminator is a first probability value corresponding to the second image and a second probability value corresponding to the third image.
The second preprocessing includes processing operations such as flipping, mirroring, scaling, and the like, which is not limited herein.
Wherein the closer the third image generated by the second generator is to the second image, the closer the second probability value is to 1.
Wherein, in each generative confrontation network training process, 1 or more first images in a preset data set are input into the second generator.
In this possible example, the first image generates a basic feature map in the second generator through an initial convolutional layer, and inputs the basic feature map into a basic neural network to obtain a target feature map through convolutional and nonlinear algorithms, and the target feature map performs semantic conversion through convolutional processing to generate the third image.
Wherein the generative countermeasure network is shown in fig. 3B.
In this example, the electronic device determines the training result by judging the similarity between the generated third image and the real second image through the discriminant by using the generative countermeasure network, which is beneficial to improving the image restoration effect of the trained first generator.
In one possible example, the objective function of the second generator is:
Figure BDA0002513227690000081
Figure BDA0002513227690000082
Figure BDA0002513227690000083
l1 is the average value of the distances between the pixels at the corresponding positions in the second image and the third image, E represents the expected average value, x r Representing said second image, x f Representing the third image or images of the object,
Figure BDA0002513227690000091
representing a discriminator, f denotes a pre-trained convolutional neural network vgg19 network, I gt Representing said second image, I out Represents the third image, and λ and η are weight values.
In one possible example, the objective function of the discriminator is:
Figure BDA0002513227690000092
where E represents taking the desired mean, x r Representing said second image, x f Representing the third image or images of the object,
Figure BDA0002513227690000093
the discriminator is shown.
The generative confrontation network inputs one or more first images into a second generator, calculates an average value L1 of distances between pixel points one by one in a third image generated by the second generator and a corresponding second image, respectively sends the third image and the second image into a pre-trained vgg19 network to obtain a corresponding characteristic diagram, and then calculates a corresponding perception loss L per The generated third image and the second image are sent to a discriminator to obtain a generation loss L G Then obtaining the discriminator loss
Figure BDA0002513227690000094
Finally, the resulting generator losses
Figure BDA0002513227690000095
And a perceptual loss L per And L1 performs a weighted summation of different weights to train the generator to lose the discriminators
Figure BDA0002513227690000096
Training the discriminator, finishing one iteration, circulating in the way until the model convergence or the repairing effect meets the requirement, and terminating the training to obtainTo the trained first generator.
As can be seen, in this example, the electronic device trains the generative countermeasure network using the objective function, and there is no normalized BN layer in the network, so that the network is stable and has less noise, and downsampling is not performed, so that the obtained third image is more realistic, and the training result and thus the image restoration capability are improved.
Referring to fig. 4, fig. 4 is a schematic flowchart illustrating another image repairing method according to an embodiment of the present disclosure. As shown in the figure, the image restoration method includes the following operations:
s401, the electronic equipment establishes a generative confrontation network, and the generative confrontation network comprises a second generator and a discriminator.
S402, the electronic equipment trains the generation type countermeasure network through a preset data set to obtain a trained first generator, the preset data set comprises a plurality of first images and second images corresponding to the plurality of first images, the definition of the first images is smaller than a first threshold value, the definition of the second images is larger than a second threshold value, and the second images are images obtained by processing the first images.
S403, the electronic equipment processes the image to be processed through first preprocessing.
S404, the electronic equipment inputs the preprocessed image to be processed into the first generator.
S405, the electronic device obtains a target image corresponding to the image to be processed output by the first generator, wherein the target image is the repaired image to be processed.
It can be seen that, in the embodiment of the present application, an electronic device processes an image to be processed through first preprocessing, and inputs the preprocessed image to be processed into a first generator, so as to obtain a target image corresponding to the image to be processed output by the first generator, where the target image is the repaired image to be processed. Therefore, the electronic equipment inputs the image to be processed into the first generator to obtain the repaired target image, so that the convenience and the convenience of repairing the low-quality image are realized, and the image is repaired only by the first generator without manual operation, so that the intelligence and the image repairing speed of image repairing are improved.
In addition, the electronic equipment trains the established generation countermeasure network by utilizing the preset data set to obtain the trained first generator and the first generator with better data enhancement effect, so that the first generator can effectively recover images and improve the image restoration effect.
In addition, the electronic equipment trains the generative confrontation network by using the constructed real-world low-quality and high-quality old photo data set, the obtained first generator better meets the requirement of image restoration, and the second image in the preset data set is the first image obtained by performing data processing on the first image instead of performing dimension reduction on the high-quality second image, so that the image restoration process is better met, and the restoration effect of the first generator is favorably enhanced.
The embodiment of the application provides an image restoration device, which can be an electronic device 100. Specifically, the image restoration apparatus is configured to perform the steps of the above image restoration method. The image restoration device provided by the embodiment of the application can comprise modules corresponding to the corresponding steps.
The embodiment of the present application may perform division of function modules for the image restoration apparatus according to the method example described above, for example, each function module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The division of the modules in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation.
Fig. 5 shows a schematic diagram of a possible structure of the image restoration apparatus according to the above embodiment, in the case of dividing each functional module according to each function. As shown in fig. 5, the image restoration apparatus 500 includes a processing unit 501, an input unit 502, and an acquisition unit 503, in which:
the processing unit 501 is configured to process an image to be processed through a first preprocessing;
the input unit 502 is configured to input the pre-processed image to be processed into a first generator;
the obtaining unit 503 is configured to obtain a target image corresponding to the to-be-processed image output by the first generator, where the target image is the to-be-processed image after being repaired.
All relevant contents of the steps related to the method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again. Of course, the image restoration device provided in the embodiments of the present application includes, but is not limited to, the above modules, for example: the image restoration apparatus may further include a storage unit. The storage unit may be used to store program codes and data of the image restoration apparatus.
In the case of using an integrated unit, a schematic structural diagram of an image restoration device provided in an embodiment of the present application is shown in fig. 6. In fig. 6, an image restoration apparatus 600 includes: a processing module 602 and a communication module 601. The processing module 602 is used to control and manage the actions of the image restoration apparatus, for example, to execute the steps performed by the processing unit 501, the input unit 502, and the acquisition unit 503, and/or to perform other processes of the techniques described herein. The communication module 601 is used to support interaction between the image restoration apparatus and other devices, or between modules inside the image restoration apparatus. As shown in fig. 6, the image restoration apparatus may further include a storage module 603, and the storage module 603 is configured to store program codes and data of the image restoration apparatus, for example, contents stored in the storage unit.
The Processing module 602 may be a Processor or a controller, and may be, for example, a Central Processing Unit (CPU), a general-purpose Processor, a Digital Signal Processor (DSP), an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor may also be a combination of computing functions, e.g., comprising one or more microprocessors, DSPs, and microprocessors, among others. The communication module 601 may be a transceiver, a radio frequency circuit or a communication interface, etc. The storage module 603 may be a memory.
All relevant contents of each scene related to the method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again. Both the image restoration apparatus 500 and the image restoration apparatus 600 can perform the image restoration method shown in any one of fig. 3A to 4.
The present embodiment also provides a computer storage medium, where computer instructions are stored, and when the computer instructions are run on an electronic device, the electronic device is caused to execute the above related method steps to implement the operation method in the above embodiment.
The present embodiment also provides a computer program product, which when running on a computer, causes the computer to execute the relevant steps described above, so as to implement the image inpainting method in the above embodiments.
In addition, embodiments of the present application also provide an apparatus, which may be specifically a chip, a component or a module, and may include a processor and a memory connected to each other; the memory is used for storing computer execution instructions, and when the device runs, the processor can execute the computer execution instructions stored in the memory, so that the chip can execute the image repairing method in the above-mentioned method embodiments.
The electronic device, the computer storage medium, the computer program product, or the chip provided in this embodiment are all configured to execute the corresponding method provided above, so that the beneficial effects achieved by the electronic device, the computer storage medium, the computer program product, or the chip may refer to the beneficial effects in the corresponding method provided above, and are not described herein again.
Through the description of the above embodiments, those skilled in the art will understand that, for convenience and simplicity of description, only the division of the above functional modules is used as an example, and in practical applications, the above function distribution may be completed by different functional modules as needed, that is, the internal structure of the device may be divided into different functional modules to complete all or part of the above described functions.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described embodiments of the apparatus are merely illustrative, and for example, a module or a unit may be divided into only one logic function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another apparatus, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed to a plurality of different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially or partially contributed to by the prior art, or all or part of the technical solutions may be embodied in the form of a software product, where the software product is stored in a storage medium and includes several instructions to enable a device (which may be a single chip, a chip, or the like) or a processor (processor) to execute all or part of the steps of the methods of the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (8)

1. An image restoration method applied to an electronic device, the method comprising:
processing an image to be processed through first preprocessing;
inputting the preprocessed image to be processed into a first generator;
obtaining a target image corresponding to the image to be processed output by the first generator, wherein the target image is the repaired image to be processed;
the method further comprises the following steps: establishing a generative confrontation network, wherein the generative confrontation network comprises a second generator and an arbiter; training the generative countermeasure network through a preset data set to obtain a trained first generator, wherein the preset data set comprises a plurality of first images and second images corresponding to the plurality of first images, the second images are images obtained by image processing of the first images, the input of the second generator is the first images subjected to second preprocessing, and the output of the second generator is a third image;
the objective function of the second generator is:
Figure FDA0003723042910000011
Figure FDA0003723042910000012
Figure FDA0003723042910000013
wherein L is G Is an objective function of the second generator,
Figure FDA0003723042910000014
for generator losses, L per For perception of loss, L 1 Is the average value of the distances between the pixel points at the corresponding positions in the second image and the third image, E represents the expected average value, x r Representing said second image, x f Representing the third image or images of the object,
Figure FDA0003723042910000015
representing the arbiter, f denotes the pre-trained convolutional neural network vgg19 network, I gt Representing said second image, I out Represents the third image, and λ and η are weight values.
2. The method of claim 1, wherein the sharpness of the first image is less than a first threshold and the sharpness of the second image is greater than a second threshold.
3. The method of claim 2, wherein the sharpness of the third image is greater than the second threshold;
the input of the discriminator is the third image and the second image, and the output of the discriminator is a first probability value corresponding to the second image and a second probability value corresponding to the third image.
4. The method of claim 3, wherein the first image is generated in the second generator by an initial convolutional layer to generate a basic feature map, and the basic feature map is input into a basic neural network to obtain a target feature map through convolutional and nonlinear algorithms, and the target feature map is subjected to semantic conversion through convolutional processing to generate the third image.
5. The method according to any one of claims 1 to 4, wherein the objective function of the discriminator is:
Figure FDA0003723042910000016
where E represents taking the desired mean, x r Representing said second image, x f Representing the third image or images of the object,
Figure FDA0003723042910000017
the discriminator is shown.
6. An image restoration apparatus applied to an electronic device, the image restoration apparatus comprising a processing unit, an input unit, and an acquisition unit, wherein:
the processing unit is used for processing the image to be processed through first preprocessing;
the input unit is used for inputting the preprocessed image to be processed into a first generator;
the acquisition unit is used for acquiring a target image corresponding to the image to be processed output by the first generator, wherein the target image is the repaired image to be processed;
the processing unit is further configured to establish a generative confrontation network, where the generative confrontation network includes a second generator and an arbiter; training the generative countermeasure network through a preset data set to obtain a trained first generator, wherein the preset data set comprises a plurality of first images and second images corresponding to the plurality of first images, the second images are images obtained by image processing of the first images, the input of the second generator is the first images subjected to second preprocessing, and the output of the second generator is a third image;
the objective function of the second generator is:
Figure FDA0003723042910000021
Figure FDA0003723042910000022
Figure FDA0003723042910000023
wherein L is G Is an objective function of the second generator,
Figure FDA0003723042910000024
for generator losses, L per For perception of loss, L 1 The average value of the distances between the pixel points at the corresponding positions in the second image and the third image is represented by E, which is an expected average value, x r Representing said second image, x f Is representative of the third image or images,
Figure FDA0003723042910000025
representing the arbiter, f denotes the pre-trained convolutional neural network vgg19 network, I gt Representing said second image, I out Represents the third image, and λ and η are weight values.
7. An electronic device comprising a processor, a memory, a communication interface, and one or more programs stored in the memory and configured to be executed by the processor, the programs comprising instructions for performing the steps in the method of any of claims 1-5.
8. A computer-readable storage medium, characterized in that a computer program for electronic data exchange is stored, wherein the computer program causes a computer to perform the method according to any one of claims 1-5.
CN202010472105.2A 2020-05-28 2020-05-28 Image restoration method and device Active CN111612723B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010472105.2A CN111612723B (en) 2020-05-28 2020-05-28 Image restoration method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010472105.2A CN111612723B (en) 2020-05-28 2020-05-28 Image restoration method and device

Publications (2)

Publication Number Publication Date
CN111612723A CN111612723A (en) 2020-09-01
CN111612723B true CN111612723B (en) 2022-08-09

Family

ID=72201704

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010472105.2A Active CN111612723B (en) 2020-05-28 2020-05-28 Image restoration method and device

Country Status (1)

Country Link
CN (1) CN111612723B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112381725B (en) * 2020-10-16 2024-02-02 广东工业大学 Image restoration method and device based on depth convolution countermeasure generation network
CN113160079A (en) * 2021-04-13 2021-07-23 Oppo广东移动通信有限公司 Portrait restoration model training method, portrait restoration method and device

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7555620B1 (en) * 2006-04-28 2009-06-30 Network Appliance, Inc. Method and system of using a backup image for multiple purposes
CN110889813A (en) * 2019-11-15 2020-03-17 安徽大学 Low-light image enhancement method based on infrared information

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10880566B2 (en) * 2015-08-28 2020-12-29 Boe Technology Group Co., Ltd. Method and device for image encoding and image decoding
CN110020996A (en) * 2019-03-18 2019-07-16 浙江传媒学院 A kind of image repair method based on Prior Knowledge Constraints, system and computer equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7555620B1 (en) * 2006-04-28 2009-06-30 Network Appliance, Inc. Method and system of using a backup image for multiple purposes
CN110889813A (en) * 2019-11-15 2020-03-17 安徽大学 Low-light image enhancement method based on infrared information

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"面向部分遮挡人脸识别的研究与实现 ";陈灿林;《《中国优秀硕士学位论文全文数据库 (信息科技辑)》》;20200115;I138-1782 *
Underwater-GAN: Underwater Image Restoration via Conditional Generative Adversarial Network;Xiaoli Yu;《International Conference on Pattern Recognition》;20181219;66–75页 *
基于条件生成对抗网络的模糊图像修复的研究;樊晶华;《中国优秀硕士学位论文全文数据库 (信息科技辑)》;20200315;I138-1177 *

Also Published As

Publication number Publication date
CN111612723A (en) 2020-09-01

Similar Documents

Publication Publication Date Title
CN111738122B (en) Image processing method and related device
CN111782879B (en) Model training method and device
CN111553846B (en) Super-resolution processing method and device
CN111768416B (en) Photo cropping method and device
CN112598594A (en) Color consistency correction method and related device
CN111669462B (en) Method and related device for displaying image
CN111400605A (en) Recommendation method and device based on eyeball tracking
WO2021008551A1 (en) Fingerprint anti-counterfeiting method, and electronic device
CN111768352A (en) Image processing method and device
CN110830645B (en) Operation method, electronic equipment and computer storage medium
CN111882642B (en) Texture filling method and device for three-dimensional model
WO2021238373A1 (en) Method for unlocking by means of gaze and electronic device
CN111612723B (en) Image restoration method and device
CN111524528B (en) Voice awakening method and device for preventing recording detection
CN111880661A (en) Gesture recognition method and device
CN114422686A (en) Parameter adjusting method and related device
CN111767016A (en) Display processing method and device
CN111381996A (en) Memory exception handling method and device
CN113781959B (en) Interface processing method and device
CN111581119B (en) Page recovery method and device
CN115390738A (en) Scroll screen opening and closing method and related product
CN111836226B (en) Data transmission control method, device and storage medium
CN115083424A (en) Person analysis system, method and related device
CN111953452A (en) Method and device for detecting SSB serial number
CN112528760B (en) Image processing method, device, computer equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant