Image processing methods and related devices
By dividing and differentiating facial images and using an image processing model guided by a mask image, the problem of unclear facial images captured by the front-facing camera was solved, achieving higher quality image output.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-22
- Publication Date
- 2026-03-13
AI Technical Summary
In facial images captured by the front-facing camera, hair and eyebrows are not clear, and skin texture is rough, which affects the user experience.
By dividing the face image into regions, different image enhancement methods are used to process different regions, including edge and contour processing of regions such as hair and eyebrows, structural processing of skin regions, and feature extraction and enhancement using an image processing model guided by a mask image.
It improves the clarity and detail of facial images, making hair and eyebrows sharper and skin smoother, thus enhancing image quality.
Smart Images

Figure CN120070225B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to an image processing method and related apparatus. Background Technology
[0002] The front-facing camera of electronic devices can capture images of the user's face. Currently, facial images captured by front-facing cameras often suffer from poor image quality or loss of detail. For example, hair or eyebrows may appear blurry, and skin texture may be rough, negatively impacting the user experience. Summary of the Invention
[0003] This application provides an image processing method and related apparatus, which are applied in the field of terminal technology. In this application, it is beneficial to improve the image quality of face images.
[0004] In a first aspect, embodiments of this application propose an image processing method, comprising: acquiring a first image in response to an operation for triggering a photograph; dividing a human figure in the first image into regions to obtain multiple regions; processing the image of the first region using a first image enhancement method, and processing the image of the second region using a second image enhancement method to obtain a second image; wherein the first region and the second region are both regions within multiple regions, and the image clarity after processing using the first image enhancement method is different from the image clarity after processing using the second image enhancement method.
[0005] The image processing method provided in this application embodiment can perform different image enhancements on different regions of a portrait, which is beneficial for performing different processing according to the clarity requirements of different regions and can improve image quality.
[0006] In one possible implementation, a first image enhancement method is used to process the edges and / or contours of the image of the first region, and a second image enhancement method is used to process the structure of the image of the second region.
[0007] The first region of the image has high requirements for edges and / or contours, while the second region of the image has high requirements for structure. Different processing can be applied to the first and second regions to improve image quality.
[0008] In one possible implementation, the first region's image includes images of one or more parts of the person's face, such as eyebrows, hair, or eyes, while the second region's image includes images of the person's skin. This allows for different processing of different regions, resulting in clearer hair and eyebrows, and smoother, more delicate facial skin, thus improving image quality.
[0009] In one possible implementation, the above-mentioned processing of the image of the first region using a first image enhancement method and processing of the image of the second region using a second image enhancement method to obtain the second image includes: inputting the first image and the first mask image into a first model to obtain the second image. The first mask image is an image obtained by dividing the human image in the first image into regions. In the first model, the first mask image is used as a guide image to extract the features of the image of the first region and the image features of the second region, thereby realizing the processing of the image of the first region using the first image enhancement method and the processing of the image of the second region using the second image enhancement method.
[0010] The first mask image is obtained by dividing the human image in the first image into regions. The first mask image includes multiple regions and can be used as a guide image to extract the image features of the first region and the image features of the second region. This allows the image of the first region to be processed using a first image enhancement method, and the image of the second region to be processed using a second image enhancement method. This facilitates the application of different image enhancement processes to different regions.
[0011] In one possible implementation, a first model extracts a first feature from the first image based on information indicated in the first mask image. This first feature is downsampled and then concatenated with the features of the first mask image to obtain a second feature. Based on the second feature, the image of the first region is processed using the first image enhancement method, and the image of the second region is processed using the second image enhancement method based on the second feature. In this way, the first model incorporates features from the first mask image and uses the first mask image as a guide to perform different image enhancement processes on different regions.
[0012] In one possible implementation, the first model includes a shallow network, an intermediate network, and a deep network; the shallow network is used to extract a first feature of the first image based on information indicated in the first mask image; the intermediate network is used to downsample the first feature and then perform feature parallel concatenation with the features of the first mask image to obtain a second feature; the deep network is used to downsample the second feature; or, the shallow network is used to extract the first feature of the first image based on information indicated in the first mask image; the intermediate network is used to downsample the first feature; the deep network is used to downsample the feature obtained from the intermediate network and then perform feature parallel concatenation with the features of the first mask image.
[0013] In the case where the first model includes shallow, intermediate, and deep networks, the features of the first mask image can be located in either the intermediate or deep network. The features of the first mask image can be concatenated with the features of the layers in which it resides, which helps the network better extract structural and detailed features of the first image. In other words, it helps the network better extract low-frequency and high-frequency features of the input image, facilitating different image enhancement processes for different regions.
[0014] In one possible implementation, the above method further includes: the first model is trained by inputting a first image sample and a second mask image into a source model to obtain the output image of the source model; the second mask image is an image obtained by dividing the human image in the second image sample into regions; the first image sample is obtained by processing the image of the first region in the second image sample using a first blurring method and processing the image of the second region in the second image sample using a second blurring method; the image sharpness after processing with the first blurring method is different from the image blurness after processing with the second blurring method; the first model is obtained when the target loss function satisfies the preset model convergence condition, wherein the target loss function is related to the first loss function and the second loss function; the first loss function is the difference between the image of the first region in the output image of the source model and the image of the first region in the second image sample; the second loss function is the difference between the image of the second region in the output image of the source model and the image of the second region in the second image sample. In this way, different regions correspond to different loss functions, which is beneficial for training different regions separately and for enabling the trained first model to perform different image enhancement processing on different regions.
[0015] In one possible implementation, the difference between the number of pixels in the first region of the first image sample and the number of pixels in the second region of the first image sample is less than or equal to a preset value. Having the same or similar number of pixels in the first region and the second region of the first image sample allows the model to learn effectively from both regions during training, reducing the probability of one region performing well while the other performs poorly.
[0016] In one possible implementation, the relationship between the target loss function, the first loss function, and the second loss function satisfies the following formula:
[0017] L = W1 * L1 + W2 * L2
[0018] Where L represents the target loss function, L i Used to represent the first loss function, L jW1 represents the weight of the first loss function, and W2 represents the weight of the second loss function. Both W1 and W2 are constants.
[0019] W1 and W2 can be the same or different, and this application does not limit this. If W1 and W2 are different, different regions can be trained to different degrees, which is beneficial to improving the training effect of the model.
[0020] In one possible implementation, before acquiring the first image in response to the operation to trigger taking a picture, the method further includes: displaying a first interface in response to the user opening the front-facing camera, the first interface including an image captured by the front-facing camera and a first control; acquiring the first image in response to the operation to trigger taking a picture includes: acquiring the first image captured by the front-facing camera in response to the user triggering the first control.
[0021] The front-facing camera has a high probability of capturing facial images. This application embodiment can perform different image enhancement processes on different regions of the portrait, which is beneficial for obtaining high-quality images. Furthermore, the facial image captured by the front-facing camera occupies a relatively large proportion of the image, allowing for better region segmentation of the portrait and the application of different image enhancement processes to different regions, thus maximizing the effectiveness of the method provided in this application embodiment.
[0022] Secondly, embodiments of this application provide an electronic device, which may also be referred to as a terminal, user equipment (UE), mobile station (MS), mobile terminal (MT), etc. The electronic device can be a mobile phone, smart TV, wearable device, tablet computer, computer with wireless transceiver capabilities, virtual reality (VR) electronic device, augmented reality (AR) electronic device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, and wireless terminal in smart home, etc.
[0023] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, the memory for storing code instructions, and the processor for running the code instructions to perform the method described in any possible implementation of the first aspect.
[0024] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the methods described in any possible implementation of the first aspect.
[0025] Fifthly, embodiments of this application provide a computer program product, which includes a computer program that, when run, causes a computer to perform the method described in any possible implementation of the first aspect.
[0026] Sixthly, embodiments of this application provide a chip or chip system including at least one processor and a communication interface. The communication interface and the at least one processor are interconnected via a circuit. The at least one processor is used to run computer programs or instructions to perform the methods described in any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, pins, or circuits, etc.
[0027] In one possible implementation, the chip or chip system described above in the embodiments of this application further includes at least one memory, which stores instructions. The memory can be an internal storage unit of the chip, such as a register or cache, or it can be a storage unit of the chip itself (e.g., read-only memory, random access memory, etc.).
[0028] It should be understood that the second to sixth aspects of the embodiments of this application correspond to the technical solutions of the first aspect of the embodiments of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be described again. Attached Figure Description
[0029] Figure 1 This is a diagram illustrating the process of capturing an image of a human face.
[0030] Figure 2 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0031] Figure 3 This is a software structure block diagram of an electronic device provided in an embodiment of this application;
[0032] Figure 4 This is a schematic diagram of an image processing method provided in an embodiment of this application;
[0033] Figure 5This is a schematic diagram of an input image and a first mask image provided in an embodiment of this application;
[0034] Figure 6 This is a schematic diagram of another image processing method provided in an embodiment of this application;
[0035] Figure 7 This is a schematic diagram of yet another image processing method provided in an embodiment of this application;
[0036] Figure 8 This is a schematic diagram of a chip provided in an embodiment of this application. Detailed Implementation
[0037] To facilitate a clear description of the technical solutions in the embodiments of this application, the following explanation is provided first:
[0038] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with substantially the same function and effect. For example, "first image" and "second image" are used only to distinguish different images and do not limit their order. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that terms such as "first" and "second" do not necessarily imply that they are different.
[0039] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0040] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, and c can be single or multiple.
[0041] It should be noted that the phrase "at...time" in the embodiments of this application can refer to the instant at which a certain situation occurs, or it can refer to a period of time before or after the occurrence of a certain situation. The embodiments of this application do not impose a specific limitation on this. In addition, the display interface provided in the embodiments of this application is only an example, and the display interface may include more or less content.
[0042] The front-facing camera of electronic devices captures images of the user's face. Because the user is close to the camera, the face occupies a large proportion of the captured image, requiring high clarity and detail in the facial features. Currently, facial images captured by front-facing cameras may exhibit issues such as unclear hair or eyebrows, and rough skin texture, negatively impacting the user experience.
[0043] For example, Figure 1 This diagram illustrates a method for capturing images of a human face. (For example...) Figure 1 As shown, in response to the user opening the front-facing camera, the electronic device can display... Figure 1 The interface is shown in the image. (Example: ...) Figure 1 As shown in interface a, the interface includes an image captured by the front-facing camera, a camera control 101, and a control 102 for viewing the captured image. In response to the user triggering the camera control 101, the electronic device captures an image using the front-facing camera and can display it. Figure 1 The b interface in the example. Figure 1 As shown in interface b, the interface includes a thumbnail 103 of an image captured by the front-facing camera. The user can trigger a control 102 to view the captured image. In response to the user triggering the control 102, the electronic device can display... Figure 1 The C interface in [the context]. For example... Figure 1 As shown in interface c, the interface includes a facial image captured by the front-facing camera. The facial image captured by the front-facing camera exhibits issues such as unclear eyebrows and rough skin.
[0044] This issue arises because the images captured by the front-facing camera undergo the same noise reduction process across the entire image. This results in uniform noise reduction across the face, hair, and background, causing problems such as unclear hair or eyebrows and rough skin texture in facial images. This degrades image quality and negatively impacts user experience. The background refers to the portion of the image excluding the person.
[0045] In view of this, embodiments of this application provide an image processing method and related apparatus that can process facial features, hair, and background in a face image to varying degrees, making hair and eyebrows clear and facial skin delicate and soft, which is beneficial to improving image quality.
[0046] The image processing method provided in this application can be applied to electronic devices, such as mobile phones or tablets. For ease of understanding, the hardware structure of the electronic device according to this application embodiment is described below.
[0047] For example, Figure 2 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Figure 2 As shown, the electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, 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, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, and a display screen 194, etc.
[0048] Optionally, the aforementioned sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0049] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0050] Camera 193 may include a front-facing camera and a rear-facing camera, both of which can capture facial images. In response to a user triggering an image capture operation, processor 110 acquires the image captured by the front-facing camera or the rear-facing camera, processes the image using the method provided in this embodiment, and stores the processed image in internal memory 121.
[0051] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. A layered architecture can use the Android system, the Apple iOS system, or other operating systems; this application embodiment does not limit this. The following uses a layered Android system as an example to exemplify the software architecture of the electronic device provided in this application embodiment.
[0052] Figure 3 This is a schematic diagram of the software architecture of an electronic device provided in an embodiment of this application. The layered architecture divides the software system of the electronic device into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system can be divided into four layers, from top to bottom: applications, application framework, hardware abstraction layer (HAL), kernel, and hardware layer. The application layer may include a series of application packages, and the application layer runs applications by calling the application programming interface (API) provided by the application framework layer. Figure 3 As shown, the application package can include applications such as camera and gallery.
[0053] The application framework layer provides APIs and a programming framework for applications within the application layer. The application framework layer includes predefined functions. For example... Figure 3 As shown, the application framework layer may include a camera access interface and a view system. The camera access interface can be used to provide an application programming interface and programming framework for camera applications. The view system includes visual controls, such as controls for taking pictures (e.g., those mentioned above). Figure 1 The camera control 101 shown in interface a) and the controls for viewing the captured image (such as those mentioned above) Figure 1 The control 102 shown in interface a is used to view the captured images.
[0054] The purpose of the HAL layer is to abstract hardware, providing a unified interface for upper-layer applications to query hardware devices, or to provide data storage services for upper-layer applications. For example... Figure 3 As shown, the HAL layer may include a camera hardware abstraction layer and a camera algorithm library. The camera hardware abstraction layer can provide virtual hardware for the camera device. The camera algorithm library may include runtime code and data that implement the image processing methods provided in the embodiments of this application.
[0055] The kernel layer is the layer between hardware and software. For example... Figure 3As shown, this kernel layer may include one or more of the following: camera device driver, digital signal processor driver, and image processor driver. The camera device driver is used to drive the camera sensor to acquire images and to drive the image signal processor to preprocess the images. The digital signal processor driver is used to drive the digital signal processor to process images. The image processor driver is used to drive the graphics processor to process images.
[0056] The hardware layer can include hardware such as cameras and displays.
[0057] It should be understood that in some embodiments, layers that perform the same function may be called by other names, or layers that can perform the functions of multiple layers may be considered as one layer, or layers that can perform the functions of multiple layers may be divided into multiple layers. This application does not impose any limitations on this.
[0058] The following is in conjunction with the above. Figure 3 The software structure shown below provides a detailed description of the image processing method in this application embodiment:
[0059] In response to a user's action of opening the camera application, such as clicking the camera application icon, the camera application calls the camera access interface in the application framework layer to launch the camera application. This then sends a command to the camera device in the camera hardware abstraction layer to start the camera. The camera hardware abstraction layer sends this command to the camera device driver in the kernel layer. The camera device driver can then start the corresponding camera to capture images. In response to a user triggering a photo-taking action, the camera device driver can control the camera to capture images and obtain the raw image.
[0060] The camera can transmit the captured raw images to the camera hardware abstraction layer via the camera device driver. The camera hardware abstraction layer can then send the raw images to the camera algorithm library.
[0061] The camera algorithm library stores program code that implements the image processing method provided in the embodiments of this application. Based on a digital signal processor and an image processor, the camera algorithm library executes the above code to perform different degrees of processing on the facial features, hair, and background of a face image, as described above, making the hair and eyebrows clear and the facial skin delicate and soft, resulting in a high-quality image. The camera algorithm library can send the high-quality image to the camera hardware abstraction layer. The camera hardware abstraction layer can then transmit it to a display screen for display.
[0062] The above combination Figure 2 and Figure 3 The electronic devices described in the embodiments of this application have been introduced. The methods provided in the embodiments of this application will be described below.
[0063] Figure 4A schematic diagram of an image processing method provided in an embodiment of this application is shown. For example... Figure 4 As shown, the method includes the following steps:
[0064] S401. The electronic device processes the input image to obtain the first mask image.
[0065] The input image can be an image captured by a camera. The input image may or may not include a human figure; this application embodiment does not impose any limitations.
[0066] Electronic devices can acquire input images in a variety of different ways.
[0067] In one possible implementation, the electronic device may include a front-facing camera and a rear-facing camera, and the electronic device may acquire input images through either the front-facing camera or the rear-facing camera. The electronic device may obtain one or more frames of input images acquired by the front-facing camera or the rear-facing camera, but this embodiment of the application does not limit this.
[0068] In some scenarios, electronic devices are equipped with camera applications, which include photo-taking controls. In response to the user opening the camera application, the front or rear camera is opened. In response to the user triggering the photo-taking controls, the input image can be acquired through the front or rear camera.
[0069] In another possible implementation, the electronic device can receive images acquired by a camera from other devices. In this case, the electronic device may not include a camera but can have image processing capabilities.
[0070] The first mask image, also known as a mask map, is obtained by dividing the input image into regions. The first mask image can include multiple regions, with no overlap between them. Each region can include one or more parts. The required sharpness of parts within different regions can vary, while the required sharpness of parts within the same region can be the same or similar. The number of regions and the parts included in each region can be preset.
[0071] For example, if the clarity requirements for hair, eyebrows, and eyes are the same or similar, and the clarity requirements for hair, eyebrows, and eyes are different from those for skin, then the first mask image may include a first region and a second region, the first region including hair, eyebrows, and eyes, and the second region including skin.
[0072] In some implementations, the electronic device processes the input image to obtain the background and human figure of the input image, segments the human figure to obtain various parts of the human figure, and divides each part into regions to obtain the first mask image.
[0073] For example, the process by which an electronic device processes an input image to obtain a first mask image may include: the electronic device processes the input image based on a human face segmentation model to obtain the region where the human face is located and the region where the background is located; and processes the human face in the input image based on a face segmentation model to obtain the regions where the hair, eyebrows, eyes, ears, nose, mouth, and skin are located; and divides each part into regions to obtain the first mask image. This application embodiment does not specifically limit the segmentation model used to obtain the first mask image; the number of segmentation models can be one or more, and this application embodiment does not limit this.
[0074] In one possible implementation, the first mask image includes one or more of the following regions: the region where the face is located, the region where the background is located, the region where the hair is located, the region where the eyebrows are located, the region where the eyes are located, the region where the ears are located, the region where the nose is located, the region where the mouth is located, or the region where the skin is located. The skin may include the skin of one or more parts of the cheek, forehead, or neck. In some implementations, the skin may also include the skin of the nose, which is not limited in this embodiment.
[0075] For example, Figure 5 A schematic diagram of an input image and a first mask image is shown. (See diagram for example.) Figure 5 As shown, the electronic device processes the input image to obtain a first mask image divided into multiple regions. The first mask image includes the region where the face is located, the region where the background is located, the region where the hair is located, the region where the eyebrows are located, the region where the eyes are located, the region where the ears are located, the region where the nose is located, the region where the mouth is located, or the region where the skin is located.
[0076] In some examples, in response to a user triggering the camera control, multiple frames of facial images can be acquired through the front or rear camera. The terminal device can then process these multiple frames of facial images to obtain a first mask image.
[0077] S403. The electronic device inputs the input image and the first mask image into the image processing model to obtain the first output image, which is used to represent the image output by the image processing model.
[0078] Image processing models can also be called image generation models; however, this application does not limit the specific name. Image processing models are used to perform different enhancement processes on different regions of a person in an input image. For example, the person in the input image can be divided into multiple regions, each of which has no overlapping areas. The image processing model can perform different degrees of image enhancement on different regions to obtain a high-quality image. If one of these regions includes hair, eyebrows, and eyes, and another region includes skin, the image processing model can perform different degrees of image enhancement on these two regions, making the hair and eyebrows clear and the facial skin smooth and soft in the first output image.
[0079] In some implementations, such as Figure 4 As shown, the image processing model provided in this application embodiment may include a five-layer network. The first and fifth layers can be considered shallow layers of the image processing model, the second and fourth layers are considered middle layers, and the third layer is considered deep. The first and fifth layers can be skip connections, as can the second and fourth layers. The transition from the first to the third layer can be understood as an encoding process, and the transition from the third to the fifth layer as a decoding process. The transitions from the first to the second layer, and from the second to the third layer, can be understood as downsampling or dimensionality reduction processes, while the transitions from the third to the fourth and from the fourth to the fifth layer can be understood as upsampling or dimensionality enhancement processes.
[0080] In some examples, the resolution of the image obtained by the first layer of the network can be 64*256*256, the resolution of the image obtained by the second layer can be 128*128*128, the resolution of the image obtained by the third layer can be 256*64*64, the resolution of the image obtained by the fourth layer can be 128*128*128, and the resolution of the image obtained by the fifth layer can be 64*256*256.
[0081] The image generation model in this embodiment imports features from a first mask image. This import can be achieved through one or more of the following methods: attention mechanism, spatial feature transformation, or sparse fast fourier transform (SFT). This embodiment does not limit the specific implementation of the import. The features of the first mask image can be located in one or more layers of the network, from the first to the fifth layer. Figure 4 In the example shown, the features of the first mask image are located in the second and fourth layers of the network.
[0082] exist Figure 4In the example shown, the first layer can be used to convolve the first mask image and the input image to extract a first feature from the input image based on the information indicated by the first mask image. The second layer incorporates features from the first mask image, can be used to obtain the first feature from the first layer, downsample the first feature, and then concatenate it with the features from the first mask image (concat or concatenate) to obtain the second feature. The third layer can be used to obtain the second feature from the second layer and downsample the second feature. The fourth layer can be used to upsample the features obtained from the third layer. The fifth layer can be used to upsample the features obtained from the fourth layer.
[0083] The features of the first mask image can be located in the middle or deep layers. The features of the first mask image can be concatenated with the features of the layers they are in (concat or conploy), which helps the network to better extract the structural and detailed features of the input image, or in other words, helps the network to better extract the low-frequency and high-frequency features of the input image.
[0084] The image processing method provided in this application process an input image to obtain a first mask image. When the image processing model extracts features from the input image, it uses the first mask image as a guide, which helps the image processing model to better extract features from different regions of the portrait. This allows for different degrees of processing of different regions of the portrait, such as facial features, hair, and background, resulting in clear hair and eyebrows and delicate and soft facial skin, which is beneficial for obtaining high-quality images.
[0085] Optionally, before executing S403, the electronic device can segment the input image and the first mask image into blocks, input the segmented input image and the segmented first mask image into the image processing model to obtain the segmented first output image, and then fuse the segmented first output images to obtain the first output image. This helps to improve processing efficiency.
[0086] For example, the resolution of both the input image and the first mask image can be 2000*3000. The electronic device can divide the input image into 50 blocks to obtain an input image comprising 50 blocks, and divide the first mask image into 50 blocks to obtain a first mask image comprising 50 blocks. The electronic device can input this input image comprising 50 blocks and the first mask image comprising 50 blocks into a first model. The first model can output a first output image comprising 50 blocks. The electronic device can fuse this first output image comprising 50 blocks to obtain a first output image.
[0087] The above Figure 4The image processing model involved is based on training samples, and the training process of the image processing model will be described in detail below.
[0088] For example, Figure 6 This diagram illustrates an image processing method provided in an embodiment of this application. The method can be executed by an electronic device or a server; this embodiment does not limit its execution. Figure 6 As shown, the method includes the following steps:
[0089] S601. Process the face image with clear texture to obtain the second mask image.
[0090] A well-textured face image is used to represent a high-quality face image. Well-textured face images can be captured by high-definition cameras. For example, a well-textured face image can be captured by a DSLR camera.
[0091] Processing a face image with clear texture to obtain a second mask image can be understood as dividing the face image with clear texture into regions to obtain a second mask image.
[0092] In some examples, the electronic device processes a textured face image based on a face segmentation model to obtain the region where the face is located and the background region. It then processes the face within the textured face image based on the face segmentation model to obtain various parts of the face, and divides each part into regions to obtain a second mask image. The segmentation model used in this step can be the same as or different from the segmentation model used in S402 described above; this application embodiment does not limit this.
[0093] The second mask image corresponding to different textured face images may include the same area or different areas, and this application embodiment does not limit this.
[0094] For example, if the second mask images corresponding to different textured face images include the same area, when the number of textured face images is 10,000, the second mask images corresponding to these 10,000 images all include areas such as face, background, hair, eyebrows, eyes, nose, mouth, and skin.
[0095] If the second mask images corresponding to different textured face images include different regions, when there are 10,000 textured face images, among these 10,000 images, there can be 1,000 images whose corresponding second mask images all include regions such as face, background, hair, eyebrows, eyes, ears, nose, mouth, and skin; there can be 4,000 images whose corresponding second mask images all include the regions where eyebrows and hair are located; there can be 2,000 images whose corresponding second mask images all include the regions where eyebrows are located; there can be 2,000 images whose corresponding second mask images all include the regions where hair is located; and there can be 1,000 images whose corresponding second mask images all include the regions where eyebrows, hair, and skin are located.
[0096] S602. Based on the second mask image, different regions in a clear face image can be degraded to different degrees to obtain a blurred image.
[0097] A high degree of degradation can be termed strong degradation, which can be understood as a high degree of blur. A low degree of degradation can be termed weak degradation, which can be understood as a low degree of blur. Strong degradation can be used for areas requiring high texture clarity, while weak degradation can be used for areas requiring a delicate and soft texture or areas that are not of primary concern.
[0098] For example, areas requiring high texture clarity may include eyebrows, hair, and eyes. In this case, areas with high texture clarity in a face image can be strongly degraded to increase the blur level. Areas requiring smoothness and softness may include skin. In this case, areas with high texture clarity in a face image can be weakly degraded to reduce the blur level. Areas of less focus may include the background. In this case, background areas in a face image with high texture clarity can be weakly degraded.
[0099] Applying different degrees of degradation to different regions in a well-textured face image helps train the model to perform different degrees of image enhancement on different regions.
[0100] S603. Input the second mask image and the blurred image into the initial model to obtain the second output image.
[0101] It is understandable that the initial model is the model before the aforementioned image processing model was trained.
[0102] The first layer of the initial model convolves the second mask image and the blurred image to obtain Feature 1. Feature 1 represents the features extracted from the face image based on the indication of the second mask image. Feature 1 is then passed to the second layer of the initial model. The second layer of the initial model incorporates features from the second mask image. It downsamples the extracted Feature 1 and concatenates it with the features from the second mask image, then passes it to the third layer of the initial model. The third layer reduces the dimensionality of the obtained features and passes them to subsequent layers for decoding to produce the second output image.
[0103] In the initial model, the features of the second mask image are imported and used as a guide image for model training. This helps the model to use the information in the second mask image to enhance images of different regions in the blurred image.
[0104] In a blurred image, if a region occupies fewer pixels, the number of blurred images in that region is greater; if a region occupies more pixels, the number of blurred images in that region is less. This allows images in different regions to contain the same or similar number of pixels.
[0105] For example, if eyebrows occupy fewer pixels in a face, the initial model input blur image can include more blurry images including eyebrows; if skin occupies more pixels in a face, the initial model input blur image can include fewer blurry images including skin.
[0106] In this way, the pixels in different regions of the image are the same or similar, which helps to reduce the probability that one region has a better training effect while another region has a poor training effect.
[0107] It should be noted that S601 and S602 above are optional. Technicians can obtain the second mask image and the blurred image through other devices and input these data into the electronic device. The electronic device can then input these data into the initial model for training.
[0108] S604. Calculate the loss function.
[0109] The electronic device can compare each region in the second output image with each region of a textured face image separately and calculate a loss function. Each region can correspond to a loss value, and the loss function is related to the loss value of each region; different loss values can correspond to different weights. The calculation methods for the loss values corresponding to different regions can be the same or different; this application embodiment does not limit this. If the calculation methods for the loss values corresponding to different regions can be different, it is beneficial to obtain higher quality images.
[0110] For example, one region includes hair and eyebrows. The loss value for the hair and eyebrow region can be calculated using a high-frequency loss method. For instance, an electronic device can calculate the loss value for the hair and eyebrow region using one or more of the following methods: Generative Adversarial Networks (GANs), Visual Geometry Groups (VGGs), or gradients. Gradient calculation refers to calculating the gradient between two images and using the gradient to calculate the loss function; this is a simplified method of VGG. Another region includes skin. The loss value for the skin region can be calculated using a low-frequency loss method. For instance, an electronic device can calculate the loss value for the skin region using the absolute value error loss function (L1). Thus, high-frequency loss helps the model learn image edges and contours to achieve clearer hair and eyebrows, while low-frequency loss helps the model learn image structure to achieve smoother and more delicate skin.
[0111] In some implementations, the weights for the eyebrow and hair regions are W1, and the loss value for these regions is L1. The weights for the skin regions are W2, and the loss value for the skin regions is L2. The loss function can be W1*L1 + W2*L2. High-frequency losses are more difficult to learn than low-frequency losses; therefore, the weights for the eyebrow and hair regions can be greater than those for the skin regions, which helps improve the accuracy of model training.
[0112] S605. If the loss function does not meet the training requirements, update the parameters in the initial model and repeat S603 and S604 above until the loss function meets the training requirements.
[0113] The image processing method provided in this application processes a face image to obtain a second mask image. When the image processing model extracts features from the face image, it uses the second mask image as a guide, which helps the image processing model extract different features from different regions. This allows for different degrees of image enhancement processing on different regions of the portrait, such as facial features, hair, and background, resulting in clear hair and eyebrows and delicate and soft facial skin, which is conducive to obtaining a high-quality image.
[0114] The training process of the model provided in the embodiments of this application has been described above. The image processing method of the embodiments of this application will be further described in detail below with reference to the step flow.
[0115] For example, Figure 7A schematic flowchart of an image processing method provided in an embodiment of this application is shown. Figure 7 As shown, the method includes:
[0116] S701, in response to an operation that triggers taking a picture, acquires a first image.
[0117] The electronic device may include a camera, and the first image may be acquired by the electronic device through the camera in response to an operation that triggers a photo capture. The first image may be acquired by a front-facing camera or a rear-facing camera; this application embodiment does not limit this.
[0118] The first image can be referenced as described above. Figure 4 The input image shown in the example.
[0119] S702. Divide the human figure in the first image into regions to obtain multiple regions.
[0120] There is no overlap between these multiple regions. The required sharpness of different parts of the portrait must be the same; similar or identical parts can be placed in the same region.
[0121] In some implementations, these multiple regions can include two regions: one region includes hair, eyebrows, and eyes, and the other region includes skin.
[0122] In other implementations, these multiple regions may include three regions: the first region includes the background, the second region includes the hair, eyebrows, and eyes, and the third region includes the skin.
[0123] In some implementations, these multiple regions may include four regions: the first region includes the background, the second region includes the hair, eyebrows, and eyes, the third region includes the skin, and the fourth region includes the region other than the background, hair, eyebrows, eyes, and skin.
[0124] S703. The image of the first region is processed using a first image enhancement method, and the image of the second region is processed using a second image enhancement method to obtain a second image; wherein, the first region and the second region are both regions of multiple regions, and the image clarity after processing using the first image enhancement method is different from the image clarity after processing using the second image enhancement method.
[0125] It is understood that the embodiments of this application use the first region and the second region as examples for illustration. The electronic device may also process the image of the third region in a third image enhancement manner while processing the image of the first region and the image of the second region.
[0126] The image processing method provided in this application embodiment can perform different image enhancements on different regions of a portrait, which is beneficial for performing different processing according to the clarity requirements of different regions and can improve image quality.
[0127] Optionally, the first image enhancement method is used to process the edges and / or contours of the image in the first region, and the second image enhancement method is used to process the structure of the image in the second region.
[0128] The first image enhancement method processes the edges and / or contours of the first region of the image, which can be understood as processing the high-frequency details of the first region of the image. The second image enhancement method processes the structure of the second region of the image, which can be understood as processing the low-frequency details of the first region of the image. If the third image enhancement method is used to process the third region of the image, the third image enhancement method can process one or more of the texture, color, shape, or contrast of the third region of the image.
[0129] The first region of the image has higher requirements for high-frequency details, while the second region of the image has higher requirements for low-frequency details. Different processing can be applied to the first and second regions to improve image quality.
[0130] Optionally, the image of the first region includes images of one or more parts of the person's eyebrows, hair, or eyes, and the image of the second region includes images of the person's skin.
[0131] One or more parts of the face, such as eyebrows, hair, or eyes, require high sharpness. Sharp skin can result in rough texture, so skin has lower sharpness requirements. Applying different processing to different areas can make hair and eyebrows sharp and facial skin smooth and soft, which helps improve image quality.
[0132] Optionally, the above-mentioned processing of the image of the first region using the first image enhancement method and processing of the image of the second region using the second image enhancement method to obtain the second image includes: inputting the first image and the first mask image into the first model to obtain the second image. The first mask image is an image obtained by dividing the human image in the first image into regions. In the first model, the first mask image is used as a guide image to extract the features of the image of the first region and the image features of the second region, thereby realizing the processing of the image of the first region using the first image enhancement method and the processing of the image of the second region using the second image enhancement method.
[0133] The first model can perform different image enhancement processes on different regions of an image. In the above... Figure 4In the example shown, the first model can be an image processing model, the first image can be an input image, and the first mask image can be obtained through step S402. The second image can be the first output image. In the above... Figure 4 In this paper, the structure of the first model is the Unet network structure, which is one possible implementation method and is not limited here.
[0134] The first mask image is obtained by dividing the human image in the first image into regions. The first mask image includes multiple regions and can be used as a guide image to extract the image features of the first region and the image features of the second region. This allows the image of the first region to be processed using a first image enhancement method, and the image of the second region to be processed using a second image enhancement method. This facilitates the application of different image enhancement processes to different regions.
[0135] Optionally, the first model is used to extract a first feature of the first image based on the information indicated in the first mask image, downsample the first feature and perform feature parallel connection with the feature of the first mask image to obtain a second feature, process the image of the first region in the first image enhancement manner based on the second feature, and process the image of the second region in the second image enhancement manner based on the second feature.
[0136] The first mask image includes multiple regions. The first model can extract the features of each region in the first image based on the location of each region in the first mask image to obtain the first feature. The first feature can be downsampled, and the downsampled first feature can be combined with the features of the first mask image in feature parallel to obtain the second feature, thereby realizing different image enhancement processing for different regions. Here, downsampling can also be called dimensionality reduction, which is not limited in this embodiment.
[0137] In this way, the first model incorporates the features of the first mask image and uses the first mask image as a guide to perform different image enhancement processes on different regions.
[0138] Optionally, the first model includes a shallow network, an intermediate network, and a deep network; the shallow network is used to extract a first feature of the first image based on the information indicated in the first mask image; the intermediate network is used to downsample the first feature and then perform feature parallel connection with the feature of the first mask image to obtain a second feature; the deep network is used to downsample the second feature; or, the shallow network is used to extract a first feature of the first image based on the information indicated in the first mask image; the intermediate network is used to downsample the first feature; the deep network is used to downsample the feature obtained from the intermediate network and then perform feature parallel connection with the feature of the first mask image.
[0139] In the case where the first model includes shallow, intermediate, and deep networks, the features of the first mask image can be located in either the intermediate or deep network. The features of the first mask image can be concatenated with the features of the layers in which it resides, which helps the network better extract structural and detailed features of the first image. In other words, it helps the network better extract low-frequency and high-frequency features of the input image, facilitating different image enhancement processes for different regions.
[0140] Optionally, the above method further includes: the first model is trained by inputting a first image sample and a second mask image into the source model to obtain the output image of the source model; the second mask image is an image obtained by dividing the human image in the second image sample into regions; the first image sample is obtained by processing the image of the first region in the second image sample with a first blurring method and processing the image of the second region in the second image sample with a second blurring method; the image clarity after processing with the first blurring method is different from the image blurring after processing with the second blurring method; the first model is obtained when the target loss function satisfies the preset model convergence condition, wherein the target loss function is related to the first loss function and the second loss function; the first loss function is the difference between the image of the first region in the output image of the source model and the image of the first region in the second image sample; and the second loss function is the difference between the image of the second region in the output image of the source model and the image of the second region in the second image sample.
[0141] In the above Figure 6 In the example shown, the second image sample can be a clear face image, the first image sample can be a blurred image obtained through S602, the second mask image can be obtained through S601, the source model can be the initial model, and the output image of the source model is the second output image. The blurring process can be understood as degradation; the first image sample is obtained by degrading different regions of the second image sample to different degrees. The target loss function can be as described above. Figure 6 The loss functions shown can be assigned to different regions of the image, with each region corresponding to a specific loss function. The target loss function can be related to the loss functions corresponding to these regions. The preset model convergence conditions can be referred to as training requirements, which are not limited in this embodiment.
[0142] In this way, different loss functions correspond to different regions, which is beneficial for training different regions separately and for enabling the first model obtained from the training to perform different image enhancement processing on different regions.
[0143] Optionally, the difference between the number of pixels in the first region of the first image sample and the number of pixels in the second region of the first image sample is less than or equal to a preset value.
[0144] The preset value represents a threshold. When the difference between the number of pixels in the first region of the first image sample and the number of pixels in the second region of the first image sample is less than or equal to the preset value, it indicates that the number of pixels in the first region of the first image sample is the same as or similar to the number of pixels in the second region of the first image sample. When the difference between the number of pixels in the first region of the first image sample and the number of pixels in the second region of the first image sample is greater than the preset value, it indicates that the difference between the number of pixels in the first region of the first image sample and the number of pixels in the second region of the first image sample is significant.
[0145] The number of pixels in the first region of the first image sample is the same as or similar to the number of pixels in the second region of the first image sample. This is beneficial for the model to learn well from both the first and second regions during training, and helps to reduce the probability that one region has a better training effect while the other region has a poor training effect.
[0146] Optionally, the relationship between the target loss function, the first loss function, and the second loss function satisfies the following formula:
[0147] L = W1 * L1 + W2 * L2
[0148] Where L represents the target loss function, L i Used to represent the first loss function, L j W1 represents the weight of the first loss function, and W2 represents the weight of the second loss function. Both W1 and W2 are constants.
[0149] W1 and W2 can be the same or different, and this application does not limit this. If W1 and W2 are different, different regions can be trained to different degrees, which is beneficial to improving the training effect of the model.
[0150] In some implementations, for the image of the first region, the edges and / or contours of the first region are learned; for the image of the second region, the structure of the second region is learned. In this case, the weight W1 of the loss function corresponding to the first region can be greater than the weight W2 of the loss function corresponding to the second region. Edges and contours are high-frequency features, while structure is a low-frequency feature. High-frequency features are more difficult to learn than low-frequency features, so their weights can be larger, which is beneficial for improving the training effect of the model.
[0151] Optionally, before acquiring the first image in response to the operation to trigger taking a picture, the method further includes: displaying a first interface in response to the user opening the front-facing camera, the first interface including an image captured by the front-facing camera and a first control; acquiring the first image in response to the operation to trigger taking a picture includes: acquiring the first image captured by the front-facing camera in response to the user triggering the first control.
[0152] The first interface can be as described above. Figure 1 As shown in interface 'a', the first image captured by the front-facing camera can be as described above. Figure 1 As shown in interface 'a'. The first control can be... Figure 1 The camera control 101 in the middle.
[0153] The scenario of applying different image enhancement processes to different regions of an image can be a scenario where an image is captured by a front-facing camera. Since front-facing cameras frequently capture facial images, this embodiment can apply different image enhancement processes to different regions of the portrait, which is beneficial for obtaining higher-quality images. Furthermore, facial images captured by front-facing cameras have a higher proportion of the image, allowing for better region segmentation of the portrait and application of different image enhancement processes to different regions, thus maximizing the effectiveness of the method provided in this embodiment.
[0154] The methods of the embodiments of this application have been described above. The apparatus for performing the above methods, provided in the embodiments of this application, is described below. Those skilled in the art will understand that the methods and apparatus can be combined with and referenced by each other, and the related apparatus provided in the embodiments of this application can perform the steps in the above methods.
[0155] To achieve the above functions, the apparatus for implementing the image processing method includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art will readily recognize that, based on the method steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0156] This application embodiment can divide the apparatus for implementing the image processing method into functional modules based on the above method examples. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0157] Figure 8 This is a schematic diagram of a chip structure provided in an embodiment of this application. Figure 8 As shown, chip 80 includes one or more processors 801, communication lines 802, communication interfaces 803, and memory 804.
[0158] In some implementations, memory 804 stores elements such as executable modules or data structures, or subsets thereof, or extended sets thereof.
[0159] The image processing method described in the embodiments of this application can be applied to or implemented by the processor 801. The processor 801 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above image processing method can be completed by the integrated logic circuit in the hardware of the processor 801 or by instructions in the form of software. The processor 801 may be a general-purpose processor (e.g., a microprocessor or conventional processor), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates, transistor logic devices, or discrete hardware components. The processor 801 can implement or execute the various processing-related methods, steps, and logic block diagrams disclosed in the embodiments of this application.
[0160] The steps of the image processing method disclosed in the embodiments of this application can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules can be located in mature storage media in the art, such as random access memory, read-only memory, programmable read-only memory, or electrically erasable programmable read-only memory (EEPROM). This storage medium is located in memory 804, and processor 801 reads the information in memory 804 and, in conjunction with its hardware, completes the steps of the above method.
[0161] The processor 801, memory 804 and communication interface 803 can communicate with each other through communication line 802.
[0162] In the above embodiments, the instructions stored in the memory for execution by the processor can be implemented in the form of a computer program product. This computer program product can be pre-written into the memory, or it can be downloaded and installed into the memory as software.
[0163] This application also provides a computer program product comprising one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that integrates one or more available media. For example, available media may include magnetic media (e.g., floppy disk, hard disk, or magnetic tape), optical media (e.g., digital versatile disc (DVD)), or semiconductor media (e.g., solid-state disk (SSD)).
[0164] This application also provides a computer-readable storage medium. The methods described in the above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any combination thereof. The computer-readable medium may include computer storage media and communication media, and may also include any medium capable of transferring a computer program from one place to another. The storage medium can be any target medium accessible by a computer.
[0165] As one possible design, computer-readable media may include compact disc read-only memory (CD-ROM), RAM, ROM, EEPROM, or other optical disc storage; computer-readable media may also include disk storage or other disk storage devices. Furthermore, any connecting cable may also be appropriately referred to as computer-readable media. For example, if software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave, then coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of media. As used herein, disks and optical discs include optical discs (CD), laser discs, optical discs, digital versatile discs (DVD), floppy disks, and Blu-ray discs, where disks typically reproduce data magnetically, while optical discs optically reproduce data using lasers.
[0166] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processing unit of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
Claims
1. An image processing method, characterized by, The method comprises: obtaining a first image in response to an operation for triggering photographing; regionally dividing a portrait in the first image to obtain a plurality of regions; processing an image of a first region in a first image enhancement manner and processing an image of a second region in a second image enhancement manner to obtain a second image, wherein the first region and the second region are regions in the plurality of regions, and the image processed in the first image enhancement manner has a different image definition from the image processed in the second image enhancement manner; the processing of the image of the first region in the first image enhancement manner and the processing of the image of the second region in the second image enhancement manner to obtain the second image comprises: inputting the first image and a first mask image into a first model to obtain the second image, the first mask image being an image obtained by regionally dividing the portrait in the first image, and in the first model, the first mask image is used as a guide image to extract features of the image of the first region and features of the image of the second region, so as to realize the processing of the image of the first region in the first image enhancement manner and the processing of the image of the second region in the second image enhancement manner; wherein the first model is used to extract first features of the first image based on information indicated in the first mask image, to perform feature parallel connection of the first features after downsampling and features of the first mask image to obtain second features, and to realize the processing of the image of the first region in the first image enhancement manner based on the second features and the processing of the image of the second region in the second image enhancement manner based on the second features.
2. The method of claim 1, wherein, The first image enhancement manner is used to process edges of the image of the first region and / or contours of the image of the first region, and the second image enhancement manner is used to process structures of the image of the second region.
3. The method of claim 1, wherein, The image of the first region comprises images of one or more parts of eyebrows, hair or eyes in the portrait, and the image of the second region comprises an image of skin in the portrait.
4. The method according to any one of claims 1 to 3, characterized in that, The first model comprises a shallow network, an intermediate network and a deep network; The shallow network is used to extract the first features of the first image based on the information indicated in the first mask image; The intermediate network is used to perform feature parallel connection of the first features after downsampling and features of the first mask image to obtain the second features, and the deep network is used to downsample the second features; or, The shallow network is used to extract the first features of the first image based on the information indicated in the first mask image; The intermediate network is used to downsample the first features, and the deep network is used to perform feature parallel connection of features obtained from the intermediate network after downsampling and features of the first mask image.
5. The method according to any one of claims 1 to 3, characterized in that, The method further comprises: The first model is obtained by training in the following manner: inputting the first image sample and a second mask image into the source model to obtain an output image of the source model, the second mask image being an image obtained after region division of a person in a second image sample, the first image sample being obtained by processing an image in a first region in the second image sample in a first blur processing manner and processing an image in a second region in the second image sample in a second blur processing manner, the image processed in the first blur processing manner having different image definition from the image processed in the second blur processing manner; obtaining the first model in a case where a target loss function meets a preset model convergence condition, wherein the target loss function is related to a first loss function and a second loss function, the first loss function being a difference between an image in the first region in the output image of the source model and an image in the first region in the second image sample, and the second loss function being a difference between an image in the second region in the output image of the source model and an image in the second region in the second image sample.
6. The method of claim 5, wherein, A difference between a number of pixel points included in the image in the first region in the first image sample and a number of pixel points included in the image in the second region in the first image sample is less than or equal to a preset value.
7. The method of claim 5, wherein, The target loss function and the first loss function and the second loss function satisfy the following formula: wherein L is used to represent a target loss function, L i is used to represent the first loss function, L j is used to represent the second loss function, W1 is used to represent a weight of the first loss function, W2 is used to represent a weight of the second loss function, and the W1 and the W2 are both constants.
8. The method of any one of claims 1-3, 6-7, wherein, Before the first image is obtained in response to the operation for triggering photographing, the method further includes: displaying a first interface in response to an operation of the user opening the front camera, the first interface including an image captured by the front camera and a first control; The first image is obtained in response to the operation for triggering photographing, including: The first image captured by the front camera is obtained in response to an operation of the user triggering the first control.
9. An electronic device, comprising: Comprise: a processor and a memory; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, so that the electronic device executes the method in any one of claims 1-8.
10. A chip system, characterized by Comprise: a processor for reading instructions stored in a memory, when the processor executes the instructions, so that the chip system implements the method in any one of claims 1-8.
11. A computer readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method in any one of claims 1-8.
12. A computer program product, characterised in that, Comprise a computer program, when the computer program is run, so that the computer executes the method in any one of claims 1-8.
Citation Information
Patent Citations
Image denoising method and device, storage medium and terminal equipment
CN114596226A
Image enhancement method, training method of image enhancement model and related equipment
CN114627034A