Special effect image generation method and apparatus, electronic device, and storage medium

By fusing the initial image and the special effects image, using translucent and non-transparent overlay processing, and combining with texture information adjustment, the problem of blunt transitions between portraits and backgrounds is solved, and the authenticity and visual effects of the special effects are improved.

WO2024217277A1PCT designated stage expired Publication Date: 2024-10-24BEIJING ZITIAO NETWORK TECH CO LTD +1

Patent Information

Application Number
PCT/CN2024/085496
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-21
Filing Date
2024-04-02
Publication Date
2024-10-24

AI Technical Summary

Technical Problem

In the existing technology, the transition between portraits and background special effects is stiff and fragmented, which affects the authenticity and visual effects of the special effects.

Method used

By fusing the target area in the initial image with the special effects image, a fused image is generated, in which the image content in the target area and the image content of the special effects image are simultaneously displayed in the sub-area, and the hair and skin areas are processed using semi-transparent and non-transparent overlay methods. Combined with texture information adjustment, smooth transition between portrait and background is achieved.

Benefits of technology

It reduces the sense of separation between the portrait and the background in the fused image, improves the authenticity and visual expressiveness of the special effects, and enhances the authenticity and fusion of the virtual background.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024085496_24102024_PF_FP_ABST
    Figure CN2024085496_24102024_PF_FP_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a special effect image generation method and apparatus, an electronic device, and a storage medium. The method comprises: acquiring an initial image, the initial image comprising a target region; and fusing the target region of the initial image with a special effect image to generate a fused image, wherein the fused image comprises at least one subregion, and image content in the target region and image content of the special effect image are simultaneously displayed in the subregion.
Need to check novelty before this filing date? Find Prior Art

Description

Special effect image generation method, device, electronic device and storage medium

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese Patent Application No. 202310437532.0, filed on April 21, 2023, entitled “Special Effects Image Generation Method, Device, Electronic Device and Storage Medium,” the disclosure of which is incorporated herein by reference in its entirety. Technical Field

[0003] The embodiments of the present disclosure relate to the field of Internet technology, and in particular to a method, device, electronic device, and storage medium for generating special effect images. Background Art

[0004] Adding background effects to images is a commonly used image editing function. By processing and replacing the background content outside the target area of ​​the original image, an output image with a virtual background effect is generated, while retaining the portrait part of the original image in the output image.

[0005] In the related art, the output image with background special effects generated by replacing the background content in the image has the problem of abrupt transition and strong sense of separation between the portrait and the background special effects, which affects the authenticity and visual effect of the special effects.

[0006] Summary of the Invention

[0007] In a first aspect, an embodiment of the present disclosure provides a method for generating a special effect image, comprising:

[0008] Acquire an initial image, wherein the initial image includes a target area; fuse the target area of ​​the initial image with a special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the image content of the target area and the image content of the special effect image are simultaneously displayed in the sub-area.

[0009] In a second aspect, an embodiment of the present disclosure provides a special effect image generating device, comprising:

[0010] An acquisition module, configured to acquire an initial image, wherein the initial image includes a target area;

[0011] A generation module is used to fuse the target area of ​​the initial image with the special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the image content of the target area and the image content of the special effect image are simultaneously displayed in the sub-area.

[0012] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0013] a processor, and a memory communicatively connected to the processor;

[0014] The memory stores computer-executable instructions;

[0015] The processor executes the computer-executable instructions stored in the memory to implement the special effect image generation method described in the first aspect and various possible designs of the first aspect.

[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the special effect image generation method described in the first aspect and various possible designs of the first aspect is implemented.

[0017] In a fifth aspect, an embodiment of the present disclosure provides a non-transient computer program product, including a computer program, which, when executed by a processor, implements the special effect image generation method described in the first aspect and various possible designs of the first aspect.

[0018] In a sixth aspect, an embodiment of the present disclosure provides a computer program, which, when executed by a processor, implements the special effect image generation method described in the first aspect and various possible designs of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or related technologies, the following is a brief introduction to the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0020] FIG1 is a diagram showing an application scenario of the special effect image generation method provided by an embodiment of the present disclosure;

[0021] FIG2 is a flowchart of a method for generating special effect images according to an embodiment of the present disclosure;

[0022] FIG3 is a schematic diagram of an initial image provided by an embodiment of the present disclosure;

[0023] FIG4 is a flowchart of a specific implementation of step S102 in the embodiment shown in FIG2 ;

[0024] FIG5 is a schematic diagram of generating a fused image according to an embodiment of the present disclosure;

[0025] FIG6 is a second flow chart of a method for generating special effect images according to an embodiment of the present disclosure;

[0026] FIG7 is a schematic diagram of image segmentation of portrait elements provided by an embodiment of the present disclosure;

[0027] FIG8 is a schematic diagram of a process of adding a reverse filter according to an embodiment of the present disclosure;

[0028] FIG9 is a flowchart of a specific implementation of step S203 in the embodiment shown in FIG6 ;

[0029] FIG10 is a flowchart of a specific implementation of step S205 in the embodiment shown in FIG6 ;

[0030] FIG11 is a schematic diagram of a second superimposed image provided by an embodiment of the present disclosure;

[0031] FIG12 is a structural block diagram of a special effect image generating device provided by an embodiment of the present disclosure;

[0032] FIG13 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure;

[0033] FIG14 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0034] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present disclosure without making any creative efforts shall fall within the scope of protection of the present disclosure.

[0035] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0036] The embodiments of the present disclosure provide a special effects image generation method, device, electronic device, and storage medium to overcome the problem of abrupt transitions and a strong sense of separation between portraits and background special effects.

[0037] The disclosed embodiments provide a method, apparatus, electronic device, and storage medium for generating special effects images. The method acquires an initial image, wherein the initial image includes a target area; the method fuses the target area of ​​the initial image with a special effects image to generate a fused image, wherein the fused image includes at least one sub-area, and the sub-area simultaneously displays the image content of the target area and the image content of the special effects image. By fusing the target area of ​​the initial image with the special effects image, a fused image is obtained that can superimpose the image content of the target area and the image content of the special effects image, thereby achieving fusion between the initial image and the special effects image, reducing the sense of separation between the portrait and the background presented in the fused image, and improving the authenticity and visual expressiveness of the special effects.

[0038] The following explains the application scenarios of the embodiments of the present disclosure:

[0039] FIG1 is an application scenario diagram of the special effect image generation method provided by the embodiment of the present disclosure. The special effect image generation method provided by the embodiment of the present disclosure can be applied to the application scenario of image special effect rendering. More specifically, it can be applied to the application scenario of adding virtual background special effects to character images. As shown in FIG1 , the method provided by the embodiment of the present disclosure can be applied to terminal devices, servers or other electronic devices that perform similar functions. Taking the terminal device as an example, the terminal device is, for example, a smart phone or a personal computer (shown as a smart phone in the figure). After the terminal device runs an application (Application, APP) with the function of adding special effects to pictures, it loads the initial image, such as the portrait photo shown in the figure, wherein the portrait photo contains a portrait area and a background area; thereafter, by triggering the special effect function, such as clicking the special effect tool provided by the application, the image content in the background area is replaced with a preset special effect image, such as a landscape photo, thereby achieving the effect of adding a virtual background special effect to the character image.

[0040] In the related art, for the application scenario of adding virtual background special effects to the above-mentioned character images, a commonly used solution is to directly segment the portrait area in the character image (initial image), and then overlay the segmentation map representing the portrait obtained after segmentation on the preset background image to generate an output image, thereby achieving background replacement, that is, adding virtual background features to the character image. However, in the solution in the above-mentioned related art, after segmenting along the portrait area of ​​the character image, the segmentation map obtained is significantly different from the background image in terms of color, brightness, image content, etc., which leads to a stiff transition and a strong sense of separation between the two, affecting the authenticity and visual effect of the virtual background image in the output image. The embodiment of the present disclosure provides a special effect image generation method to solve the above-mentioned problem.

[0041] Referring to FIG2 , FIG2 is a flow chart of a special effect image generation method provided by an embodiment of the present disclosure. The method of this embodiment can be applied in an electronic device, and the special effect image generation method includes:

[0042] Step S101: Acquire an initial image, where the initial image includes a target area.

[0043] Referring to the application scenario diagram shown in Figure 1, the execution entity of the special effect image generation method provided in the embodiment of the present disclosure can be a terminal device, a server or other electronic device with specific similar functions. In this embodiment, the terminal device is introduced as the execution entity by way of example. The implementation methods of other execution entities are similar and will not be repeated here.

[0044] Exemplarily, a terminal device can load an initial image containing a target object in response to a user operation. The target object can be a human body or a part of a human body, such as a human head, and the area containing the human body or part of the human body is the target area, also known as the portrait area. Of course, in other possible implementations, the target object can also be implemented in other ways, such as an animal, an object, etc., and this case is not described in detail here. In the case where the target area is a portrait area, the target area is used to represent the area where all portrait elements that constitute the portrait are located, while the area outside the target area in the initial image is the non-target area. Exemplarily, the non-target area represents the background area of ​​the portrait. Furthermore, the target area can include multiple portrait elements that constitute the portrait, such as hair, skin, and the person's clothing. Each portrait element is located in a sub-area of ​​the target area. For example, the area corresponding to hair is the hair area, the area corresponding to skin is the skin area, and the area corresponding to the person's clothing is the clothing area. The sub-area can be a continuous image area or a combined area composed of multiple non-continuous image areas. FIG3 is a schematic diagram of an initial image provided by an embodiment of the present disclosure. As shown in FIG3 , the target region, i.e., the region corresponding to the outline of a person in the image, is further divided into a hair region corresponding to the person's hair and skin regions corresponding to the person's face and neck. The target region in the initial image, as well as subregions of the target region (e.g., the hair region and the skin region), can be determined by performing image recognition on the initial image. The specific implementation method is conventional and will not be further described here.

[0045] Step S102: Fusing the target area of ​​the initial image with the special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the sub-area simultaneously displays the image content of the target area and the image content of the special effect image.

[0046] For example, the terminal device further reads a special effect image, uses the image content in the special effect image as a virtual background special effect, and fuses it with the initial image to obtain a fused image with the virtual background special effect. The special effect image can be an image selected from multiple candidate images based on a user's selection instruction, or it can be a fixed preset image. The content of the special effect image can be a landscape image such as a forest, a mountain, a river, or a starry sky, or other content, without limitation.

[0047] Furthermore, when fusing the initial image with the special effect image, the image content within the target area of ​​the initial image is fused with the special effect image, so that the image content within the target area and the image content of the special effect image are simultaneously displayed within at least one sub-area of ​​the generated fused image. In one possible implementation, the target area includes at least the hair area. As shown in FIG4 , the specific implementation of step S102 includes:

[0048] Step S1021: superimposing the image content in the hair area of ​​the initial image on the special effect image in a semi-transparent manner to obtain a first superimposed image.

[0049] Step S1022: obtaining a fused image based on the first superimposed image.

[0050] Exemplarily, referring to the schematic diagram of the target area shown in FIG3 , the hair area is the area where the hair elements are displayed. When the target area of ​​the initial image is fused with the special effect image, the image content of the hair area, i.e., the hair elements, are superimposed on the special effect image in a semi-transparent manner to obtain a first superimposed image. The semi-transparent manner referred to here means that when the hair elements are superimposed on the special effect image, the first superimposed image generated simultaneously displays the image features of the hair elements and the image features of the special effect image of the corresponding area, so that the hair elements present a "transparent" visual effect. The specific implementation method for superimposing the image content within the hair area of ​​the initial image on the special effects image in a semi-transparent manner can be achieved by performing brightness weighting on the pixels within the hair area of ​​the initial image and the pixels of the special effects image. For example, the brightness of the pixels within the hair area is lowered, the brightness of the pixels of the special effects image is increased, and then the pixels within the hair area are pixel-fused with the pixels at corresponding positions in the special effects image. The degree of transparency of the hair element, i.e., the transparency, is determined based on the specific weighting method and weighting value for performing brightness weighting on the pixels within the hair area and the pixels of the special effects image. The specific implementation process is described in subsequent embodiments.

[0051] Afterwards, for example, after obtaining the first superimposed image, further post-processing may be performed on the first superimposed image, such as superimposing the image content in other image regions except the hair region onto corresponding positions in the first superimposed image to obtain a fused image. In one possible implementation, the specific implementation of step S1022 includes:

[0052] Step S1022A: superimposing the image content in the skin area on the first superimposed image in a non-transparent manner to obtain a second superimposed image;

[0053] Step S1022B: Obtain a fused image based on the second superimposed image.

[0054] Exemplarily, after obtaining the first overlay image, the image content within the skin region of the initial image is further overlaid on the first overlay image in a non-transparent manner to obtain a second overlay image. In this case, within the subregion corresponding to the hair region of the second overlay image, the image content within the hair region (the person's hair) and the image content of the special effects image are simultaneously displayed, achieving a fusion display of the background special effects of the person's hair. Furthermore, within the subregion corresponding to the skin region, the image content of the initial image (the person's skin) obscures the image content of the special effects image, i.e., only the image content of the initial image is displayed, thereby achieving a display of the person's skin. In another possible implementation, the image content within the skin region of the initial image can also be overlaid on the first overlay image in a semi-transparent manner. Specifically, for example, the skin region can be further divided into a facial skin region and a neck skin region. Exemplarily, the image content of the facial skin region is overlaid on the first overlay image in a non-transparent manner, while the image content of the neck skin region is overlaid on the first overlay image in a semi-transparent manner. This achieves a more delicate portrait edge transition in the second overlay image, improving the fusion effect between the background special effects (the image content of the special effects image) and the person (the image content of the target region). Afterwards, illustratively, further post-processing may be performed based on the second superimposed image to obtain a fused image; or, the second superimposed image may be directly used as the fused image, which will not be described in detail here.

[0055] FIG5 is a schematic diagram of a method for generating a fused image according to an embodiment of the present disclosure. As shown in FIG5 , for example, an initial image includes a portrait, and a special effect image includes a "starry sky" image. The image size of the initial image is equal to that of the special effect image. The initial image includes a target area, which includes a hair area and a skin area. First, the image content of the hair area is semi-transparently superimposed on the special effect image to generate a first superimposed image. In this first superimposed image, the hair texture of the portrait is fused with the special effect image of the corresponding area. That is, the hair texture and the "starry sky" are simultaneously displayed in the sub-area corresponding to the hair area. Subsequently, based on the first superimposed image, the image content of the skin area in the initial image is non-transparently superimposed on the special effect image to generate a second superimposed image. The second superimposed image is then further processed to generate a fused image, or the second superimposed image is directly used as the fused image. The skin of the person in the fused image obtained based on the second superimposed image can be clearly displayed, thereby highlighting the person's facial contours and restoring the person's facial expressions. At the same time, the person's hair is integrated with the background special effects, achieving a smooth transition between the portrait and the background special effects and optimizing the display effect, thereby improving the visual display effect.

[0056] Furthermore, optionally, after the fused image is generated, the image content of the fused image may be further adjusted so that the image content of the fused image better matches the portrait and the display effect is improved. For example, after step S102, the following steps may be optionally included:

[0057] Step S1031: Acquire texture information corresponding to the hair region, where the texture information represents the texture direction of the hair in the hair region.

[0058] Step S1032: Based on the texture information, the target elements in the fused image are moved so that the target elements are arranged or moved along the texture direction of the hair.

[0059] Illustratively, by recognizing the initial image, texture information representing the texture directions of hair strands within the hair region can be obtained. Exemplarily, the texture information includes, for example, coordinate groups corresponding to multiple reference hair strands, each coordinate group including coordinates representing multiple hair strand nodes. The coordinate groups are used to represent the texture paths of the corresponding reference hair strands. Specifically, for example, by recognizing the initial image, texture information corresponding to the hair region is obtained as hair_Info = (L1, L2, L3..., Ln). L1, L2, L3,..., Ln are the hair strand paths of n reference hair strands. Taking L1 as an example, L1 = [p1_1, p1_2, p1_3, p1_4], where p1_1, p1_2, p1_3, and p1_4 represent the four hair strand nodes on reference hair strand #1. These four hair strand nodes are used to identify the hair strand path L1 corresponding to reference hair strand #1. The representation of other hair strand paths is similar and will not be further described. The set of hair paths of each reference hair is texture information. The specific implementation method of identifying hair in the image and generating the corresponding hair path is existing technology and will not be repeated here.

[0060] Furthermore, after obtaining the texture information, the position of the target element in the fused image is adjusted based on the texture information. Specifically, for example, the special effects image used to generate the fused image is a "starry sky" image, and therefore the target element in the fused image is a "star in the starry sky." After identifying the target element in the fused image, the texture information is used to adjust the position of the target element so that the position of the target element matches the texture direction of the hair, thereby achieving, for example, the effect of "stars in the starry sky" being arranged along the hair texture, or flowing along the hair texture direction. Through the scheme of the steps of this embodiment, the degree of fusion and integration of the virtual background special effect (the image content of the special effects image) and the portrait (the image content within the target area) in the fused image can be further improved, thereby improving the authenticity and visual expressiveness of the virtual background special effect.

[0061] Furthermore, optionally, after generating a fused image, dynamic special effects can be further added to the static fused image to generate a dynamic special effects image. The special effect type of the dynamic special effect is determined by the image content of the special effects image. For example, if the content of the special effects image is "starry sky", then the special effect of "twinkling stars" is selected as its corresponding target dynamic special effect, so that the target dynamic special effect matches the content theme of the generated fused image, thereby improving the special effect visual expression of the generated dynamic special effects image. The mapping relationship between the dynamic special effect and the image content of the special effects image can be preset, and can be mapped to the target dynamic special effect based on the identification of the special effects image, or can be mapped to the target dynamic special effect based on the type identification of the image content after detecting the image content of the special effects image. The specific setting can be made as needed and will not be repeated here.

[0062] Afterwards, after the fused image is generated, when the terminal device is used as the executor of the method provided in this embodiment, the fused image can be directly displayed on the terminal device side, for example, displayed in the image editing software running on the terminal device, to achieve the effect display of the special effect image; when the server or other electronic device is used as the executor of the method provided in this embodiment, the fused image can be sent to the terminal device side for display, or stored, to complete the production and display process of the special effect image, and the specific process will not be repeated here.

[0063] In this embodiment, an initial image is acquired, including a target area. The target area of ​​the initial image is fused with a special effect image to generate a fused image. The fused image includes at least one sub-area, and the sub-area simultaneously displays the image content of the target area and the image content of the special effect image. By fusing the target area of ​​the initial image with the special effect image, a fused image is generated that superimposes the image content of the target area and the image content of the special effect image. This achieves fusion between the initial image and the special effect image, reduces the sense of separation between the portrait and the background presented in the fused image, and improves the realism and visual expressiveness of the special effect.

[0064] Referring to FIG6 , FIG6 is a second flow chart of the special effect image generation method provided by an embodiment of the present disclosure. Based on the embodiment shown in FIG2 , this embodiment refines step S102 and further introduces the implementation process of fusing the target area of ​​the initial image with the special effect image. The special effect image generation method includes:

[0065] Step S201: Acquire an initial image, where the initial image includes a target area.

[0066] Step S202: performing image segmentation on at least one portrait element in the target area to obtain a mask image with the portrait element as the edge.

[0067] Exemplarily, in obtaining the initial image, image segmentation can be performed based on the portrait elements in the initial image, and the segmentation result obtained is a mask image, wherein the mask is a type of information used to mark the valid area in the image, usually composed of 0 and 1, wherein the area where the pixel corresponding to 0 is located is the invalid area, and the area where the pixel corresponding to 1 is located is the valid area. The process of image segmentation is achieved by "blocking" the image to be processed by the mask, which is mask calculation. In this embodiment, after identifying the target area of ​​the initial image (or the initial image as a whole), the portrait elements therein are masked and thus pixel-level segmentation of the above-mentioned portrait elements is achieved. The segmentation result obtained thereafter is a mask image with the portrait elements as the edge. The image size of the mask image can be the same as the image size of the initial image. In the valid area corresponding to the portrait element in the mask image, the pixel value of each pixel is the same as the pixel value of the pixel corresponding to the portrait element in the initial image; and in the invalid area of ​​the mask image that does not correspond to the portrait element, the pixel value of each pixel is 0 or empty.

[0068] In a possible implementation, the portrait element includes a hair element, and a specific implementation of step S202 includes: performing image segmentation on the hair element to obtain a corresponding first mask image.

[0069] Illustratively, in this embodiment, hair elements in the target area are first identified, and then image segmentation is performed with the hair elements as the target. A first mask image with the hair elements as the edges can be obtained. The first mask image is a segmentation map that represents the hair elements, that is, the hair texture of the person in the initial image.

[0070] Optionally, after obtaining the first mask image, the method further includes sharpening the first mask image to obtain a sharpened image. Since the hair strands in the first mask image representing the hair are of similar color, directly performing subsequent processing steps (adding filters or fusing with special effects images) on the first mask image may render the hair strands indistinguishable, visually blending them together, and affecting the visual texture of the hair. In this embodiment, by sharpening the first mask image, the contrast between pixels is increased, thereby highlighting the hair outlines, making the edges between hair strands clearer, and improving the visual texture of the hair.

[0071] It can be understood that the steps of this embodiment are optional steps. Therefore, in subsequent steps, the sharpened image obtained through the steps of this embodiment can be used to continue subsequent processing, or the first mask image can be directly used for subsequent processing, which can be set as needed.

[0072] Optionally, the portrait element further includes a skin element, and the specific implementation of step S202 further includes:

[0073] Step S2022: performing image segmentation on skin elements to obtain a corresponding second mask image.

[0074] For example, further to the image segmentation of the hair element, the skin element (portrait element) in the initial image can be segmented to obtain a second mask image representing the skin element, wherein the second mask image is obtained in a similar manner to the first mask image, that is, after first identifying the target area (or the entire initial image), the image area where the skin element is located is determined, and then image segmentation is performed with the skin element as the target, and a second mask image with the skin element as the edge is obtained using mask calculation. For example, the location of the hair element in the first mask image and the area where the skin element is located in the second mask image are consistent with the locations of the hair element and the skin element in the initial image. Figure 7 is a schematic diagram of an image segmentation of a portrait element provided by an embodiment of the present disclosure. As shown in Figure 7, after performing mask calculation on the hair element and the skin element in the initial image, the pixels corresponding to the hair element are segmented to obtain the first mask image; the pixels corresponding to the skin element are segmented to obtain the second mask image.

[0075] Of course, in other possible implementations, the hair element can be segmented separately to obtain a mask image for subsequent steps; or the skin element can be segmented separately to obtain a mask image for subsequent steps. That is, steps S2021 and S2022 can be performed separately to implement step S202, and will not be further described here.

[0076] Optionally, it also includes:

[0077] Step S203: adding an inversion filter to the mask image to obtain a corresponding filter image, where the inversion filter is at least used to invert the brightness of pixels in the mask image.

[0078] Exemplarily, after step S202, an inversion filter may be further added to the mask image obtained in step S202 to obtain a corresponding filter image. Adding an inversion filter at least includes performing an inversion calculation on the image to invert the brightness of the pixels in the mask image. Specifically, for example, the initial image is an RGB image. Each pixel in the mask image obtained by segmenting the initial image has three pixel values ​​(abbreviated as RGB values) corresponding to the red channel (R value), the green channel (G value), and the blue channel (B value). In one implementation, the grayscale value corresponding to the pixel is obtained by grayscale conversion of the RGB value. The grayscale value represents the brightness of the pixel. In another implementation, the RGB value is weighted averaged, and the corresponding brightness value representing the brightness is obtained based on the different weights of the R channel, the G channel, and the B channel. The specific weight of each channel can be set as needed and will not be repeated here. Afterwards, taking the case where the grayscale value represents the brightness as an example, the grayscale value is inverted. For example, if the grayscale value is: gray, the calculation method for inverting it is: 255-gray. The result obtained by performing the above-mentioned brightness (grayscale value) inverse calculation on each pixel in the mask image is the inverse calculation result. Afterwards, the inverse calculation result can be directly used as a filter image, or other filters can be further added to the inverse calculation result to obtain a filter image. Figure 8 is a schematic diagram of a process of adding an inverse filter provided by an embodiment of the present disclosure. As shown in Figure 8, first, based on the R value, G value, and B value of each pixel in the mask image, a gray value gray representing the brightness is obtained; then, the gray value gray is inversely calculated to obtain a filter image. Optionally, in the above process, a filter can be further added to the mask image before the grayscale calculation (shown as the left position in Figure 8), or a filter can be added to the obtained inverse image after the grayscale calculation and inversion (shown as the right position in Figure 8), thereby achieving further settings of the filter image. The specific implementation method of adding a filter to the image is a prior art and will not be repeated here.

[0079] Furthermore, in the above steps, when the mask image includes multiple, such as a first mask image and a second mask image, the same or different inverting filters can be used to process each mask image separately, thereby obtaining a filter image corresponding to each mask image, for example, obtaining a first filter image corresponding to the first mask image and obtaining a second filter image corresponding to the second mask image. The specific process will not be repeated here.

[0080] For example, as shown in FIG9 , the specific implementation of step S203 includes:

[0081] Step S2031: Obtain corresponding filter parameters according to the image content of the special effect image.

[0082] Step S2032: Based on the filter parameters, add an inversion filter to the mask image to obtain a corresponding filtered image.

[0083] For example, when applying an inversion filter to a mask image, to further improve the consistency between the resulting filtered image and the special effect image, filter parameters can be adjusted based on the image content of the special effect image, so that the hue and brightness of the resulting filtered image are consistent with those of the special effect image. For example, the special effect image content is "starry sky," and the special effect image has a dark background, so the overall brightness is relatively dark. Based on the aforementioned image content characteristics of the special effect image, when performing the inversion calculation on the mask image, a brightness offset, offset, is added to the normal inversion calculation. The inversion calculation method is: 255 - gray + offset; that is, the gray value gray is inverted and an offset is added. When the offset, offset, is less than zero, the brightness of the filtered image can be further reduced; when the offset, offset, is greater than zero, the brightness of the filtered image can be further increased. This ensures that the resulting filtered image matches the special effect image, reduces the sense of disconnection between the filtered image and the special effect image, and improves the visual effect of the resulting integrated image.

[0084] Among them, the above-mentioned offset is a possible implementation form of the filter parameters, which can be determined based on the average pixel brightness of the special effects image. It can be understood that the filter parameters can also include other possible implementation forms, such as determining the weight coefficient based on the average pixel brightness of the special effects image, and further adjusting the result of the inversion calculation of the mask image (255-gray) by the weight coefficient; at the same time, the filter parameters can also be adjustment parameters of the filter added to the inverted image or the mask image, which can be set as needed and will not be repeated here.

[0085] It should be noted that, in this embodiment, when the content of the special effects image is a starry sky image, by adding an inverting filter to the mask image, the brightness of the mask image is inverted, which can achieve the effect of highlighting the facial contour of the portrait against the background of the starry sky image. Combined with the subsequent second overlay strategy for the skin area, the face appears to be in a non-transparent state, while other skin areas appear to be in a certain transparent state, thereby achieving a prominent display of the facial elements of the character and improving the visual expressiveness of the image.

[0086] Step S204: Obtain the superposition strategy corresponding to each filter image.

[0087] Step S205: Based on the superposition strategy corresponding to each filter image, the filter images are superimposed on the special effect image to generate a fused image.

[0088] Exemplarily, after the above steps of this embodiment, a first filter image corresponding to the first mask image and a second filter image corresponding to the second mask image are obtained. Subsequently, the second filter image and the second filter image are processed based on different overlay strategies, so that the first filter image and the second filter image present different visual effects. Specifically, the first filter image generated based on the first mask image (a mask image containing hair elements) corresponds to the first overlay strategy, while the second filter image generated based on the second mask image (a mask image containing skin elements) corresponds to the second overlay strategy. Specifically, the first overlay strategy is used to overlay the image content in the hair region on the special effect image in a semi-transparent manner to obtain the first overlay image, while the second overlay strategy is used to overlay the image content in the skin region on the first overlay image in a non-transparent or semi-transparent manner to obtain the second overlay image. In one possible implementation, after obtaining the first overlay image corresponding to the hair elements using the first overlay strategy and the second overlay image corresponding to the skin elements using the second overlay strategy, the first overlay image and the second overlay image are spliced ​​together to obtain a fused image.

[0089] For example, as shown in FIG10 , the specific implementation of step S205 includes:

[0090] Step S2051: Based on a first superposition strategy, superimpose the first filter image on the special effect image to generate a first superimposed image, wherein the brightness of pixels in the first superimposed image is determined by the brightness of pixels at corresponding positions in the special effect image.

[0091] Step S2052: Based on the second superposition strategy, superimpose the second filter image on the special effect image to generate a second superimposed image, wherein the brightness of the pixels in the second superimposed image is determined by the brightness of the pixels at corresponding positions in the second mask image.

[0092] Step S2053: Generate a fused image based on the first superimposed image and the second superimposed image.

[0093] The specific implementation methods of the first overlay strategy and the second overlay strategy are respectively introduced in detail below. For example, the first overlay strategy is the overlay blending mode. In the overlay blending mode, the special effect image is the base image (also called the base color), the first filter image is the mixed image (also called the mixed color), and the first filter image is superimposed on the special effect image, and the resulting mixture is combined into the first overlay image (also called the fusion result). In the process of superimposing the first filter image on the special effect image, the pixels in the first filter image are pixel-fused with the pixels at the corresponding positions in the special effect image. The pixel fusion is, for example, calculating the weighted average between the pixel values. The brightness of the pixel in the fusion result is determined by the brightness value of the pixel at the corresponding position in the base image, and the brightness value of the pixel is obtained by weighted averaging the RGB values ​​of the pixel. The specific calculation method of the brightness value can be set based on specific needs. Specifically, the first overlay strategy can be expressed by formula (1):

[0094] Mix_1 is the fusion result based on the first overlay strategy, i.e., the pixel value of the pixel in the first overlay image. P1 is the brightness value (e.g., expressed as a grayscale value) of the pixel in the special effect image. P2 is the brightness value (e.g., expressed as a grayscale value) of the pixel in the first filter image. In this embodiment, the first filter image corresponding to the hair element is fused using the first overlay strategy described above. This allows high-brightness image elements in the special effect image (i.e., the background portion of the fused image), such as stars and lights in the sky, to be fully displayed, achieving the visual effect of "seeing through" the hair texture in the first filter image. Low-brightness image elements in the special effect image are evenly blended with the hair texture in the first filter image, preserving the contour shape of the hair texture. This achieves the technical effect of semi-transparently overlaying the image content in the hair region on the special effect image, allowing the fused image to simultaneously display both the image content in the target region and the image content in the special effect image.

[0095] Exemplarily, the second overlay strategy is a common blending mode based on brightness weight. Based on this common blending mode, in the process of superimposing the second filter image onto the special effect image, the pixels in the second filter image and the pixels at corresponding positions in the special effect image are weightedly fused based on the brightness of the pixels in the second filter image.

[0096] Exemplarily, the specific implementation of step S2052 includes:

[0097] Step S2052A: Obtain the grayscale value of each pixel in the second filtered image.

[0098] Step S2052B: Using the grayscale value as a weight, the pixels in the second filter image and the pixels at corresponding positions in the special effect image are fused to generate a second superimposed image.

[0099] For example, by performing a weighted average calculation on the pixel values ​​(RGB values) of each pixel in the second filter image, a grayscale value representing the brightness corresponding to the pixel can be obtained. Then, the grayscale value of the pixel in the second filter image is used as a weight to fuse the pixel in the second filter image with the pixel at the corresponding position in the special effect image to generate a second superimposed image. Specifically, the second superposition strategy can be expressed by formula (2): Mix_2=mix(P_3,P_1,gray) (2)

[0100] Mix_2 is the fusion result based on the second overlay strategy, that is, the pixel value of the pixel in the second overlay image. Mix() is the function that calculates pixel fusion. P_1 is the pixel value of the pixel in the special effect image; P_3 is the pixel value of the pixel in the second filtered image. Gray is the grayscale value of the pixel in the second filtered image. For example, gray = (P3_R + P3_G + P3_B) / 3, that is, the grayscale value of the pixel in the second filtered image is the average of the pixel's R, G, and B channel values. Afterwards, P_3 and P_1 are fused based on the grayscale value, wherein the smaller the gray (brightness), the more prominent the image content (skin elements) in the second superimposed image after fusion, that is, the lower the transparency; conversely, the larger the gray, the less prominent the image content (skin elements) in the second superimposed image after fusion, that is, the higher the transparency. Specifically, for example, the implementation method of mix(P_3, P_1, gray) is: mix(P_3, P_1, gray) = P_3 + P_1 × gray.

[0101] Afterwards, based on the positional relationship between the hair elements and the skin elements in the initial image, the first superimposed image and the second superimposed image are deduplicated and spliced ​​to obtain a fused image.

[0102] In the steps of this embodiment, the second filter image corresponding to the skin element is fused using the aforementioned second overlay strategy. This allows for masking of the special effects image (i.e., the background portion of the fused image) based on the brightness of the skin element. Since the second filter image is the result of applying an inverting filter to the second mask image representing the skin element, its brightness is exactly the opposite of that of the second mask image. Specifically, in terms of visual effects, the facial skin in the facial region of the skin element has a higher brightness, while the corresponding second filter image has a lower brightness. Therefore, the blended fused image has low transparency, and the background portion of the special effects image is almost completely obscured, thereby achieving the technical effect of highlighting the facial contours and restoring the facial expressions of the subject. Conversely, the facial skin in the neck region of the skin element has a lower brightness, while the corresponding second filter image has a higher brightness. Therefore, the blended fused image still has a certain degree of transparency, i.e., is semi-transparent, allowing the background content (i.e., the image content in the special effects image) to partially show through. This achieves visual fusion of the neck skin element and the special effects image, further enhancing the fusion effect of the subject and background in the fused image.

[0103] Furthermore, since the grayscale values ​​between each pixel in the second filtered image vary continuously, the transparency of the skin elements (including facial skin and neck skin, etc.) corresponding to the second filtered image in the second overlay image and the final fused image obtained based on the method of this embodiment also varies continuously. FIG11 is a schematic diagram of a second overlay image provided by an embodiment of the present disclosure. As shown in FIG11 , the special effect image includes target elements P1, P2, and P3 (shown as P1, P2, and P3 in the figure). After the second filtered image is fused with the special effect image (or the first overlay image), based on the grayscale values ​​(brightness) between each pixel in the second filtered image, the transparency of the target elements P1, P2, and P3 in the second overlay image varies continuously within the skin area corresponding to the person's skin. For example, the transparency of target element P1 is 80%, the transparency of target element P1 is 50%, and the transparency of target element P1 is 0%. This achieves a more natural fusion effect between the person and the background, avoids obvious segmentation boundaries, and improves the visual effect of the generated fused image.

[0104] Of course, it will be understood that the first and second filtered images in the above embodiment are obtained based on the first and second mask images. Therefore, in other implementations, the above steps can be performed directly on the first and second mask images to obtain a fused image. That is, the step of adding the inversion filter can be omitted. The specific implementation is similar, and this scenario will not be further described here.

[0105] Corresponding to the special effect image generation method of the above embodiment, FIG12 is a structural block diagram of the special effect image generation device provided by the embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown. Referring to FIG12, the special effect image generation device 3 includes:

[0106] An acquisition module 31 is used to acquire an initial image, where the initial image includes a target area;

[0107] The generating module 32 is configured to fuse the target area of ​​the initial image with the special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the image content of the target area and the image content of the special effect image are simultaneously displayed in the sub-area.

[0108] In one embodiment of the present disclosure, the target area includes at least a hair area, and the generation module 32 is specifically configured to: superimpose the image content in the hair area on the special effect image in a semi-transparent manner to obtain a first superimposed image; and obtain a fused image based on the first superimposed image.

[0109] In one embodiment of the present disclosure, the target area also includes at least a skin area. When the generation module 32 obtains the fused image based on the first superimposed image, it is specifically used to: superimpose the image content in the skin area on the first superimposed image in a non-transparent or semi-transparent manner to obtain a second superimposed image; and obtain the fused image based on the second superimposed image.

[0110] In one embodiment of the present disclosure, the generation module 32 is further configured to: obtain texture information corresponding to the hair region, where the texture information represents the texture direction of the hair in the hair region; and move the target element in the fused image based on the texture information so that the target element is arranged or moved along the texture direction of the hair.

[0111] In one embodiment of the present disclosure, after acquiring the initial image, the generation module 32 is further used to: perform image segmentation on at least one portrait element in the target area to obtain at least two mask images with the portrait element as the edge; when the generation module 32 fuses the target area of ​​the initial image with the special effect image to generate a fused image, it is specifically used to: superimpose the mask image onto the special effect image based on the overlay strategy corresponding to the mask image to generate a fused image.

[0112] In one embodiment of the present disclosure, the portrait element includes a hair element; when the generation module 32 performs image segmentation on at least one portrait element in the target area to obtain a mask image with the portrait element as the edge, the generation module 32 is specifically used to: perform image segmentation on the hair element to obtain a corresponding first mask image; when the generation module 32 superimposes the mask image on the special effect image based on an overlay strategy corresponding to the mask image to generate a fused image, the generation module 32 is specifically used to: superimpose the first mask image on the special effect image based on the first overlay strategy to generate a first overlay image, wherein the brightness of the pixel points in the first overlay image is determined by the brightness of the pixel points at the corresponding position in the special effect image; and generate a fused image based on the first overlay image.

[0113] In one embodiment of the present disclosure, after performing image segmentation on the hair element to obtain the corresponding first mask image, the generation module 32 is further used to: sharpen the first mask image to obtain a sharpened image; when the generation module 32 superimposes the first mask image on the special effect image based on the first superposition strategy to generate the first superimposed image, the generation module 32 is specifically used to: superimpose the sharpened image on the special effect image based on the first superposition strategy to generate the first superimposed image.

[0114] In one embodiment of the present disclosure, the portrait elements include skin elements; when the generation module 32 performs image segmentation on at least one portrait element in the target area to obtain a mask image with the portrait element as the edge, the generation module 32 is specifically used to: perform image segmentation on the skin element to obtain a corresponding second mask image; when the generation module 32 superimposes the mask image on the special effect image based on an overlay strategy corresponding to the mask image to generate a fused image, the generation module 32 is specifically used to: superimpose the second mask image on the special effect image based on the second overlay strategy to generate a second overlay image, wherein the brightness of the pixel points in the second overlay image is determined by the brightness of the pixel points at the corresponding position in the second mask image; and generate a fused image based on the second overlay image.

[0115] In one embodiment of the present disclosure, when the generation module 32 superimposes the second mask image onto the special effect image based on the second superposition strategy to generate the second superimposed image, it is specifically used to: obtain the grayscale value of each pixel in the second mask image; use the grayscale value as the weight, fuse the pixel points in the second mask image and the pixel points at the corresponding position in the special effect image to generate the second superimposed image.

[0116] In one embodiment of the present disclosure, the generation module 32 is further used to: add an inverting filter to the mask image to obtain a corresponding filter image, and the inverting filter is at least used to invert the brightness of the pixels in the mask image; when the generation module 32 superimposes the mask image on the special effect image to generate a fused image, it is specifically used to: superimpose at least one filter image on the special effect image to generate a fused image.

[0117] In one embodiment of the present disclosure, when the generation module 32 adds an inverting filter to the mask image to obtain a corresponding filter image, it is specifically used to: obtain corresponding filter parameters according to the image content of the special effect image; and add an inverting filter to the mask image based on the filter parameters to obtain a corresponding filter image.

[0118] In one embodiment of the present disclosure, after the target area of ​​the initial image is fused with the special effect image to generate a fused image, the generation module 32 is further used to: add a dynamic special effect to the second target area in the fused image to obtain a dynamic special effect image, wherein the special effect type of the dynamic special effect is determined by the image content of the special effect image.

[0119] The acquisition module 31 is connected to the generation module 32. The special effect image generation device 3 provided in this embodiment can implement the technical solution of the above method embodiment, and its implementation principle and technical effect are similar, which will not be described in detail in this embodiment.

[0120] FIG13 is a schematic structural diagram of an electronic device provided by an embodiment of the present disclosure. As shown in FIG13 , the electronic device 4 includes:

[0121] A processor 41, and a memory 42 communicatively connected to the processor 41;

[0122] Memory 42 stores computer-executable instructions;

[0123] The processor 41 executes the computer-executable instructions stored in the memory 42 to implement the special effect image generation method in the embodiments shown in FIG. 2 to FIG. 11 .

[0124] Optionally, the processor 41 and the memory 42 are connected via a bus 43 .

[0125] The relevant explanations can be understood by referring to the relevant descriptions and effects corresponding to the steps in the embodiments corresponding to Figures 2 to 11, and no further details will be given here.

[0126] An embodiment of the present disclosure provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement the special effect image generation method provided in any of the embodiments corresponding to Figures 2 to 11 of the present disclosure.

[0127] An embodiment of the present disclosure provides a non-transient computer program product, including a computer program. When the computer program is executed by a processor, the special effect image generation method in the embodiments shown in Figures 2 to 11 is implemented.

[0128] An embodiment of the present disclosure provides a computer program, which, when executed by a processor, implements the special effect image generation method in the embodiments shown in Figures 2 to 11.

[0129] Referring to FIG14 , there is shown a schematic diagram of the structure of an electronic device 900 suitable for implementing an embodiment of the present disclosure. The electronic device 900 may be a terminal device or a server. The terminal device may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle-mounted terminals (e.g., vehicle-mounted navigation terminals), and fixed terminals such as digital TVs and desktop computers. The electronic device shown in FIG14 is merely an example and should not limit the functionality and scope of use of the embodiments of the present disclosure.

[0130] As shown in FIG14 , the electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. Various programs and data required for the operation of the electronic device 900 are also stored in the RAM 903. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0131] Typically, the following devices can be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 908 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 can allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Although FIG14 shows an electronic device 900 with various devices, it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.

[0132] 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 computer-readable medium, and the computer program includes 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 via the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.

[0133] 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.

[0134] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0135] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.

[0136] 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 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 a 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., via the Internet using an Internet Service Provider).

[0137] 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.

[0138] 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."

[0139] 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.

[0140] 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.

[0141] In a first aspect, according to one or more embodiments of the present disclosure, a method for generating a special effect image is provided, comprising:

[0142] Acquire an initial image, wherein the initial image includes a target area; fuse the target area of ​​the initial image with a special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the image content of the target area and the image content of the special effect image are simultaneously displayed in the sub-area.

[0143] According to one or more embodiments of the present disclosure, the target area includes at least a hair area, and fusing the target area of ​​the initial image with the special effect image to generate a fused image includes: superimposing image content within the hair area on the special effect image in a semi-transparent manner to obtain a first superimposed image; and obtaining the fused image based on the first superimposed image.

[0144] According to one or more embodiments of the present disclosure, the target area also includes at least a skin area, and obtaining the fused image based on the first superimposed image includes: superimposing the image content in the skin area on the first superimposed image in a non-transparent or semi-transparent manner to obtain a second superimposed image; and obtaining the fused image based on the second superimposed image.

[0145] According to one or more embodiments of the present disclosure, the method further includes: obtaining texture information corresponding to the hair region, the texture information representing the texture direction of the hair in the hair region; and moving the target element in the fused image based on the texture information so that the target element is arranged or moved along the texture direction of the hair.

[0146] According to one or more embodiments of the present disclosure, after acquiring the initial image, it also includes: performing image segmentation on at least one portrait element in the target area to obtain at least two mask images with the portrait element as the edge; fusing the target area of ​​the initial image with the special effect image to generate a fused image, including: based on an overlay strategy corresponding to the mask image, superimposing the mask image on the special effect image to generate the fused image.

[0147] According to one or more embodiments of the present disclosure, the portrait element includes a hair element; performing image segmentation on at least one portrait element in the target area to obtain a mask image with the portrait element as an edge includes: performing image segmentation on the hair element to obtain a corresponding first mask image; superimposing the mask image on the special effect image based on an overlay strategy corresponding to the mask image to generate the fused image includes: superimposing the first mask image on the special effect image based on a first overlay strategy to generate a first overlay image, wherein the brightness of pixels in the first overlay image is determined by the brightness of pixels at corresponding positions in the special effect image; and generating the fused image based on the first overlay image.

[0148] According to one or more embodiments of the present disclosure, after performing image segmentation on the hair element to obtain the corresponding first mask image, the method further includes: performing sharpening processing on the first mask image to obtain a sharpened image; and superimposing the first mask image on the special effect image based on a first superposition strategy to generate a first superimposed image, including: superimposing the sharpened image on the special effect image based on the first superposition strategy to generate the first superimposed image.

[0149] According to one or more embodiments of the present disclosure, the portrait elements include skin elements; the image segmentation is performed on at least one portrait element in the target area to obtain a mask image with the portrait element as the edge, including: image segmentation is performed on the skin element to obtain a corresponding second mask image; based on the overlay strategy corresponding to the mask image, the mask image is superimposed on the special effect image to generate the fused image, including: based on the second overlay strategy, the second mask image is superimposed on the special effect image to generate a second overlay image, wherein the brightness of the pixel points in the second overlay image is determined by the brightness of the pixel points at the corresponding position in the second mask image; based on the second overlay image, the fused image is generated.

[0150] According to one or more embodiments of the present disclosure, the second mask image is superimposed on the special effect image based on the second overlay strategy to generate the second overlay image, including: obtaining the grayscale value of each pixel in the second mask image; using the grayscale value as the weight, fusing the pixel points in the second mask image and the pixel points at corresponding positions in the special effect image to generate the second overlay image.

[0151] According to one or more embodiments of the present disclosure, the method further includes: adding an inverting filter to the mask image to obtain a corresponding filter image, wherein the inverting filter is at least used to invert the brightness of pixels in the mask image; superimposing the mask image on the special effect image to generate the fused image includes: superimposing at least one of the filter images on the special effect image to generate the fused image.

[0152] According to one or more embodiments of the present disclosure, adding an inverting filter to the mask image to obtain a corresponding filtered image includes: obtaining corresponding filter parameters based on the image content of the special effects image; and adding an inverting filter to the mask image based on the filter parameters to obtain the corresponding filtered image.

[0153] According to one or more embodiments of the present disclosure, after fusing the target area of ​​the initial image with the special effect image to generate a fused image, the method further includes: adding a dynamic special effect to a second target area in the fused image to obtain a dynamic special effect image, wherein the special effect type of the dynamic special effect is determined by the image content of the special effect image.

[0154] In a second aspect, according to one or more embodiments of the present disclosure, a special effect image generating device is provided, comprising:

[0155] An acquisition module, configured to acquire an initial image, wherein the initial image includes a target area;

[0156] A generation module is used to fuse the target area of ​​the initial image with the special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the image content of the target area and the image content of the special effect image are simultaneously displayed in the sub-area.

[0157] According to one or more embodiments of the present disclosure, the target area includes at least a hair area, and the generation module is specifically configured to: superimpose the image content in the hair area on the special effect image in a semi-transparent manner to obtain a first superimposed image; and obtain the fused image based on the first superimposed image.

[0158] According to one or more embodiments of the present disclosure, the target area also includes at least a skin area. When the generation module obtains the fused image based on the first overlay image, it is specifically used to: superimpose the image content in the skin area on the first overlay image in a non-transparent or semi-transparent manner to obtain a second overlay image; and obtain the fused image based on the second overlay image.

[0159] According to one or more embodiments of the present disclosure, the generation module is further configured to: obtain texture information corresponding to the hair region, where the texture information represents a texture direction of hair strands within the hair region; and move a target element in the fused image based on the texture information so that the target element is arranged or moved along the texture direction of the hair strands.

[0160] According to one or more embodiments of the present disclosure, after acquiring the initial image, the generation module is further used to: perform image segmentation on at least one portrait element in the target area to obtain at least two mask images with the portrait element as the edge; when the generation module 32 fuses the target area of ​​the initial image with the special effect image to generate a fused image, it is specifically used to: based on the overlay strategy corresponding to the mask image, superimpose the mask image onto the special effect image to generate the fused image.

[0161] According to one or more embodiments of the present disclosure, the portrait element includes a hair element; when the generation module performs image segmentation on at least one portrait element in the target area to obtain a mask image with the portrait element as an edge, the generation module is specifically configured to: perform image segmentation on the hair element to obtain a corresponding first mask image; when the generation module superimposes the mask image on the special effect image based on an overlay strategy corresponding to the mask image to generate the fused image, the generation module is specifically configured to: superimpose the first mask image on the special effect image based on the first overlay strategy to generate a first overlay image, wherein the brightness of the pixels in the first overlay image is determined by the brightness of the pixels at corresponding positions in the special effect image; and generate the fused image based on the first overlay image.

[0162] According to one or more embodiments of the present disclosure, after performing image segmentation on the hair element to obtain the corresponding first mask image, the generation module is further configured to: perform sharpening processing on the first mask image to obtain a sharpened image; and when superimposing the first mask image onto the special effect image based on a first superposition strategy to generate the first superimposed image, the generation module is specifically configured to: superimpose the sharpened image onto the special effect image based on the first superposition strategy to generate the first superimposed image.

[0163] According to one or more embodiments of the present disclosure, the portrait elements include skin elements; when the generation module performs image segmentation on at least one portrait element in the target area to obtain a mask image with the portrait element as the edge, the generation module is specifically used to: perform image segmentation on the skin element to obtain a corresponding second mask image; when the generation module superimposes the mask image on the special effect image based on an overlay strategy corresponding to the mask image to generate the fused image, the generation module is specifically used to: superimpose the second mask image on the special effect image based on a second overlay strategy to generate a second overlay image, wherein the brightness of the pixel points in the second overlay image is determined by the brightness of the pixel points at the corresponding position in the second mask image; and generate the fused image based on the second overlay image.

[0164] According to one or more embodiments of the present disclosure, when the generation module superimposes the second mask image onto the special effect image based on the second overlay strategy to generate the second overlay image, the generation module is specifically used to: obtain the grayscale value of each pixel in the second mask image; use the grayscale value as the weight, fuse the pixel points in the second mask image and the pixel points at the corresponding position in the special effect image to generate the second overlay image.

[0165] According to one or more embodiments of the present disclosure, the generation module is further used to: add an inverting filter to the mask image to obtain a corresponding filter image, and the inverting filter is at least used to invert the brightness of the pixels in the mask image; when the generation module superimposes the mask image on the special effect image to generate the fused image, the generation module is specifically used to: superimpose at least one of the filter images on the special effect image to generate the fused image.

[0166] According to one or more embodiments of the present disclosure, when the generation module adds an inverting filter to the mask image to obtain a corresponding filter image, it is specifically used to: obtain corresponding filter parameters based on the image content of the special effect image; and add an inverting filter to the mask image based on the filter parameters to obtain the corresponding filter image.

[0167] According to one or more embodiments of the present disclosure, after the target area of ​​the initial image is fused with the special effect image to generate a fused image, the generation module is further used to: add a dynamic special effect to the second target area in the fused image to obtain a dynamic special effect image, wherein the special effect type of the dynamic special effect is determined by the image content of the special effect image.

[0168] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: a processor, and a memory communicatively connected to the processor;

[0169] The memory stores computer-executable instructions;

[0170] The processor executes the computer-executable instructions stored in the memory to implement the special effect image generation method described in the first aspect and various possible designs of the first aspect.

[0171] In a fourth aspect, according to one or more embodiments of the present disclosure, a non-volatile computer-readable storage medium is provided, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the special effect image generation method described in the first aspect and various possible designs of the first aspect is implemented.

[0172] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the special effect image generation method described in the first aspect and various possible designs of the first aspect.

[0173] In a sixth aspect, an embodiment of the present disclosure provides a computer program, which, when executed by a processor, implements the special effect image generation method described in the first aspect and various possible designs of the first aspect.

[0174] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. 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 the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.

[0175] 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.

[0176] 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. A method for generating a special effect image, comprising: Acquire an initial image, wherein the initial image includes a target area; The target area of ​​the initial image is fused with the special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the image content of the target area and the image content of the special effect image are simultaneously displayed in the sub-area.

2. The method according to claim 1, wherein: The target area at least includes a hair area, and fusing the target area of ​​the initial image with the special effect image to generate a fused image includes: superimposing the image content in the hair area on the special effect image in a semi-transparent manner to obtain a first superimposed image; The fused image is obtained based on the first superimposed image.

3. The method according to claim 2, wherein: The target area at least includes a skin area, and obtaining the fused image based on the first superimposed image includes: superimposing the image content in the skin area on the first superimposed image in a non-transparent or semi-transparent manner to obtain a second superimposed image; The fused image is obtained based on the second superimposed image.

4. The method according to claim 2, wherein: The method further comprises: Acquire texture information corresponding to the hair region, where the texture information represents a texture direction of hair in the hair region; Based on the texture information, the target element in the fused image is moved so that the target element is arranged or moved along the texture direction of the hair.

5. The method according to claim 1, wherein: After acquiring the initial image, also include: Performing image segmentation on at least one portrait element in the target area to obtain at least two mask images with the portrait element as edges; The step of fusing the target area of ​​the initial image with the special effect image to generate a fused image includes: Based on a superposition strategy corresponding to the mask image, the mask image is superimposed on the special effect image to generate the fused image.

6. The method according to claim 5, wherein: The portrait element includes a hair element; The image segmentation is performed on at least one portrait element in the target area to obtain a The mask image of the edge, including: Performing image segmentation on the hair element to obtain a corresponding first mask image; The step of superimposing the mask image onto the special effect image based on a superposition strategy corresponding to the mask image to generate the fused image includes: Based on a first superposition strategy, superimposing the first mask image onto the special effect image to generate a first superimposed image, wherein the brightness of a pixel in the first superimposed image is determined by the brightness of a pixel at a corresponding position in the special effect image; The fused image is generated based on the first superimposed image.

7. The method according to claim 6, wherein: After performing image segmentation on the hair element to obtain a corresponding first mask image, the method further includes: Performing a sharpening process on the first mask image to obtain a sharpened image; The step of superimposing the first mask image onto the special effect image based on the first superposition strategy to generate a first superimposed image includes: Based on a first superposition strategy, the sharpened image is superimposed on the special effect image to generate a first superimposed image.

8. The method according to claim 5, wherein: The portrait element includes a skin element; and performing image segmentation on at least one portrait element in the target area to obtain a mask image with the portrait element as an edge includes: Performing image segmentation on the skin element to obtain a corresponding second mask image; The step of superimposing the mask image onto the special effect image based on a superposition strategy corresponding to the mask image to generate the fused image includes: Based on a second superposition strategy, superimposing the second mask image onto the special effect image to generate a second superimposed image, wherein the brightness of a pixel in the second superimposed image is determined by the brightness of a pixel at a corresponding position in the second mask image; The fused image is generated based on the second superimposed image.

9. The method according to claim 8, wherein: The step of superimposing the second mask image onto the special effect image based on the second superposition strategy to generate a second superimposed image includes: Obtaining the grayscale value of each pixel in the second mask image; The pixel points in the second mask image and the pixel points at corresponding positions in the special effect image are fused with the grayscale value as a weight to generate the second superimposed image.

10. The method according to claim 5, wherein: The method further comprises: Adding an inversion filter to the mask image to obtain a corresponding filter image, wherein the inversion filter is at least used to invert the brightness of pixels in the mask image; The step of superimposing the mask image onto the special effect image to generate the fused image includes: At least one of the filter images is superimposed on the special effect image to generate the fused image.

11. The method according to claim 10, wherein: The adding an inversion filter to the mask image to obtain a corresponding filter image includes: Obtaining corresponding filter parameters according to the image content of the special effect image; Based on the filter parameters, an inversion filter is added to the mask image to obtain the corresponding filter image.

12. The method according to claim 1, wherein: After fusing the target area of ​​the initial image with the special effect image to generate a fused image, the method further includes: A dynamic special effect is added to the second target area in the fused image to obtain a dynamic special effect image, wherein the special effect type of the dynamic special effect is determined by the image content of the special effect image.

13. A special effect image generating device, comprising: An acquisition module, used for acquiring an initial image, wherein the initial image includes a target area; A generation module is used to fuse the target area of ​​the initial image with the special effect image to generate a fused image, wherein the fused image includes at least one sub-area, and the image content of the target area and the image content of the special effect image are simultaneously displayed in the sub-area.

14. An electronic device comprising: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the special effect image generation method according to any one of claims 1 to 12.

15. A non-transitory computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the special effect image generation method according to any one of claims 1 to 12 is implemented.

16. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for generating special effect images according to any one of claims 1 to 12 is implemented.

17. A computer program, which, when executed by a processor, implements the special effect image generating method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Method and device for processing image

    CN110458781A

  • Image processing method and device, electronic equipment and scale storage medium

    CN113034354A

  • Image processing method and device, computer equipment and storage medium

    CN115293994A

  • Special effect image generation method and device, electronic equipment and storage medium

    CN116452412A

  • Image generating device, image processing method, and program

    JP2011203835A

Cited By

  • Polyester filament broken filament detection method and system based on image processing technology

    CN119887620A