An audio and video synthesis processing method based on artificial intelligence
By using the deep automatic codec model and edge detection technology in video synthesis, calculating the instability coefficient and blur index, and performing targeted edge blur processing, the problem of uneven edges when replacing portraits in video synthesis is solved, and the picture is realized Stable and efficient blur processing.
Patent Information
- Application Number
- CN202311863748.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-12-28
AI Technical Summary
When existing video synthesis technology processes two videos of the same scene, it is easy to produce uneven edges during the portrait replacement process. Existing blur methods lack evaluation criteria for edge differences, making it difficult to effectively handle the edges of objects of different shapes.
Adopt an artificial intelligence-based audio and video synthesis processing method to identify portraits through edge detection, use a deep automatic codec model to train new portraits, and calculate the instability coefficient and blur index between the new portrait and the old background environment to perform targeted edge detection. Blurring.
It realizes the optimization of image edges during the video synthesis process, ensuring the stability of the picture and avoiding excessive blur, and improving the efficiency and effect of blur processing.
Smart Images

Figure CN117789093B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an audio and video synthesis processing method based on artificial intelligence. Background Art
[0002] At present, with the rapid development of streaming media, in order to better protect privacy and video effects, video synthesis technology has emerged to protect user privacy.
[0003] There are already a lot of applications for protecting privacy by segmenting images based on edge computing and attaching stickers to faces in videos. However, for two videos of the same scene, replacing a changing human image is a technical challenge. Like artificial intelligence face-changing technology, both will produce uneven edge defects in the process of synthesizing videos. Therefore, blurring technology is needed to reduce the impact of defects. For existing blurring methods, most of them directly blur the image area at a specific distance, and lack evaluation criteria for edge differences. Therefore, for objects of different shapes, the edge blurring processing method still needs to be improved. Summary of the invention
[0004] In order to solve the above technical problems, the purpose of the present invention is to provide an audio and video synthesis processing method based on artificial intelligence. On the basis of edge detection and recognition of portraits, an edge blurring algorithm is used to control the edge display of the image to achieve the purpose of optimizing the picture.
[0005] The present invention provides an audio and video synthesis processing method based on artificial intelligence, comprising the following steps:
[0006] S1. Segment the old portrait in the image by edge detection, remove the old portrait part and leave the old background environment, and extract the outline of the old portrait in the process;
[0007] S2, use the deep auto-encoder-decoder model, train the model, and input the portrait into the trained model to obtain a new portrait;
[0008] S3, processing the extracted old portrait outline to obtain vector information of the old background environment;
[0009] S4, processing the new portrait to obtain vector information of the new portrait;
[0010] S5, calculating the instability coefficient D between the new portrait and the old background environment according to the vector information of the old background environment and the vector information of the new portrait;
[0011] S6. Traverse all edge points and calculate the blur index B of each edge point i ;
[0012] S7. Get the blur index B of each edge point i Then, the pixel blur number M of the edge point i Calculate and obtain the number of pixels actually blurred;
[0013] S8. Perform blurring processing according to the actual number of pixels to be blurred.
[0014] Preferably, step S2 specifically includes:
[0015] Use the deep auto-encoder-decoder model to iterate and train the model's ability to recognize and restore portraits multiple times. Repeat the cycle until the model is trained. Input the portrait into the trained deep auto-encoder-decoder model to obtain the corresponding new portrait.
[0016] Preferably, step S3 is specifically:
[0017] 3a Count the number of pixels within the contour, the number of pixels is recorded as S, and the pixel statistics include the pixels at the edge of the contour;
[0018] 3b For a closed contour, a closed figure is obtained. The centroid of the figure is found on the plane as the reference point for subsequent analysis. The coordinates of this point are marked as (0, 0). The method of statistical centroid is obtained by the method of balance line. Two balance lines that evenly divide the pixels of the figure are used to draw the intersection point;
[0019] 3c connects each pixel point of the edge of the contour with the centroid coordinates to form a line and establish vector information. For a figure with n pixel points on the edge contour, n vectors will be generated to obtain the vector information of the old background environment;
[0020] 3d takes the modulus of the established vector information and obtains the corresponding n values, which are recorded as l1, l2...l n .
[0021] Preferably, step S4 is specifically:
[0022] 4a In the same way as the outline of the old portrait, process the new portrait and find the center of mass;
[0023] 4b Evenly select n pixels from the pixels of each contour edge, connect these points with the centroid, obtain the vector information of the new portrait, and then perform modulus to obtain j1, j2...j n .
[0024] Preferably, step S5 is specifically:
[0025] By analyzing the difference of data, the vector information of the old background environment and the vector information of the new portrait are subtracted to preliminarily evaluate the matching degree between the new portrait and the old background environment when performing image replacement, and the statistics of (l1-j1), (l2-j2)...(ln -j n ) is taken as the instability coefficient D between the new portrait and the old background environment. The calculation formula of the instability coefficient D is as follows:
[0026] D=Var[(l1-j1), (l2-j2)...(l n -j n )].
[0027] Preferably, step S6 specifically includes:
[0028] Since the pixels of the portrait part are different, the size of the blurred part has different effects on vision. In order to consider every pixel of the portrait edge, the blur index B is set. i To evaluate each point on the edge separately, the blur index B i It is an evaluation mechanism acting on a single edge pixel. Its purpose is to evaluate the abruptness of the point on the portrait image based on the entire portrait image. The blur index B i The calculation formula is as follows:
[0029]
[0030] Among them, D is the instability coefficient between the new portrait and the old background environment, which is the variance in value, S is the total number of pixels in the outline of the old portrait, and j i It is the modulus of the distance vector corresponding to the new portrait particle.
[0031] Preferably, in step S7, the pixel blur number M of the edge point is i The calculation formula is as follows:
[0032]
[0033] Among them, B i-1 is the blur index of the previous point of the edge point, ave(j1+j2+…j n ) is the average value of all distance moduli, representing the average distance from all edge points of the new portrait to the centroid, j i is the distance from the current edge point to the centroid, arctan[(B i -B i-1 )(B i+1 -B i )] is a normalized evaluation of the blurring index of adjacent edge points, indicating the difference in blurring index between the edge point and the adjacent edge points.
[0034] Preferably, the pixel blur number M i Round up to the integer number of pixels actually blurred.
[0035] Preferably, step S8 is specifically:
[0036] 8a Connect the edge point and the centroid into a line as a separate axis. On the axis, take the edge point as the center and take M pixels at both ends of the axis as the pixel points to be processed;
[0037] 8b According to the pre-set amplification factor Continue to select N pixel points on the axis. The number of pixel points to be selected should be And round N upwards;
[0038] 8c selects 2 (M+N) pixels to be processed, selects (M+N) pixels in the direction of the particle on the axis, and selects (M+N) pixels in the opposite direction, and performs average weighted transition blurring on the selected pixels, that is, weighted average of their RGB parameters to complete blurring;
[0039] 8d loops the above operation to traverse each edge pixel in the image, and the blurring process of the entire image is completed.
[0040] Compared with the prior art, the present invention has the following beneficial effects:
[0041] 1. By processing the fusion replacement of specific image parts in the video, a new blur algorithm is used to appropriately optimize the image in the process of synthesizing the video to ensure that the image is stable and not over-processed;
[0042] 2. During the processing, the centroid statistics method is used to evaluate the overall instability of the portrait, and the variance D is used as the instability coefficient. The single edge pixel point is further analyzed to construct the edge blur index B. The influence of the edge pixels around the single edge pixel point is further considered to obtain the number of blurred pixels M;
[0043] 3. Through the amplification factor Determine 2 (M+N) pixels that need to be processed and perform blurring on them. This blurring method takes the edge point as the center and selects limited pixels for processing along two symmetrical directions connected to the centroid, so that the processing range is relatively small and the image will not be blurred too much. On the other hand, the calculation is convenient and directional, which reduces the repeated selection of pixels for blurring, and the blurring efficiency is relatively high. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a principle flow chart of the present invention. DETAILED DESCRIPTION
[0045] The following is a clear and complete description of the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are 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 the present application.
[0046] like Figure 1 As shown, the present invention provides an audio and video synthesis processing method based on artificial intelligence, comprising the following steps:
[0047] Step 1: Collect and analyze portrait information.
[0048] 1. By using the edge detection method (this method is a prior art means and will not be described in detail here), the old portrait is segmented out from the image, and the old portrait part is removed to leave the old background environment, and the outline of the old portrait is extracted in the process.
[0049] 2. Use the deep auto-encoder model to train a large number of old and new portraits, train the model's ability to recognize and restore portraits, and repeat until it can relatively stably convert any portrait into a fixed new portrait. Therefore, when a portrait is input to the deep auto-encoder model, a corresponding new portrait can be output. However, since the outline of the new portrait does not completely match the outline of the old background environment, it cannot be perfectly embedded in the old background and needs to be blurred.
[0050] 3. Process the extracted old portrait outline. Under the current portrait outline, it is a complete closed curve and needs to be processed as follows:
[0051] 3a Count the number of pixels within the contour, the number of pixels is recorded as S, and the pixel statistics include the pixels at the edge of the contour.
[0052] 3b For a closed contour, a closed figure is obtained. The centroid of the figure is found on the plane as a reference point for subsequent analysis. The coordinates of this point are marked as (0, 0). The method of statistical centroid can be obtained by the method of balance line. Two balance lines that evenly divide the pixels of the figure are used to draw the intersection and find the centroid. This method of finding the centroid is relatively mature and common.
[0053] 3c Further, each pixel point of the contour edge is connected to the centroid coordinates to form a line and establish vector information. Then, for a figure with n pixel points in the edge contour, n vectors will be generated, and the vector information of the old background environment will be obtained (because the old portrait contour and the old background environment contour are the same contour, the vector information of the old background environment can be obtained through the vector information of the old portrait contour).
[0054] 3d takes the modulus of the established vector information and obtains the corresponding n values, which are recorded as l1, l2...l n .
[0055] 4. Further processing of the outline of the new portrait
[0056] 4a Use the same method as the old portrait outline to find the center of mass.
[0057] 4b Evenly select n pixels from the pixels of each contour edge, connect these points with the centroid, obtain the vector information of the new portrait, and then perform modulus to obtain j1, j2...j n .
[0058] 5. By analyzing the difference of data, subtracting the vector information of the old background environment from the vector information of the new portrait, we can preliminarily evaluate the matching degree between the new portrait and the old background environment when performing image replacement. The worse the matching degree, the more blurring needs to be increased to improve it. The better the matching degree, the more blurring needs to be reduced to make the image look more natural. Therefore, statistics (l1-j1), (l2-j2)...(l n -j n ) can be used as the instability coefficient D between the new portrait and the old background environment. The calculation formula of the instability coefficient D is as follows:
[0059] D=Var[(l1-j1), (l2-j2)...(l n -j n )].
[0060] This method of measuring the shape of macroscopic images is to evaluate the abstractness of the entire image. The larger the variance D is, the more unstable the portrait matching is.
[0061] Step 2: Further analyze the matching degree between the new portrait and the old background environment at the edge, and perform different degrees of blurring on each intersection point.
[0062] 6. Traverse all edge points and calculate the blur index B of each edge point i .
[0063] Since the pixels of the portrait part are different, the size of the blurred part has different visual effects. In order to consider each pixel of the portrait edge, a blur index is set to evaluate each point of the edge separately. The matching degree is combined with the overall pixel at a single point and evaluated in the form of an index.
[0064] Blur Index B i It is an evaluation mechanism acting on a single edge pixel. Its purpose is to evaluate the abruptness of the point on the portrait image based on the entire portrait image. The blur index B iThe calculation formula is as follows:
[0065]
[0066] Among them, D is the instability coefficient between the new portrait and the old background environment, which is the variance in value, S is the total number of pixels in the outline of the old portrait, and j i It is the modulus of the distance vector corresponding to the new portrait particle.
[0067] When the total number of pixels S in the outline of the old portrait is larger, that is, the larger the hole in the background, the less obvious the edge conflict is in the overall picture. The larger the variance D is, the less suitable it is to use the same blurring method, and the more it is necessary to consider the edge pixels.
[0068] This blur index B i It is just a preliminary macroscopic evaluation of the degree to which the current pixel needs to be blurred, without considering the influence of local factors. The blur index B i The larger the value, the higher the overall blur.
[0069] 7. Further, the blur index B of each edge point is obtained i After that, it is necessary to further blur the pixel number M of the edge point i Perform calculations.
[0070] Since the image edges need to be protected from distortion, the degree of blurring needs to be as small as possible while covering up the edge mutation. For an edge point, the line connecting the points in the direction of the centroid is used as a blurring axis, and the pixels on this axis need to be blurred.
[0071] In order to ensure that the blurred part is as small as possible, it is necessary to consider the edge blur index on both sides of the edge pixel point. If the difference between the adjacent pixels is not large, the number of pixels that need to be blurred should also be appropriately reduced.
[0072] 7a The number of pixel blurs at edge points M i The calculation formula is as follows:
[0073]
[0074] Among them, B i-1 is the blur index of the previous point of the edge point, ave(j1+j2+…j n ) is the average value of all distance moduli, representing the average distance from all edge points of the new portrait to the centroid, j i is the distance from the current edge point to the centroid, arctan[(B i -B i-1 )(B i+1 -B i)] is a normalized evaluation of the blur index of adjacent edge points, indicating the difference in blur index between this edge point and adjacent edge points. The larger the value, the greater the difference, and more pixels are needed for transition.
[0075] 7b Further, the pixel blur number M i Round up to the integer number of pixels actually blurred.
[0076] This rounding-up mechanism ensures that the number of blurred pixels is never zero.
[0077] 8. Perform blur processing.
[0078] 8a Connect the edge point and the centroid into a line as a separate axis. Take the edge point as the center on the axis and take M pixels at both ends of the axis as the pixel points to be processed.
[0079] 8b According to the pre-set amplification factor Continue to select N pixel points on the axis. Generally speaking, if the amplification factor If it is set to 0.2, the number of pixels to be selected should be And N is rounded up.
[0080] 8c In this way, a total of 2 (M+N) pixels to be processed are selected, and (M+N) pixels are selected in the direction of the particle on the axis, and (M+N) pixels are selected in the opposite direction. The selected pixels are averagely weighted and transitionally blurred, that is, the weighted average of their RGB parameters is used to complete the blurring process. Because the axis is constructed, this blurring process is directional.
[0081] 8d loops the above operation to traverse each edge pixel in the image, and the blurring process of the entire image is completed.
[0082] To sum up, this audio and video synthesis processing method mainly focuses on processing the fusion and replacement of specific image parts in the video. In the process of synthesizing the video, a new fuzzy algorithm is used to appropriately optimize the picture to ensure that the picture is stable and not over-processed.
[0083] During the processing, the centroid statistics method is used to evaluate the overall instability of the portrait. The variance D is used as the instability coefficient. The single edge pixel point is further analyzed to construct the edge blur index B. The influence of the edge pixels around the single edge pixel point is further considered to obtain the number of blurred pixels M.
[0084] Finally, the amplification factor Determine 2 (M+N) pixels that need to be processed and perform blurring on them. This blurring method takes the edge point as the center and selects limited pixels along two symmetrical directions connected to the centroid for processing, so that the processing range is relatively small and the image will not be blurred too much; on the other hand, it is easy to calculate and has directionality, which reduces repeated selection of pixels for blurring, and the blurring efficiency is relatively high.
[0085] The above embodiments are only used to illustrate the technical method of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical method of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical method of the present invention.
Claims
1. An audio and video synthesis processing method based on artificial intelligence, characterized in that: The following steps are involved: S1. Segment the old portrait in the image by edge detection, remove the old portrait part and leave the old background environment, and extract the outline of the old portrait in the process; S2, use the deep auto-encoder-decoder model, train the model, and input the portrait into the trained model to obtain a new portrait; S3, processing the extracted old portrait outline to obtain vector information of the old background environment; S4, processing the new portrait to obtain vector information of the new portrait; S5, calculating the instability coefficient D between the new portrait and the old background environment according to the vector information of the old background environment and the vector information of the new portrait; S6. Traverse all edge points and calculate the blur index B of each edge point i ; S7. Get the blur index B of each edge point i Then, the number of pixel blurs at the edge point is M i Calculate and obtain the number of pixels actually blurred; S8, performing blurring processing according to the number of pixels actually blurred; Step S3 is specifically as follows: 3a. Count the number of pixels within the contour, the number of pixels is recorded as S, and the pixel statistics include the pixels at the edge of the contour; 3b. For a closed contour, a closed figure is obtained. The centroid of the figure is found on the plane as the reference point for subsequent analysis. The coordinates of this point are marked as (0, 0). The method of statistical centroid is obtained by the method of balance line. Two balance lines that evenly divide the pixels of the figure are used to draw the intersection point; 3c. Connect each pixel point of the edge of the contour with the centroid coordinates to form a line and establish vector information. For a figure with n pixel points on the edge contour, n vectors will be generated to obtain the vector information of the old background environment. 3d. Take the modulus of the established vector information and obtain the corresponding n values, recorded as l1, l2...l n ; Step S4 is specifically as follows: 4a. Process the new portrait in the same way as the old portrait outline to find the center of mass; 4b. Evenly select n pixels from the pixels of each contour edge, connect these points with the centroid, obtain the vector information of the new portrait, and then perform modulo operation to obtain j1, j2...j n ; Step S5 is specifically as follows: By analyzing the difference of data, the vector information of the old background environment and the vector information of the new portrait are subtracted to preliminarily evaluate the matching degree between the new portrait and the old background environment when performing image replacement, and the statistics of (l1-j1), (l2-j2)...(l n -j n ) is taken as the instability coefficient D between the new portrait and the old background environment. The calculation formula of the instability coefficient D is as follows: <h2 style=";text-align:left;direction:ltr">D = Var[(l1-j1)、(l2-j2)...(l<h2 style=";text-align:left;direction:ltr"> n <h2 style=";text-align:left;direction:ltr"> -j<h2 style=";text-align:left;direction:ltr"> n <h2 style=";text-align:left;direction:ltr"> )]; Step S6 is specifically as follows: Since the pixels of the portrait part are different, the size of the blurred part has different effects on vision. In order to consider every pixel of the portrait edge, the blur index B is set. i To evaluate each point on the edge separately, the blur index B i It is an evaluation mechanism acting on a single edge pixel. Its purpose is to evaluate the abruptness of the point on the portrait image based on the entire portrait image. The blur index B i The calculation formula is as follows: Among them, D is the instability coefficient between the new portrait and the old background environment, which is the variance in value, S is the total number of pixels in the outline of the old portrait, and j i is the modulus of the distance vector to the new portrait particle; In step S7, the pixel blur number M of the edge point i The calculation formula is as follows: Among them, B i-1 is the blur index of the previous point of the edge point, ave(j1+j2+…j n ) is the average value of all distance moduli, representing the average distance from all edge points of the new portrait to the centroid, j i is the distance from the current edge point to the centroid, arctan[(B i -B i-1 )(B i+1 -B i )] is a normalized evaluation of the blurring index of adjacent edge points, indicating the difference in blurring index between the edge point and the adjacent edge points.
2. The method for audio and video synthesis processing based on artificial intelligence according to claim 1, characterized in that: Step S2 is specifically as follows: Use the deep auto-encoder-decoder model to iterate and train the model's ability to recognize and restore portraits multiple times. Repeat the cycle until the model is trained. Input the portrait into the trained deep auto-encoder-decoder model to obtain the corresponding new portrait.
3. The method for audio and video synthesis based on artificial intelligence according to claim 1, characterized in that: The number of pixels blurred is M i Round up to the integer number of pixels actually blurred.
4. The method for audio and video synthesis processing based on artificial intelligence according to claim 3 is characterized in that: Step S8 is specifically as follows: 8a. Connect the edge point and the centroid into a line as a separate axis. Take M pixels from both ends of the axis with the edge point as the center as the pixel points to be processed; 8b. According to the pre-set amplification coefficient Continue to select N pixel points on the axis. The number of pixel points to be selected should be And round N upwards; 8c. A total of 2 (M+N) pixels to be processed are selected. (M+N) pixels are selected on the axis in the direction of the particle, and (M+N) pixels are selected in the opposite direction. The selected pixels are subjected to average weighted transition blurring, that is, the weighted average of their RGB parameters is taken to complete the blurring process. 8d. Repeat the above operation to traverse each edge pixel in the image, and the blurring process of the entire image is completed.
