Image processing method and electronic device
By processing the image difference data collected by the phase photosensitive element, the neural network model is used to improve the accuracy of the focus information, solving the problem of difficulty in focusing in dark light or weak texture scenes with the existing technology, and achieving higher image clarity.
Patent Information
- Application Number
- CN202310962315.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-01
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-08-01
AI Technical Summary
Existing phase focusing methods are difficult to accurately predict the focus position in dark light or weak texture scenes, resulting in low image clarity and low accuracy of neural network model focus information.
By obtaining the difference data of the first image and the second image collected by the phase photosensitive element, the trained neural network model is used to process the data to determine the focus information, and the influence of the difference data is considered to improve the accuracy of the focus information.
The accuracy of focus results in different scenarios is improved, ensuring that the images collected by the sensor are clearer after the lens is moved.
Smart Images

Figure CN117714860B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and more specifically, to an image processing method and an electronic device. Background Art
[0002] With the rapid development of electronic technology and image processing technology, the camera functions of smart terminals such as smartphones and tablet computers are becoming more and more powerful, and the camera capabilities of some smart terminals are even comparable to those of ordinary digital cameras. In the process of taking pictures with smart terminals, in order to take pictures with better clarity, it is necessary to focus on the image of the current scene, that is, to adjust the position of the lens according to the current scene to obtain the highest definition photo.
[0003] The phase focusing method determines the focus position by processing the data collected by a sensor including multiple phase photosensitive element pairs. In the sensor, the first photosensitive element and the second photosensitive element in each phase photosensitive element pair are respectively used to receive light from different side areas of the pixel. The focus information can be determined by detecting the distance between the first image collected by the first photosensitive element in the sensor and the second image collected by the second photosensitive element in the sensor. After the lens is moved according to the focus information, the image is collected using the sensor, which can achieve a higher definition of the image.
[0004] However, in some specific scenes, such as dark scenes, weak texture scenes (such as snowy mountains, sky, white walls, etc.), the phase focusing method based on the distance between the first image and the second image often cannot predict the focus position, making it difficult to obtain a clear image. The accuracy of the focus information determined by processing the first image and the second image through the neural network model is low. Summary of the invention
[0005] The present application provides an image processing method and electronic equipment, which can improve the accuracy of phase focusing results.
[0006] In a first aspect, an image processing method is provided, the method comprising: acquiring data to be processed, the data to be processed comprising a first image, a second image and difference data, the difference data representing the difference between the first image and the second image, the first image and the second image being images respectively obtained by a first element set and a second element set in a sensor when a lens is located at an initial position, the first element set comprising a plurality of first photosensitive elements, each first photosensitive element being used to receive light transmitted through the lens to a first side of a pixel where the first photosensitive element is located, the second element set comprising a plurality of second photosensitive elements, each second photosensitive element being used to receive light transmitted through the lens to a second side of a pixel where the second photosensitive element is located, the first side being opposite to the direction represented by the second side; processing the data to be processed using a processing model to obtain focus information, the focus information representing a movement vector of the lens, the processing model being a trained neural network model.
[0007] The image processing method provided in the embodiment of the present application considers the influence of the difference between the first image and the second image during the process of determining the focus information, so that the determined focus information is more accurate.
[0008] In a possible implementation, the acquiring of the data to be processed includes: performing feature extraction on the first image and the second image respectively to obtain a first feature of the first image and a second feature of the second image, and the difference data includes a feature difference between the first feature and the second feature.
[0009] The difference data includes feature differences between features of the first image and the second image, so that the obtained focus information is more accurate.
[0010] In a possible implementation, the feature extraction is performed on the first image and the second image respectively to obtain a first feature of the first image and a second feature of the second image, including: performing feature extraction on the first image using a first feature extraction model to obtain the first feature; performing feature extraction on the second image using a second feature extraction model to obtain the second feature, and the parameters of the first feature extraction model and the second feature extraction model are the same.
[0011] The first feature extraction model and the second feature extraction model with the same parameters respectively extract features from the first image and the second image, so that the feature extraction from the first image and the second image can be performed in parallel, thereby improving processing efficiency.
[0012] In a possible implementation, the first feature includes a first sub-feature output by each of the multiple first feature extraction layers in the first feature extraction model, the second feature includes a second sub-feature output by each of the multiple second feature extraction layers in the second feature extraction model, the feature difference includes a plurality of layer difference features corresponding to the multiple first feature extraction layers, the layer difference feature corresponding to each first feature extraction layer is the difference between the first sub-feature output by the first feature extraction layer and the second sub-feature output by the second feature extraction layer corresponding to the first feature extraction layer, and each first feature extraction layer has the same parameters as the second feature extraction layer corresponding to the first feature extraction layer.
[0013] The influence of different features of multiple layers is considered to make the focus information more accurate.
[0014] In one possible implementation, the processing model is used to process the data to be processed and the difference data, including: inputting the layer difference features corresponding to each first feature extraction layer into the processing layer corresponding to the first feature extraction layer in the processing model, different first feature extraction layers correspond to different processing layers, and the depth of the processing layer corresponding to each first feature extraction layer is positively correlated with the depth of the first feature extraction layer.
[0015] Different layer difference feature inputs process different processing layers in the model, and the depth of the first feature extraction layer corresponding to the layer difference feature is positively correlated with the depth of the processing layer of the layer difference feature input. The processing layers of multiple layer difference feature inputs are more reasonable, so that the obtained focus information is more accurate.
[0016] In a possible implementation manner, the difference data includes a difference image, and a pixel value of each pixel in the difference image represents a difference between pixel values of the first image and the second image at the pixel.
[0017] The difference data includes a difference image, so that the obtained focus information is more accurate.
[0018] The difference image can be fed into the input layer of the processing model.
[0019] In a possible implementation, the processing model is obtained by training an initial processing model using training data, the training data including training samples and annotated focus information, the sample data including a first training image, a second training image and training difference data, the training difference data indicating a difference between the first training image and the second training image, the first training image and the second training image being images respectively obtained by a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position, the first training element set including a plurality of first training photosensitive elements, each first training photosensitive element being used to receive light transmitted through the training lens to the first side of a pixel where the first photosensitive element is located, and the second training element set including a plurality of second training element sets. training photosensitive elements, each second training photosensitive element is used to receive the light transmitted from the training lens to the second side of the pixel where the second photosensitive element is located, the annotated focus information represents the training movement vector of the training lens, the target training position to which the training lens moves according to the training movement vector is a position among multiple positions of the training lens where the image contrast of the area located in the focus area in the image captured by the training sensor for the scene recorded by the first training image is the highest, and the focus area is located in the area where the first training image is located; the training comprises: processing the sample data using the initial processing model to obtain the training focus information; adjusting the parameters of the initial processing model according to the difference between the training focus information and the annotated focus information to obtain the processing model.
[0020] In a second aspect, a neural network model training method is provided, the method comprising: acquiring training data, the training data comprising sample data and annotated focus information, the sample data comprising a first training image, a second training image and training difference data, the training difference data representing the difference between the first training image and the second training image, the first training image and the second training image being images acquired by respectively capturing a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position, the first training element set comprising a plurality of first training photosensitive elements, each first training photosensitive element being used to receive light transmitted through the training lens to a first side of a pixel where the first training photosensitive element is located, the second training element set comprising a plurality of second training photosensitive elements, each second training photosensitive element being used to The method comprises: receiving light transmitted to a second side of a pixel where the second photosensitive element is located through the training lens, the first side and the second side are in opposite directions, the annotated focus information represents a training movement vector of the training lens, and the target training position to which the training lens is moved according to the training movement vector is a position among multiple positions of the training lens where the image contrast of a region located in a focus area in an image captured by the training sensor for the scene recorded by the first training image is the highest, and the focus area is located in the region where the first training image is located; processing the sample data using an initial processing model to obtain training focus information; adjusting the parameters of the initial processing model according to the difference between the training focus information and the annotated focus information to minimize the difference, and the initial processing model after the parameter adjustment is the processing model obtained through training.
[0021] In a possible implementation, the acquiring of training data includes: performing feature extraction on a first training image using a first initial feature extraction model to obtain a first training feature; performing feature extraction on a second training image using a second initial feature extraction model to obtain a second training feature, and the training difference data includes a training feature difference between the first training feature and the second training feature; and adjusting the parameters of the initial processing model according to the difference between the training focus information and the annotated focus information includes: adjusting the parameters of the initial processing model, the parameters of the first initial feature extraction model, and the parameters of the second initial feature extraction model according to the difference between the training focus information and the annotated focus information.
[0022] In a possible implementation, the first initial feature extraction model has the same parameters as the second initial feature extraction model, and the adjusted parameters of the first initial feature extraction model have the same parameters as the adjusted parameters of the second initial feature extraction model.
[0023] In a possible implementation, the first training feature includes a first training sub-feature output by each of the multiple first initial feature extraction layers of the first initial feature extraction model, the second training feature includes a second training sub-feature output by each of the multiple second initial feature extraction layers of the second initial feature extraction model, the training feature difference includes a plurality of training layer difference features corresponding to the multiple first initial feature extraction layers, the training layer difference feature corresponding to each first initial feature extraction layer is the difference between the first training sub-feature output by the first initial feature extraction layer and the second training sub-feature output by the second initial feature extraction layer corresponding to the first initial feature extraction layer, and the parameters of each first initial feature extraction layer and the second initial feature extraction layer corresponding to the first initial feature extraction layer are the same.
[0024] In one possible implementation, different first initial feature extraction layers correspond to different processing layers of the processing model; the sample data is processed using the initial processing model to obtain training focus information, including: inputting the training layer difference features corresponding to each first initial feature extraction layer into the processing layer corresponding to the feature extraction layer in the initial processing model, and different first initial feature extraction layers correspond to different initial processing layers.
[0025] In a possible implementation manner, the training difference data includes a training difference image, and a pixel value of each pixel in the training difference image represents a difference between pixel values of the pixel in the first training image and the second training image.
[0026] In a third aspect, an image processing device is provided, comprising various units for executing the method in the first aspect. The device may be an electronic device or a chip in an electronic device.
[0027] In a fourth aspect, a neural network model training device is provided, comprising various units for executing the method of the second aspect.
[0028] In a fifth aspect, an electronic device is provided, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the electronic device executes the method of the first aspect or the second aspect.
[0029] A sixth aspect provides a chip, comprising a processor. When the processor executes instructions, the processor executes the method of the first aspect or the second aspect.
[0030] In a seventh aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program code, and the computer program code is used to implement the method of the first aspect or the second aspect.
[0031] In an eighth aspect, a computer program product is provided, the computer program product comprising: a computer program code, wherein the computer program code is used to implement the method of the first aspect or the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a schematic diagram of a hardware system of an electronic device applicable to the present application;
[0033] Figure 2 is a schematic diagram of a software system for an electronic device applicable to the present application;
[0034] Figure 3 is a schematic diagram of an image acquisition scenario;
[0035] Figure 4 It is a schematic diagram of the focus position;
[0036] Figure 5 It is a schematic structural diagram of a neural network model;
[0037] Figure 6 is a schematic flow chart of an image processing method provided in an embodiment of the present application;
[0038] Figure 7 is a schematic structural diagram of a phase photosensitive element pair;
[0039] Figure 8 is a schematic structural diagram of an image processing system provided in an embodiment of the present application;
[0040] Fig. 9 is a schematic flow chart of a neural network model training method provided in an embodiment of the present application;
[0041] Fig.10 is a schematic diagram of a graphical user interface provided in an embodiment of the present application;
[0042] Fig.11 is a schematic flow chart of a data processing method provided in an embodiment of the present application;
[0043] Fig.12 is a schematic structural diagram of an image processing device provided by the present application;
[0044] Fig.13 It is a schematic structural diagram of an electronic device for image processing provided by the present application. DETAILED DESCRIPTION
[0045] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0046] Figure 1 A hardware system of an electronic device suitable for the present application is shown.
[0047] The method provided in the embodiments of the present application can be applied to various electronic devices capable of network communication, such as mobile phones, tablet computers, wearable devices, laptop computers, netbooks, personal digital assistants (PDAs), etc. The embodiments of the present application do not impose any restrictions on the specific types of electronic devices.
[0048] Figure 1 1 shows a schematic diagram of the structure of the 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 charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a gyroscope 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, etc.
[0049] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0050] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0051] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0052] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0053] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0054] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.
[0055] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.
[0056] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0057] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.
[0058] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.
[0059] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0060] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0061] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0062] The charging management module 140 is used 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 through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0063] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0064] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0065] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0066] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0067] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0068] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0069] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0070] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0071] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0072] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0073] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0074] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0075] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0076] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0077] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0078] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0079] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0080] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0081] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0082] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0083] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0084] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
[0085] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0086] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
[0087] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.
[0088] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
[0089] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.
[0090] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.
[0091] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
[0092] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.
[0093] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0094] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.
[0095] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
[0096] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0097] The bone conduction sensor 180M can obtain a vibration signal. In some embodiments, the bone conduction sensor 180M can obtain a vibration signal of a vibrating bone block of the vocal part of the human body. The bone conduction sensor 180M can also contact the human pulse to receive a blood pressure beat signal. In some embodiments, the bone conduction sensor 180M can also be set in an earphone and combined into a bone conduction earphone. The audio module 170 can parse out a voice signal based on the vibration signal of the vibrating bone block of the vocal part obtained by the bone conduction sensor 180M to realize a voice function. The application processor can parse the heart rate information based on the blood pressure beat signal obtained by the bone conduction sensor 180M to realize a heart rate detection function.
[0098] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0099] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0100] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0101] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0102] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0103] Figure 2 1 is a software structure diagram of the electronic device 100 of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the system library of the Android runtime (Android runtime), and the kernel layer. The application layer can include a series of application packages.
[0104] like Figure 2 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0105] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0106] like Figure 2 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0107] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0108] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0109] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0110] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).
[0111] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0112] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0113] Android runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0114] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0115] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0116] The system library may include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0117] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0118] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0119] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0120] A 2D graphics engine is a drawing engine for 2D drawings.
[0121] The kernel layer is the layer between hardware and software. The kernel layer can include driver modules such as display driver, camera driver, audio driver and sensor driver.
[0122] With the rapid development of electronic technology and image processing technology, the camera functions of smart terminals such as smartphones and tablet computers are becoming more and more powerful, and the camera capabilities of some smart terminals are even comparable to those of ordinary digital cameras. In the process of taking pictures with smart terminals, in order to take pictures with better clarity, it is necessary to focus on the image of the current scene, that is, to adjust the position of the lens according to the current scene to obtain the highest definition photo.
[0123] Focusing is the process of changing the distance and position of the subject through the camera's focus mechanism to make the image of the subject clear. Focusing is also called focusing on light or focusing.
[0124] The camera 193 includes a lens and a sensor. A plurality of phase photosensitive element pairs may be provided in the sensor, and the first photosensitive element and the second photosensitive element in each phase photosensitive element pair are respectively used to receive light from different side areas of the pixel. Thus, the image collected by the sensor is processed using the phase detection auto focus (PDAF) technology to determine the focus position.
[0125] PDAF technology can also be called phase focusing technology. By detecting the distance between the first image captured by the first element set in the sensor and the second image captured by the second element set in the sensor, the focus position can be determined. The first photosensitive element in the first element set and the second photosensitive element in the second element set are respectively used to detect light on different sides of the pixel where the photosensitive element is located. By pushing the lens to the focus position and using the sensor to capture the image again, an image with higher clarity can be obtained.
[0126] However, under certain lighting conditions or scenes with specific image content, PDAF technology often cannot predict the focus position, so it is difficult to obtain a clear image using the phase focusing method. Figure 3 The scene with the portrait in backlight as shown in (a) Figure 3 (b) in the scene with a zigzag pattern or other repeated textures, such as Figure 3 For scenes with weak texture or low contrast, such as the white wall shown in (c) Figure 3 The high-contrast scene shown in (d) is Figure 3 In a scene where the display content shown in (e) includes a lot of moiré patterns, the PDAF technology cannot accurately predict the focus position.
[0127] by Figure 3 Taking the white wall shown in (c) as an example, the white wall area is divided into multiple detection areas, and the focus position determined by the PDAF technology for each detection area is as follows: Figure 4 shown. Figure 4 In the figure, different values on the horizontal axis represent different areas, and the vertical axis represents the focus position determined by PDAF technology. Figure 4 It can be seen that the focus position determined by the PDAF technology has large fluctuations and is inaccurate, so that the clarity of the image captured by the sensor is still low after the lens moves to the focus position.
[0128] In order to increase the range of applicable scenarios of PDAF technology and improve the accuracy of the determined focus position, so that the sensor can stably capture clear images when the lens moves to the focus position, the trained neural network model can be used to process the first image and the second image captured by the sensor.
[0129] like Figure 5 As shown, the focus position can be obtained by processing the first image and the second image using the neural network model 500. The neural network model 500 may include an input layer 510, a plurality of hidden layers 521 to 524, and an output layer 530.
[0130] The input layer 510 is only responsible for inputting data.
[0131] All layers between the input layer and the output layer in the neural network model can be called hidden layers. The initial hidden layer (e.g., hidden layer 511) often extracts more general features, which can also be called low-level features; as the depth of the convolutional neural network model increases, the features extracted by the later hidden layers (e.g., hidden layer 514) become more and more complex, such as high-level semantic features. It should be understood that features with higher semantics are more suitable for the problem to be solved. The depth of hidden layers 521 to 524 gradually increases.
[0132] The output layer 530 is responsible for outputting the prediction results of the neural network model 500.
[0133] The neural network model 500 is used to process the first image and the second image collected by the phase sensing element in the sensor. Figure 3 The prediction of the focus position is realized in the various scenarios shown, and has a relatively wide range of applications. However, the accuracy of the focus position obtained by the neural network model is low.
[0134] In order to solve the above problems, the embodiments of the present application provide an image processing method and an electronic device.
[0135] Combine the following Figures 6 to 8 The image processing method provided in the embodiment of the present application is described in detail.
[0136] Figure 6 It is a schematic flow chart of the image processing method provided in an embodiment of the present application.
[0137] Figure 6 The image processing method shown includes steps S610 to S620, which are described in detail below.
[0138] Step S610, obtaining data to be processed, wherein the data to be processed includes a first image, a second image and difference data, wherein the difference data indicates the difference between the first image and the second image, wherein the first image and the second image are images respectively obtained by a first element set and a second element set in the sensor when the lens is in an initial position, wherein the first element set includes a plurality of first photosensitive elements, each of which is used to receive light transmitted through the lens to a first side of a pixel where the first photosensitive element is located, and the second element set includes a plurality of second photosensitive elements, each of which is used to receive light transmitted through the lens to a second side of a pixel where the second photosensitive element is located, and the first side is opposite to the direction indicated by the second side.
[0139] The first image and the second image may be referred to as a left image and a right image, respectively.
[0140] The camera may include a lens and a sensor. The sensor includes a plurality of photosensitive elements. The plurality of photosensitive elements may be arranged as a photosensitive element array. In order to achieve phase focusing, a phase photosensitive element pair may be arranged in the sensor. Each phase photosensitive element pair includes a first photosensitive element and a second photosensitive element.
[0141] In some embodiments, the phase photosensitive element pair can be a dual pixel formed by blocking. Blocking one side of the photosensitive element can form a first photosensitive element and a second photosensitive element, wherein the second side of the first photosensitive element is blocked and the first side of the second photosensitive element is blocked. The first side and the second side represent opposite directions. For example, Figure 7 The first side and the second side shown in (a) may be an upper side and a lower side, respectively. Figure 7 The first side and the second side shown in (b) may be the left side and the right side, respectively. Figure 7 The first side and the second side shown in (c) may be the upper left side and the lower right side, respectively.
[0142] In the sensor, the first photosensitive element and the second photosensitive element in each phase photosensitive element pair may have the same relative position relationship.
[0143] The first photosensitive element and the second photosensitive element in a phase photosensitive element pair can be arranged adjacent to each other. For example, the first photosensitive element and the second photosensitive element are located in the same row, and the first photosensitive element is located in a column adjacent to the second photosensitive element; or, the first photosensitive element and the second photosensitive element are located in the same column, and the first photosensitive element is located in a row adjacent to the second photosensitive element; or, the first photosensitive element and the second photosensitive element in a phase photosensitive element pair can be located in adjacent rows and adjacent columns, respectively. The phase photosensitive element pair can also have other arrangements, which are not limited in the embodiments of the present application.
[0144] The first photosensitive element and the second photosensitive element in the phase photosensitive element pair formed by shielding can be arranged in different pixels.
[0145] It should be understood that the closer the distance between the first photosensitive element and the second photosensitive element constituting a phase photosensitive element pair is, the more accurate the focus information determined based on the first image and the second image is.
[0146] In some other embodiments, the phase sensing element pair may be disposed in the same pixel.
[0147] Two phase photosensitive elements may be provided in each pixel. Each photosensitive element may be used to receive light on the side of the pixel where the photosensitive element is located. The two phase photosensitive elements in a pixel are respectively a first photosensitive element and a second photosensitive element.
[0148] For example, Figure 7 As shown in (d), each pixel can have 4 photosensitive units arranged in 2×2. The two photosensitive units on the left side of each pixel can be used as the first photosensitive element, and the two photosensitive units on the right side of each pixel can be used as the second photosensitive element. Alternatively, the two photosensitive units on the upper side of each pixel can be used as the first photosensitive element, and the two photosensitive units on the lower side of each pixel can be used as the second photosensitive element. Alternatively, the two photosensitive units at the two vertices of the diagonal line in each pixel, that is, two non-adjacent photosensitive units, can be used as the first photosensitive element and the second photosensitive element, respectively. Using Figure 7 The phase detection performed by the sensor in the arrangement of the phase photosensitive element shown in (d) can be called quad phase detection (QPD).
[0149] The initial position of the lens can be any position within the range of the lens movement.
[0150] In the sensor, the phase photosensitive element pairs can be arranged in an array. That is, the arrangement of the phase photosensitive element pairs can form a phase photosensitive element pair array. When the lens is in the initial position, the data collected by each first photosensitive element can form a first image, and the data collected by each second photosensitive element can form a second image.
[0151] The first image and the second image may be images captured by all phase photosensitive element pairs in the sensor, or images captured by some phase photosensitive element pairs in the sensor. Exemplarily, the first image and the second image may be images located in the focus frame area of the sensor. The focus frame area may have a preset size, or the size of the focus frame area may be determined according to user operation. The position of the focus frame area may be preset, or may be determined by an electronic device equipped with the sensor and the lens according to an image captured by the sensor, or may be determined by the electronic device according to user operation. It should be understood that the first image is the same size as the second image.
[0152] Fig.10 (a) of the figure shows a graphical user interface (GUI) of the electronic device, which is a desktop 1010 of the electronic device. When the electronic device detects that a user clicks on an icon 1011 of a camera application (application, APP) on the desktop 1010, the camera application can be started and a display such as Fig.10 Another GUI shown in (b) of FIG. 1 may be referred to as a shooting interface 1020. The shooting interface 1020 may include a viewfinder 1021. In a preview state, a preview image may be displayed in real time in the viewfinder 1021.
[0153] Different positions in the viewfinder correspond to different positions in the sensor. When the electronic device detects that the user clicks in the viewfinder 1021, the position in the sensor corresponding to the user's click position can be used as the position of the center of the focus frame area.
[0154] When the size of the focus frame area is a preset size, the focus frame area in the sensor can be determined according to the position of the center of the focus frame area. When the size of the focus frame area can be determined according to user operation, size icons of multiple focus frame sizes can also be displayed on the shooting interface 1020. When the electronic device detects that the user clicks on a size icon on the shooting interface 1020, the size corresponding to the size icon can be used as the size of the focus frame area. Thus, the electronic device can determine the focus frame area in the sensor according to the position of the center of the focus frame area and the size of the focus frame area.
[0155] In the case where the first image and the second image are images of the focus frame area, the data to be processed may also include position information, which is used to indicate the position of the focus frame area. Exemplarily, the position information may be indicated as the position of the center point of the focus frame area, and the position information may be the coordinates of the center point.
[0156] Exemplarily, the data to be processed may also include image position information, which indicates the position of the first image in the image captured by the sensor. The position of the first image in the image captured by the sensor may also be understood as the position of the second image in the image captured by the sensor or the position of the focus frame area. The image position information may include the position coordinates of the center point of the first image, and may also include other information such as the size of the first image.
[0157] Step S620: Process the data to be processed by using a processing model to obtain focus information, where the focus information represents a movement vector of the lens, and the processing model is a trained neural network model.
[0158] It should be understood that the neural network model in the embodiments of the present application can be a deep neural network.
[0159] A deep neural network (DNN), also known as a multi-layer neural network, can be understood as a neural network with multiple hidden layers. According to the position of different layers, the neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the layers in between are all hidden layers. In a DNN, the layers can be fully connected, that is, any neuron in the i-th layer must be connected to any neuron in the i+1-th layer.
[0160] The movement vector includes the movement direction and the movement distance. The lens can move in the direction close to the sensor or away from the sensor. The position of the lens can be understood as the relative position between the lens and the sensor.
[0161] The difference data may include feature differences and / or difference images.
[0162] Each pixel in the difference image may represent the difference between the pixel values of the first image and the second image at that pixel.
[0163] At S620, the difference image may be input into an input layer of the processing model.
[0164] The feature difference represents a difference between a first feature of the first image and a second feature of the second image.
[0165] Before performing S620, feature extraction may be performed on the first image and the second image respectively to obtain a first feature of the first image and a second feature of the second image. A difference between the first feature and the second feature may be calculated to obtain a feature difference.
[0166] In some embodiments, the feature extraction model is used to extract features from the first image and the second image respectively, thereby obtaining the first feature and the second feature.
[0167] The feature extraction model may include multiple feature extraction layers.
[0168] The first feature may only include the feature output by the feature extraction model of the last feature extraction layer in the first image processing process, and the second feature may only include the feature output by the feature extraction model of the last feature extraction layer in the second image processing process.
[0169] The feature difference may be a difference in features output by the last feature extraction layer of the feature extraction layer when the feature extraction layer extracts features from the first image and the second image respectively.
[0170] Alternatively, the first feature may include the first sub-feature output by the feature extraction model for each feature extraction layer in the first image processing process, and the second feature may include the second sub-feature output by the feature extraction model for each feature extraction layer in the second image processing process.
[0171] Each feature extraction layer may include one or more convolutional layers.
[0172] A convolutional layer is a neuron layer that performs convolution processing on the input signal. Each convolutional layer can include many convolution operators, also known as kernels. Its role in image processing is equivalent to a filter that extracts specific information from the input image matrix. The convolution operator can essentially be a weight matrix, which is usually predefined. In the process of performing convolution operations on the image, the weight matrix is usually processed horizontally on the input image one pixel after another (or two pixels after two pixels... depending on the value of the stride), thereby completing the work of extracting specific features from the image.
[0173] The weight values in the weight matrix need to be obtained through a lot of training in practical applications. The weight matrices formed by the weight values obtained through training can be used to extract accurate features from the input image, so that correct predictions can be obtained based on these features.
[0174] Some feature extraction layers may also include a pooling layer. Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolution layer. The pooling layer may be introduced in a way that a convolution layer is followed by a pooling layer, or in a way that multiple convolution layers are followed by one or more pooling layers. In the image processing process, the purpose of the pooling layer is to reduce the spatial size of the image. The pooling layer may include an average pooling operator and / or a maximum pooling operator to sample the input image to obtain an image of a smaller size. The average pooling operator may calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling. The maximum pooling operator may take the pixel with the largest value within a specific range as the result of maximum pooling. The feature size output after processing by the pooling layer may be smaller than the feature size of the input pooling layer, and each bit in the feature size output by the pooling layer represents the average value or maximum value of the corresponding sub-region of the feature of the input pooling layer.
[0175] In the case where the first feature includes the first sub-feature output by each feature extraction layer, and the second feature includes the second sub-feature output by each feature extraction layer, the feature difference may include multiple layer difference features corresponding to multiple feature extraction layers, and the layer difference feature corresponding to each feature extraction layer is the difference between the first sub-feature and the second sub-feature output by the feature extraction layer. Different feature extraction layers correspond to different layer difference features.
[0176] That is, the feature difference may include a layer difference feature between a first sub-feature and a second sub-feature output by each feature extraction layer.
[0177] In some other embodiments, the first feature may be obtained by extracting features from the first image using a first feature extraction model, and the second feature may be obtained by extracting features from the second image using a second feature extraction model.
[0178] The first feature extraction model and the second feature extraction model may be neural network models with equal parameters. Exemplarily, the first feature extraction model and the second feature extraction model may be twin neural networks.
[0179] The first feature extraction model and the second feature extraction model are used to extract features from the first image and the second image respectively, so that feature extraction of the first image and feature extraction of the second image can be performed in parallel, shortening the time required for feature extraction and improving the efficiency of image processing.
[0180] The first feature extraction model may include multiple first feature extraction layers, and the second feature extraction model may include multiple second feature extraction layers. The number of first feature extraction layers in the first feature extraction model is equal to the number of second feature extraction layers in the second feature extraction model. In addition, the multiple first feature extraction layers have a corresponding relationship with the multiple second feature extraction layers, and each first feature extraction layer has the same parameters as the second feature extraction layer corresponding to the first feature extraction layer.
[0181] The first feature may only include the feature output by the last first feature extraction layer of the first image processing process of the first feature extraction model, and the second feature may only include the feature output by the last second feature extraction layer of the second image processing process of the second feature extraction model.
[0182] The feature difference may be a difference between a feature output by a last feature extraction layer of the first feature extraction model and a feature output by a last feature extraction layer of the second feature extraction model.
[0183] Alternatively, the first feature may include the first sub-feature output by each first feature extraction layer, and the second feature may include the second sub-feature output by each second feature extraction layer.
[0184] The feature difference may include multiple layer difference features corresponding to multiple first feature extraction layers, and the layer difference feature corresponding to each first feature extraction layer is the difference between a first sub-feature output by the first feature extraction layer and a second sub-feature output by a second feature extraction layer corresponding to the first feature extraction layer.
[0185] It should be understood that the first feature extraction model and the second feature extraction model are twin networks, so the i-th first feature extraction layer and the i-th second feature extraction layer have the same parameters.
[0186] The processing model may include multiple processing layers, wherein each processing layer may include one or more convolutional layers. Multiple layer difference features may be input into a certain processing layer of the processing model, or the multiple layer difference features may be respectively input into different processing layers in the processing model. Exemplarily, the layer difference features corresponding to the first feature extraction layer may be input into the processing layer corresponding to the first feature extraction layer, and different first feature extraction layers correspond to different processing layers. The processing layer corresponding to the deeper first feature extraction layer may have a deeper depth. That is to say, in the correspondence between the multiple first feature extraction layers and the multiple processing layers, the depth of the first feature extraction layer is positively correlated with the depth of the processing layer.
[0187] It should be understood that one or more hidden layers may be provided before the first processing layer of the layer difference feature input in the processing model.
[0188] The processing model processes the data to be processed, and the output of the processing model may be a movement vector of the lens.
[0189] The information to be processed may also include initial position information, where the initial position information indicates an initial position of the lens.
[0190] In the case where the information to be processed includes initial position information, the output of the processing model may also be target position information, which indicates the target position of the lens. Thus, the movement vector of the lens may be determined based on the initial position information and the target position information. In other words, the focus information may be the target position information.
[0191] In the process of determining focus information based on the first image and the second image respectively captured by the first element set and the second element set when the lens is in the initial position, the influence of the initial position of the lens is considered, and the input of the processing model is richer and more comprehensive, thereby improving the accuracy of the output result of the processing model.
[0192] Different positions of the lens can correspond to different object distances. The correspondence between the lens position and the object distance is determined by the focal length of the lens. Figure 6 The electronic device of the method shown can store the correspondence between the position of the lens and the object distance. The object distance represents the distance between the object and the lens. The distance between the lens and the sensor is much smaller than the distance between the object and the lens, so the object distance can also be understood as the distance between the object and the sensor. The lens position corresponding to the object distance can be the lens position where the sensor captures the clearest object image when the object is located at the object distance, that is, the lens position where the image contrast of the object captured by the sensor is the highest.
[0193] According to the correspondence between the distance and the lens position, the initial object distance corresponding to the initial position represented by the initial position information can be determined. In the case where the information to be processed includes the initial object distance, the focus information output by the processing model can be the target object distance information. The target object distance represented by the target object distance information can be understood as the predicted object distance obtained by the processing model for the first image and the second image, that is, the predicted value of the distance between the object recorded by the first image and the second image and the sensor. The target position is the lens position corresponding to the target object distance. In other words, according to the correspondence between the distance and the lens position, the target position corresponding to the target object distance represented by the target object distance information can be determined. According to the initial position and the target position, the movement vector of the lens can be determined.
[0194] The focal length of the lens may be different in different cameras. This means that for different lenses, the position of the lens when the sensor can capture a clear image of a certain scene may be different. The focus information is the object distance corresponding to the target position. According to the correspondence between the object distance applicable to the lens and the lens position, the target position of the lens can be determined. Therefore, the processing model can be applicable to the case where the camera has lenses of different focal lengths, and is applicable to various situations where the camera uses different aperture sizes and the lens movement range is different. The processing model has a wider applicability.
[0195] It should be understood that the initial position information can be input into the input layer of the processing model.
[0196] The image processing method provided in the embodiment of the present application considers the influence of difference data on focus information when using a processing model to process a first image and a second image to obtain focus information. The input of the processing model is increased with difference data representing the difference between the second image and the second image. The input of the processing model is richer and more comprehensive, so that the determined focus information is more accurate. Therefore, after the lens moves according to the focus information, the sensor re-captures the scene recorded by the first image, and the obtained image is clearer.
[0197] Combine the following Figure 8 ,right Figure 6 The neural network model used in the image processing method shown is explained.
[0198] Figure 8 It is a schematic structural diagram of the image processing system provided in an embodiment of the present application.
[0199] The image processing system 800 includes a first feature extraction model 810, a second feature extraction model 820, and a processing model 830. The first feature extraction model 810, the second feature extraction model 820, and the processing model 830 may all be convolutional neural network models (CNN).
[0200] The first feature extraction model 810 is used to extract features from the first image. The second feature extraction model 810 is used to extract features from the second image.
[0201] The first image and the second image are obtained by respectively capturing the target object by the first element set and the second element set in the sensor when the lens is in the initial position. The first element set includes a plurality of first photosensitive elements, and the second element set includes a plurality of second photosensitive elements corresponding to the plurality of first photosensitive elements. The sensor includes a plurality of phase photosensitive element pairs. Each phase photosensitive element pair includes a first photosensitive element and a second photosensitive element corresponding to the first photosensitive element.
[0202] The first photosensitive element is used to receive light transmitted through the lens to the first side of the pixel, and the second photosensitive element is used to receive light transmitted through the lens to the second side of the pixel. The first side and the second side represent opposite directions. Thus, the first image and the second image can be used for phase focusing.
[0203] It should be understood that the first photosensitive element and the second photosensitive element may be located in the same or different pixels.
[0204] The first feature extraction model 810 includes a plurality of first feature extraction layers 811 to 813. The second feature extraction model 820 includes a plurality of second feature extraction layers 821 to 823.
[0205] The first feature extraction model 810 and the second feature extraction model 820 are twin neural networks and have the same parameters. In addition, the first feature extraction layer 811 and the second feature extraction layer 821, the first feature extraction layer 812 and the second feature extraction layer 822, and the first feature extraction layer 813 and the second feature extraction layer 823 all have the same parameters.
[0206] During the process of the first feature extraction model 810 processing the first image, the first feature extraction layer 811 is used to perform feature extraction on the first image to obtain a first output of the first feature extraction layer 811. The first feature extraction layer 812 is used to perform feature extraction on the first output of the first feature extraction layer 811 to obtain a first output of the first feature extraction layer 812. The first feature extraction layer 813 is used to perform feature extraction on the first output of the first feature extraction layer 812 to obtain a first output of the first feature extraction layer 813.
[0207] During the process of the second feature extraction model 820 processing the first image, the second feature extraction layer 821 is used to extract features from the first image to obtain a second output of the second feature extraction layer 821. The second feature extraction layer 822 is used to extract features from the second output of the second feature extraction layer 821 to obtain a second output of the second feature extraction layer 822. The second feature extraction layer 823 is used to extract features from the second output of the second feature extraction layer 822 to obtain a second output of the second feature extraction layer 823.
[0208] Subtract each bit in the first output of the first feature extraction layer 811 from each bit in the second output of the second feature extraction layer 821 to obtain the layer difference feature corresponding to the first feature extraction layer 811. Subtract each bit in the first output of the first feature extraction layer 812 from each bit in the second output of the second feature extraction layer 822 to obtain the layer difference feature corresponding to the first feature extraction layer 812. Subtract each bit in the first output of the first feature extraction layer 813 from each bit in the second output of the second feature extraction layer 823 to obtain the layer difference feature corresponding to the first feature extraction layer 813.
[0209] The processing model 830 is used to process the first image, the second image, the difference image and the multiple layer difference features to obtain focus information. The focus information represents the movement vector of the lens.
[0210] The processing model 830 includes an input layer 831 and processing layers 832 to 834. The processing layer may further include a plurality of hidden layers between the input layer 831 and the processing layer 832.
[0211] The difference data includes a plurality of layer difference features and a difference image.
[0212] The first image, the second image and the difference image are input to the input layer 831 of the processing model 830 .
[0213] The layer difference features corresponding to the multiple first feature extraction layers are respectively input into the processing layers corresponding to the first feature extraction layers.
[0214] The input of the processing layer 832 includes the processing results of the layers before the processing layer 832 on the first image, the second image, and the difference image, and the layer difference features corresponding to the first feature extraction layer 811. The input of the processing layer 833 includes the processing results of the processing layer 832 and the layer difference features corresponding to the first feature extraction layer 812. The input of the processing layer 834 includes the processing results of the processing layer 833 and the layer difference features corresponding to the first feature extraction layer 813.
[0215] The first image and the second image may be images acquired by all pairs of phase-sensitive elements in the sensor, or may be images acquired by some pairs of phase-sensitive elements in the sensor.
[0216] The processing model can process the first image, the second image, and the difference data between the second image and the second image to obtain focus information. In the process of determining the focus information, the processing model considers the influence of the difference data on the focus information, so that the determined focus information is more accurate, so that the image captured by the sensor of the target object is clearer after the lens moves according to the focus information.
[0217] Fig. 9 It is a schematic flowchart of a neural network model training method provided in an embodiment of the present application. Fig. 9 The neural network model training method shown includes steps S910 to S930, and these steps are described in detail below.
[0218] Step S910, acquiring training data, wherein the training data includes sample data and annotated focus information, the sample data includes a first training image, a second training image, and training difference data, wherein the training difference data indicates a difference between the first training image and the second training image, wherein the first training image and the second training image are images respectively obtained by a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position, wherein the first training element set includes a plurality of first training photosensitive elements, each of which is used to receive light transmitted through the training lens to a first side of a pixel where the first training photosensitive element is located, and the second training element set includes a plurality of second training photosensitive elements, each of which is used to receive light transmitted through the training lens to a second side of a pixel where the second photosensitive element is located, wherein the first side and the second side are opposite in direction, and the annotated focus information indicates a training movement vector of the training lens, and a target training position to which the training lens moves according to the training movement vector is a position among the plurality of positions of the training lens that makes the image contrast of a region located in a focus area in an image captured by the training sensor for the scene recorded by the first training image the highest, and the focus area is located in the region where the first training image is located.
[0219] Step S920: Process the sample data using the initial processing model to obtain training focus information.
[0220] Step S930, adjusting the parameters of the initial processing model according to the difference between the training focus information and the annotated focus information to minimize the difference, and the initial processing model after parameter adjustment is the processing model obtained through training.
[0221] The resulting processing model can be used to implement Figure 6 The image processing method shown. Fig. 9The method shown in the figure captures the first training image and the second training image of the training sensor and Figure 6 The sensors used in the image processing methods shown may be the same or different.
[0222] The training sensor may include a plurality of training phase photosensitive element pairs, each training phase photosensitive element pair including a first training photosensitive element and a second training photosensitive element.
[0223] Figure 6 The training sensor trains the phase photosensitive element pairs and Fig. 9 The phase photosensitive element pairs in the sensor may have the same structure. That is, the direction represented by the first side of the first training photosensitive element and the first side of the first photosensitive element is the same.
[0224] For example, when the relative position relationship between the first photosensitive element and the second photosensitive element is the same as the relative position relationship between the first training photosensitive element and the second training photosensitive element, Figure 6 The processing model trained by the method shown can be applied to Fig. 9 In the method shown.
[0225] To improve Fig. 9 The accuracy of the method shown, Figure 6 The density of the training phase photosensitive element pairs in the training sensor is Fig. 9 The density difference between the density of the phase photosensitive element pairs in the sensor can be less than or equal to the preset density difference. In other words, the processing model obtained by training has a certain generalization ability.
[0226] For example, Figure 6 The training sensor in the method shown is Fig. 9 The sensors in the method shown may be sensors with the same structure, for example, they may be sensors with the same model. The marked focus information may be understood as a label corresponding to the sample data.
[0227] In order to obtain training samples and annotate focus information, the training lens is controlled to move within the moving range.
[0228] A certain position within the moving range of the training lens is taken as an initial training position, an image of the training object captured by the first training element set when the training lens is located at the initial training position is taken as a first training image, and an image of the training object captured by the second training element set is taken as a second training image.
[0229] The training lens is controlled to move within the moving range. When the training lens is at different positions, the training sensor can be used to capture images of the training object to obtain multiple candidate images. For example, each time the training lens moves to a preset step length, the training sensor can capture images of the training object once to obtain a candidate image corresponding to the position of the training lens. The multiple candidate images captured by the training sensor of the training object during the process of the training lens moving from one end of the moving range to the other end can be called a full scan (fullsweep).
[0230] During the process of collecting multiple candidate images, the position of the training sensor should remain unchanged. Before collecting candidate images, the electronic device equipped with the training sensor and the training lens can be fixed in position by a fixing device such as a tripod.
[0231] Afterwards, the contrast of each candidate image is calculated.
[0232] Generally, when the training lens moves within the moving range, the image captured by the training sensor gradually focuses from a defocused state, and then defocuses again, that is, the candidate image captured by the training sensor gradually becomes clear and then gradually becomes blurred. The clarity of the image can be expressed by the contrast of the image. When the image is clearer, the image contrast is higher. Conversely, the more blurred the image is, the lower the image contrast is.
[0233] Exemplarily, the candidate image can be represented as I, and the contrast C(I) of the candidate image I can be represented as C(I)=∑(L*I) 2 / I 2 , where * represents convolution, / represents point-by-point division, and L is a preset matrix, which can be expressed as
[0234]
[0235] Among the multiple candidate images, the position of the training lens corresponding to the candidate image with the highest contrast can be used as the target training position. Alternatively, a curve fitting can be performed for the contrast of the multiple candidate images and the positions of the training lenses corresponding to the multiple candidate images. Thus, the position of the training lens corresponding to the point with the highest contrast in the fitted curve is used as the target training position.
[0236] The marking focus information may be determined according to the target training position and the initial training position. The marking focus information is determined according to the training movement vector representing the movement of the training lens from the initial position to the target training position.
[0237] In some embodiments, the training difference data may include a training difference image. The pixel value of each pixel in the training difference image represents the difference between the pixel values of the pixel in the first training image and the second training image.
[0238] In step S920, the training graph difference data may be input into an input layer of an initial processing model.
[0239] In other embodiments, the training difference data may include training feature differences.
[0240] In step S920, the first initial feature extraction model may be used to extract features from the first training image to obtain a first training feature, and the second initial feature extraction model may be used to extract features from the second training image to obtain a second training feature. The training feature difference may represent the difference between the first training feature and the second training feature.
[0241] In step S930, according to the difference between the training focus information and the annotated focus information, the parameters of the initial adjustment model, the parameters of the first initial feature extraction model, and the parameters of the second initial feature extraction model can be adjusted to obtain the first feature extraction model and the second feature extraction model. The initial processing model after parameter adjustment is the processing model, the first initial feature extraction model after parameter adjustment is the first feature extraction model, and the second initial feature extraction model after parameter adjustment is the second feature extraction model.
[0242] The parameters of the first initial feature extraction model and the second initial feature extraction model may be the same or different. When the parameters of the first initial feature extraction model and the second initial feature extraction model are different, during the training process, the parameters of the first initial feature extraction model and the second initial feature extraction model may tend to be the same.
[0243] The parameters of the first initial feature extraction model and the parameters of the second initial feature extraction model can be the same, and the parameters of the adjusted first initial feature extraction model and the parameters of the adjusted second initial feature extraction model are the same. That is to say, during the training process, the first initial feature extraction model and the second initial feature extraction model can always be the same model. The first feature extraction model and the second feature extraction model can be understood as twin neural networks.
[0244] The difference between the training focus information and the labeled focus information can be expressed as a loss value.
[0245] In the process of training the neural network model, because the output of the neural network model is as close as possible to the value that we really want to predict, we can compare the predicted value of the current network with the target value that we really want, and then update the weight vector of each layer of the neural network according to the difference between the two (of course, there is usually an initialization process before the first update, that is, pre-configuring parameters for each layer in the neural network model). For example, if the model's predicted value is high, adjust the weight vector to make it predict a lower value, and keep adjusting until the neural network model can predict the target value that we really want or a value that is very close to the target value that we really want. Therefore, it is necessary to pre-define "how to compare the difference between the predicted value and the target value", which is the loss function or objective function, which are important equations used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value of the loss function, that is, the loss value (loss), the greater the difference, so the training of the neural network model becomes a process of minimizing this loss as much as possible.
[0246] The back propagation (BP) algorithm can be used to correct the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, the forward transmission of the input signal to the output will generate error loss, and the parameters in the initial neural network model are updated by backpropagating the error loss information, so that the error loss converges. The backpropagation algorithm is a backpropagation movement dominated by error loss, which aims to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0247] The parameters of the first initial feature extraction model and the second initial feature extraction model may be equal or unequal.
[0248] The first initial feature extraction model and the second initial feature extraction model may be the same neural network model. The first feature extraction model and the second feature extraction model may also be the same neural network model.
[0249] When the first initial feature extraction model and the second initial extraction model are the same neural network model, the neural network model can be used as the first initial feature extraction model and the second initial extraction model in sequence to perform feature extraction on the first training image and the second training image, respectively.
[0250] Alternatively, the first feature extraction model and the second feature extraction model may be twin neural networks. It should be understood that when the first initial feature extraction model and the second initial feature extraction model are twin neural networks, or the first initial feature extraction model and the second initial feature extraction model may be the same neural network model, both the first feature extraction model and the second feature extraction model may be twin neural networks.
[0251] The training feature difference may include multiple training layer feature differences.
[0252] The first training feature may be an output of the last layer of the first initial feature extraction model, and the second training feature may be an output of the last layer of the second initial feature extraction model.
[0253] Alternatively, the first training feature may include a first training sub-feature output by each of the multiple first initial feature extraction layers in the first initial feature extraction model. The second training feature may include a second training sub-feature output by each of the multiple second initial feature extraction layers in the second initial feature extraction model. The training feature difference includes a plurality of training layer difference features corresponding to the multiple first initial feature extraction layers, the training layer difference feature corresponding to each first initial feature extraction layer being the difference between the first training sub-feature output by the first initial feature extraction layer and the second training sub-feature output by the second initial feature extraction layer corresponding to the first initial feature extraction layer, and each first initial feature extraction layer has the same parameters as the second initial feature extraction layer corresponding to the first initial feature extraction layer.
[0254] The first initial feature extraction layer after parameter adjustment is the first feature extraction layer, and the second initial feature extraction layer after parameter adjustment is the second feature extraction layer.
[0255] The initial processing model may include one or more initial processing layers. Each initial processing layer may include one or more convolutional layers.
[0256] At S920 , the training difference features may be input into an initial processing model.
[0257] The training difference features may be input into a certain layer of the initial processing model. For example, the certain layer may be an input layer or a hidden layer.
[0258] Alternatively, the method of inputting the training difference features into the initial processing model can also be to input the training layer difference features corresponding to each first initial feature extraction layer into the initial processing layer corresponding to the first initial feature extraction layer in the initial processing model, and different first initial feature extraction layers correspond to different initial processing layers.
[0259] It should be understood that the first training image and the second training image may be acquired by all phase photosensitive element pairs in the training sensor, or may be acquired by the phase photosensitive element pairs located in the focus frame area. The position of the focus frame area may be specified by the user, or may be determined by the electronic device according to the content of the image acquired by the training sensor. It should be understood that the first training image and the second training image have equal or approximately equal sizes, and the first training image and the second training image are located at the same or approximately the same position in the image acquired by the training sensor.
[0260] In the case where the first training image and the second training image are acquired by a phase photosensitive element pair located in the focus frame area, the sample data may further include training position information of the focus frame area.
[0261] The number of training data may be one or more. When the number of training data is multiple, each training data includes sample data and annotated focus information corresponding to the sample data. At S920, the multiple sample data may be processed respectively using the initial processing model to obtain the training focus information corresponding to each sample data. Thereafter, at S930, the parameters of the initial processing model may be adjusted according to the difference between the training focus information corresponding to each sample data and the annotated focus information corresponding to the sample data, thereby obtaining a processing model.
[0262] In the plurality of training data, the first training images in each training data may have the same or different sizes. In the case where the sizes of the first training images in the plurality of sample data are different, the neural network model trained using the plurality of training data has the ability to process images of different sizes, thereby improving the applicability of the image processing method using the neural network model.
[0263] In some embodiments, the training sample may further include initial training position information, and the initial training position information is used to indicate the initial training position. In the case where the training sample includes the initial training position information, the output of the initial processing model may be the annotated position information. The annotated position information indicates the target training position of the training shot.
[0264] In S920, the difference between the training focus information and the annotated focus information may be understood as the difference between the initial training position information and the annotated position information.
[0265] The marked position information may be the coordinates or normalized coordinates of the target training position, or the marked position information may also be the target training object distance corresponding to the target training position.
[0266] Different training lens positions of the training lens may correspond to different object distances. The corresponding relationship between the training lens position and the object distance may be determined according to the focal length of the lens.
[0267] The object distance represents the distance between the object and the training sensor. The training lens position corresponding to the object distance is the training lens position that enables the training sensor to acquire the image with the highest contrast when acquiring the object at the object distance. It should be understood that the highest contrast can also be understood as the training lens position corresponding to the point with the highest contrast in the fitting curve of contrast and training lens position among multiple images acquired by the training sensor for the acquisition of the object at the object distance.
[0268] The initial training position information in the training sample may be the initial training object distance. According to the correspondence between the training lens position and the object distance, the initial training object distance is the object distance corresponding to the initial training position of the training lens. When the initial training position information in the training sample is the initial training object distance, the annotated focus information may be the target training object distance.
[0269] It should be understood that the initial training object distance and the target training object distance can be the value of the object distance or the normalized result of the object distance. The normalized result of the object distance can be called the normalized object distance, which can be understood as setting the normalized result of the maximum object distance corresponding to multiple positions within the moving range of the training lens to 1, the normalized result of the minimum object distance corresponding to 0, and the normalized results of the object distance corresponding to other positions to be between 0 and 1. The normalized result of the object distance has a corresponding relationship with the object distance, and different normalized results of the object distance correspond to different object distances, and the normalized result of the object distance is positively correlated with the object distance.
[0270] When the sensor uses different lenses, the correspondence between the object distance and the lens position may be different. In the process of training the processing model, the position of the training lens is represented by the object distance, and the output of the trained processing model is the object distance information. Therefore, when the camera is set with lenses of different focal lengths, the target position of the lens can be determined according to the correspondence between the object distance and the lens position applicable to the lens. That is, the trained processing model can be applied to lenses with different focal lengths, and the processing model has a wider applicability.
[0271] The training data may include multiple training samples and annotated focus information corresponding to each training sample. In different training samples, the sizes of the first training images may be the same or different. In each first training image, the focus area may be a central area in the first training image.
[0272] The focus area may be the entire area of the first training image, or the focus area may be the central area of the first training image. The central area of the first training image is located at the center of the first training image. The ratio between the size of the central area and the size of the first training image may be a preset ratio. Alternatively, the size of the central area may be a preset size.
[0273] In the edge area of the first training image, other objects different from those recorded in the center area may be recorded. During the training process, the focus area in each first training image is located at the center of the first training image. Then, in the process of processing the data to be processed, the processing model obtained by training can reduce the influence of other objects recorded near the border position in the first image on the focus information. The lens moves according to the processed focus information so that the image contrast of the center area of the first image in the image captured by the sensor is the highest, that is, the image in the center area of the first image is the clearest, thereby improving the accuracy of the focus information.
[0274] The size of the first image can be understood as the size of the focus frame area. Thus, the processing model can be applicable to scenes with different focus frame area sizes.
[0275] The neural network model obtained by training from S910 to S930 considers the difference between the first training image and the second training image during the training process, and applies the trained neural network model to Figure 6 In the image processing process shown, the difference between the first image and the second image may be taken into account, so that the determined focus information is more accurate.
[0276] Figure 8 In the image processing system 800 shown, the first feature extraction model 810, the second feature extraction model 820 and the processing model 830 can be obtained through end-to-end training. The system 800 can also be understood as a neural network model. In the scenario of using the system 800 for image processing, the training and reasoning process of the system 800 can be referred to in Fig.11 Description.
[0277] Fig.11 It is a schematic flow chart of a data processing method provided in an embodiment of the present application. Fig.11 The data processing method shown includes steps S1101 to S1105, and these steps are described in detail below.
[0278] Step S1101, collecting sample data.
[0279] For the system 800 , the sample data may include a first training image, a second training image, and a difference image.
[0280] Step S1102, calibrating labels corresponding to sample data.
[0281] The label corresponding to the sample data is the annotated focus information corresponding to the sample data.
[0282] Step S1103, constructing an initial model.
[0283] The initial model includes a first initial feature extraction model, a second initial feature extraction model, and an initial processing model. The parameters of the first initial feature extraction model and the second initial feature extraction model are the same. The initial model can also be called an initial neural network model.
[0284] Step S1104, using the sample data and the corresponding labels, adjust the parameters of the initial model to obtain a trained model.
[0285] The sample data is processed using the initial model to obtain training focus information. According to the difference between the training focus information and the labeled focus information, the parameters of the initial model are adjusted to minimize the difference. The initial model after parameter adjustment is the trained model. The trained model can be called a trained neural network model, which can be Figure 8 System 800 is shown.
[0286] In the initial model, the first initial feature extraction model is used to extract features from the first training image to obtain first training features; and the second initial feature extraction model is used to extract features from the second training image to obtain second training features.
[0287] The first initial feature extraction model includes a plurality of first initial feature extraction layers, and the second initial feature extraction model includes a plurality of second initial feature extraction layers.
[0288] The first training features include first training sub-features output by each first initial feature extraction layer, and the second training features include second training sub-features output by each second initial feature extraction layer.
[0289] The difference between the first training sub-feature output by each first initial feature extraction layer and the second training sub-feature output by the second initial feature extraction layer corresponding to the first initial feature extraction layer can be expressed as a training layer difference feature corresponding to the first initial feature extraction layer.
[0290] The initial processing model is used to process the first training image, the second training image, the training image difference, and the training feature difference to obtain training focus information.
[0291] The initial processing model includes an input layer and a plurality of processing layers corresponding to the plurality of first initial feature extraction layers. The depth of the first initial feature extraction layer is positively correlated with the depth of the processing layer corresponding to the first initial feature extraction layer. That is, as the depth of the first initial feature extraction layer increases, the depth of the processing layer corresponding to the first initial feature extraction layer increases.
[0292] The first training image, the second training image, and the training image difference are input into the initial processing model at the input layer. The training layer difference feature corresponding to each first initial feature extraction layer is input into the initial processing model at the processing layer corresponding to the first initial feature extraction layer.
[0293] Adjusting the parameters of the initial model includes adjusting the parameters of multiple first initial feature extraction layers in the first initial feature extraction model, the parameters of multiple second initial feature extraction layers in the second initial feature extraction model, and the parameters of multiple initial processing layers in the initial processing model.
[0294] The first initial feature extraction model after parameter adjustment is the first feature extraction model 810 , the second initial feature extraction model after parameter adjustment is the second feature extraction model 820 , and the initial processing model after parameter adjustment is the processing model 830 .
[0295] Step S1105, performing inference using the trained model.
[0296] Using the trained model for reasoning can be understood as the application process of the neural network model, that is, the process of determining the focus information. Figure 5 or Figure 8 Description.
[0297] exist Fig.11 In the data processing method shown, step S1101 may be performed by the first electronic device, step S1102 may be implemented using the first electronic device, step S1103 may be implemented manually, step S1104 may be performed by the second electronic device, and step S1105 may be performed by the third electronic device. The first electronic device, the second electronic device, and the third electronic device may be the same or different electronic devices. Exemplarily, the first electronic device and the third electronic device may be different terminals, and the second electronic device may be a server.
[0298] It should be understood that the above examples are intended to help those skilled in the art understand the embodiments of the present application, rather than to limit the embodiments of the present application to the specific numerical values or specific scenarios illustrated. Those skilled in the art can obviously make various equivalent modifications or changes based on the above examples, and such modifications or changes also fall within the scope of the embodiments of the present application.
[0299] Combination of the above Figures 1 to 11 The image processing method of the embodiment of the present application is described in detail. Fig.12 and Fig.13 It should be understood that the image processing device in the embodiment of the present application can execute various image processing methods in the aforementioned embodiment of the present application, that is, the specific working process of the following various products can refer to the corresponding process in the aforementioned method embodiment.
[0300] Fig.12 It is a schematic diagram of an image processing device provided in an embodiment of the present application.
[0301] The image processing device 1200 includes: an acquisition unit 1210 and a processing unit 1220 .
[0302] In some embodiments, the image processing apparatus 1200 may perform Figure 6 The image processing method shown.
[0303] The acquisition unit 1210 is used to acquire data to be processed, wherein the data to be processed includes a first image, a second image and difference data, wherein the difference data represents the difference between the first image and the second image, wherein the first image and the second image are images respectively obtained by a first element set and a second element set in a sensor when the lens is located at an initial position, wherein the first element set includes a plurality of first photosensitive elements, each of which is used to receive light transmitted through the lens to a first side of a pixel where the first photosensitive element is located, and wherein the second element set includes a plurality of second photosensitive elements, each of which is used to receive light transmitted through the lens to a second side of a pixel where the second photosensitive element is located, and wherein the first side is opposite to the direction indicated by the second side.
[0304] The processing unit 1220 is used to process the data to be processed by using a processing model to obtain focus information, where the focus information represents a movement vector of the lens, and the processing model is a trained neural network model.
[0305] Optionally, the acquisition unit 1210 is specifically configured to perform feature extraction on the first image and the second image respectively to obtain a first feature of the first image and a second feature of the second image, and the difference data includes a feature difference between the first feature and the second feature.
[0306] Optionally, the acquisition unit 1210 is specifically used to perform feature extraction on the first image using a first feature extraction model to obtain the first feature; and perform feature extraction on the second image using a second feature extraction model to obtain the second feature, and the parameters of the first feature extraction model and the second feature extraction model are the same.
[0307] Optionally, the first feature includes a first sub-feature output by each of the multiple first feature extraction layers in the first feature extraction model, the second feature includes a second sub-feature output by each of the multiple second feature extraction layers in the second feature extraction model, the feature difference includes a plurality of layer difference features corresponding to the multiple first feature extraction layers, the layer difference feature corresponding to each first feature extraction layer is the difference between the first sub-feature output by the first feature extraction layer and the second sub-feature output by the second feature extraction layer corresponding to the first feature extraction layer, and each first feature extraction layer has the same parameters as the second feature extraction layer corresponding to the first feature extraction layer.
[0308] Optionally, the processing unit 1220 is specifically used to input the layer difference features corresponding to each first feature extraction layer into the processing layer corresponding to the first feature extraction layer in the processing model, different first feature extraction layers correspond to different processing layers, and the depth of the processing layer corresponding to each first feature extraction layer is positively correlated with the depth of the first feature extraction layer.
[0309] Optionally, the difference data comprises a difference image, a pixel value of each pixel in the difference image representing a difference between pixel values of the first image and the second image at the pixel.
[0310] Optionally, the data to be processed further includes initial position information, and the focus information is target position information of the lens.
[0311] Optionally, different object distances correspond to different lens positions, the initial position information is the initial object distance corresponding to the initial position, and the target position information is the target object distance corresponding to the target position.
[0312] Optionally, the data to be processed further includes image position information, where the image position information indicates a position of the first image in an image captured by the sensor.
[0313] Optionally, the processing model is obtained by training an initial processing model using training data, the training data including training samples and annotated focus information, the sample data including a first training image, a second training image and training difference data, the training difference data indicating a difference between the first training image and the second training image, the first training image and the second training image being images respectively obtained by a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position, the first training element set including a plurality of first training photosensitive elements, each of the first training photosensitive elements being used to receive light transmitted through the training lens to the first side of a pixel where the first photosensitive element is located, and the second training element set including a plurality of second training photosensitive elements The invention relates to a device for detecting a focus area of a pixel in which the training lens is located, wherein each second training photosensitive element is used to receive light transmitted from the training lens to the second side of the pixel where the second photosensitive element is located, the annotated focus information represents a training movement vector of the training lens, and the target training position to which the training lens is moved according to the training movement vector is a position among multiple positions of the training lens where the image contrast of the area located in the focus area in the image captured by the training sensor for the scene recorded by the first training image is the highest, and the focus area is located in the area where the first training image is located; the training comprises: processing the sample data using the initial processing model to obtain training focus information; and adjusting the parameters of the initial processing model according to the difference between the training focus information and the annotated focus information to obtain the processing model.
[0314] In some other embodiments, the image processing device 1200 may also be referred to as a neural network model training device for performing Fig. 9 The neural network model training method shown.
[0315] The acquisition unit 1210 is used to acquire training data, where the training data includes sample data and annotated focus information. The sample data includes a first training image, a second training image, and training difference data, where the training difference data indicates a difference between the first training image and the second training image. The first training image and the second training image are images acquired by respectively acquiring a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position. The first training element set includes a plurality of first training photosensitive elements, each of which is used to receive light transmitted through the training lens to a first side of a pixel where the first training photosensitive element is located. The second training element set includes a plurality of second training photosensitive elements, each of which is used to receive light transmitted through the training lens to a second side of a pixel where the second photosensitive element is located. The first side and the second side are opposite in direction. The annotated focus information indicates a training movement vector of the training lens. The target training position to which the training lens moves according to the training movement vector is a position among the plurality of positions of the training lens that makes the image contrast of a region located in a focus area in an image acquired by the training sensor for a scene recorded by the first training image the highest. The focus area is located in the region where the first training image is located.
[0316] The processing unit 1220 is used to process the sample data using the initial processing model to obtain training focus information.
[0317] The processing unit 1220 is further configured to adjust the parameters of the initial processing model according to the difference between the training focus information and the annotated focus information to minimize the difference, and the initial processing model after parameter adjustment is the processing model obtained through training.
[0318] Optionally, the acquisition unit 1210 is specifically used to perform feature extraction on the first training image using a first initial feature extraction model to obtain a first training feature; and perform feature extraction on the second training image using a second initial feature extraction model to obtain a second training feature, and the training difference data includes the training feature difference between the first training feature and the second training feature.
[0319] The processing unit 1220 is specifically configured to adjust the parameters of the initial processing model, the parameters of the first initial feature extraction model, and the parameters of the second initial feature extraction model according to the difference between the training focus information and the annotated focus information.
[0320] Optionally, the parameters of the first initial feature extraction model are the same as those of the second initial feature extraction model, and the parameters of the adjusted first initial feature extraction model are the same as those of the adjusted second initial feature extraction model.
[0321] Optionally, the first training feature includes a first training sub-feature output by each of the multiple first initial feature extraction layers of the first initial feature extraction model, the second training feature includes a second training sub-feature output by each of the multiple second initial feature extraction layers of the second initial feature extraction model, the training feature difference includes a plurality of training layer difference features corresponding to the multiple first initial feature extraction layers, the training layer difference feature corresponding to each first initial feature extraction layer is the difference between the first training sub-feature output by the first initial feature extraction layer and the second training sub-feature output by the second initial feature extraction layer corresponding to the first initial feature extraction layer, and the parameters of each first initial feature extraction layer and the second initial feature extraction layer corresponding to the first initial feature extraction layer are the same.
[0322] Optionally, different first initial feature extraction layers correspond to different processing layers of the processing model.
[0323] The processing unit 1220 is specifically used to input the training layer difference features corresponding to each first initial feature extraction layer into the processing layer corresponding to the feature extraction layer in the initial processing model, and different first initial feature extraction layers correspond to different initial processing layers.
[0324] Optionally, the training difference data comprises a training difference image, and a pixel value of each pixel in the training difference image represents a difference between pixel values of the pixel in the first training image and the second training image.
[0325] Optionally, different object distances correspond to different training lens positions, the initial training position information is the initial training object distance corresponding to the initial training position, and the annotated focus information is the target object distance corresponding to the target training position.
[0326] Optionally, the focus area is a central area of the first training image.
[0327] Optionally, the sizes of the first training images in the multiple training samples are different.
[0328] Optionally, the training sample further includes training image position information, where the training image position information indicates a position of the first training image in an image acquired by the training sensor.
[0329] It should be noted that the above-mentioned image processing device 1200 is embodied in the form of a functional unit. The term "unit" here can be implemented in the form of software and / or hardware, and is not specifically limited to this.
[0330] For example, a "unit" may be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (e.g., a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit, and / or other suitable components that support the described functions.
[0331] Therefore, the units of each example described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0332] Fig.13 A structural schematic diagram of an electronic device provided by the present application is shown. Fig.13 The dotted line in indicates that the unit or the module is optional. The electronic device 1300 can be used to implement the image processing method described in the above method embodiment.
[0333] The electronic device 1300 includes one or more processors 1301, which can support the electronic device 1300 to implement the image processing method in the method embodiment. The processor 1301 can be a general-purpose processor or a special-purpose processor. For example, the processor 1301 can be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.
[0334] The processor 1301 may be used to control the electronic device 1300, execute software programs, and process data of the software programs. The electronic device 1300 may also include a communication unit 1305 to implement input (reception) and output (transmission) of signals.
[0335] For example, the electronic device 1300 may be a chip, the communication unit 1305 may be an input and / or output circuit of the chip, or the communication unit 1305 may be a communication interface of the chip, and the chip may be a component of a terminal device or other electronic devices.
[0336] For another example, the electronic device 1300 may be a terminal device, and the communication unit 1305 may be a transceiver of the terminal device, or the communication unit 1305 may be a transceiver circuit of the terminal device.
[0337] The electronic device 1300 may include one or more memories 1302 on which a program 1304 is stored. The program 1304 can be executed by the processor 1301 to generate instructions 1303, so that the processor 1301 executes the image processing method described in the above method embodiment according to the instructions 1303.
[0338] Optionally, data may be stored in the memory 1302. Optionally, the processor 1301 may read data stored in the memory 1302. The data may be stored at the same storage address as the program 1304, or may be stored at a different storage address than the program 1304.
[0339] The processor 1301 and the memory 1302 may be provided separately or integrated together; for example, integrated on a system on chip (SOC) of a terminal device.
[0340] Exemplarily, the memory 1302 can be used to store the related program 1304 of the image processing method or the neural network model training method provided in the embodiment of the present application, and the processor 1301 can be used to call the related program 1304 of the image processing method or the neural network model training method stored in the memory 1302 to execute the image processing method or the neural network model training method of the embodiment of the present application. For example, processor 1301 can be used to: obtain data to be processed, the data to be processed including a first image, a second image and difference data, the difference data representing the difference between the first image and the second image, the first image and the second image being images respectively obtained by a first element set and a second element set in a sensor when the lens is in an initial position, the first element set including a plurality of first photosensitive elements, each first photosensitive element being used to receive light transmitted through the lens to a first side of a pixel where the first photosensitive element is located, the second element set including a plurality of second photosensitive elements, each second photosensitive element being used to receive light transmitted through the lens to a second side of a pixel where the second photosensitive element is located, the first side being opposite to the direction represented by the second side; and process the data to be processed using a processing model to obtain focus information, the focus information representing a movement vector of the lens, and the processing model being a trained neural network model. Alternatively, the processor 1301 may be configured to: acquire training data, the training data including sample data and annotated focus information, the sample data including a first training image, a second training image, and training difference data, the training difference data representing a difference between the first training image and the second training image, the first training image and the second training image being images acquired by respectively acquiring a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position, the first training element set including a plurality of first training photosensitive elements, each of which is configured to receive light transmitted through the training lens to a first side of a pixel where the first training photosensitive element is located, the second training element set including a plurality of second training photosensitive elements, each of which is configured to receive light transmitted through the training lens to a second side of a pixel where the second photosensitive element is located, the first side being opposite to the second side, the annotated focus information representing a training movement vector of the training lens, the target training position to which the training lens is moved according to the training movement vector being a position among the plurality of positions of the training lens where an image contrast of a region located in a focus area in an image acquired by the training sensor for a scene recorded by the first training image is the highest, and the focus area is located in a region where the first training image is located;
[0341] The sample data is processed using an initial processing model to obtain training focus information; according to the difference between the training focus information and the labeled focus information, the parameters of the initial processing model are adjusted to minimize the difference, and the initial processing model after parameter adjustment is the processing model obtained through training.
[0342] The present application also provides a computer program product, which, when executed by the processor 1301, implements the image processing method described in any method embodiment of the present application.
[0343] The computer program product may be stored in the memory 1302 , for example, a program 1304 , which is converted into an executable target file that can be executed by the processor 1301 after preprocessing, compiling, assembling, linking and other processing processes.
[0344] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a computer, the image processing method described in any method embodiment of the present application is implemented. The computer program can be a high-level language program or an executable target program.
[0345] The computer-readable storage medium is, for example, a memory 1302. The memory 1302 may be a volatile memory or a nonvolatile memory, or the memory 1302 may include both a volatile memory and a nonvolatile memory. Among them, the nonvolatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0346] In the description of this application, the terms "first", "second", etc. are used only for descriptive purposes and should not be understood as indicating or implying relative importance, or a specific order or sequence. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0347] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0348] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0349] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0350] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0351] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0352] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0353] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0354] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An image processing method, characterized in that: The method comprises: Acquire data to be processed, the data to be processed comprising a first image, a second image and difference data, the difference data representing a difference between the first image and the second image, the first image and the second image being images respectively obtained by a first element set and a second element set in a sensor when the lens is located at an initial position, the first element set comprising a plurality of first photosensitive elements, each of which is used to receive light transmitted through the lens to a first side of a pixel where the first photosensitive element is located, the second element set comprising a plurality of second photosensitive elements, each of which is used to receive light transmitted through the lens to a second side of a pixel where the second photosensitive element is located, the first side being opposite to the second side; The data to be processed is processed by using a processing model to obtain focus information, wherein the focus information represents a movement vector of the lens, and the processing model is a trained neural network model.
2. The method according to claim 1, characterized in that The obtaining of the data to be processed includes: Feature extraction is performed on the first image and the second image respectively to obtain a first feature of the first image and a second feature of the second image, and the difference data includes a feature difference between the first feature and the second feature.
3. The method according to claim 2, characterized in that The extracting features from the first image and the second image respectively to obtain a first feature of the first image and a second feature of the second image includes: Using a first feature extraction model to extract features from the first image to obtain the first features; A second feature extraction model is used to perform feature extraction on the second image to obtain the second feature, and parameters of the first feature extraction model and the second feature extraction model are the same.
4. The method according to claim 3, characterized in that The first feature includes a first sub-feature output by each of the multiple first feature extraction layers in the first feature extraction model, the second feature includes a second sub-feature output by each of the multiple second feature extraction layers in the second feature extraction model, the feature difference includes a plurality of layer difference features corresponding to the multiple first feature extraction layers, the layer difference feature corresponding to each first feature extraction layer is the difference between the first sub-feature output by the first feature extraction layer and the second sub-feature output by the second feature extraction layer corresponding to the first feature extraction layer, and each first feature extraction layer has the same parameters as the second feature extraction layer corresponding to the first feature extraction layer.
5. The method according to claim 4, characterized in that The method of using the processing model to process the data to be processed and the difference data includes: inputting the layer difference feature corresponding to each first feature extraction layer into the processing layer corresponding to the first feature extraction layer in the processing model, different first feature extraction layers correspond to different processing layers, and the depth of the processing layer corresponding to each first feature extraction layer is positively correlated with the depth of the first feature extraction layer.
6. The method according to any one of claims 1 to 5, characterized in that The difference data includes a difference image, a pixel value of each pixel in the difference image representing a difference between pixel values of the first image and the second image at the pixel.
7. The method according to any one of claims 1 to 5, characterized in that The processing model is obtained by training an initial processing model using training data, the training data including training samples and annotated focus information, the sample data including a first training image, a second training image and training difference data, the training difference data indicating the difference between the first training image and the second training image, the first training image and the second training image being images respectively obtained by a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position, the first training element set including a plurality of first training photosensitive elements, each of which is used to receive light transmitted through the training lens to the first side of a pixel where the first training photosensitive element is located, the second training element set including a plurality of second training photosensitive elements, each of which is used to receive light transmitted through the training lens to the second side of a pixel where the second training photosensitive element is located, the annotated focus information indicating a training movement vector of the training lens, the target training position to which the training lens moves according to the training movement vector is a position among the plurality of positions of the training lens that makes the image contrast of a region located in a focus area in an image captured by the training sensor for the scene recorded by the first training image the highest, and the focus area is located in the area where the first training image is located; The training includes: Processing the sample data using the initial processing model to obtain training focus information; According to the difference between the training focus information and the annotated focus information, the parameters of the initial processing model are adjusted to obtain the processing model.
8. A neural network model training method, characterized in that: The method comprises: Acquire training data, the training data comprising sample data and annotated focus information, the sample data comprising a first training image, a second training image and training difference data, the training difference data representing the difference between the first training image and the second training image, the first training image and the second training image being images acquired by respectively acquiring a first training element set and a second training element set in a training sensor when a training lens is located at an initial training position, the first training element set comprising a plurality of first training photosensitive elements, each of which is used to receive light transmitted through the training lens to a first side of a pixel where the first training photosensitive element is located, the second training element set comprising a plurality of second training photosensitive elements, each of which is used to receive light transmitted through the training lens to a second side of a pixel where the second training photosensitive element is located, the first side being opposite to the second side, the annotated focus information representing a training movement vector of the training lens, the target training position to which the training lens is moved according to the training movement vector being a position among the plurality of positions of the training lens that makes the image contrast of a region located in a focus area in an image acquired by the training sensor for the scene recorded by the first training image the highest, the focus area being located in the area where the first training image is located; Processing the sample data using an initial processing model to obtain training focus information; According to the difference between the training focus information and the annotated focus information, the parameters of the initial processing model are adjusted to minimize the difference, and the initial processing model after the parameter adjustment is the processing model obtained through training.
9. The method according to claim 8, characterized in that The obtaining of training data comprises: Using a first initial feature extraction model to extract features from a first training image to obtain first training features; Performing feature extraction on a second training image using a second initial feature extraction model to obtain a second training feature, wherein the training difference data includes a training feature difference between the first training feature and the second training feature; The adjusting the parameters of the initial processing model according to the difference between the training focus information and the annotated focus information includes: adjusting the parameters of the initial processing model, the parameters of the first initial feature extraction model and the parameters of the second initial feature extraction model according to the difference between the training focus information and the annotated focus information.
10. The method according to claim 9, characterized in that The parameters of the first initial feature extraction model are the same as the parameters of the second initial feature extraction model, and the parameters of the adjusted first initial feature extraction model are the same as the parameters of the adjusted second initial feature extraction model.
11. The method according to claim 9 or 10, characterized in that: The first training feature includes a first training sub-feature output by each of the multiple first initial feature extraction layers of the first initial feature extraction model, the second training feature includes a second training sub-feature output by each of the multiple second initial feature extraction layers of the second initial feature extraction model, the training feature difference includes a plurality of training layer difference features corresponding to the multiple first initial feature extraction layers, the training layer difference feature corresponding to each first initial feature extraction layer is the difference between the first training sub-feature output by the first initial feature extraction layer and the second training sub-feature output by the second initial feature extraction layer corresponding to the first initial feature extraction layer, and the parameters of each first initial feature extraction layer and the second initial feature extraction layer corresponding to the first initial feature extraction layer are the same.
12. The method according to claim 11, characterized in that Different first initial feature extraction layers correspond to different processing layers of the processing model; The sample data is processed using the initial processing model to obtain training focus information, including: inputting the training layer difference feature corresponding to each first initial feature extraction layer into the processing layer corresponding to the feature extraction layer in the initial processing model, and different first initial feature extraction layers correspond to different initial processing layers.
13. The method according to any one of claims 8 to 10 and 12, characterized in that: The training difference data includes a training difference image, and a pixel value of each pixel in the training difference image represents a difference between pixel values of the pixel in the first training image and the second training image.
14. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the electronic device executes the method described in any one of claims 1 to 7, or the method described in any one of claims 8 to 13.
15. A chip, characterized in that: The method comprises a processor, and when the processor executes instructions, the processor performs the method according to any one of claims 1 to 7, or the method according to any one of claims 8 to 13.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method according to any one of claims 1 to 7, or the method according to any one of claims 8 to 13.
Citation Information
Patent Citations
Image stabilization system and digital camera
CN102790847A
Pixel, image sensor, focusing method and device and terminal equipment
CN111787237A
Image processing method, image processing device, storage medium and electronic equipment
CN112217996A
Image processing apparatus
JP2010068471A
