Method, device, equipment and readable storage medium for generating special effects of video images
By obtaining the target video and preset replacement sequence frames, determining the pixel coordinate offset, and performing expansion and feathering processing, the problem of low efficiency in image generation of glitch special effects is solved, and efficient and diverse glitch special effects generation is achieved.
Patent Information
- Application Number
- CN202310431119.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-20
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-04-20
AI Technical Summary
In the existing technology, the efficiency of generating glitch special effects in images is low and requires a lot of manual design, which results in high time consumption.
By obtaining the target video and the preset replacement sequence frames, the pixel coordinate offset under each set of replacement sequence frames is determined, and expansion processing and feathering edge processing are performed to generate an image with burr effects.
It improves the efficiency of image generation glitch effects, meets the diverse needs of users, and enriches effect materials.
Smart Images

Figure CN117726722B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, electronic device and computer-readable storage medium for generating special effects for video images. Background Art
[0002] Under the tide of the Internet, when people share pictures or videos on some social platforms, the demand for displaying the image content in the pictures or videos is becoming more and more personalized. Sometimes, in order to meet people's needs, the image content is generally controlled to present certain special effects, such as image glitch effects.
[0003] The existing glitch effects generally need to be designed manually. However, since different glitch effects correspond to different requirements, it will undoubtedly take a lot of time to achieve the glitch effects of the image only by manual methods, resulting in low efficiency in generating glitch effects for the image. Summary of the invention
[0004] The embodiments of the present application provide a method, device, electronic device and computer-readable storage medium for generating special effects for a video image, which can improve the efficiency of generating burr special effects for an image.
[0005] In a first aspect, an embodiment of the present application provides a method for generating special effects of a video image, the method comprising:
[0006] Acquire a target video, wherein the image frame of the target video contains a target image to be processed with burr special effects;
[0007] Acquire at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value;
[0008] In the arrangement order of the image frames of the target video, one offset replacement picture in each group of replacement sequence frames corresponds to one image frame in the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames is determined;
[0009] Performing at least two dilation processes on the target image in the image frame, determining an edge path corresponding to the target image after each dilation process, and performing feathering edge processing on at least two edge paths corresponding to the target image to obtain the target image after the feathering edge processing;
[0010] Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing and the coordinate offset of each pixel point of the above image frame under each group of replacement sequence frames, a target image with burr special effects is generated in the above image frame.
[0011] In a second aspect, an embodiment of the present application further provides a special effects generating device for a video image, the device comprising:
[0012] A video acquisition module, used for acquiring a target video, wherein the image frame of the target video contains a target image to be processed with burr special effects;
[0013] A sequence frame acquisition module, used to acquire at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value;
[0014] An offset determination module is used to correspond one offset replacement picture in each group of replacement sequence frames to one image frame in the target video in the arrangement order of the image frames of the target video, and determine the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame;
[0015] a dilation processing module, configured to perform at least two dilation processes on the target image in the image frame, determine an edge path corresponding to the target image after each dilation process, and perform feathering process on at least two edge paths corresponding to the target image to obtain the target image after the feathering process;
[0016] The burr generation module is used to generate a target image with burr special effects in the above image frame based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing and the coordinate offset of each pixel point of the above image frame under each group of replacement sequence frames.
[0017] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing a plurality of instructions; the processor loads instructions from the memory to execute the steps in any one of the special effects generation methods for video images provided in the embodiments of the present application.
[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, wherein the instructions are suitable for a processor to load to execute the steps in any one of the special effects generation methods for video images provided in the embodiments of the present application.
[0019] In the embodiment of the present application, a target video is obtained, wherein the image frame of the target video contains a target image to be processed with burr special effects; at least one preset group of replacement sequence frames is obtained, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value; in the arrangement order of the image frames of the target video, one frame of the offset replacement picture in each group of replacement sequence frames corresponds to one image frame in the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames is determined; The target image in the above-mentioned image frame is subjected to at least two dilation processes, the edge path corresponding to the above-mentioned target image after each dilation process is determined, and at least two edge paths corresponding to the above-mentioned target image are subjected to feathering edge processing to obtain the target image after the feathering edge processing; based on the transparency of each pixel point on the edge area corresponding to the target image after the feathering edge processing, and the coordinate offset of each pixel point of the above-mentioned image frame under each group of permutation sequence frames, a target image with a burr special effect is generated in the above-mentioned image frame, so that the burr special effect is generated by determining the parameters required for the image to generate the burr special effect, so as to improve the efficiency of the image to generate the burr special effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 It is a flowchart of a method for generating special effects of a video image provided by an embodiment of the present application;
[0022] Figure 2a Schematic diagram of the cropping method of the offset replacement image provided in the embodiment of the present application;
[0023] Figure 2b is a schematic diagram of the cropping range of the offset replacement image provided in the embodiment of the present application;
[0024] Figure 3a It is a schematic diagram of the first layer burr effect provided in the embodiment of the present application;
[0025] Figure 3b is a schematic diagram of the second layer burr effect provided in an embodiment of the present application;
[0026] Figure 4 is a curve diagram of a method for generating special effects of a video image provided in an embodiment of the present application;
[0027] Figure 5a is a schematic diagram of the edge path of a target image provided in an embodiment of the present application;
[0028] Figure 5b is a schematic diagram of a burr effect of a target image provided in an embodiment of the present application;
[0029] Figure 6 is a schematic diagram of a target image after feathering edge processing provided in an embodiment of the present application;
[0030] Figure 7 is another schematic diagram of burr effect of a target image provided by an embodiment of the present application;
[0031] Figure 8 It is a structural schematic diagram of a special effects generating device for a video image provided in an embodiment of the present application;
[0032] Fig. 9 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0034] Before explaining the embodiments of the present application in detail, some terms involved in the embodiments of the present application are first explained.
[0035] Among them, in the description of the embodiments of the present application, the terms "first", "second", etc. may be used in this article to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0036] The embodiments of the present application provide a method, device, electronic device and computer-readable storage medium for generating special effects of video images. Specifically, the method for generating special effects of video images of the embodiments of the present application can be performed by an electronic device, wherein the electronic device can be a terminal or a server. The terminal can be a terminal device such as a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA), etc. The terminal can also include a client, which can be a game application client, a browser client carrying a game program, or an instant messaging client, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0037] For example, the electronic device is described by taking a terminal as an example, and the terminal can obtain a target video, wherein the image frame of the target video includes a target image that needs to be processed with burr special effects; obtain at least one preset group of replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value; according to the arrangement order of the image frames of the target video, a frame of offset replacement pictures in each group of replacement sequence frames corresponds to an image frame in the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames is determined; the target image in the image frame is expanded at least twice, the edge path corresponding to the target image after each expansion process is determined, and the at least two edge paths corresponding to the target image are feathered to obtain the target image after the feathered edge process; based on the transparency of each pixel point on the edge area corresponding to the target image after the feathered edge process, and the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames, a target image with burr special effects is generated in the image frame.
[0038] Based on the above problems, the embodiments of the present application provide a method, device, electronic device and computer-readable storage medium for generating special effects for video images, which can improve the efficiency of generating burr special effects for images.
[0039] The following is a detailed description of the embodiments in conjunction with the accompanying drawings. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.
[0040] In this embodiment, a terminal is taken as an example for description. This embodiment provides a method for generating special effects of a video image, such as Figure 1 As shown, the specific process of the special effects generation method of the video image can be as follows:
[0041] 101. Obtain a target video, wherein the image frames of the target video include a target image that needs to be processed with burr special effects.
[0042] Among them, the above-mentioned target video is the video that needs to be processed currently, that is, the image content of each frame in the video needs to be processed with special effects, such as glitch effects, so that the image content in the image frame after special effects processing has glitch effects. Accordingly, the above-mentioned image content that needs to be processed with glitch effects is the above-mentioned target image, for example, people and animals in the image frame.
[0043] In some embodiments, the terminal can copy the original video by texture copying to obtain the target video, wherein the terminal can use the video texture of the original video as the object to be copied to obtain the target video, and each image frame in the target video is copied from each image frame in the original video.
[0044] 102. Obtain at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value.
[0045] In this embodiment, since in the replacement sequence frame, each pixel point on an offset replacement picture corresponds to an offset replacement value, the offset replacement value can be used to offset the pixels in the image to add a layer of distortion replacement to the image, so that the image presents a burr special effect. Therefore, the terminal can pre-set at least one group of replacement sequence frames so that each image frame of the target video can be processed by each group of replacement sequence frames, that is, an offset replacement picture is used to provide a replacement offset value to a pixel point on an image frame in the target video. In order to make different image frames in the target video present different burr effects so that the burr special effect of the target video changes more vividly, the images of different offset replacement pictures in the replacement sequence frames are different, and the images of each group of replacement sequence frames are also different. Different offset replacement pictures in the replacement sequence frames can be set based on user needs. For example, if the burr special effect of the target video is to be presented with a gradual effect, the replacement offset values corresponding to the pixels at the same position of adjacent offset replacement pictures can be made to differ by a preset value so that the change of the pixels of the image frame presents a gradual effect.
[0046] In some embodiments, the pixel value of a pixel point of an offset replacement image may be used to store relevant information associated with the pixel point. For example, the replacement offset value corresponding to the pixel point may be stored through a color channel of the pixel value that constitutes the pixel point.
[0047] 103. According to the arrangement order of the image frames of the target video, one offset replacement picture in each group of replacement sequence frames corresponds to one image frame in the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames is determined.
[0048] The arrangement order of the image frames of the target video is the play order of the image frames in the target video, for example, the first played image frame is ranked first.
[0049] Among them, the terminal can correspond one offset replacement picture in each group of replacement sequence frames to an image frame in the target video, and in order to make the burr special effects between different image frames of the target video more vivid, the offset replacement pictures corresponding to two adjacent image frames are different.
[0050] For example, the terminal can make one-to-one correspondences according to the arrangement order of the offset replacement pictures in the replacement sequence frames and the arrangement order of the image frames of the target video. For example, the offset replacement picture ranked first in the replacement sequence frames corresponds to the image frame ranked first in the target video; the offset replacement picture ranked second in the replacement sequence frames corresponds to the image frame ranked second in the target video.
[0051] Optionally, if the number of offset replacement pictures in the replacement sequence frames is less than the number of image frames in the target video, the offset replacement pictures in the replacement sequence frames are randomly matched with the image frames in the target video, or the offset replacement pictures in the replacement sequence frames are matched with the image frames in the target video in sequence, under the premise of ensuring that the offset replacement pictures corresponding to two adjacent image frames are different.
[0052] Among them, since in each group of replacement sequence frames, an offset replacement picture corresponds to an image frame in the target video, the corresponding offset replacement pictures and image frames can be compared pixel by pixel. Based on the principle of pixel position matching, the coordinate offset of the pixel at the corresponding position on the image frame can be determined according to the replacement offset value of a pixel of the position-matched offset replacement picture.
[0053] It is understandable that a set of replacement sequence frames is used to process each image frame of the target video, resulting in a layer of burr effect on the target image in each image frame of the target video. The processing of a layer of burr effect causes the target image to present an effect that is not very delicate. Therefore, the terminal can obtain a preset number of different groups of replacement sequence frames according to demand to add multiple layers of distortion replacement to the target image, so as to make the burr effect presented by the target image more delicate. Since different replacement sequence frames correspond to different styles, the target image can be burred for multiple times according to different styles to make the presented effect delicate.
[0054] Specifically, if there are multiple groups of replacement sequence frames at present, the terminal can simultaneously determine the coordinate offset of the pixel points of the image frame under each group of replacement sequence frames, and then perform offset replacement processing on the pixel points of the image frame at the same time; the terminal can also determine the coordinate offset of the pixel points of the image frame under each group of replacement sequence frames in turn, and perform offset replacement processing on the pixel points of the image frame when one group of coordinate offsets is determined, and then determine the coordinate offset of the pixel points of the image frame under the next group of replacement sequence frames, until the corresponding coordinate offsets are determined for all replacement sequence frames, and the corresponding pixels are subjected to offset replacement processing.
[0055] In some embodiments, since the replacement sequence frames can be used to perform glitch effects processing on different pictures, and the resolutions of different pictures are different, in order to facilitate post-processing, the resolution of the offset replacement picture can be set larger when setting the replacement sequence frames. When the offset of the image in the image frame needs to be determined through the replacement sequence frames, the resolutions of the image frame and the offset replacement picture can be determined, and the offset replacement picture can be cropped based on the resolution of the image frame so that the resolution of the image frame is equal to the resolution of the offset replacement picture.
[0056] Among them, the above-mentioned cropping method can be to determine the center position of the image frame and the offset replacement picture, overlap the image frame and the offset replacement picture with the center position, and thus crop the offset replacement picture; the above-mentioned cropping method can also be to determine the corresponding edge position of the image frame and the offset replacement picture in the same direction, such as the upper left corner, the lower left corner, the upper right corner, etc., and thus overlap the image frame and the offset replacement picture based on the corresponding edge position in the same direction, and thus crop the offset replacement picture.
[0057] For example, Figure 2a As shown, based on the resolution of the image frame, a coordinate system is established, and the image texture coordinate cropping method is adopted. The offset displacement image is first moved to the center of the coordinate system, that is, Figure 2a The center point of the offset displacement image corresponds to the center of the coordinate system, and then the texture coordinates are enlarged in the corresponding proportion. Finally, the cropping range of the offset displacement image is determined, and then cropping is performed, such as the 9:16, 16:9, 3:4, 4:3, 1:1 and other different proportions in the figure.
[0058] Among them, the cropping algorithm for the offset displacement image is as follows:
[0059] vec2 new_texcoord = uv; / / input texture coordinates
[0060] new_texcoord -= vec2(0.5); / / Center scaling
[0061] new_texcoord.x*=720.0 / 1280.0; / / horizontal axis enlarged 1.78 times
[0062] new_texcoord += vec2(0.5)
[0063] Among them, the cropping range of the offset displacement image is as follows: Figure 2b For example, if the default texture coordinate value range is [0-1], and the image frame resolution ratio is image_width / image_height=0.5625, then the texture coordinates of the cropping range of the offset replacement image in the horizontal direction are new_texcoord.x=UV(original texture coordinates)*0.5625, and the final cropping range of the offset replacement image can be obtained.
[0064] In some embodiments, the coordinate offset of each pixel point of the above-mentioned image frame under each group of replacement sequence frames is determined based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the above-mentioned image frame, including: converting the replacement offset value of each pixel point of the offset replacement picture corresponding to the above-mentioned image frame into a target replacement offset value within a preset range to facilitate the calculation of the coordinate offset; matching the pixel points of the offset replacement picture corresponding to the above-mentioned image frame with the pixel points of the above-mentioned image frame to determine the target replacement offset value corresponding to the position-matched pixel points in the above-mentioned image frame; determining the coordinate offset of each pixel point of the above-mentioned image frame based on the target replacement offset value corresponding to each pixel point of the above-mentioned image frame.
[0065] When converting the displacement offset value of each pixel point of the offset displacement picture corresponding to the above image frame into a target displacement offset value within a preset range, the preset range can be set according to user needs. For example, the preset range is [-1 to 1].
[0066] Specifically, the code for determining the target displacement offset value is as follows:
[0067] float DisplacePercent=DisplacementMapColor.r*2.0-1.0
[0068] Among them, the above DisplacePercent is the target displacement offset value, and the above DisplacementMapColor.r is the displacement offset value.
[0069] Specifically, the terminal can preset a replacement coefficient to process the target replacement offset value corresponding to the pixel point through the replacement coefficient to obtain the coordinate offset of the pixel point, thereby avoiding excessive pixel offset by setting a replacement coefficient, and the replacement coefficient is equivalent to the maximum horizontal replacement value.
[0070] Exemplarily, if the terminal is set to obtain two groups of replacement sequence frames, namely replacement sequence frame A and replacement sequence frame B, and the resolutions of the offset replacement pictures in the replacement sequence frame A and the offset replacement pictures in the replacement sequence frame B are both 960*960, based on the resolution of the image frame, the offset replacement pictures in the replacement sequence frame A and the offset replacement pictures in the replacement sequence frame B are cropped so that the offset replacement pictures in the replacement sequence frame A and the offset replacement pictures in the replacement sequence frame B are consistent with the resolution of the image frame.
[0071] Then, the offset replacement picture in the replacement sequence frame A is sampled first to obtain the replacement offset value of the r channel of the offset replacement picture, and the replacement offset value of each pixel point of the offset replacement picture corresponding to the above image frame is converted into a target replacement offset value in the range of -1 to 1. The pixel points of the offset replacement picture corresponding to the above image frame and the pixel points of the above image frame are matched in position, and the target replacement offset value corresponding to the position-matched pixel points in the above image frame is determined to facilitate the calculation of the coordinate offset. A maximum horizontal replacement value (denoted as AProgress), that is, the above replacement coefficient, is introduced to process the target replacement offset value corresponding to the pixel point through AProgress, so as to obtain the A coordinate offset of the pixel point, and the pixel point is subjected to offset replacement processing based on the A coordinate offset of the pixel point, and the image frame after the offset replacement processing is sampled to obtain the first layer of burr effect of the replaced image frame, as shown in FIG. Figure 3a shown.
[0072] Then, the offset replacement picture in the replacement sequence frame B is sampled to obtain the replacement offset value of the r channel of the offset replacement picture, and the replacement offset value of each pixel point of the offset replacement picture corresponding to the above image frame is converted into a target replacement offset value in the range of -1 to 1. The pixel points of the offset replacement picture corresponding to the above image frame and the pixel points of the above image frame are matched in position, and the target replacement offset value corresponding to the position-matched pixel points in the above image frame is determined to facilitate the calculation of the coordinate offset. A maximum horizontal replacement value (denoted as BProgress), that is, the above replacement coefficient, is introduced to process the target replacement offset value corresponding to the pixel point through BProgress, so as to obtain the B coordinate offset of the pixel point, and the pixel point is subjected to offset replacement processing based on the B coordinate offset of the pixel point, and the image frame after the offset replacement processing is sampled to obtain the second layer of burr effect of the replaced image frame, as shown in FIG. Figure 3b As shown, the burr effect corresponding to the two groups of replacement sequence frames is superimposed, so that the rendering obtains a densely arranged burr effect.
[0073] Among them, the algorithm for obtaining a two-layer burr effect by sampling the offset displacement image is as follows:
[0074] vec2 new_texcoord=vec2(v_texcoord.x+percentX,v_texcoord.y+percentY)
[0075] In some embodiments, the above-mentioned target displacement offset value corresponding to each pixel point of the above-mentioned image frame is used to determine the coordinate offset of each pixel point of the above-mentioned image frame, including: determining the displacement coefficient corresponding to the above-mentioned image frame based on a preset coefficient curve, wherein one coordinate axis of the above-mentioned coefficient curve is time, and the other coordinate axis is the displacement coefficient; based on the displacement coefficient corresponding to the above-mentioned image frame, the target displacement offset value corresponding to each pixel point of the above-mentioned image frame is processed respectively to obtain the coordinate offset of each pixel point of the above-mentioned image frame.
[0076] It can be understood that each image frame in the target video corresponds to a replacement coefficient through the coefficient curve, so that the burr special effect of the target image in different image frames presents different effects, which is equivalent to showing different burr effects at different time stages, making the change of the burr special effect of the target image in the target video more vivid. Among them, since there can be two or more groups of replacement sequence frames in this embodiment, the coefficient curves corresponding to the two groups of replacement sequence frames obtained by the terminal can be set to be different, so as to realize different replacement sources corresponding to different replacement coefficients.
[0077] Exemplarily, based on the above-mentioned example of permuted sequence frame A and permuted sequence frame B, as shown in FIG. Figure 4 As shown, Figure 4 From top to bottom, there are the first curve, the second curve and the third curve. Figure 4 The horizontal axis is time, which is used to indicate each image frame in the icon video, and the vertical axis varies according to the curve. In this example, only Figure 4 The second and third curves in the figure are coefficient curves, and the vertical axes of the second and third curves are the permutation coefficients. Figure 4 It can be seen from the curve in that Figure 4 Each frame in corresponds to a replacement coefficient. The second curve corresponds to replacement sequence frame A, and the third curve corresponds to replacement sequence frame B.
[0078] 104. Perform at least two dilation processes on the target image in the image frame, determine an edge path corresponding to the target image after each dilation process, and perform feathering process on at least two edge paths corresponding to the target image to obtain the target image after feathering process.
[0079] In this embodiment, in order to better improve the display effect of the burr special effect of the target image, the terminal can use multiple expansion processes to ensure that the burr effect is applied within a certain range of the target image and its surroundings, and to ensure that the burr effect will not be blurred during the subsequent image mixing process. The number of expansion processes can be set as required, for example, 3 times; each edge path is used to add a displaced burr effect to the target image.
[0080] Specifically, the terminal can obtain the target material image by performing image cutout detection on the target image frame, and perform at least two dilation processes on the contour of the target material image to obtain the edge path corresponding to the above-mentioned target image after each dilation process, and then further perform feathering edge processing by further Gaussian blurring the multiple edge paths to obtain the target image after feathering edge processing.
[0081] In some embodiments, the target image in the image frame is dilated at least twice to determine an edge path corresponding to the target image after each dilation process, including: performing edge search on the target image to obtain an edge position of the target image; and dilating the edge position of the target image with a preset dilation offset to obtain an edge path corresponding to the target image after the dilation process.
[0082] Specifically, the dense contour, i.e., the edge position, can be obtained by searching the contour edge of the target image. Then, the terminal can sparse the dense contour by a polygonal approximation method to obtain a sparse contour. The sparse contour is then expanded based on the Clipper library to obtain a polygonal path after offset, i.e., the edge path.
[0083] For example, if the target image is a human body mask, since there are at least two edge paths, the at least two edge paths can be combined and filled to obtain the final polygonal area, such as Figure 5a As shown, three expansion processes are performed, and the expansion offsets corresponding to each expansion process are 14, 8, and 5, respectively, so that three edge paths are obtained, namely Figure 5a There are three paths A, B, and C in the image, and the colors of the edge paths are different. The value corresponding to each pixel on each edge path can be set in the color channel corresponding to the pixel, such as the r channel, for feathering edge processing.
[0084] It is understandable that if only one edge path is used to generate the post-production burr effect without feathering the edge, it is easy to cause obvious stratification of the edge area of the target image and poor replacement effect, such as Figure 5b As shown, by designing at least two edge paths and performing feathering processing on at least two edge paths, the transition of the edge area of the feathered target area can be made more natural, as shown in FIG. Figure 6 shown.
[0085] In some embodiments, each dilation offset corresponds to a transparency, and as the number of dilation times increases, the transparency corresponding to the dilation offset becomes lower, thereby obtaining a gradient grayscale image corresponding to the target image.
[0086] Exemplarily, based on the above examples where the expansion offsets are 14, 8, and 5 respectively, the color values of the edge paths corresponding to the expansion offsets 14, 8, and 5 are 0.75, 0.5, and 0.25 respectively, thereby forming a gradient grayscale image.
[0087] 105. Based on the transparency of each pixel point on the edge area corresponding to the target image after the feathered edge processing and the coordinate offset of each pixel point of the above image frame under each group of replacement sequence frames, a target image with a burr special effect is generated in the above image frame.
[0088] In this embodiment, the terminal can generate a target image with a glitch special effect based on the above conditions at the same time; it can also generate a target image with a glitch special effect based on the above conditions in sequence. Through the above method, a target image with a glitch special effect that meets user needs can be obtained, thereby improving the efficiency of image generation of glitch special effects, and enriching the effect materials required by users to meet various user needs.
[0089] In some embodiments, based on the transparency of each pixel point on the edge area corresponding to the target image after the feathering edge processing and the coordinate offset of each pixel point of the above-mentioned image frame under each group of replacement sequence frames, a target image with a burr special effect is generated in the above-mentioned image frame, including: based on the coordinate offset of each pixel point of the above-mentioned image frame under each group of replacement sequence frames, pixel offset processing is performed on each pixel point of the above-mentioned image frame, so that the image in the above-mentioned image frame has a burr special effect; based on the transparency of each pixel point on the edge area corresponding to the target image after the feathering edge processing, the above-mentioned image frame with the burr special effect and the above-mentioned image frame without the burr special effect are mixed, so that the target image in the above-mentioned image frame has a burr special effect, such as Figure 7 shown.
[0090] In some embodiments, in order to avoid the glitch effect of the target image becoming blurred and not meeting user needs, before generating the target image with the glitch effect in the above-mentioned image frames, the image frames of the target video may be horizontally Gaussian blurred, and then the glitch effect may be generated based on the image frames after the horizontal Gaussian blurred processing.
[0091] Specifically, the terminal can determine the blur value corresponding to each image frame of the target video based on a preset Gaussian blur curve, wherein one coordinate axis of the Gaussian blur curve is time and the other coordinate axis is the blur value; based on the blur value corresponding to each image frame of the target video, perform horizontal Gaussian blur processing on each image frame of the target video.
[0092] It can be understood that the terminal introduces a Gaussian blur curve, such as Figure 4The first curve in the image, i.e., the top curve, has a fuzzy value on its vertical axis. Different fuzzy values corresponding to different image frames are achieved through the Gaussian fuzzy curve, thereby obtaining a set of fuzzy values that change with time, so that the target image in the target video produces a changing burr effect. Moreover, through the horizontal Gaussian fuzzy processing, the edge burrs of the target image after displacement can have a feathered soft feeling, and the spikes are more obvious, thereby avoiding the stiffness of the edge burrs of the target image after displacement.
[0093] The blur value is positively correlated with the horizontal displacement strength when the burr special effect is subsequently generated. For example, the Gaussian blur curve corresponds to the following:
[0094]
[0095]
[0096] It can be seen from the above content that a target video is obtained, wherein the image frame of the target video contains a target image that needs to be processed with burr special effects; at least one preset group of replacement sequence frames is obtained, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value; in the arrangement order of the image frames of the target video, a frame of offset replacement pictures in each group of replacement sequence frames corresponds to an image frame in the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames is determined. The invention relates to a method for generating a target image in the image frame by dilating the target image at least twice, determining an edge path corresponding to the target image after each dilating process, and performing edge feathering process on at least two edge paths corresponding to the target image to obtain the target image after the edge feathering process; based on the transparency of each pixel point on the edge area corresponding to the target image after the edge feathering process, and the coordinate offset of each pixel point of the image frame under each group of permuted sequence frames, generating a target image with a burr special effect in the image frame, thereby generating the burr special effect by determining the parameters required for the image to generate the burr special effect, so as to improve the efficiency of the image to generate the burr special effect.
[0097] In order to better implement the above method, an embodiment of the present application also provides a special effects generation device for a video image, which can be specifically integrated into an electronic device, such as a computer device, which can be a terminal, server, or other device.
[0098] Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer and other devices; the server can be a single server or a server cluster composed of multiple servers.
[0099] For example, in this embodiment, the method of the embodiment of the present application is described in detail by taking the special effects generation device of the video image specifically integrated in the terminal as an example. This embodiment provides a special effects generation device for a video image, such as Figure 8 As shown, the special effects generating device of the video image may include:
[0100] The video acquisition module 801 is used to acquire a target video, wherein the image frame of the target video contains a target image that needs to be processed with burr special effects;
[0101] The sequence frame acquisition module 802 is used to acquire at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value;
[0102] The offset determination module 803 is used to correspond one offset replacement picture in each group of replacement sequence frames to one image frame in the target video in the arrangement order of the image frames of the target video, and determine the coordinate offset of each pixel point of the image frame in each group of replacement sequence frames based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame;
[0103] The dilation processing module 804 is used to perform at least two dilation processes on the target image in the image frame, determine the edge path corresponding to the target image after each dilation process, and perform feathering process on at least two edge paths corresponding to the target image to obtain the target image after the feathering process;
[0104] The burr generation module 805 is used to generate a target image with burr special effects in the above image frame based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing and the coordinate offset of each pixel point of the above image frame under each group of replacement sequence frames.
[0105] In some embodiments, the offset determination module 803 is specifically used to:
[0106] Converting the displacement offset value of each pixel point of the displacement displacement picture corresponding to the above image frame into a target displacement offset value within a preset range;
[0107] Positionally matching the pixel points of the offset replacement picture corresponding to the image frame with the pixel points of the image frame, and determining the target replacement offset value corresponding to the position-matched pixel points in the image frame;
[0108] Based on the target replacement offset value corresponding to each pixel point of the image frame, the coordinate offset of each pixel point of the image frame is determined.
[0109] In some embodiments, the offset determination module 803 is specifically used to:
[0110] Determine a replacement coefficient corresponding to the image frame based on a preset coefficient curve, wherein one coordinate axis of the coefficient curve is time and the other coordinate axis is the replacement coefficient;
[0111] Based on the replacement coefficient corresponding to the above image frame, the target replacement offset value corresponding to each pixel point of the above image frame is processed respectively to obtain the coordinate offset of each pixel point of the above image frame.
[0112] In some embodiments, the burr generation module 805 is specifically used for:
[0113] Based on the coordinate offset of each pixel point of the above image frame under each set of permuted sequence frames, pixel offset processing is performed on each pixel point of the above image frame, so that the image in the above image frame has a burr special effect;
[0114] Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing, the above image frame with burr special effect and the above image frame without burr special effect are mixed to make the target image in the above image frame have burr special effect.
[0115] In some embodiments, the expansion processing module 804 is specifically used to:
[0116] Perform edge search on the target image to obtain the edge position of the target image;
[0117] The edge position of the target image is expanded with a preset expansion offset to obtain an edge path corresponding to the target image after the expansion.
[0118] In some embodiments, each expansion offset corresponds to a transparency, and as the number of expansions increases, the transparency corresponding to the expansion offset becomes lower.
[0119] In some embodiments, the special effects generating device for the video image further includes a blur processing module, and the blur processing module is specifically used for:
[0120] Based on a preset Gaussian blur curve, determining a blur value corresponding to each image frame of the target video, wherein one coordinate axis of the Gaussian blur curve is time, and the other coordinate axis is blur value;
[0121] Based on the blur values corresponding to the respective image frames of the target video, horizontal Gaussian blur processing is performed on the respective image frames of the target video.
[0122] As can be seen from the above, the target video is acquired through the video acquisition module 801, wherein the image frame of the target video contains the target image to be processed with burr special effects; at least one set of preset replacement sequence frames is acquired through the sequence frame acquisition module 802, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value; the offset determination module 803 is used to correspond a frame of the offset replacement picture in each set of replacement sequence frames to an image frame in the target video in the arrangement order of the image frames of the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the displacement offset value of each pixel point of the image frame under each set of replacement sequence frames is determined. Coordinate offset; performing at least two dilation processes on the target image in the above image frame through the dilation processing module 804, determining the edge path corresponding to the above target image after each dilation process, and performing feathering edge processing on at least two edge paths corresponding to the above target image to obtain the target image after the feathering edge processing; generating a target image with a burr special effect in the above image frame based on the transparency of each pixel point on the edge area corresponding to the target image after the feathering edge processing and the coordinate offset of each pixel point of the above image frame under each group of permutation sequence frames through the burr generation module 805, thereby generating the burr special effect by determining the parameters required for the image to generate the burr special effect, so as to improve the efficiency of the image to generate the burr special effect.
[0123] Accordingly, the embodiment of the present application also provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Fig. 9 As shown, Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 900 includes a processor 901 having one or more processing cores, a memory 902 having one or more computer-readable storage media, and a computer program stored in the memory 902 and executable on the processor. The processor 901 is electrically connected to the memory 902. It will be understood by those skilled in the art that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
[0124] The processor 901 is the control center of the electronic device 900. It uses various interfaces and lines to connect various parts of the entire electronic device 900, executes various functions of the electronic device 900 and processes data by running or loading software programs and / or modules stored in the memory 902, and calling data stored in the memory 902, thereby monitoring the electronic device 900 as a whole.
[0125] In the embodiment of the present application, the processor 901 in the electronic device 900 loads instructions corresponding to the processes of one or more application programs into the memory 902 according to the following steps, and the processor 901 runs the application programs stored in the memory 902 to implement various functions:
[0126] Acquire a target video, wherein the image frame of the target video contains a target image to be processed with burr special effects;
[0127] Acquire at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value;
[0128] In the arrangement order of the image frames of the target video, one offset replacement picture in each group of replacement sequence frames corresponds to one image frame in the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames is determined;
[0129] Performing at least two dilation processes on the target image in the image frame, determining an edge path corresponding to the target image after each dilation process, and performing feathering edge processing on at least two edge paths corresponding to the target image to obtain the target image after the feathering edge processing;
[0130] Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing and the coordinate offset of each pixel point of the above image frame under each group of replacement sequence frames, a target image with burr special effects is generated in the above image frame.
[0131] In some embodiments, the determining of the coordinate offset of each pixel point of the image frame under each group of permuted sequence frames based on the permuted offset value of each pixel point of the offset permuted picture corresponding to the image frame includes:
[0132] Converting the displacement offset value of each pixel point of the displacement displacement picture corresponding to the above image frame into a target displacement offset value within a preset range;
[0133] Positionally matching the pixel points of the offset replacement picture corresponding to the image frame with the pixel points of the image frame, and determining the target replacement offset value corresponding to the position-matched pixel points in the image frame;
[0134] Based on the target replacement offset value corresponding to each pixel point of the image frame, the coordinate offset of each pixel point of the image frame is determined.
[0135] In some embodiments, determining the coordinate offset of each pixel point of the image frame based on the target replacement offset value corresponding to each pixel point of the image frame includes:
[0136] Determine a replacement coefficient corresponding to the image frame based on a preset coefficient curve, wherein one coordinate axis of the coefficient curve is time and the other coordinate axis is the replacement coefficient;
[0137] Based on the replacement coefficient corresponding to the above image frame, the target replacement offset value corresponding to each pixel point of the above image frame is processed respectively to obtain the coordinate offset of each pixel point of the above image frame.
[0138] In some embodiments, the transparency of each pixel point on the edge area corresponding to the target image after the feathered edge processing and the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames generate a target image with burr special effects in the image frame, including:
[0139] Based on the coordinate offset of each pixel point of the above image frame under each set of permuted sequence frames, pixel offset processing is performed on each pixel point of the above image frame, so that the image in the above image frame has a burr special effect;
[0140] Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing, the above image frame with burr special effect and the above image frame without burr special effect are mixed to make the target image in the above image frame have burr special effect.
[0141] In some embodiments, the step of performing at least two dilation processes on the target image in the image frame and determining an edge path corresponding to the target image after each dilation process includes:
[0142] Perform edge search on the target image to obtain the edge position of the target image;
[0143] The edge position of the target image is expanded with a preset expansion offset to obtain an edge path corresponding to the target image after the expansion.
[0144] In some embodiments, each expansion offset corresponds to a transparency, and as the number of expansions increases, the transparency corresponding to the expansion offset becomes lower.
[0145] In some embodiments, before generating a target image with a burr special effect in the above image frame, the method further includes:
[0146] Based on a preset Gaussian blur curve, determining a blur value corresponding to each image frame of the target video, wherein one coordinate axis of the Gaussian blur curve is time, and the other coordinate axis is blur value;
[0147] Based on the blur values corresponding to the respective image frames of the target video, horizontal Gaussian blur processing is performed on the respective image frames of the target video.
[0148] Therefore, the electronic device 900 provided by this embodiment can bring the following technical effects: improving the efficiency of generating burr special effects in images.
[0149] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0150] Optional, such as Fig. 9 As shown, the electronic device 900 further includes: a touch screen 903, a radio frequency circuit 904, an audio circuit 905, an input unit 906, and a power supply 907. The processor 901 is electrically connected to the touch screen 903, the radio frequency circuit 904, the audio circuit 905, the input unit 906, and the power supply 907, respectively. Those skilled in the art can understand that Fig. 9 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0151] The touch display screen 903 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 903 may include a display panel and a touch panel. Among them, the display panel may be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces may be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel may be used to collect the user's touch operation on or near it (such as the user using any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts, a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 901, and can receive the command sent by the processor 901 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 901 to determine the type of touch event, and then the processor 901 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 903 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 903 can also be used as a part of the input unit 906 to realize the input function.
[0152] The radio frequency circuit 904 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
[0153] The audio circuit 905 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 905 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 905 and converted into audio data, and then the audio data is output to the processor 901 for processing, and then sent to another electronic device through the radio frequency circuit 904, or the audio data is output to the memory 902 for further processing. The audio circuit 905 may also include an earplug jack to provide communication between an external headset and an electronic device.
[0154] The input unit 906 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0155] The power supply 907 is used to supply power to various components of the electronic device 900. Optionally, the power supply 907 can be logically connected to the processor 901 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 907 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0156] although Fig. 9 Not shown, the electronic device 900 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0157] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0158] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0159] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of computer programs are stored, and the computer program can be loaded by a processor to execute the steps in any of the special effects generation methods for video images provided in the embodiments of the present application. For example, the computer program can execute the following steps:
[0160] Acquire a target video, wherein the image frame of the target video contains a target image to be processed with burr special effects;
[0161] Acquire at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value;
[0162] In the arrangement order of the image frames of the target video, one offset replacement picture in each group of replacement sequence frames corresponds to one image frame in the target video, and based on the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame, the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames is determined;
[0163] Performing at least two dilation processes on the target image in the image frame, determining an edge path corresponding to the target image after each dilation process, and performing feathering edge processing on at least two edge paths corresponding to the target image to obtain the target image after the feathering edge processing;
[0164] Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing and the coordinate offset of each pixel point of the above image frame under each group of replacement sequence frames, a target image with burr special effects is generated in the above image frame.
[0165] In some embodiments, the determining of the coordinate offset of each pixel point of the image frame under each group of permuted sequence frames based on the permuted offset value of each pixel point of the offset permuted picture corresponding to the image frame includes:
[0166] Converting the displacement offset value of each pixel point of the displacement displacement picture corresponding to the above image frame into a target displacement offset value within a preset range;
[0167] Positionally matching the pixel points of the offset replacement picture corresponding to the image frame with the pixel points of the image frame, and determining the target replacement offset value corresponding to the position-matched pixel points in the image frame;
[0168] Based on the target replacement offset value corresponding to each pixel point of the image frame, the coordinate offset of each pixel point of the image frame is determined.
[0169] In some embodiments, determining the coordinate offset of each pixel point of the image frame based on the target replacement offset value corresponding to each pixel point of the image frame includes:
[0170] Determine a replacement coefficient corresponding to the image frame based on a preset coefficient curve, wherein one coordinate axis of the coefficient curve is time and the other coordinate axis is the replacement coefficient;
[0171] Based on the replacement coefficient corresponding to the above image frame, the target replacement offset value corresponding to each pixel point of the above image frame is processed respectively to obtain the coordinate offset of each pixel point of the above image frame.
[0172] In some embodiments, the transparency of each pixel point on the edge area corresponding to the target image after the feathered edge processing and the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames generate a target image with burr special effects in the image frame, including:
[0173] Based on the coordinate offset of each pixel point of the above image frame under each set of permuted sequence frames, pixel offset processing is performed on each pixel point of the above image frame, so that the image in the above image frame has a burr special effect;
[0174] Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing, the above image frame with burr special effect and the above image frame without burr special effect are mixed to make the target image in the above image frame have burr special effect.
[0175] In some embodiments, the step of performing at least two dilation processes on the target image in the image frame and determining an edge path corresponding to the target image after each dilation process includes:
[0176] Perform edge search on the target image to obtain the edge position of the target image;
[0177] The edge position of the target image is expanded with a preset expansion offset to obtain an edge path corresponding to the target image after the expansion.
[0178] In some embodiments, each expansion offset corresponds to a transparency, and as the number of expansions increases, the transparency corresponding to the expansion offset becomes lower.
[0179] In some embodiments, before generating a target image with a burr special effect in the above image frame, the method further includes:
[0180] Based on a preset Gaussian blur curve, determining a blur value corresponding to each image frame of the target video, wherein one coordinate axis of the Gaussian blur curve is time, and the other coordinate axis is blur value;
[0181] Based on the blur values corresponding to the respective image frames of the target video, horizontal Gaussian blur processing is performed on the respective image frames of the target video.
[0182] It can be seen that the computer program can be loaded by the processor to execute the steps in any one of the special effects generation methods for video images provided in the embodiments of the present application, thereby bringing about the following technical effects: improving the efficiency of image generation of burr special effects.
[0183] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0184] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0185] Since the computer program stored in the computer-readable storage medium can execute the steps in any one of the special effects generation methods for video images provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the special effects generation methods for video images provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0186] The above is a detailed introduction to a special effects generation method, device, electronic device and computer-readable storage medium for a video image provided by an embodiment of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for generating special effects of a video image, characterized in that: The method comprises: Acquire a target video, wherein the image frame of the target video contains a target image that needs to be processed with burr special effects; Acquire at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value; According to the arrangement order of the image frames of the target video, one offset replacement picture in each group of replacement sequence frames corresponds to one image frame in the target video, and the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame is converted into a target replacement offset value within a preset range; the pixel points of the offset replacement picture corresponding to the image frame are matched with the pixel points of the image frame to determine the target replacement offset value corresponding to the position-matched pixel points in the image frame; based on a preset coefficient curve, the replacement coefficient corresponding to the image frame is determined, wherein one coordinate axis of the coefficient curve is time and the other coordinate axis is the replacement coefficient; based on the replacement coefficient corresponding to the image frame, the target replacement offset value corresponding to each pixel point of the image frame is processed respectively to obtain the coordinate offset of each pixel point of the image frame; Performing at least two dilation processes on the target image in the image frame, determining an edge path corresponding to the target image after each dilation process, and performing feathering edge processing on at least two edge paths corresponding to the target image to obtain the target image after the feathering edge processing; Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing and the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames, a target image with burr special effects is generated in the image frame.
2. The method for generating special effects of a video image according to claim 1, wherein: The target image with burr special effects is generated in the image frame based on the transparency of each pixel point on the edge area corresponding to the target image after the feathered edge processing and the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames, including: Based on the coordinate offset of each pixel point of the image frame under each set of permuted sequence frames, pixel offset processing is performed on each pixel point of the image frame, so that the image in the image frame has a burr special effect; Based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing, the image frame with the burr special effect and the image frame without the burr special effect are mixed to make the target image in the image frame have the burr special effect.
3. The method for generating special effects of a video image according to claim 1, characterized in that: The step of performing at least two dilation processes on the target image in the image frame and determining an edge path corresponding to the target image after each dilation process comprises: Performing edge search on the target image to obtain edge positions of the target image; The edge position of the target image is expanded with a preset expansion offset to obtain an edge path corresponding to the target image after the expansion.
4. The method for generating special effects of a video image according to claim 3, characterized in that: Each expansion offset corresponds to a transparency, and as the number of expansions increases, the transparency corresponding to the expansion offset becomes lower.
5. The method for generating special effects of a video image according to any one of claims 1 to 4, characterized in that: Before generating a target image with a burr special effect in the image frame, the method further includes: Determine the blur value corresponding to each image frame of the target video based on a preset Gaussian blur curve, wherein one coordinate axis of the Gaussian blur curve is time and the other coordinate axis is blur value; Based on the blur values corresponding to the respective image frames of the target video, horizontal Gaussian blur processing is performed on the respective image frames of the target video.
6. A video image special effects generating device, characterized in that: The device comprises: A video acquisition module, used for acquiring a target video, wherein the image frame of the target video contains a target image to be processed with burr special effects; A sequence frame acquisition module, used to acquire at least one set of preset replacement sequence frames, wherein the replacement sequence frames include at least two frames of offset replacement pictures, and each pixel point on the offset replacement pictures corresponds to a replacement offset value; An offset determination module is used to correspond an offset replacement picture in each group of replacement sequence frames to an image frame in the target video in the arrangement order of the image frames of the target video, and convert the replacement offset value of each pixel point of the offset replacement picture corresponding to the image frame into a target replacement offset value within a preset range; positionally match the pixel points of the offset replacement picture corresponding to the image frame with the pixel points of the image frame to determine the target replacement offset value corresponding to the position-matched pixel points in the image frame; determine the replacement coefficient corresponding to the image frame based on a preset coefficient curve, wherein one coordinate axis of the coefficient curve is time and the other coordinate axis is the replacement coefficient; based on the replacement coefficient corresponding to the image frame, respectively process the target replacement offset value corresponding to each pixel point of the image frame to obtain the coordinate offset of each pixel point of the image frame; a dilation processing module, configured to perform at least two dilation processes on the target image in the image frame, determine an edge path corresponding to the target image after each dilation process, and perform feathering edge processing on at least two edge paths corresponding to the target image to obtain the target image after the feathering edge processing; The burr generation module is used to generate a target image with burr special effects in the image frame based on the transparency of each pixel point on the edge area corresponding to the target image after feathering edge processing and the coordinate offset of each pixel point of the image frame under each group of replacement sequence frames.
7. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the method for generating special effects of a video image as claimed in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the method for generating special effects for a video image according to any one of claims 1 to 5.
