Image processing method, device, electronic device and storage medium
By using the image segmentation model to determine the target rendering area and add special effects, the model's universality problem caused by differences in user hairstyles and hair dyeing effects is solved, and efficient and convenient special effects processing is achieved.
Patent Information
- Application Number
- CN202111552501.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-17
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-12-17
AI Technical Summary
In the existing technology, users' hairstyles and hair dyeing effects vary greatly, which requires training multiple models, resulting in poor model universality and the need to obtain a large number of training samples, making it inconvenient to add rendering special effects.
The image to be processed is segmented through the image segmentation model, the target rendering area is determined, and special effects are added to the target object based on the special effects parameters, reducing the need for neural network training for different rendering methods.
It improves the convenience and adaptability of special effects processing, reduces the number of training models and sample requirements, and achieves more efficient special effects addition.
Smart Images

Figure CN114240742B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of image processing technology, and in particular to an image processing method, device, electronic device, and storage medium. Background Art
[0002] With the development of short video technology, users have higher and higher requirements for the richness of short video content. In order to meet the diverse needs of users, corresponding special effects can be added to the subjects being filmed.
[0003] Currently, special effects are mainly processed through GAN neural networks. For example, the neural network corresponding to the hair dyeing special effect requires obtaining a large number of hair dyeing effect pictures, and then training the corresponding model based on the hair dyeing effect pictures.
[0004] However, there are certain differences in the hairstyles and hair dyeing effects of different users. There is a problem that the obtained samples are not uniform, resulting in inaccurate trained models. Furthermore, due to the large differences in hair dyeing effects, it is necessary to train models corresponding to different hair dyeing effects. There is a large number of trained models, that is, there is a problem of poor model universality. Summary of the Invention
[0005] The present disclosure provides an image processing method, device, electronic device, and storage medium to achieve the technical effects of authenticity and diversity of special effect display.
[0006] In a first aspect, an embodiment of the present disclosure provides an image processing method, the method comprising:
[0007] In response to a special effect adding instruction, collecting an image to be processed including a target object;
[0008] Segmenting the image to be processed based on an image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed;
[0009] Based on the at least two target rendering areas and the special effect parameters, a target image with a target special effect added to the target object is obtained.
[0010] In a second aspect, an embodiment of the present disclosure further provides an image processing device, the device comprising:
[0011] An image acquisition module, configured to acquire an image to be processed including a target object in response to a special effect adding instruction;
[0012] a rendering region determining module, configured to segment the image to be processed based on an image segmentation model to obtain at least two target rendering regions corresponding to the image to be processed;
[0013] The target image determination module is configured to obtain a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters.
[0014] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0015] one or more processors;
[0016] a storage device for storing one or more programs,
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method as described in any of the embodiments of the present disclosure.
[0018] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to execute the image processing method as described in any one of the embodiments of the present disclosure.
[0019] The technical solution of the disclosed embodiment can collect an image to be processed including a target object when a triggering special effect adding instruction is detected, and determine a target rendering area in the image to be processed based on an image segmentation model, and add a target special effect to the target object according to the target rendering area and special effect parameters, thereby obtaining a target image. This solves the problem in the prior art that neural networks corresponding to different rendering methods need to be trained, which not only requires more models to be trained but also requires a large number of training samples, resulting in inconvenience in adding rendering special effects. This achieves the goal of only requiring a neural network to determine the rendering area to be processed, and then adding corresponding special effects to the rendering area, thereby improving the convenience of special effect processing and achieving a technical effect with a high degree of adaptability to actual use. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0021] Figure 1 A flowchart of an image processing method provided in the first embodiment of the present disclosure;
[0022] Figure 2 A schematic diagram of an ear dyeing effect provided by an embodiment of the present disclosure;
[0023] Figure 3 A flowchart of an image processing method provided in the second embodiment of the present disclosure;
[0024] Figure 4 A flowchart of an image processing method provided in the third embodiment of the present disclosure;
[0025] Figure 5 A schematic diagram of the structure of an image processing device provided in the fourth embodiment of the present disclosure;
[0026] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Example 5 of the present disclosure. DETAILED DESCRIPTION
[0027] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0028] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0029] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0030] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0031] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0032] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0033] Example 1
[0034] Figure 1This is a flowchart of an image processing method provided in the first embodiment of the present disclosure. The embodiment of the present disclosure is applicable to any image display or video shooting scenario supported by the Internet, and is used to add special effects to the corresponding objects in the image so that the added special effects are most suitable for the objects. The method can be executed by an image processing device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, PC or server. Any image display scenario is usually implemented by the cooperation of a client and a server. The method provided in this embodiment can be executed by the server, the client, or the cooperation of the client and the server.
[0035] like Figure 1 As shown, the method includes:
[0036] S110 : In response to a special effect adding instruction, an image to be processed including a target object is collected.
[0037] It should be noted that the application scenarios can be explained first with examples. The disclosed technical solution can be applied to any screen that requires special effects. For example, special effects can be displayed during video calls; or special effects can be displayed for the host user during live broadcasts. Of course, it can also be applied to situations where special effects can be displayed for the image corresponding to the user being filmed during video shooting, such as in short video shooting scenarios. It can also be applied to situations where special effects can be added to users in static images.
[0038] It should be noted that the device for executing the image processing method provided in the embodiments of the present disclosure can be integrated into application software that supports image processing functions, and the software can be installed in an electronic device. Optionally, the electronic device can be a mobile terminal or a PC. The application software can be a type of software for image / video processing. The specific application software will not be described in detail here, as long as it can implement image / video processing.
[0039] When a user needs to add special effects to a short video, live stream, or image containing a target object, the display interface may include a button for adding special effects. Optionally, when the user triggers the special effects button, at least one effect to be added may pop up, and the user can select one from the multiple effects to be added as the target effect. Alternatively, upon detecting the control corresponding to the trigger for adding a special effect, the server may determine that the corresponding special effect should be added to the object in the frame. In this case, the server or client may respond to the special effects addition instruction and capture an image to be processed that includes the target object. The image to be processed may be an image captured by the application software, or an image captured at the time the special effects addition instruction was triggered. This image may include the object to which the special effects are to be added. The object to which the special effects are to be added is the target object. Optionally, if a user's hairstyle or hair color needs to be changed, the target object may be the user; if a kitten or puppy's fur color needs to be changed, the kitten or puppy may be the target object. For example, in a live stream or video recording scenario, if the user's hair color needs to be changed, an image containing the user is captured as the image to be processed. At this time, the camera device may start collecting the to-be-processed images including the target object in the target scene in real time or intermittently starting from the triggering of the special effect instruction.
[0040] Optionally, in response to a special effect adding instruction, collecting an image to be processed including the target object, includes: when a target object is detected to trigger a special effect adding wake-up word, generating a special effect adding instruction, and collecting an image to be processed including the target object; or, when a triggering special effect adding control is detected, generating the special effect adding instruction, and collecting an image to be processed including the target object; or, when the target object is detected to be included in the field of view, collecting an image to be processed including the target object.
[0041] In live video broadcast scenarios, such as livestreaming a product or filming a video, voice information from the host or subject can be collected and analyzed to identify the text corresponding to the voice information. If the text corresponding to the voice information includes a pre-set wake-up word, optionally a phrase such as "Please enable special effects," it indicates that special effects should be displayed for the host or subject. In this case, a pre-processed image including the target object can be collected. In other words, in this case, the target object has triggered the wake-up word for adding special effects, and the corresponding special effects provided by this technical solution can be added to the target object. Optionally, the added special effect can be a hair dyeing effect for the target object. This hair dyeing effect does not directly replace the target object's hair color with the color to be displayed, as disclosed in the prior art. The special effect addition control can be a button displayed on the application software's display interface. The triggering of this button indicates the need to capture the image to be processed and perform special effects processing on the processed image. When the user triggers this button, it can be considered to trigger the image function for displaying special effects. In this case, the pre-processed image including the target object can be collected. For example, if applied in a static image shooting scenario, if the user triggers the special effects processing control, it can automatically trigger the acquisition of the image to be processed including the target object. Of course, in specific application scenarios, for example, in the scene of shooting a pantomime video, the facial features in the collected image to be used can be analyzed and processed in real time to obtain the feature detection results of each part in the facial image, and use them as the features to be detected. If each feature to be detected matches the preset feature, optionally, at least one feature for triggering the special effects display of each part is pre-set. When the corresponding feature is triggered at a certain part, a special effects adding instruction can be generated, and then the image to be processed can be acquired. Alternatively, when it is detected that the target object is included in the frame entering the camera, it indicates that image acquisition has been triggered, and the image to be processed including the target object can be acquired.
[0042] It should be noted that, whether in a live video scene or an image processing scene, if there is a need to capture the target object in the target scene in real time, images can be captured in real time, and the images captured at this time can be used as images to be used. Accordingly, the images to be used can be analyzed and processed. If the results of the analysis meet specific requirements, the images to be used that meet the specific requirements can be used as images to be processed.
[0043] It should also be noted that the implementation of this technical solution can be achieved by the client or by the server; it can be a situation where each video frame in the video is processed after the video shooting is completed and then sent to the client for display, or it can be a situation where each video frame shot is processed in sequence during the video shooting process, and at this time each video frame is an image to be processed.
[0044] S120 : Segment the image to be processed based on an image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed.
[0045] Among them, the image segmentation model is a pre-trained neural network model. If it is necessary to determine the rendering area in the image to be processed, multiple training samples can be obtained (the training samples are training images), and multiple areas in each training sample can be marked, such as marking multiple areas in the training image. The training image is used as the input parameter of the image segmentation model to be trained, and the image containing the marked area is used as the output of the image segmentation model. Based on the training image in the training sample and the corresponding marked area in the image, the image segmentation model can be trained. The number of at least two target rendering areas can be two, three or more, and the specific rendering areas correspond to the training samples of the image segmentation model.
[0046] Specifically, the image to be processed may be input into a pre-trained image segmentation model, and multiple rendering areas in the image to be processed may be determined based on the image segmentation model. The multiple rendering areas determined at this time are used as target rendering areas.
[0047] It should be noted that the input of the image segmentation model can be the image to be processed, and the output of the model can be an image that determines the rendering area in the current image to be processed. The image segmentation model is a neural network, and the structure of the network can be VGG, ResNet, GoogleNet, MobileNet, ShuffleNet, etc. For different network structures, the computational complexity of each network structure is different. It can be understood that not all models are lightweight. That is, some models have a large computational complexity and are not suitable for deployment on mobile terminals, while models with small computational complexity, high computational efficiency, and simplicity are easier to deploy on mobile terminals. If the implementation of this technical solution is based on a mobile terminal, then the MobileNet and ShuffleNet model structures can be adopted. The principle of the above model structure is to transform traditional convolution into separable convolution, namely depthwise convolution and point-wise convolution, in order to reduce the amount of calculation; in addition, Inverted Residuals is used to improve the feature extraction ability of depthwise convolution; at the same time, the simple operation of shuffle channel is also used to improve the expressiveness of the model. The above is the basic module design of the model. The model is basically composed of the above modules stacked together. The advantage of this type of model is that the inference time is relatively low and it can be applied to terminals with higher time requirements. If it is implemented on a server, then any of the above neural networks can be used, as long as it can determine the rendering area in the image to be processed. It should be noted that the above is only a description of the image segmentation model and does not limit it.
[0048] In an embodiment of the present disclosure, segmenting the image to be processed based on an image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed includes: segmenting a target object in the image to be processed based on the image segmentation model to determine an edge frame area and at least one to-be-processed rendering area corresponding to the target object; and determining the at least two target rendering areas based on the edge frame area and the at least one to-be-processed rendering area.
[0049] In this embodiment, the at least two target rendering areas are ear rendering areas, and the edge frame area is an area surrounding the hair of the target object.
[0050] It can be understood that the special effects added to the target object in this technical solution can be hair dyeing special effects, in order to make the hair dyeing special effects most compatible with the real scene, or the personalized needs of the user. For example, if it is necessary to determine the hair dyeing effect of each color, or the effect of each color dyed into the corresponding area, it can be determined based on this technical solution. Among them, the ear dyeing area can be understood as using the edge line of the ear as the dividing line for image segmentation, and the area below the edge line and closer to the face is used as the inner ear dyeing area; the area above the edge line and relatively far from the face is used as the outer ear dyeing area, see Figure 2 The area corresponding to marker 1 is the inner ear dye area, and the area corresponding to marker 2 is the outer ear dye area. The edge frame area can be the area corresponding to the target subject's hair. Marker 1 represents the left and right outer ear dye areas, and marker 2 represents the left and right inner ear dye areas.
[0051] The image segmentation model can segment the input image to be processed, determine the area within the image to be processed where special effects need to be added, and then treat the area to be rendered as the target area. In actual applications, the image segmentation model may segment the target area not located on the hair, i.e., the segmented area is inaccurate. In this case, the area initially segmented by the image segmentation model can be used as the target area. The target area can then be further filtered based on the edge frame to determine the area actually located on the hair that needs to be rendered, i.e., the target area.
[0052] Specifically, the image to be processed can be segmented based on the image segmentation model to obtain multiple rendering areas to be processed. In order to further determine whether the rendering area to be processed is located on the hair, the rendering area to be processed can be filtered based on the edge frame area, and the rendering area to be processed located inside the edge frame area is used as the target rendering area.
[0053] S130 : Obtaining a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters.
[0054] As can be seen above, the target rendering area is the ear-dyed area within the hair. The special effect parameters may be pre-selected parameters for adding a corresponding special effect to the target rendering area. The image determined after adding the special effect to the target rendering area is used as the target image, and the special effect added based on the target parameters is used as the target special effect. Optionally, the target special effect may be a color effect.
[0055] Specifically, when the trigger operation is determined, the determined special effect parameters, and optionally, the bleaching color information, are added to the determined target rendering area to obtain a target image with the target special effect added to the target object.
[0056] Optionally, obtaining a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters includes: determining a target pixel value of each pixel in the at least two target rendering areas according to the special effect parameters; and updating the original pixel value of each pixel in the at least two target rendering areas based on the target pixel value to obtain a target image for adding a target special effect to the target object.
[0057] Each pixel in the displayed image has a corresponding pixel value. Optionally, the three RGB channels have corresponding values. The values in the three channels can be replaced with the values corresponding to the corresponding bleaching colors (special effect parameters), thereby obtaining a target image after adding the target special effect to the target object. The pixel values of the pixels within the target rendering area of the image to be processed are used as the original pixel values. The pixel values corresponding to the special effect parameters are used as the target pixel values. The original pixel values can be replaced based on the target pixel values.
[0058] It should also be noted that the bleached color may have multiple colors, for example, a gray-white gradient color. In this case, the target pixel value of each pixel point will also be different. The specific value of the target pixel point value is adapted to the special effect parameters.
[0059] Optionally, obtaining a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters includes: rendering the special effect parameters and the at least two target rendering areas based on a rendering model to obtain a target image for adding a target special effect to the target object.
[0060] The rendering model may be a pre-trained neural network used to process special effect parameters and determine target pixel values corresponding to the special effect parameters, or a model that processes target rendering to match the special effect parameters.
[0061] Specifically, after determining at least two target rendering areas, the special effect parameters and the image including the target rendering area can be used as input of the rendering model. Based on the rendering model, a rendering image matching the special effect parameters can be output. The image obtained at this time can be used as the target image obtained after adding the target special effect to the target object.
[0062] It should also be noted that this technical solution can be applied to any scene that requires local rendering, thereby obtaining a schematic diagram of the local rendering effect.
[0063] The technical solution of the disclosed embodiment can collect an image to be processed including a target object when a triggering special effect adding instruction is detected, and determine a target rendering area in the image to be processed based on an image segmentation model, and add a target special effect to the target object according to the target rendering area and special effect parameters, thereby obtaining a target image. This solves the problem in the prior art that neural networks corresponding to different rendering methods need to be trained, which not only requires more models to be trained but also requires a large number of training samples, resulting in inconvenience in adding rendering special effects. This achieves the goal of only requiring a neural network to determine the rendering area to be processed, and then adding corresponding special effects to the rendering area, thereby improving the convenience of special effect processing and achieving a technical effect with a high degree of adaptability to actual use.
[0064] Example 2
[0065] Figure 3 This is a flowchart of an image processing method provided in Example 2 of the present disclosure. Based on the aforementioned embodiments, there is a need to add multiple special effects to a target object. This can be achieved based on this technical solution. For specific implementations, please refer to the detailed description of this technical solution. Technical terms that are the same as or corresponding to those in the aforementioned embodiments are not repeated here.
[0066] like Figure 3 As shown, the method includes:
[0067] S210 : In response to a special effect adding instruction, an image to be processed including a target object is collected.
[0068] S220 : Segment the image to be processed based on an image segmentation model to obtain at least two target rendering areas and an edge frame area corresponding to the image to be processed.
[0069] S230: Add a first special effect to the edge frame area of the target object based on a first special effect processing module.
[0070] The first special effect may be a special effect that needs to be added to the entire edge frame area. The first special effect processing module may be a first special effect adding model, i.e., a pre-trained neural network. The first special effect may be added to the entire edge frame area based on special effect parameters, such as [amount of text needed for the image]. The first special effect may be a solid color special effect, such as dyeing the entire hair yellow.
[0071] Specifically, based on the first special effect processing module, the special effect corresponding to the first special effect in the special effect parameters can be added to the edge frame area of the target object.
[0072] S240: Update the first special effects of the at least two target rendering areas located in the edge area to the second special effects, and obtain a target image with the target special effects added to the target object.
[0073] The second special effect may be a special effect superimposed on the target rendering area, or may be a special effect that updates the target rendering area. For example, if gray bleaching needs to be added to the target rendering area, i.e., the ear dyeing area, the gray bleaching may be updated in the target rendering area.
[0074] Specifically, while adding the first special effect to the edge area, the second special effect can be added to the target rendering area. For the target rendering area, the first special effect and the second special effect can be superimposed, or the target rendering area can only include the second rendering special effect. The image corresponding to the addition of the special effects is used as the target image, and the final effect can be seen in Figure 2 .
[0075] On the basis of the above technical solutions, the present invention further includes: when an operation is detected that triggers the replacement of the first special effect, the second special effect is kept unchanged and the first special effect corresponding to the triggering operation is updated; and when an operation is detected that triggers the replacement of the second special effect, the first special effect is kept unchanged and the second special effect corresponding to the triggering operation is updated.
[0076] The technical solution of the disclosed embodiment can collect an image to be processed including a target object when a triggering special effect adding instruction is detected, and determine a target rendering area in the image to be processed based on an image segmentation model, and add a target special effect to the target object according to the target rendering area and special effect parameters, thereby obtaining a target image. This solves the problem in the prior art that neural networks corresponding to different rendering methods need to be trained, which not only requires more models to be trained but also requires a large number of training samples, resulting in inconvenience in adding rendering special effects. This achieves the goal of only requiring a neural network to determine the rendering area to be processed, and then adding corresponding special effects to the rendering area, thereby improving the convenience of special effect processing and achieving a technical effect with a high degree of adaptability to actual use.
[0077] Example 3
[0078] As an alternative embodiment of the above embodiment, Figure 4 This is a flowchart of an image processing method provided in the third embodiment of the present disclosure, wherein technical terms that are the same as or corresponding to those in the above embodiments are not repeated here.
[0079] like Figure 4 As shown, the current image to be processed is input into the image segmentation model, and ear coloring is processed to obtain the left ear outer coloring region, the left ear inner coloring region, the right ear outer coloring region, the right ear inner coloring region, and the hair region including the hair. That is, the at least two target rendering regions can be the left ear outer coloring region, the left ear inner coloring region, the right ear outer coloring region, and the right ear inner coloring region mentioned above; the hair region is the edge frame region mentioned above.
[0080] It should be noted that each pixel in the output ear staining area may have a corresponding value. Optionally, the value is in the range of 0 to 1, and the value is used to indicate whether it is an ear staining area.
[0081] In this embodiment, ear coloring regions are processed. Since the image segmentation model's segmentation results may include ear coloring regions in non-hair areas, each of the four ear coloring regions can be filtered using the hair region. This means that the ear coloring regions are constrained by the hair region, meaning they must be located within the hair region. After filtering, since the output value of the ear coloring (ranging from 0 to 1) is not very high, the ear coloring effect can fluctuate. In this case, the ear coloring regions can be further post-processed. This post-processing can be performed by enhancing the ear coloring results, typically by stretching the curve to force portions less than 0.1 to equal 0 and portions greater than 0.9 to equal 1. This results in weaker areas being directly 0 and stronger areas being directly 1, resulting in four well-processed ear coloring regions, the target rendering regions mentioned above.
[0082] After obtaining all the ear dyeing areas that can be used, hair dyeing effects can be added to the ear dyeing areas. In actual applications, it is also possible to have both hair dyeing and ear dyeing. In this case, on the basis of dyeing the hair in a solid color, new bleaching and dyeing can be added to the ear dyeing areas.
[0083] A specific implementation method is: after obtaining the ear dye area, the color of the ear dye area needs to be replaced. There are two methods for this. The first method is to replace the RGB values of the ear dye area with the corresponding bleaching color values based on traditional methods. The second method is to dye the hair a solid color based on a pre-generated neural network model. In this case, only different hair colors need to be trained to train the model, eliminating the need to train samples corresponding to different hair lengths, different hairstyles, and different colors, thus reducing the difficulty of obtaining training data.
[0084] Based on the ear dye segmentation results above, the results of the solid hair dye module are superimposed to create the final effect. Furthermore, the ear dyeing capabilities are highly reusable; simply by changing the solid hair color, new effects can be achieved. Original image / ear dye effect image / pure blonde image / pure dark image / ear dye mask.
[0085] The technical solution of the disclosed embodiments can segment the image to obtain the left and right, inner and outer ear dyed regions corresponding to the target subject, and then overlay the dyed hair color to create the ear dyed hairstyle effect. For the hairstyle change effect, the neural network used for this type of normal change effect does not require a large number of images of the target effect. For example, dyeing hair blonde would require many photos of blondes, meaning that different hair dyeing models would need to be trained for different hair colors. Furthermore, hair and ear dyeing is a highly personalized hairstyle, so there will be less sample data corresponding to the ear dyeing image. At the same time, the hairstyles corresponding to ear dyeing can be various and in various colors, so it is difficult to collect corresponding renderings. Furthermore, even if a large number of ear dyeing images that meet the effect requirements are collected and the corresponding neural network is trained, a neural network model can only produce one effect. If different colors of ear dyeing effects are required, different models must be trained, and the reusability is low, which increases a lot of workload. However, if we can produce an ear dyeing effect that can specify any color with this technical solution, we only need to train an image segmentation model to obtain the corresponding ear dyeing effect. Subsequently, we only need to replace all the ear dyeing colors. The reusability is high, and the data is very easy to collect. It not only improves the convenience of adding special effects, but also provides a technical effect of rich special effect content and universality.
[0086] Example 4
[0087] Figure 5 This is a structural diagram of an image processing device provided by the fourth embodiment of the present disclosure, such as Figure 5 As shown, the apparatus includes: an image acquisition module 410 , a rendering area determination module 420 and a target image determination module 430 .
[0088] The image acquisition module 410 is used to acquire an image to be processed including a target object in response to a special effect adding instruction; the rendering area determination module 420 is used to segment the image to be processed based on an image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed; the target image determination module 430 is used to obtain a target image for adding a target special effect to the target object based on the at least two target rendering areas and special effect parameters.
[0089] Based on the above technical solution, the image acquisition module is also used to: when a target object is detected to trigger a special effect adding wake-up word, generate a special effect adding instruction and collect the image to be processed including the target object; or, when a special effect adding control is detected to be triggered, generate the special effect adding instruction and collect the image to be processed including the target object.
[0090] On the basis of the above technical solution, the rendering area determination module includes: a to-be-processed rendering area determination unit, configured to segment the target object in the to-be-processed image based on the image segmentation model, and determine an edge frame area corresponding to the target object and at least two to-be-processed rendering areas;
[0091] The target rendering area determining unit is configured to determine the at least two target rendering areas based on the edge frame area and the at least two to-be-processed rendering areas.
[0092] On the basis of the above technical solution, the target image determination module includes:
[0093] a pixel value determining unit, configured to determine a target pixel value of each pixel in the at least two target rendering areas according to the special effect parameter;
[0094] The pixel value updating unit is used to update the original pixel value of each pixel point in the at least two target rendering areas based on the target pixel value to obtain a target image with a target special effect added to the target object.
[0095] On the basis of the above technical solution, the target image determination module includes:
[0096] The special effect parameters and the at least two target rendering areas are rendered based on a rendering model to obtain a target image with a target special effect added to the target object.
[0097] On the basis of the above technical solution, the target image determination module is further used to:
[0098] adding a first special effect corresponding to the special effect parameter to the edge frame area of the target object based on a first special effect processing module;
[0099] Updating the first special effects of the at least two target rendering areas located in the edge area to second special effects corresponding to the special effect parameters, to obtain a target image with the target special effect added to the target object;
[0100] Or the special effect is superimposed on the at least two target rendering areas to obtain a target image with a target special effect added to the target object.
[0101] On the basis of the above technical solution, the device further includes: a special effect adding module, configured to keep the second special effect unchanged and update the first special effect corresponding to the triggering operation when an operation to replace the first special effect is detected; and
[0102] When an operation of replacing with the second special effect is detected, the first special effect is kept unchanged and the second special effect corresponding to the triggering operation is updated.
[0103] Based on the above technical solution, the at least two target rendering areas are hair dyeing areas, and the edge frame area is an area corresponding to the hair.
[0104] The technical solution of the disclosed embodiment can collect an image to be processed including a target object when a triggering special effect adding instruction is detected, and determine a target rendering area in the image to be processed based on an image segmentation model, and add a target special effect to the target object according to the target rendering area and special effect parameters, thereby obtaining a target image. This solves the problem in the prior art that neural networks corresponding to different rendering methods need to be trained, which not only requires more models to be trained but also requires a large number of training samples, resulting in inconvenience in adding rendering special effects. This achieves the goal of only requiring a neural network to determine the rendering area to be processed, and then adding corresponding special effects to the rendering area, thereby improving the convenience of special effect processing and achieving a technical effect with a high degree of adaptability to actual use.
[0105] The image processing device provided by the embodiments of the present disclosure can execute the image processing method provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0106] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0107] Example 5
[0108] Figure 6 This is a structural diagram of an electronic device provided by the fifth embodiment of the present disclosure. Figure 6 , which shows an electronic device (eg Figure 6 The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0109] like Figure 6As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 506 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device 500 are also stored in the RAM 503. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An edit / output (I / O) interface 505 is also connected to the bus 504.
[0110] Typically, the following devices may be connected to the I / O interface 505: an editing device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 506 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 6 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0111] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 506, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0112] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0113] The electronic device provided by the embodiment of the present disclosure and the image processing method provided by the above embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0114] Example 6
[0115] An embodiment of the present disclosure provides a computer storage medium having a computer program stored thereon. When the program is executed by a processor, the image processing method provided by the above embodiment is implemented.
[0116] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0117] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0118] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0119] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0120] In response to a special effect adding instruction, collecting an image to be processed including a target object;
[0121] Segmenting the image to be processed based on an image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed;
[0122] Based on the at least two target rendering areas and the special effect parameters, a target image with a target special effect added to the target object is obtained.
[0123] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0124] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0125] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."
[0126] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0127] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0128] According to one or more embodiments of the present disclosure, [Example 1] provides an image processing method, the method comprising:
[0129] In response to a special effect adding instruction, collecting an image to be processed including a target object;
[0130] Segmenting the image to be processed based on an image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed;
[0131] Based on the at least two target rendering areas and the special effect parameters, a target image with a target special effect added to the target object is obtained.
[0132] According to one or more embodiments of the present disclosure, [Example 2] provides an image processing method, the method further comprising:
[0133] Optionally, in response to the special effect adding instruction, collecting the image to be processed including the target object includes:
[0134] When a target object is detected to trigger a special effect adding wake-up word, a special effect adding instruction is generated, and an image to be processed including the target object is collected; or
[0135] When it is detected that the special effect adding control is triggered, the special effect adding instruction is generated, and the image to be processed including the target object is collected.
[0136] According to one or more embodiments of the present disclosure, [Example 3] provides an image processing method, the method further comprising:
[0137] Optionally, the segmenting the image to be processed based on the image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed includes:
[0138] Segmenting the target object in the image to be processed based on the image segmentation model to determine an edge frame area corresponding to the target object and at least two rendering areas to be processed;
[0139] The at least two target rendering areas are determined based on the edge frame area and the at least two to-be-processed rendering areas.
[0140] According to one or more embodiments of the present disclosure, [Example 4] provides an image processing method, the method further comprising:
[0141] Optionally, obtaining a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters includes:
[0142] Determining target pixel values of each pixel in the at least two target rendering areas according to the special effect parameters;
[0143] The original pixel value of each pixel point in the at least two target rendering areas is updated based on the target pixel value to obtain a target image with a target special effect added to the target object.
[0144] According to one or more embodiments of the present disclosure, [Example 5] provides an image processing method, the method further comprising:
[0145] Optionally, obtaining a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters includes:
[0146] The special effect parameters and the at least two target rendering areas are rendered based on a rendering model to obtain a target image with a target special effect added to the target object.
[0147] According to one or more embodiments of the present disclosure, [Example 6] provides an image processing method, the method further comprising:
[0148] Optionally, obtaining a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters includes:
[0149] adding a first special effect corresponding to the special effect parameter to the edge frame area of the target object based on a first special effect processing module;
[0150] Updating the first special effects of the at least two target rendering areas located in the edge area to second special effects corresponding to the special effect parameters, to obtain a target image with the target special effect added to the target object;
[0151] Or the special effect is superimposed on the at least two target rendering areas to obtain a target image with a target special effect added to the target object.
[0152] According to one or more embodiments of the present disclosure, [Example 7] provides an image processing method, the method further comprising:
[0153] Optionally, when an operation that triggers replacement of the first special effect is detected, the second special effect is kept unchanged and the first special effect corresponding to the triggering operation is updated; and
[0154] When an operation that triggers replacement with the second special effect is detected, the first special effect is kept unchanged and the second special effect corresponding to the triggering operation is updated.
[0155] According to one or more embodiments of the present disclosure, [Example 8] provides an image processing method, the method further comprising:
[0156] Optionally, the at least two target rendering areas are ear dyeing areas, and the edge frame area is an area surrounding the hair of the target object. The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned disclosed concepts. For example, the above-mentioned features are replaced with the technical features with similar functions disclosed in this disclosure (but not limited to) by each other to form a technical solution.
[0157] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0158] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. An image processing method, characterized in that: include: In response to a special effect adding instruction, collecting an image to be processed including a target object; Segmenting the image to be processed based on an image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed, specifically comprising: segmenting the image to be processed based on the image segmentation model to obtain a plurality of rendering areas to be processed; filtering the rendering areas to be processed based on an edge frame area, and using the rendering areas to be processed located within the edge frame area as the target rendering areas; Based on the at least two target rendering areas and the special effect parameters, a target image with a target special effect added to the target object is obtained.
2. The method according to claim 1, characterized in that The step of collecting an image to be processed including a target object in response to a special effect adding instruction includes: When a target object is detected to trigger a special effect adding wake-up word, a special effect adding instruction is generated, and an image to be processed including the target object is collected; or When a special effect adding control is detected to be triggered, the special effect adding instruction is generated, and an image to be processed including the target object is collected; or When it is detected that the field of view includes the target object, an image to be processed including the target object is acquired.
3. The method according to claim 1, characterized in that The step of segmenting the image to be processed based on the image segmentation model to obtain at least two target rendering areas corresponding to the image to be processed includes: Segmenting the target object in the image to be processed based on the image segmentation model to determine an edge frame area corresponding to the target object and at least two rendering areas to be processed; The at least two target rendering areas are determined based on the edge frame area and the at least two to-be-processed rendering areas.
4. The method according to claim 1, wherein The step of obtaining a target image with a target special effect added to the target object based on the at least two target rendering areas and the special effect parameters includes: Determining target pixel values of each pixel in the at least two target rendering areas according to the special effect parameters; The original pixel value of each pixel point in the at least two target rendering areas is updated based on the target pixel point value to obtain a target image with a target special effect added to the target object.
5. The method according to claim 1, characterized in that The step of obtaining a target image with a target special effect added to the target object based on the at least two target rendering areas and the special effect parameters includes: The special effect parameters and the at least two target rendering areas are rendered based on a rendering model to obtain a target image with a target special effect added to the target object.
6. The method according to claim 1, characterized in that The step of obtaining a target image with a target special effect added to the target object based on the at least two target rendering areas and the special effect parameters includes: adding a first special effect corresponding to the special effect parameter to the edge frame area of the target object based on a first special effect processing module; Updating the first special effects of the at least two target rendering areas located in the edge frame area to second special effects corresponding to the special effect parameters, to obtain a target image with the target special effect added to the target object; Or the special effect is superimposed on the at least two target rendering areas to obtain a target image with a target special effect added to the target object.
7. The method according to claim 6, characterized in that Also includes: When an operation that triggers the replacement of the first special effect is detected, the second special effect is kept unchanged and the first special effect corresponding to the triggering operation is updated; as well as, When an operation that triggers replacement with the second special effect is detected, the first special effect is kept unchanged and the second special effect corresponding to the triggering operation is updated.
8. The method according to any one of claims 1 to 6, characterized in that: The at least two target rendering areas are ear rendering areas, and the edge frame area is an area surrounding the hair of the target object.
9. An image processing device, characterized in that: include: An image acquisition module, configured to acquire an image to be processed including a target object in response to a special effect adding instruction; a rendering region determination module, configured to segment the image to be processed based on an image segmentation model to obtain at least two target rendering regions corresponding to the image to be processed, specifically comprising: segmenting the image to be processed based on the image segmentation model to obtain a plurality of rendering regions to be processed; filtering the rendering regions to be processed based on an edge frame region, and selecting the rendering regions to be processed located within the edge frame region as the target rendering regions; The target image determination module is configured to obtain a target image for adding a target special effect to the target object based on the at least two target rendering areas and the special effect parameters.
10. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the image processing method according to any one of claims 1 to 8.
11. A storage medium comprising computer-executable instructions, wherein the computer-executable instructions are used to perform the image processing method according to any one of claims 1 to 8 when executed by a computer processor.
Citation Information
Patent Citations
Image processing method and device, electronic equipment and storage medium
CN111091610A
Hair color rendering method and device, electronic equipment and storage medium
CN112465944A