Image processing method and related device
By updating and optimizing the foreground and background segmentation model, and using user feedback for model correction and learning, the problem of inaccurate image segmentation in the existing technology is solved, the portrait shooting effect is improved, and the user's demand for high-quality shooting is met.
Patent Information
- Application Number
- CN201910578773.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-28
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2039-06-28
AI Technical Summary
It is difficult for the existing technology to accurately segment the foreground and background in the image in portrait mode, resulting in poor shooting effects and unable to meet users' needs for high-quality shooting.
By updating the locally stored foreground and background segmentation model, user feedback is used to correct and optimize the model, and incremental learning and device-cloud combined learning are used to update the model to improve segmentation accuracy.
It improves the accuracy of foreground and background segmentation results in image processing, improves portrait shooting effects, and meets users' needs for high-quality shooting.
Smart Images

Figure CN112150499B
Abstract
Description
Technical Field
[0001] The present application relates to the fields of computer graphics processing and machine learning, and in particular to image processing methods and related devices. Background Art
[0002] With the development of electronic technology, the shooting functions of electronic devices such as mobile phones are becoming more and more abundant. For example, electronic devices provide a portrait mode when shooting. In the portrait mode, the electronic device can process the captured image, and the processing may include: highlighting the subject in the image, such as a portrait, and blurring the background in the image.
[0003] Portrait mode relies on foreground-background segmentation technology. The electronic device needs to first segment the captured image into foreground and background, and then it can specifically highlight the foreground and blur the background to achieve the portrait shooting effect.
[0004] Currently, users have higher and higher requirements for shooting with electronic devices. For example, when using portrait mode, users hope to accurately highlight the subject, such as the body of the portrait, including the edge of the hair, fingers, etc. In order to meet the needs of users, it is necessary to propose a technical solution to accurately segment the foreground and background in the image, thereby providing users with better portrait shooting effects. Summary of the invention
[0005] The present application provides an image processing method and related devices. The electronic device can update the locally stored foreground and background segmentation model according to the user's feedback, and use the updated foreground and background segmentation model to segment the foreground and background in the image, so that the segmentation result is more accurate. Based on the accurate segmentation result, the electronic device can achieve better image processing.
[0006] In the first aspect, an embodiment of the present application provides an image processing method, which is applied to an electronic device. The method may include: the electronic device displays a first user interface, the first user interface including: an image I1 obtained by the electronic device processing an initial image I0 based on an initial segmentation result; the initial segmentation result is obtained by the electronic device using an initial segmentation model M0 to perform foreground and background segmentation on the initial image I0; the electronic device receives a first operation for indicating that the initial segmentation result is accurate, and in response to the first operation, the initial image I0 and the initial segmentation result are stored in association; or, the electronic device receives a second operation for indicating a revised segmentation result, and in response to the second operation, the initial image I0 and the revised segmentation result are stored in association; the electronic device uses at least one of the following to update the initial segmentation model M0 to obtain a segmentation model M1: the associated stored initial image I0 and the initial segmentation result, or, the associated stored initial image I0 and the revised segmentation result; the segmentation model M1 is used to perform foreground and background segmentation on the image.
[0007] By implementing the method of the first aspect, the electronic device can update the locally stored foreground and background segmentation model based on user feedback, and use the updated foreground and background segmentation model to segment the foreground and background in the image, thereby making the segmentation result more accurate.
[0008] In the method of the first aspect, the initial image I0 refers to an image that has not been subjected to foreground-background segmentation processing, nor any other processing (such as highlighting the foreground, blurring the background, replacing the background, retaining the background / foreground color, etc.). The initial image I0 can be a picture or a video. The initial image I0 can be captured by a camera of an electronic device, or can be downloaded by the electronic device from the Internet or obtained from other devices.
[0009] In the method of the first aspect, the initial segmentation model M0 can be a segmentation model pre-stored in the electronic device when it leaves the factory, or a segmentation model received by the electronic device from a server after learning or updating. The initial segmentation model M0 is obtained by learning a large amount of training data using a machine learning method.
[0010] In the method of the first aspect, the segmentation result may be expressed in the form of a mask image, that is, the initial segmentation result may be expressed in the form of an initial mask image, and the modified segmentation result may be expressed in the form of a modified mask image.
[0011] In combination with the first aspect, in some embodiments, after the electronic device updates the initial segmentation model M0 and obtains the segmentation model M1, the electronic device can also use the segmentation model M1 to perform foreground and background segmentation on the first image to obtain a first segmentation result; and process the first image based on the first segmentation result. Here, the first image can be any image that needs to be processed based on the segmentation result, such as an image captured by a camera or an image downloaded from the Internet. Through this embodiment, the electronic device can obtain an accurate segmentation result using the segmentation model M1, and achieve better image processing based on the accurate segmentation result.
[0012] In combination with the first aspect, in some embodiments, the processing performed by the electronic device on the initial image I0 based on the initial segmentation result includes one or more of the following: highlighting the foreground, blurring the background, replacing the background, retaining the background color, or retaining the foreground color.
[0013] In combination with the first aspect, in some embodiments, after the electronic device receives the second operation for indicating the revised segmentation result, the electronic device may use an interactive segmentation algorithm and revise the initial segmentation result according to the second operation to obtain a revised segmentation result. Here, the interactive segmentation algorithm includes one or more of the following: Magic Wand algorithm, Intelligent Scissors algorithm, Graph Cut algorithm, Bayes Matting algorithm, or Knockout algorithm.
[0014] In combination with the first aspect, in some embodiments, the electronic device may use the following methods to update the initial segmentation model M0 to obtain the segmentation model M1:
[0015] (1) The electronic device updates the initial segmentation model M0 using an incremental learning method to obtain a segmentation model M1.
[0016] (2) The electronic device updates the initial segmentation model M0 using a combined end-cloud learning method to obtain a segmentation model M1. When the electronic device stores data locally, the method (2) can update the initial segmentation model without the user having to transmit data to the cloud, thereby protecting user privacy.
[0017] (3) When the amount of data associated with the electronic device is greater than a first threshold and less than a second threshold, the initial segmentation model M0 is updated using an incremental learning method to obtain a segmentation model M1; when the amount of data associated with the electronic device is greater than or equal to the second threshold, the initial segmentation model M0 is updated using an end-cloud combined learning method to obtain a segmentation model M1.
[0018] Here, the amount of data stored in association with the electronic device includes: the initial image I0 and the initial segmentation result stored in association with each other, and the initial image I0 and the modified segmentation result stored in association with each other.
[0019] By using different learning methods in stages to update the initial segmentation model M0 in the third method, when a small amount of data is stored in an electronic device, the local update requirement can be met, and when a large amount of data is stored in an electronic device, the update requirements of multiple electronic devices can be met. This method can effectively utilize the data stored in the electronic device.
[0020] In some embodiments, the electronic device uses a combined end-cloud learning method to update the initial segmentation model M0 to obtain a segmentation model M1: specifically, the following steps may be included: the electronic device updates the initial segmentation model M0 locally, and sends the updated model parameters to the cloud server; the electronic device receives the segmentation model M1 sent by the cloud server, and the segmentation model M1 is obtained after the cloud server learns the model parameters.
[0021] In combination with the first aspect, in some embodiments, the first user interface further includes: a first control and a second control. The first operation includes, but is not limited to: operations acting on the first control, such as touch operations, click operations, voice commands, gesture commands, etc. The second operation includes: operations, voice commands, gesture commands, etc. for marking the foreground or marking the background on the image I1, which are received by the electronic device after receiving the operations acting on the second control. Here, the operations for marking the foreground or marking the background on the image I1 may include: sliding operations on the image I1, etc.
[0022] In combination with the first aspect, in some embodiments, the electronic device may further display a second user interface before displaying the first user interface. The second user interface includes: the image I1 and the third control. The electronic device may display the first user interface in response to an operation on the third control in the second user interface.
[0023] In combination with the first aspect, in some embodiments, the image I1 is an image captured by the electronic device in portrait mode. That is, the electronic device can update the initial segmentation model according to user feedback in the scene of capturing images in portrait mode, so that the portrait shooting effect can be improved.
[0024] In a second aspect, an embodiment of the present application provides an image processing method, which is applied to an electronic device. The method may include: the electronic device displays a first user interface, the first user interface including: an image I1 obtained by the electronic device processing an initial image I0 based on an initial segmentation result; the initial segmentation result is obtained by the electronic device performing foreground and background segmentation on the initial image I0 using an initial segmentation model M0; the initial image I0 and the initial segmentation result are stored in association; the electronic device uses the associated stored initial image I0 and the initial segmentation result to update the initial segmentation model M0 to obtain a segmentation model M2; the segmentation model M2 is used to perform foreground and background segmentation on the image.
[0025] By implementing the method of the second aspect, the electronic device can use the foreground-background segmentation result obtained when performing image processing based on the foreground-background segmentation result to autonomously update the initial segmentation model and obtain an updated segmentation model. This process does not require user feedback, which can reduce the interaction between the user and the electronic device and is more convenient for the user.
[0026] In the method of the second aspect, the initial image I0, the initial segmentation model M0, and the presentation form of the segmentation result can refer to the relevant description of the first aspect, which will not be repeated here.
[0027] In combination with the second aspect, in some embodiments, after the electronic device updates the initial segmentation model M0 and obtains the segmentation model M2, the electronic device can also use the segmentation model M2 to perform foreground and background segmentation on the first image to obtain a first segmentation result; and process the first image based on the first segmentation result.
[0028] In combination with the second aspect, in some embodiments, the processing performed by the electronic device on the initial image I0 based on the initial segmentation result includes one or more of the following: highlighting the foreground, blurring the background, replacing the background, retaining the background color, or retaining the foreground color.
[0029] In conjunction with the second aspect, in some embodiments, after receiving the second operation for indicating the revised segmentation result, the electronic device can use the interactive segmentation algorithm and revise the initial segmentation result according to the second operation, thereby obtaining the revised segmentation result. For details, please refer to the relevant description of the first aspect.
[0030] In conjunction with the second aspect, in some embodiments, the electronic device updates the initial segmentation model M0. The specific manner in which the segmentation model M2 is obtained can refer to the relevant description of the first aspect.
[0031] In combination with the second aspect, the first user interface, the first operation, and the second operation may refer to the relevant description of the first aspect.
[0032] In conjunction with the second aspect, in some embodiments, the electronic device may further display a second user interface before displaying the first user interface. The second user interface may refer to the relevant description of the first aspect.
[0033] In a third aspect, an embodiment of the present application provides an electronic device. The electronic device includes one or more processors, a memory, and a display screen; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute:
[0034] A first user interface is displayed on the display screen, the first user interface comprising: an image I1 obtained by the electronic device processing the initial image I0 based on the initial segmentation result; the initial segmentation result is obtained by the electronic device performing foreground and background segmentation on the initial image I0 using the initial segmentation model M0;
[0035] A first operation for indicating that the initial segmentation result is accurate is received, and in response to the first operation, the initial image I0 and the initial segmentation result are stored in association; or a second operation for indicating a revised segmentation result is received, and in response to the second operation, the initial image I0 and the revised segmentation result are stored in association;
[0036] The initial segmentation model M0 is updated using at least one of the following items to obtain a segmentation model M1: the associated stored initial image I0 and the initial segmentation result, or the associated stored initial image I0 and the revised segmentation result; the segmentation model M1 is used to perform foreground and background segmentation on the image.
[0037] Based on the same inventive concept, the one or more processors call the computer instructions to enable the electronic device to perform the method described in the first aspect or any possible implementation of the first aspect. The steps performed by the electronic device and the beneficial effects brought about by them are not repeated.
[0038] In a fourth aspect, an embodiment of the present application provides an electronic device, which includes one or more functional units, and is used to correspondingly execute the method provided in the first aspect or any one of the possible implementation modes of the first aspect.
[0039] In a fifth aspect, the present application provides an electronic device. The electronic device includes one or more processors, a memory, and a display screen; the memory is coupled to the one or more processors, the memory is used to store a computer program code, the computer program code includes a computer instruction, and the one or more processors call the computer instruction to enable the electronic device to execute:
[0040] A first user interface is displayed on the display screen, the first user interface comprising: an image I1 obtained by the electronic device processing the initial image I0 based on the initial segmentation result; the initial segmentation result is obtained by the electronic device performing foreground and background segmentation on the initial image I0 using the initial segmentation model M0;
[0041] storing the initial image I0 and the initial segmentation result in association;
[0042] The initial image I0 and the initial segmentation result stored in association are used to update the initial segmentation model M0 to obtain a segmentation model M1: the segmentation model M1 is used to perform foreground and background segmentation on the image.
[0043] Based on the same inventive concept, the one or more processors call the computer instructions to enable the electronic device to perform the method described in the second aspect or any possible implementation of the second aspect. The steps performed by the electronic device and the beneficial effects brought about by them are not repeated.
[0044] In a sixth aspect, an embodiment of the present application provides an electronic device, which includes one or more functional units, and is used to correspondingly execute the method provided in the second aspect or any one of the possible implementations of the second aspect.
[0045] In a seventh aspect, an embodiment of the present application provides a chip, which is applied to an electronic device. The chip includes: one or more processors and an interface; the interface is used to receive a code instruction and transmit the code instruction to the processor, and the processor is used to run the code instruction so that the electronic device executes the method provided in any one of the first aspect or the possible implementation methods of the first aspect.
[0046] In an eighth aspect, an embodiment of the present application provides a chip, which is applied to an electronic device. The chip includes: one or more processors, and an interface; the interface is used to receive a code instruction and transmit the code instruction to the processor, and the processor is used to run the code instruction so that the electronic device executes the method provided in any one of the second aspect or the possible implementation methods of the second aspect.
[0047] In a ninth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when the computer program product is run on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible implementation method of the first aspect.
[0048] In the tenth aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, which, when executed on an electronic device, enables the electronic device to execute the method described in the first aspect and any possible implementation method of the first aspect.
[0049] In the eleventh aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when the above-mentioned computer program product runs on an electronic device, enables the above-mentioned electronic device to execute the method described in the second aspect and any possible implementation method of the second aspect.
[0050] In the twelfth aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions. When the above instructions are executed on an electronic device, the above electronic device executes the method described in the second aspect and any possible implementation method of the second aspect.
[0051] By implementing the technical solution provided in the embodiment of the present application, the electronic device can update the initial segmentation model to obtain an updated segmentation model. The electronic device can use the updated segmentation model to perform foreground and background segmentation on the image, obtain a more accurate foreground and background segmentation result, and achieve a better image processing effect based on the accurate foreground and background segmentation result. The image processing may include but is not limited to: highlighting the foreground, blurring the background, replacing the background, or retaining the background / foreground color. In the scene of shooting images, the implementation of the technical solution provided in the embodiment of the present application can make the portrait shooting effect better and better. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1A is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0053] Figure 1B is a software architecture block diagram of an electronic device provided in an embodiment of the present application;
[0054] Figure 2A-2I It is a schematic diagram of human-computer interaction provided by an embodiment of the present application;
[0055] Figure 3A A schematic diagram of the foreground and background provided for an embodiment of the present application;
[0056] Figure 3B , Figure 3C The pictures taken in the portrait mode before and after the initial segmentation model is updated according to the embodiment of the present application;
[0057] Figure 4 A flowchart of an image processing method provided in an embodiment of the present application;
[0058] Figure 5 , Figure 6 A mask schematic diagram provided for an embodiment of the present application;
[0059] Figure 7 A flowchart of another image processing method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0061] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0062] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
[0063] The following embodiments of the present application provide an image processing method and related devices, whereby an electronic device can update a locally stored foreground-background segmentation model based on user feedback, and use the updated foreground-background segmentation model to segment the foreground and background in an image, thereby making the segmentation result more accurate. Based on the accurate segmentation result, the electronic device can achieve better image processing.
[0064] In the following embodiments of the present application, image processing performed based on the segmentation results may include but is not limited to: highlighting the foreground, blurring the background, replacing the background, or retaining the background / foreground color. Among them, highlighting the foreground means emphasizing or highlighting the foreground by deepening the outline, color, etc. of the foreground. Blurring the background means blurring the background to make the depth of field of the background shallower, etc. Replacing the background means replacing the background with other images. Retaining the foreground color means retaining the foreground color and changing the background color to gray, black, etc. Retaining the background color means retaining the background color and changing the foreground color to gray, black, etc.
[0065] The images mentioned in the following embodiments of the present application may include: pictures, videos. Pictures may include static pictures and dynamic pictures. The images in the following embodiments of the present application may be captured by a camera of an electronic device, or may be downloaded from the Internet by the electronic device. The images in the following embodiments of the present application may be stored locally on the electronic device, or may be stored in the cloud.
[0066] In the following embodiments of the present application, an image may include a foreground and a background. The foreground is the area where the subject of the image is located, generally the area where the shooting focus is located, and the background is the area other than the foreground in the image. The subject in the image may include but is not limited to: people, animals, static objects (such as a cup placed on a table, flowers in a flowerpot, buildings on the street, etc.), etc.
[0067] In the following embodiments of the present application, the segmentation result refers to the result obtained after dividing the image into two areas, the foreground and the background. The segmentation result can also be called the foreground-background segmentation result. The segmentation result is obtained by the electronic device after processing the image using the foreground-background segmentation model. Here, the foreground-background segmentation model is a function that can obtain an output from an input, the input is an image, and the output is the foreground-background segmentation result. The foreground-background segmentation model can be used to identify the foreground and background in an image and separate the foreground and background of the image.
[0068] In an embodiment of the present application, the image segmentation result is expressed as a mask (mask image). After the electronic device performs foreground and background segmentation processing on the image, a mask image corresponding to the image can be obtained, that is, the segmentation result. Specifically, the mask image is used to block part or all of the image. In an embodiment of the present application, the mask image is used to block the foreground or background in the image, so as to facilitate the image processing by region, that is, to process the image based on the segmentation result. Regarding the actual form of the mask image, please refer to the relevant description of the subsequent drawings and embodiments, which will not be repeated here.
[0069] It is understandable that after the electronic device presents an image processed based on the foreground-background segmentation result (e.g., a picture taken in portrait mode, a picture after background replacement, etc.), the user can know the segmentation result obtained by the electronic device after performing foreground-background segmentation processing on the image. For example, after the electronic device displays a picture taken in portrait mode on the display screen, the user can know which areas of the picture the electronic device has segmented as foreground and which areas have been segmented as background based on the blur effect.
[0070] In the following embodiments of the present application, user feedback refers to the user's feedback on the segmentation result after the electronic device presents the image processing effect. The feedback may include: whether the segmentation result is accurate, the segmentation result corrected by the user if the segmentation result is inaccurate, etc.
[0071] The following first introduces the electronic device provided by the embodiments of the present application.
[0072] The electronic device in the embodiment of the present application is a device with image processing capability. Image processing may include the foreground prominence, background blur, background replacement, foreground / background color retention, etc. mentioned above. The embodiment of the present application does not limit the type of electronic device, and the electronic device may be a mobile phone, a tablet computer, a personal digital assistant (PDA), a wearable device (such as a smart bracelet, a smart watch), a laptop computer (laptop), a laptop computer (laptop) with a touch-sensitive surface (such as a touch panel), and other portable electronic devices. Exemplary embodiments of portable electronic devices include but are not limited to portable electronic devices equipped with iOS, Android, Microsoft or other operating systems. It should also be understood that in some other embodiments, the above-mentioned electronic device may not be a portable electronic device, but a desktop computer with a touch-sensitive surface or a touch panel.
[0073] refer to Figure 1A , Figure 1A A schematic structural diagram of an exemplary electronic device 100 provided in an embodiment of the present application is shown.
[0074] 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, etc. 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.
[0075] 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.
[0076] 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 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.
[0077] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0078] 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.
[0079] 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.
[0080] 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.
[0081] 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.
[0082] 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.
[0083] 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.
[0084] 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.
[0085] 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.
[0086] 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.
[0087] 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.
[0088] 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.
[0089] 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 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.
[0090] 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.
[0091] 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.
[0092] 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.
[0093] 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.
[0094] 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.
[0095] 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).
[0096] 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.
[0097] 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.
[0098] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0099] 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.
[0100] 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.
[0101] 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.
[0102] 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.
[0103] 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.
[0104] 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.
[0105] The internal memory 121 can be used to store computer executable program codes, which include instructions. 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. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor.
[0106] 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.
[0107] 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.
[0108] 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.
[0109] 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.
[0110] 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.
[0111] 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.
[0112] 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.
[0113] 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.
[0114] 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.
[0115] 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.
[0116] 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.
[0117] 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.
[0118] 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.
[0119] 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.
[0120] 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.
[0121] 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.
[0122] 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.
[0123] 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.
[0124] 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.
[0125] 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.
[0126] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0127] 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.
[0128] In some embodiments of the present application, the memory 121 may be used to store the initial segmentation model M0. The initial segmentation model M0 may refer to the relevant description of the subsequent embodiments, which will not be described here.
[0129] In some embodiments of the present application, the processor 110 (eg, NPU) may be used to perform foreground and background segmentation on the initial image I0 using the initial segmentation model M0 to obtain an initial segmentation result. The initial image I0 and the initial segmentation result may refer to the relevant description of the subsequent embodiments, which will not be described here.
[0130] In some embodiments of the present application, the memory 121 may be used to associate and store the initial image I0 with the initial segmentation result, and / or to associate and store the initial image I0 with the revised segmentation result. The revised segmentation result may refer to the relevant description of the subsequent embodiments, which will not be described here.
[0131] In some embodiments of the present application, the processor 110 (e.g., NPU) may also be used to update the initial segmentation model M0 using the data stored in the memory 121 to obtain an updated segmentation model M1. The specific implementation of the processor 110 updating the initial segmentation model M0 may refer to the relevant description of the subsequent embodiments, which will not be repeated here.
[0132] 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.
[0133] Figure 1B It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.
[0134] The layered architecture divides the software into several layers, each with clear roles 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: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
[0135] The application layer can include a series of application packages.
[0136] like Figure 1B As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0137] 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.
[0138] like Figure 1B 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.
[0139] 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.
[0140] 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.
[0141] 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.
[0142] 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.).
[0143] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0144] 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.
[0145] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0146] 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.
[0147] 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.
[0148] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0149] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0150] 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.
[0151] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0152] A 2D graphics engine is a drawing engine for 2D drawings.
[0153] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0154] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.
[0155] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event. For example, if the touch operation is a touch single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer to capture static images or videos through the camera 193.
[0156] based on Figure 1A The electronic device 100 shown below describes the image processing method provided in the embodiment of the present application through a specific application scenario in combination with the user interface provided in the embodiment of the present application.
[0157] The term "user interface (UI)" in the embodiments of the present application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. A common form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operation displayed in a graphical manner. It can be an interface element such as an icon, window, or control displayed on a display screen of an electronic device, wherein a control may include visual interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets.
[0158] The following describes the image processing method provided in an embodiment of the present application by taking a scenario in which an electronic device takes images in portrait mode as an example.
[0159] refer to Figure 2A , Figure 2A The user interface 21 provided in the embodiment of the present application is a method for implementing a "photographing interface".
[0160] The user interface 21 may be provided by a "camera" application. "Camera" is an application for capturing images installed on electronic devices such as smartphones and tablet computers. The embodiment of the present application does not limit the name of the application. The application may support the display of various types of images captured by the camera 193, that is, the object displayed by the "camera" is the image captured by the camera 193. The camera 193 may be a front camera or a rear camera. The user interface 21 may be a user interface opened by a user clicking on a camera icon on the desktop provided by the electronic device, or it may be a user interface for capturing images opened by a user in other applications, for example, a user may click on a shooting control in the "WeChat" application to open the user interface 21.
[0161] As shown in 2A, the user interface 21 may include: a captured image echo area 201, a shooting control 202, a control 203 for switching cameras, a shooting mode menu 204, a viewfinder 205, and some other controls such as a control for adjusting the size of the image displayed in the viewfinder, a control for displaying introductory information about the shooting mode, a control for setting various parameters during shooting, and a control for turning on / off the flash, etc.
[0162] The captured image echo area 201 is used to display the image most recently saved by the electronic device. The image can be captured by the camera of the electronic device or downloaded from the Internet. The image can be saved locally on the electronic device or in the cloud. The captured image echo area 201 is also used to monitor user operations to open the album. The electronic device can detect user operations (such as click operations) acting on area 201, and in response to the operation, the electronic device starts the album and displays the most recently saved image. Here, the album is an application installed on the electronic device for displaying images saved locally on the electronic device or in the cloud.
[0163] The shooting control 202 is used to monitor the user operation of shooting an image. The electronic device can detect the user operation (such as a click operation) acting on the shooting control 202, and save the image captured by the camera in response to the user operation. In other words, the user can click the shooting control 202 to shoot an image.
[0164] The control 203 for switching the camera can monitor the user operation for switching the camera. The electronic device 100 can detect the user operation (such as a click operation) acting on the control 203, and switch the camera in response to the user operation, such as switching the rear camera to the front camera, or switching the front camera to the rear camera.
[0165] The viewfinder 205 can be used to display the image captured by the camera. In other words, the viewfinder 205 can be used to display the preview image. The electronic device 100 can refresh the display content therein in real time. The image displayed in the viewfinder 205 can be captured by the rear camera or the front camera.
[0166] The shooting mode menu 204 may display one or more shooting mode options, such as large aperture mode options, night scene mode options, portrait mode options, photo mode options, video mode options, professional mode options, etc. The shooting mode options may be implemented as icons, text, or other forms.
[0167] like Figure 2A As shown, the current shooting mode of the electronic device is portrait mode. In portrait mode, the electronic device can use the currently stored foreground and background segmentation model to perform foreground and background segmentation on the original image acquired by the camera, and then process the image based on the foreground and background segmentation result, and display the processed image in the viewfinder 205. The processing may include highlighting the portrait subject, blurring the background, beautifying the face (e.g., face slimming, acne removal, etc.), beautifying the body (e.g., weight loss, etc.), etc. Here, the foreground and background segmentation model currently stored in the electronic device can be a segmentation model pre-stored when the electronic device leaves the factory, or it can be a segmentation model after learning or updating, and the embodiments of the present application do not limit this. Here, the foreground and background segmentation model currently stored in the electronic device can be referred to as the initial segmentation model M0. For a detailed description of the initial segmentation model M0, please refer to the relevant description of the subsequent embodiments, which will not be repeated here.
[0168] For example, Figure 2A and 2B As shown, the user can input a user operation (such as a touch operation) on the control 202 to save the image displayed in the viewfinder 205. In response to the user operation, the electronic device saves the image displayed in the viewfinder 205. Figure 2B As shown, in response to the user operation, the image saved by the electronic device is displayed in the captured image echo area 201 .
[0169] like Figure 2C As shown, in response to Figure 2B In response to a user operation (e.g., a touch operation) detected on the captured image echo area 201, the electronic device starts the photo album application and displays the most recently saved image, i.e., the image 206 captured by the electronic device in the portrait mode. Image 206 is obtained by the electronic device performing foreground and background segmentation on the original image captured by the camera, and then performing processing such as highlighting the portrait subject, blurring the background, beautifying the face, and beautifying the body based on the foreground and background segmentation results. In other words, the electronic device displays the image as Figure 2CThe picture 206 shown is the effect of the electronic device processing the image based on the foreground and background segmentation result.
[0170] After the electronic device presents the effect of processing the image based on the background segmentation result, the user can learn the foreground and background segmentation result of the image through the effect and give feedback on the foreground and background segmentation result.
[0171] Figure 2D-2H A method for a user to provide feedback on the foreground and background segmentation results of an image is exemplified.
[0172] refer to Figure 2D , the electronic device can respond to Figure 2C An operation (such as a touch operation, a long press operation, etc.) detected in any area of the user interface 22 is displayed, and one or more controls for processing the image 206 are displayed. The one or more controls may include, but are not limited to: a control for sharing an image, a control for collecting an image, a control for a user to delete an image, a control 207 for feeding back a foreground-background segmentation result, and other controls. The one or more controls may be expressed in a form including, but not limited to, text or an icon.
[0173] refer to Figure 2E , Figure 2D The control 207 in the figure can be used to monitor user operations (such as touch operations). In response to the user operation, the electronic device displays a window 208 in the user interface 22. Window 208 is used to ask the user whether he thinks that the electronic device's foreground and background segmentation result of the picture 206 is accurate. Window 208 may include: prompt information 208A, control 208B and control 208C. Prompt information 208A is used to prompt the user to input feedback on the foreground and background segmentation result, for example, it can be a text message "Is the foreground and background segmentation result accurate?". Control 208B can be used to monitor user operations (such as touch operations), and the user operation is used to indicate that the electronic device is accurate in the foreground and background segmentation result of the picture 206. Control 208C can be used to monitor user operations (such as touch operations), and the user operation is used to indicate that the electronic device is inaccurate in the foreground and background segmentation result of the picture 206. The expression forms of controls 208B and 208C may include but are not limited to text or icons.
[0174] Understandably, users see Figure 2E When the picture 206 shown is shown, the segmentation result obtained by the electronic device after using the initial segmentation model M0 to perform foreground and background segmentation processing on the picture 206 can be known based on the blurring effect of the background in the picture 206, the highlighting effect of the portrait subject, etc., that is, which areas in the picture 206 are segmented as foreground and which areas are segmented as background by the electronic device.
[0175] In some embodiments of the present application, in order to make the user more clearly aware of the segmentation result obtained by the electronic device after performing foreground and background segmentation processing on the image using the initial segmentation model M0, the electronic device may also prompt the user with the segmentation result. The electronic device may prompt the user in ways including but not limited to: drawing the edge of the foreground / background with lines, covering the foreground / background area with shadows, etc. For example, refer to Figure 2E , the electronic device covers the foreground with a shadow. Figure 2E It can be seen that the hair edge, part of the arm and other areas of the portrait in the picture 206 that should be the foreground are segmented as the background, and such segmentation result is not accurate enough.
[0176] After the user knows the segmentation result, he can input feedback on the segmentation result through window 208. It is not limited to inputting feedback through window 208. In other embodiments of the present application, the user can also input feedback through voice, gesture, etc., and the present application does not limit this.
[0177] In some embodiments of the present application, when the user believes that the segmentation result generated by the electronic device is inaccurate, for example, the electronic device Figure 2E When a user operation is detected on the control 208C shown, the electronic device may also prompt the user to correct the segmentation result, so that the user can manually mark a more accurate foreground and / or background on the image.
[0178] Figure 2F A method in which an electronic device prompts a user to correct a segmentation result is shown.
[0179] like Figure 2F As shown, in response to Figure 2E In response to a user operation (such as a touch operation) detected on the control 208C in the image, the electronic device may display text information 209, control 210 and control 211 in the user interface 22. Among them, the text information 209 is used to prompt the user to mark the accurate foreground and / or background, and the text information 209 may be, for example, "Please mark the accurate foreground or background". Control 210 may be used to monitor user operations (such as touch operations), and in response to the user operations, the electronic device may receive operations for marking the foreground. Control 211 may be used to monitor user operations (such as touch operations), and in response to the user operations, the electronic device may receive operations for marking the background. The expression forms of controls 210 and 211 may include, but are not limited to, text or icons.
[0180] Figure 2G-2H A method for a user to modify a segmentation result is exemplified.
[0181] For example, reference Figure 2G , in response to Figure 2FIn some embodiments, the electronic device may receive an operation for marking the foreground in response to a user operation (e.g., a touch operation) detected on the control 210 in the image. For ease of description, the state in which the electronic device is in response to a user operation detected on the control 210 may be referred to as a "foreground marking mode". In the "foreground marking mode", the user may mark the more accurate foreground that is artificially segmented on the image. In some embodiments, in the "foreground marking mode", the user may zoom in on the image 206 and then mark the accurate foreground on the image. For example, the user may input a two-finger zoom-in gesture on the display screen to zoom in on the image 206.
[0182] The user can input a user operation by hand in the foreground area of the image 206. In response to the user operation, the electronic device marks the area receiving the user operation as the foreground. The user operation may include but is not limited to: a gesture of drawing a graphic, a sliding gesture, a touch gesture, etc. Figure 2G , area 212 is the area where the hair edge and part of the arm of the portrait in the picture are located, and the area 212 is marked as foreground by the user.
[0183] In the embodiment of the present application, after the electronic device enters the "foreground annotation mode", after receiving an operation for annotating the foreground, the control 213 and the control 214 may also be displayed on the display screen. Figure 2H , control 213 can be used to monitor user operations, and in response to the user operations, the electronic device cancels all or the most recent annotation operations input by the user. Control 214 can be used to monitor user operations, and in response to the user operations, the electronic device records all annotation operations input by the user.
[0184] refer to Fig.2I , in response to Figure 2H The electronic device records a new foreground area for user operations (such as touch operations) input on the control 214 shown, that is, stores the segmentation result corrected by the user. The new foreground area includes: a first area and a second area. The first area is the area in the foreground area obtained by the electronic device using the initial segmentation model M0 to perform foreground and background segmentation on the image, which is not marked as background by the user; the second area is the area in the background area obtained by the electronic device using the initial segmentation model M0 to perform foreground and background segmentation on the image, which is marked as foreground by the user. Reference Figure 3A , Figure 3A A possible first area and second area are shown, and the area filled with oblique lines in the figure is a new foreground area.
[0185] In some embodiments, the electronic device may also cover the new foreground area with a shadow after storing the segmentation result modified by the user, so as to facilitate the user to view. Fig.2IAs shown, the shadow on the foreground area in the picture can automatically disappear after being displayed for a period of time without user interaction. If the user is still inaccurate for the segmentation result of this correction, the user can also give feedback to the picture 206 again.
[0186] How users annotate the background and Figure 2F-Figure 2I The method in which the user marks the foreground in the embodiment is similar and will not be described in detail here.
[0187] Not limited to the above Figure 2A-2I For the static pictures shown in the embodiment, the user can also provide feedback on the foreground and background segmentation results of dynamic pictures, videos and other images, which is not limited in the embodiment of the present application.
[0188] Not limited to the above Figure 2A-2I In the illustrated embodiment, the user can also provide feedback on the segmentation result generated by the electronic device in other scenarios, such as when the electronic device displays an image after replacing the background or when the electronic device displays an image after retaining the foreground / background colors.
[0189] In an embodiment of the present application, the electronic device can update the stored initial segmentation model M0 according to the user's feedback to obtain an updated segmentation model. Using the updated segmentation model, the electronic device can obtain a more accurate foreground and background segmentation result, thereby achieving a better image processing effect based on the accurate foreground and background segmentation result. In an embodiment of the present application, when the electronic device uses the updated segmentation model to perform foreground and background segmentation on an image, and processes the image based on the segmentation result, the image can be referred to as a first image, and the segmentation result can be referred to as a first segmentation result.
[0190] For example, reference Figure 3B , a and b show two pictures obtained by an electronic device taking the same picture in portrait mode. The picture shown in a is obtained by the electronic device using the initial segmentation model M0 to perform foreground and background segmentation on the original picture obtained by the camera, and then blurring the background of the picture based on the segmentation result. The picture shown in b is obtained by the electronic device using the updated segmentation model to perform foreground and background segmentation on the original picture obtained by the camera, and then blurring the background of the picture based on the segmentation result.
[0191] For example, reference Figure 3C, a and b show two pictures obtained by an electronic device taking the same picture in portrait mode. The picture shown in a is obtained by the electronic device using the initial segmentation model M0 to perform foreground and background segmentation on the original picture obtained by the camera, and then blurring the background of the picture based on the segmentation result. The picture shown in b is obtained by the electronic device using the updated segmentation model to perform foreground and background segmentation on the original picture obtained by the camera, and then blurring the background of the picture based on the segmentation result.
[0192] How the electronic device updates the initial segmentation model M0 according to the user's feedback will be described in detail below.
[0193] refer to Figure 4 , Figure 4 FIG. 2 is a flow chart of a method for updating an initial segmentation model M0 provided in an embodiment of the present application. Figure 4 As shown, the method may include the following steps:
[0194] Step S110: The electronic device uses the initial segmentation model M0 to perform foreground and background segmentation on the initial image I0, and processes the initial image I0 based on the segmentation result to obtain a processed image I1. The processing may include but is not limited to: highlighting the foreground, blurring the background, replacing the background, or retaining the background / foreground color.
[0195] In the embodiment of the present application, the initial image I0 refers to an image that has not been processed by foreground-background segmentation, nor by any other processing (such as highlighting the foreground, blurring the background, replacing the background, retaining the background / foreground color, etc.). The initial image I0 can be a picture or a video. In some embodiments, the initial image I0 can be captured by a camera of an electronic device, for example, the initial image can be the above-mentioned Figure 2A and Figure 2B In the embodiment, the initial image I0 is an image captured by the camera when the electronic device starts the camera application. In other embodiments, the initial image I0 may also be downloaded by the electronic device from the network or obtained from other devices.
[0196] In an embodiment of the present application, the initial segmentation model M0 may be a segmentation model pre-stored in the electronic device when it leaves the factory, or it may be a segmentation model received by the electronic device from a server after learning or updating. The initial segmentation model M0 is obtained by learning a large amount of training data using machine learning. The machine learning may include but is not limited to various algorithms in deep learning (DL), such as convolutional neural network (CNN). The training data may include: an image, and an accurate foreground and background segmentation result of the image. The accurate foreground and background segmentation result of the image may be expressed in the form of a mask image. The mask image with accurate foreground and background segmentation results may be a machine-generated mask image collected by R&D personnel, or it may be a mask image obtained by manual annotation. The process of training or learning to obtain the initial segmentation model may be performed by a server with powerful computing power. The server may send the initial segmentation model M0 obtained by training or learning to the electronic device.
[0197] The electronic device can use the initial segmentation model M0 to perform foreground and background segmentation on the initial image I0, identify the foreground and background in the initial image I0, and obtain a foreground and background segmentation result. In an embodiment of the present application, the segmentation result obtained by the electronic device using the initial segmentation model M0 to perform foreground and background segmentation on the initial image I0 is referred to as an initial segmentation result. The initial segmentation result can be an initial mask image F0.
[0198] refer to Figure 5 a and b in FIG. 1 , a shows an initial image I0, which may be Figure 2A and Figure 2B In the embodiment, captured by the camera, b is an initial mask image F0 obtained after the electronic device uses the initial segmentation model M0 to perform foreground and background segmentation on the initial image I0 shown in a.
[0199] refer to Figure 6 In a and b, a shows an initial image I0, and b is an initial mask image F0 obtained after the electronic device uses the initial segmentation model M0 to perform foreground and background segmentation on the initial image I0 shown in a.
[0200] In an embodiment of the present application, after obtaining the initial segmentation result, the electronic device may process the initial image I0 based on the initial segmentation result. The processing may include but is not limited to: highlighting the foreground, blurring the background, replacing the background, or retaining the background / foreground color.
[0201] It is understandable that in different scenarios, the electronic device may execute step S110 at different times.
[0202] For example, in a scenario where an electronic device is shooting an image, the electronic device may execute step S110 in response to the user selecting the portrait mode. That is, after the electronic device activates the camera application and enters the portrait mode, the initial segmentation model M0 may be used to perform foreground and background segmentation on the initial image I0 acquired by the camera, and based on the initial segmentation result, the initial image I0 may be processed to highlight the portrait subject, blur the background, beautify the face, beautify the body, etc., so as to obtain a processed image I1.
[0203] For another example, when the electronic device starts the album application to display an image, step S110 may be executed in response to an operation for replacing the image background. That is, after receiving the operation for replacing the image background, the electronic device may use the initial segmentation model M0 to perform foreground and background segmentation on the initial image I0 (i.e., the currently displayed image), and replace the background of the initial image I0 based on the initial segmentation result, thereby obtaining a processed image I1.
[0204] Step S120: The electronic device displays the processed image I1.
[0205] For example, in a scene where an electronic device captures an image, the electronic device performs foreground and background segmentation on the initial image I0 and processes the image I1 based on the initial segmentation result. Figure 2C and Figure 2D Picture 206 is shown.
[0206] Step S130: The electronic device receives user feedback on the initial segmentation result, and stores the initial image I0 and the initial segmentation result in association with each other according to the feedback, and / or stores the initial image I0 and the revised segmentation result in association with each other according to the feedback.
[0207] It is understandable that after the electronic device displays the processed image I1, the user can learn the initial segmentation result through the image I1. Figure 2C After viewing the picture 206 shown in 2D or 2D, the user can know which areas in the picture 206 the electronic device has segmented as foreground (for example, the hair edge and part of the arm of the portrait in the picture 206 are segmented as background) and which areas are segmented as background according to the blurring effect.
[0208] The user may input feedback on the initial segmentation result to the electronic device, and the feedback may include: an operation for indicating whether the initial segmentation result is accurate (for example, an operation on Figure 2E operations on the control 208B or the control 208C shown (e.g., touch operations)), operations for marking the foreground and / or background when the initial segmentation result is inaccurate (e.g., Figure 2HHere, the electronic device receives the user's feedback on the initial segmentation result in a manner that can be specifically referred to above. Figure 2E-Figure 2I Description of the embodiments.
[0209] When the electronic device receives an operation for indicating that the initial segmentation result is accurate, that is, when the user believes that the initial segmentation result is accurate, the electronic device stores the initial image I0 and the initial segmentation result in association. In some embodiments, the electronic device stores an image pair (I0, F0), where I0 is the initial image, and F0 is the initial mask image F0 obtained by the electronic device after performing foreground and background segmentation on the initial image I0 using the initial segmentation model, that is, the initial segmentation result.
[0210] When the electronic device receives an operation for indicating that the initial segmentation result is inaccurate, that is, when the user believes that the initial segmentation result is inaccurate, the electronic device does not perform any processing on the initial image I0 and the initial segmentation result.
[0211] When the electronic device receives an operation for indicating that the initial segmentation result is inaccurate, that is, when the user believes that the initial segmentation result is inaccurate, and when the electronic device receives an operation for marking the foreground and / or background, the electronic device stores the initial image I0 and the segmentation result corrected by the user in association. In some embodiments, the electronic device stores an image pair (I0, F0'), where I0 is the initial image and F0' is the corrected mask image, that is, the segmentation result generated by the electronic device based on the foreground and / or background marked by the user. Figure 5 c, which shows the above Figure 2E-Figure 2I In the embodiment shown, when the user marks the foreground and / or background, the electronic device generates a modified mask image F0'. Figure 6 FIG. 3 shows another modified mask image F0′ generated by the electronic device. FIG.
[0212] In an embodiment of the present application, the modified mask image F0' can be obtained in the following manner: the electronic device receives the operation of marking the foreground and / or background by the user, and uses the interactive segmentation algorithm to process the foreground and / or background marked by the user to obtain the modified mask image F0'. Here, the interactive segmentation algorithm can improve the foreground and background segmentation results through the foreground and / or background marked by the user to generate a modified mask image F0'. The interactive segmentation algorithm may include but is not limited to the Magic Wand algorithm, the Intelligent Scissors algorithm, the Graph Cut algorithm, the Bayes Matting algorithm, the Knockout algorithm, and the like.
[0213] The electronic device can store the initial image I0 and the initial segmentation result, and / or the initial image I0 and the modified segmentation result on the local side, or store them in the cloud, and the embodiments of the present application are not limited to this. It is understandable that when the electronic device stores the initial image I0 and the initial segmentation result, and / or the initial image I0 and the modified segmentation result on the local side, it can avoid leaking user privacy and has high security.
[0214] Step S140: The electronic device uses the stored data to update the initial segmentation model M0 to obtain an updated segmentation model M1.
[0215] In the embodiment of the present application, the electronic device may perform the above steps S110 to S130 multiple times to store a certain amount of data. The data stored by the electronic device includes: the associated stored initial image I0 and the initial segmentation result, and / or, the associated stored initial image I0 and the modified segmentation result,
[0216] In some embodiments, the electronic device may update the initial segmentation model periodically. For example, the electronic device may update the initial segmentation model once a week. In other embodiments, the electronic device may update the initial segmentation model under the triggering of the user.
[0217] In the embodiment of the present application, the electronic device may update the initial segmentation model M0 in the following ways:
[0218] (1) The electronic device uses incremental learning to update the initial segmentation model M0.
[0219] Incremental learning is a type of machine learning. Electronic devices use incremental learning to learn new knowledge from new stored data without having to reprocess previously processed data. Incremental learning algorithms may include one or more of the following: decision tree, fuzzy ARTMAP, support vector machine (SVM) incremental learning algorithm, etc.
[0220] (2) The electronic device uses a combined end-cloud learning approach to update the initial segmentation model M0.
[0221] The electronic device may use the end-cloud combined learning method to update the initial segmentation model M0, which may include the following steps:
[0222] 1. The electronic device updates the initial segmentation model M0 locally using the stored data, and uploads the updated model parameters to the cloud server. The embodiment of the present application does not impose any restrictions on the way in which the electronic device updates the initial segmentation model M0 locally. For example, the electronic device can use the incremental learning algorithm in the above-mentioned method (1) to update the initial segmentation model M0 locally. Here, the model parameters are used to describe the model.
[0223] 2. The cloud server integrates and learns the model parameters uploaded by one or more electronic devices to obtain an updated segmentation model M1.
[0224] 3. The cloud server sends the updated segmentation model M1 to the electronic device.
[0225] It is understandable that if the electronic device stores the initial image I0 and the initial segmentation result, and / or the initial image I0 and the modified segmentation result on the local side, then using the above-mentioned end-cloud combination method (2), the electronic device can update the initial segmentation model M0 without uploading the data to the cloud to obtain the updated segmentation model M1. This method can protect the user's personal privacy.
[0226] (3) The electronic device uses a combination of incremental learning and end-cloud combined learning to update the initial segmentation model M0.
[0227] Specifically, the electronic device may determine which learning method to use to update the initial segmentation model M0 according to the amount of stored data.
[0228] In a specific embodiment, when N1<N<N2, the electronic device uses an incremental learning method to update the initial segmentation model; when N≥N2, the electronic device uses a combined end-cloud learning method to update the initial segmentation model M0. Wherein N is the number of image pairs stored by the electronic device. The image pair includes: an image pair (I0, F0) associated and stored by the electronic device when the initial segmentation result is accurate, and / or an image pair (I0, F0') associated and stored by the electronic device when the initial segmentation result is inaccurate and the user has marked the foreground and background. N1 is a first threshold, N2 is a second threshold, and N1≥N2. N1 and N2 can be set in advance.
[0229] By using different learning methods in stages to update the initial segmentation model M0 in the third method, when a small amount of data is stored in an electronic device, the local update requirement can be met, and when a large amount of data is stored in an electronic device, the update requirements of multiple electronic devices can be met. This method can effectively utilize the data stored in the electronic device.
[0230] pass Figure 4The electronic device can obtain an updated segmentation model M1 by using the updated segmentation model M1 to perform foreground and background segmentation processing on the image, thereby obtaining a more accurate foreground and background segmentation result, thereby achieving a better image processing effect based on the accurate foreground and background segmentation result.
[0231] The method of updating the initial segmentation model M0 according to the user's feedback is not limited to this method. The embodiment of the present application also provides a method for an electronic device to autonomously update the initial segmentation model M0. Figure 7 , Figure 7 The schematic diagram of the method for the electronic device to autonomously update the initial segmentation model M0 is shown. Figure 7 As shown, the method may include the following steps:
[0232] Step 210: The electronic device uses the initial segmentation model M0 to perform foreground and background segmentation on the initial image I0, and processes the initial image I0 based on the segmentation result to obtain a processed image I1. The processing may include but is not limited to: highlighting the foreground, blurring the background, replacing the background, or retaining the background / foreground color.
[0233] Step S220: The electronic device displays the processed image I1.
[0234] Step S210 can refer to Figure 4 For the description of step S110, please refer to Figure 4 The relevant description of step S120 is shown.
[0235] Step S230: The electronic device stores the initial image I0 and the initial segmentation result in association with each other.
[0236] In some embodiments, the electronic device stores an image pair (I0, F0), where I0 is an initial image, and F0 is an initial mask image obtained by the electronic device after performing foreground and background segmentation on the initial image I0 using an initial segmentation model M0, that is, an initial segmentation result.
[0237] Step S240: The electronic device updates the initial segmentation model M0 using the associated stored initial image I0 and the initial segmentation result to obtain an updated segmentation model M2.
[0238] Specifically, the electronic device regards the initial segmentation result in step S210 as an accurate segmentation result, and uses the segmentation result to update the segmentation model.
[0239] In some embodiments, the electronic device may update the initial segmentation model periodically. For example, the electronic device may update the initial segmentation model once a week. In other embodiments, the electronic device may update the initial segmentation model under the triggering of the user.
[0240] Here, the electronic device can use incremental learning to update the initial segmentation model M0, or can use end-cloud combined learning to update the initial segmentation model M0, or can use a combination of incremental learning and end-cloud combined learning to update the initial segmentation model M0, which is not limited in the present embodiment. The specific implementation of the electronic device updating the initial segmentation model M0 can be referred to Figure 4 The relevant description in step S140 in the embodiment will not be repeated here.
[0241] pass Figure 7 In the method shown, the electronic device can utilize the foreground-background segmentation result obtained when performing image processing based on the foreground-background segmentation result to autonomously update the initial segmentation model M0 and obtain the updated segmentation model M2. Figure 7 The process of the electronic device autonomously updating the segmentation model shown does not require user feedback, which can reduce the interaction between the user and the electronic device and is more convenient for the user.
[0242] In the embodiments of the present application, Figure 2E The illustrated user interface 22 may be referred to as a first user interface.
[0243] The operation received by the electronic device to indicate that the initial segmentation result is accurate can be referred to as a first operation. The first operation may include but is not limited to: Figure 2E Operations on the control 208B in the user interface 22 shown, such as touch operations, click operations, voice commands, gesture commands, etc.
[0244] The operation received by the electronic device for indicating the modified segmentation result may be referred to as a second operation. The second operation may include but is not limited to: Figure 2E After an operation (eg, a touch operation) on the control 208C in the user interface 22 is shown, an operation (eg, a sliding operation) is performed on the picture 206 to mark the foreground or mark the background.
[0245] In the embodiments of the present application, Figure 2D The user interface 22 shown may be referred to as a second user interface. The control 207 may be referred to as a third control.
[0246] Through the above Figure 2A-2I The user interface shown, Figure 4 and Figure 7The method for updating the initial segmentation model M0 shown in the figure can obtain an updated segmentation model for the electronic device. The electronic device can use the updated segmentation model to perform foreground and background segmentation on the image, obtain a more accurate foreground and background segmentation result, and achieve a better image processing effect based on the accurate foreground and background segmentation result. The image processing may include but is not limited to: highlighting the foreground, blurring the background, replacing the background, or retaining the background / foreground color. In the scene of shooting an image, the technical solution provided by the embodiment of the present application is implemented to make the portrait shooting effect better and better.
[0247] The various implementation modes of the present application can be combined arbitrarily to achieve different technical effects.
[0248] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in this application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk), etc.
[0249] In short, the above description is only an embodiment of the technical solution of the present invention, and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made according to the disclosure of the present invention shall be included in the protection scope of the present invention.
Claims
1. An image processing method, It is characterized in that include: The electronic device displays a first user interface, wherein the first user interface includes: the electronic device performs segmentation of the initial image I based on the initial segmentation result; 0 The image I obtained after processing 1 The initial segmentation result is obtained by the electronic device using the initial segmentation model M 0 For the initial image I 0 Get it by doing foreground and background segmentation; The electronic device receives a first operation indicating that the initial segmentation result is accurate, and in response to the first operation, stores the initial image I in association with the initial image. 0 and the initial segmentation result; or, the electronic device receives a second operation for indicating a revised segmentation result, and in response to the second operation, stores the initial image I in association 0 and the modified segmentation result; When the amount of data associated with the electronic device is greater than a first threshold and less than a second threshold, the initial segmentation model M is updated using an incremental learning method based on the associated stored data. 0 , get the segmentation model M 1 ; When the amount of data associated with the electronic device is greater than or equal to a second threshold, the electronic device updates the initial segmentation model M locally based on the associated stored data using an incremental learning method. 0 and sending the parameters of the updated model to the cloud server; the electronic device receives the segmentation model M sent by the cloud server 1 , the segmentation model M 1 The cloud server is obtained by learning the parameters of the models uploaded by multiple electronic devices; The segmentation model M 1 Used to segment the foreground and background of an image.
2. The method according to claim 1, It is characterized in that The electronic device obtains the segmentation model M 1 Afterwards, the method further comprises: The electronic device uses the segmentation model M 1 Perform foreground and background segmentation on the first image to obtain a first segmentation result; The first image is processed based on the first segmentation result.
3. The method according to claim 1, It is characterized in that The electronic device performs segmentation on the initial image I based on the initial segmentation result. 0 The processing performed includes one or more of the following: highlighting the foreground, blurring the background, replacing the background, retaining the background color, or retaining the foreground color.
4. The method according to claim 1, It is characterized in that The modified segmentation result is obtained by the electronic device using an interactive segmentation algorithm to modify the initial segmentation result according to the second operation; the interactive segmentation algorithm includes one or more of the following: Magic Wand algorithm, Intelligent Scissors algorithm, Graph Cut algorithm, Bayes Matting algorithm or Knockout algorithm.
5. The method according to claim 1, It is characterized in that The first user interface further includes: a first control and a second control; The first operation includes: an operation acting on the first control; The second operation includes: after the electronic device receives the operation acting on the second control, the received 1 The operation of marking the foreground or marking the background.
6. The method according to claim 5, It is characterized in that The electronic device displays a first user interface, specifically comprising: The electronic device displays the first user interface in response to an operation on a third control in the second user interface; the second user interface includes: the image I 1 , the third control.
7. The method according to any one of claims 1 to 6, It is characterized in that The image I 1 It is an image captured by the electronic device in portrait mode.
8. An electronic device, It is characterized in that The electronic device comprises one or more processors, a memory and a display screen; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute: A first user interface is displayed on the display screen, wherein the first user interface includes: the electronic device performs segmentation of the initial image I based on the initial segmentation result; 0 The image I obtained after processing 1 The initial segmentation result is obtained by the electronic device using the initial segmentation model M 0 For the initial image I 0 Get it by doing foreground and background segmentation; receiving a first operation for indicating that the initial segmentation result is accurate, and in response to the first operation, storing the initial image I in association with the initial image 0 and the initial segmentation result; or, receiving a second operation for indicating a modified segmentation result, in response to the second operation, storing the initial image I in association 0 and the modified segmentation result; When the amount of data associated with the electronic device is greater than a first threshold and less than a second threshold, the initial segmentation model M is updated using an incremental learning method based on the associated stored data. 0 , get the segmentation model M 1 ; When the amount of data associated with the electronic device is greater than or equal to a second threshold, the initial segmentation model M is updated locally based on the associated stored data using an incremental learning method. 0 , and send the parameters of the updated model to the cloud server; receive the segmentation model M sent by the cloud server 1 , the segmentation model M 1 The cloud server learns the parameters of the models uploaded by multiple electronic devices; the segmentation model M 1 Used to segment the foreground and background of an image.
9. The electronic device according to claim 8, It is characterized in that The one or more processors are further configured to call the computer instructions to cause the electronic device to execute: Using the segmentation model M 1 Perform foreground and background segmentation on the first image to obtain a first segmentation result; The first image is processed based on the first segmentation result.
10. The electronic device according to claim 8, It is characterized in that The electronic device performs segmentation on the initial image I based on the initial segmentation result. 0 The processing performed includes one or more of the following: highlighting the foreground, blurring the background, replacing the background, retaining the background color, or retaining the foreground color.
11. The electronic device according to claim 8, It is characterized in that The modified segmentation result is obtained by the electronic device using an interactive segmentation algorithm to modify the initial segmentation result according to the second operation; the interactive segmentation algorithm includes one or more of the following: Magic Wand algorithm, Intelligent Scissors algorithm, Graph Cut algorithm, Bayes Matting algorithm or Knockout algorithm.
12. The electronic device according to claim 8, It is characterized in that The first user interface further includes: a first control and a second control; The first operation includes: an operation acting on the first control; The second operation includes: after the electronic device receives the operation acting on the second control, the received 1 The operation of marking the foreground or marking the background.
13. The electronic device according to claim 12, It is characterized in that The one or more processors are specifically configured to call the computer instruction so that the electronic device executes: In response to an operation on a third control in a second user interface, the first user interface is displayed; the second user interface includes: the image I 1 , the third control.
14. The electronic device according to any one of claims 8 to 13, It is characterized in that The image I 1 It is an image captured by the electronic device in portrait mode.
15. A chip, the chip is applied to electronic equipment, the chip include: one or more processors, interfaces; The interface is used to receive code instructions and transmit the code instructions to the processor, and the processor is used to run the code instructions so that the electronic device executes the method according to any one of claims 1 to 7.
