Optimization method, device and related components for portrait segmentation images

The original video frame image is processed through the portrait segmentation model, and size reduction, mean filtering and edge optimization are performed, which solves the problem of image sawtooth and unclear edges after video portrait segmentation, and realizes the natural transition and stable effect of image edges.

CN114140479BActive Publication Date: 2024-12-20SHENZHEN WONDERSHARE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111460044.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-02
Publication Date
2024-12-20
Estimated Expiration
2041-12-02

AI Technical Summary

Technical Problem

In the prior art, after video portrait segmentation, the image sawtooth phenomenon is serious and the edges are not clean and smooth enough, resulting in unstable edges of the foreground of the video portrait and obvious wavy shapes.

Method used

The original video frame image is processed through the portrait segmentation model, and size reduction, mean filtering, pixel value completion, edge optimization are performed, and finally enlarged to the original image size to achieve natural transition and sawtooth reduction at the edge of the image.

Benefits of technology

After portrait segmentation, the image edge transition is achieved with natural image edges without obvious jagging and unnecessary blurred edges, making the foreground edges of the video portrait look more stable and obtains better synthesis effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114140479B_ABST
    Figure CN114140479B_ABST
Patent Text Reader

Abstract

The present invention discloses an optimization method, device and related components for portrait segmentation images. The method comprises: using a portrait segmentation model to process each original image of an image sequence to obtain a first intermediate image after the size is reduced; performing mean filtering on the first intermediate image, completing the pixel value of each pixel point on the first intermediate image, and obtaining a second intermediate image; performing mean filtering on the second intermediate image, and traversing all edge pixel points of the processed second intermediate image, judging whether the pixel value of the current edge pixel point is greater than a preset optimization threshold, if greater, retaining the corresponding pixel value, if less, performing inward optimization processing on the current edge pixel point, and obtaining a third intermediate image; enlarging the third intermediate image to obtain a target image of the same size as the original image. The method can optimize the generated first intermediate image to achieve a natural transition of the image edge without obvious jagged edges and redundant blurred edges.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing, and in particular to an optimization method, device and related components for a portrait segmentation picture. Background Art

[0002] Video portrait segmentation refers to the segmentation of each frame of the video stream, separating the human body contour from the image background, and returning the segmented binary image, grayscale image or foreground image with transparent background; the portrait segmentation algorithm often obtains a grayscale mask image mask, which is used to segment the foreground portrait of the original input image separately, so as to superimpose more other operations on the foreground portrait or background, such as replacing the background, adding special effects to the edge of the human figure, etc.

[0003] The mask is usually a small-resolution grayscale (or binary) image. For example, portrait segmentation is performed on a newly input image or on each frame of a decoded video. The original image is 1280*720 in size, and the output image resolution after being processed by the portrait segmentation algorithm may be only 224*224.

[0004] General processing solutions or technologies include the following methods used alone or in combination: 1) using an interpolation algorithm to directly enlarge the image size from a small resolution to the resolution of the original image. This method will produce more obvious aliasing; 2) using the method in 1) and then performing edge smoothing (usually using mean filtering or Gaussian filtering, etc.), which can reduce certain aliasing, but will include a portion of the original image background, that is, the more obvious blurred "extra" edges of non-foreground characters, which will appear to be not clean and smooth enough in the video. Summary of the invention

[0005] The purpose of the present invention is to provide a method, device and related components for optimizing portrait segmentation images, aiming to solve the problems of image jaggedness and unclear and unclear image edges in videos processed by existing image optimization methods.

[0006] In order to solve the above technical problems, the object of the present invention is to achieve the following technical solutions: to provide a method for optimizing a portrait segmentation picture, which comprises:

[0007] After decoding the input initial video into an image sequence, processing each original frame of the image sequence using the portrait segmentation model to obtain a first intermediate image with a reduced size;

[0008] Performing mean filtering on the first intermediate image, and completing pixel values ​​of each pixel point on the processed first intermediate image to obtain a second intermediate image, so that pixel values ​​below a pixel threshold in the first intermediate image become smaller, pixel values ​​above the pixel threshold become larger, and the pixel value of each pixel point is between 0 and 1;

[0009] Performing mean filtering processing on the second intermediate image, and traversing all edge pixel points of all processed second intermediate images, determining whether the pixel value of the current edge pixel point is greater than a preset optimization threshold, if the pixel value of the current edge pixel point is greater than the preset optimization threshold, retaining the corresponding pixel value, and if the pixel value of the current edge pixel point is less than the preset optimization threshold, performing indentation optimization processing on the current edge pixel point to obtain a third intermediate image;

[0010] The third intermediate image is enlarged to obtain a target image of the same size as the original image.

[0011] In addition, the technical problem to be solved by the present invention is to provide an optimization device for a portrait segmentation picture, which comprises:

[0012] A reduction unit, configured to, after decoding the input initial video into an image sequence, process each original frame of the image sequence using a portrait segmentation model, and obtain a first intermediate image with a reduced size;

[0013] A preprocessing unit, configured to perform mean filtering on the first intermediate image, and to perform complement processing on the pixel value of each pixel point on the processed first intermediate image, so as to obtain a second intermediate image, so that the pixel values ​​below the pixel threshold in the first intermediate image become smaller, the pixel values ​​above the pixel threshold become larger, and the pixel value of each pixel point is between 0 and 1;

[0014] an optimization unit, configured to perform mean filtering processing on the second intermediate image, and traverse all edge pixel points of all processed second intermediate images, and determine whether a pixel value of a current edge pixel point is greater than a preset optimization threshold value; if the pixel value of the current edge pixel point is greater than the preset optimization threshold value, retain the corresponding pixel value; if the pixel value of the current edge pixel point is less than the preset optimization threshold value, perform indentation optimization processing on the current edge pixel point to obtain a third intermediate image;

[0015] The enlarging unit is used to enlarge the third intermediate image to obtain a target image of the same size as the original image.

[0016] In addition, an embodiment of the present invention provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for optimizing the portrait segmentation image described in the first aspect above is implemented.

[0017] In addition, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method for optimizing portrait segmentation images described in the first aspect above.

[0018] The embodiment of the present invention discloses an optimization method, device and related components for portrait segmentation pictures, wherein the method comprises: after decoding an input initial video into an image sequence, using a portrait segmentation model to process each frame of the original image of the image sequence, and correspondingly obtaining a first intermediate image after the size is reduced; performing mean filtering processing on the first intermediate image, and completing the pixel value of each pixel point on the processed first intermediate image, to obtain a second intermediate image, so that the pixel values ​​below the pixel threshold in the first intermediate image become smaller, and the pixel values ​​above the pixel threshold become larger, and the pixel value of each pixel point is between 0 and 1; performing mean filtering processing on the second intermediate image, and traversing all edge pixel points of all processed second intermediate images, judging whether the pixel value of the current edge pixel point is greater than a preset optimization threshold, if the pixel value of the current edge pixel point is greater than the preset optimization threshold, retaining the corresponding pixel value, if the pixel value of the current edge pixel point is less than the preset optimization threshold, performing indentation optimization processing on the current edge pixel point, to obtain a third intermediate image; enlarging the third intermediate image, to obtain a target image of the same size as the original image. This method can optimize the first intermediate image generated after portrait segmentation to achieve a natural transition of image edges without obvious jagged edges and unnecessary blurred edges, thereby making the edges of the foreground of the re-encoded video portrait appear more stable without obvious waves, thereby obtaining a better synthesis effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.

[0020] Figure 1 A schematic diagram of a flow chart of a method for optimizing a portrait segmentation image provided by an embodiment of the present invention;

[0021] Figure 2 A schematic flow chart of a method for optimizing a portrait segmentation image provided by a specific embodiment of the present invention;

[0022] Figure 3 A schematic diagram of the structure of a window provided by an embodiment of the present invention;

[0023] Figure 4 A schematic diagram of a sub-process of a method for optimizing a portrait segmentation image provided by an embodiment of the present invention

[0024] Figure 5 A schematic block diagram of a device for optimizing a portrait segmentation image provided by an embodiment of the present invention;

[0025] Figure 6 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0028] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0029] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0030] See also Figure 1 , Figure 1 A schematic diagram of a flow chart of a method for optimizing a portrait segmentation image provided by an embodiment of the present invention;

[0031] like Figure 1 As shown, the method includes steps S101 to S104.

[0032] S101, after decoding the input initial video into an image sequence, using a portrait segmentation model to process each frame of the image sequence, and correspondingly obtaining a first intermediate image after size reduction;

[0033] S102, performing mean filtering processing on the first intermediate image, and completing pixel values ​​of each pixel point on the processed first intermediate image to obtain a second intermediate image, so that pixel values ​​below a pixel threshold in the first intermediate image become smaller, pixel values ​​above the pixel threshold become larger, and the pixel value of each pixel point is between 0 and 1;

[0034] S103, performing mean filtering processing on the second intermediate image, and traversing all edge pixel points of all processed second intermediate images, determining whether the pixel value of the current edge pixel point is greater than a preset optimization threshold, if the pixel value of the current edge pixel point is greater than the preset optimization threshold, retaining the corresponding pixel value, if the pixel value of the current edge pixel point is less than the preset optimization threshold, performing indentation optimization processing on the current edge pixel point, and obtaining a third intermediate image;

[0035] S104: Enlarge the third intermediate image to obtain a target image of the same size as the original image.

[0036] In the actual image processing process, on the basis of accurate segmentation effect of portrait segmentation (no portrait segmentation error), if the foreground edge of the character to be obtained looks smooth and natural without obvious jagged edges, and if the new background is replaced and the edge has a natural transition sense after fusion, then the processing of the mask is extremely important. It should be noted that the mask represents the image obtained after processing by the portrait segmentation model, such as the first intermediate image, the second intermediate image and the third intermediate image in this application.

[0037] Combination Figure 2 In this embodiment, the portrait segmentation technology is first used to segment the foreground characters of the video frame sequence, and then the segmented original image is successively reduced, mean filtered, completed, mean filtered and optimized by shrinking, and finally enlarged to obtain a target image with the same size as the original image. The optimization and improvement method of the present application can optimize the first intermediate image generated after the portrait segmentation, so as to achieve a natural transition of the image edge without obvious jagged edges and unnecessary blurred edges, thereby making the edge of the foreground of the re-encoded video portrait look more stable without obvious wavy shapes, thereby obtaining a better synthesis effect.

[0038] In one embodiment, step S101 includes the following steps:

[0039] S10, decoding the input initial video into an image sequence, and performing portrait segmentation on each frame of the original image in the image sequence using a portrait segmentation model to obtain a grayscale image or a binary image with a size of M×N;

[0040] S11. Use a bicubic difference method to reduce the grayscale image or the binary image to obtain a first intermediate image of 0.5M×0.5N.

[0041] In this embodiment, after the initial video is decoded into an image sequence, the original image in the image sequence is processed frame by frame using a portrait segmentation model to obtain a grayscale image or a binary image of size M×N, wherein the grayscale image or the binary image is used to obtain the portrait foreground from the original image and synthesize a new image, and the pixel value of each pixel in the grayscale image is between 0 and 1, a value of 0 indicates that the pixel belongs to the background image, a value of 1 indicates that the pixel belongs to the foreground of the person, and a value between 0 and 1 indicates how likely the pixel is to belong to the foreground image, wherein it should be noted that the pixel value of the pixel in the binary image has only two values, 1 and 0, indicating that the pixel is either the foreground or the background.

[0042] It should be noted that the portrait segmentation model is processed using a deep learning-based method. For example, models with HRNetV2 and EfficientNet as the main networks are used for portrait segmentation processing. The grayscale or binary image is the output result after being processed by the portrait segmentation model. The resolution of the grayscale or binary image obtained by different portrait segmentation models will be different.

[0043] In step S11, the grayscale image or binary image is reduced by using the bicubic difference method to obtain a first intermediate image of 0.5M×0.5N, that is, the grayscale image or binary image is reduced by 0.5 times. In actual application scenarios, the grayscale image or binary image can also be reduced to other multiples, but the reduction multiple is preferably set in the range of 0.3 to 0.6. If the reduction multiple is too small, there will be obvious jaggedness when it is finally restored to the same size as the original image, and if the reduction multiple is too large, the processing speed will increase.

[0044] It should be noted that the bicubic difference, i.e., the value of the function f at (x, y), can be obtained by weighted average of the sixteen nearest sampling points in the rectangular network. In this embodiment, two polynomial difference cubic functions are required, one for each direction, wherein the bicubic interpolation formula is:

[0045]

[0046] Among them, a(i, j) is the weighting coefficient;

[0047] In this embodiment, the weighting coefficient is solved according to the following formula:

[0048]

[0049] Among them, a=-0.5.

[0050] In a specific embodiment, in step S102, a relatively simple mean filter is selected to obtain a relatively smooth transition, and the algorithm used is simple and fast. It should be noted that mean smoothing means that for each element, within a window centered on the element, the average value of the pixel value of the field pixel point is taken to replace the pixel value of the pixel point. The window generally selects odd values ​​such as 3×3 or 5×5.

[0051] like Figure 3 As shown, with the pixel value of 0.3 as the center, covering a 3×3 window, the following calculation is performed:

[0052] Value=(0.3×1+0.4×1+0.15×1+0.01×1+0.3×1+0.58×1+0.77×1+0.14×1+0.35×1) / 9;

[0053] Replace 0.3 with the calculated value of Value, then move the window one pixel to the right, and calculate with the pixel point centered at 0.58 as the center. And so on. Move the window from the beginning of the image to the right to the edge, then return to the next pixel point as the center to calculate and slide to the right until it reaches the edge. It is worth noting that after testing multiple window scales, this application found that choosing a 7×7 window can achieve better results.

[0054] In one embodiment, the step S102 performs a completion process on the pixel value of each pixel point on the processed first intermediate image to obtain the second intermediate image, including:

[0055] S20, completing the pixel value of the current pixel point according to the following formula:

[0056] I * (x,y) =p1×(p1 / s)

[0057] Wherein, p1 represents the pixel value of the pixel at the xth row and yth column of the first intermediate image, and s represents the pixel threshold;

[0058] S21, intercept the pixel value of the current pixel point according to the following formula:

[0059]

[0060] Among them, I (x,y) Represents the pixel value of the pixel at the xth row and yth column of the second intermediate image.

[0061] In this embodiment, during the portrait segmentation, i.e., the execution of step S10, erroneous segmentation may actually occur. For example, the background may be mistakenly identified as the foreground portrait, and the pixel value of each pixel of this part may be greater than 0, and the pixel value of the pixel of this part may be closer to 0; or some parts of the body of the background portrait may be mistakenly segmented as the background, and the pixel value of each pixel of this part may be less than 1, and the pixel value of the pixel of this part may be closer to 1.

[0062] Therefore, this application uses the above formula to complement the pixel values ​​of the pixels, that is, the larger the pixel value of the large pixel is, the higher the probability of being classified as the foreground; the smaller the pixel value of the small pixel is, the higher the probability of being classified as the background. Assuming that the pixel threshold is 0.39, if p1 = 0.6, then after calculation I (x,y) =0.92; if p1 = 0.1, then after calculation I (x,y) =0.025, at the same time, when I * (x,y) When I is greater than 1, (x,y) Equal to 1, when I * (x,y) When I is less than 1, (x,y) Equal to 0, the calculation of the above formula will make the pixel values ​​of the pixels greater than the pixel threshold that are mis-segmented in the human body part larger after calculation, indicating that they are closer to the foreground. Similarly, the pixel values ​​of the pixels below the pixel threshold that are mis-segmented in the background will be smaller after calculation, indicating that they are closer to the background.

[0063] Furthermore, the pixel threshold value ranges from 0.27 to 0.52.

[0064] According to the actual situation, the pixel threshold is selected in the range of 0.27-0.52, which has a better completion effect.

[0065] In one embodiment, if the pixel value of the current edge pixel point is less than a preset optimization threshold in step S103, the current edge pixel point is subjected to indentation optimization processing to obtain a third intermediate image, including:

[0066] S30, performing internal contraction optimization processing on the pixel value of the current edge pixel point according to the following formula:

[0067] II (x,y) =p2×(p2 / retrackThreshold)

[0068] Where p2 represents the pixel value of the current edge pixel in the xth row and yth column of the second intermediate image, II (x,y) represents the pixel value of the pixel at the xth row and yth column in the third intermediate image, and retrackThreshold represents the optimization threshold.

[0069] It should be noted that the mean filter processing principle in step S103 is consistent with that in step S102, but the window of the mean filter in step S103 is preferably set to 3×3, which can improve the speed and obtain better results.

[0070] The optimization threshold in step S103 is used to determine whether further processing is required for the image edge. For example, the closer the pixel at the edge of the image is to the foreground, the larger the pixel value of the pixel, and the closer the pixel is to the portrait edge, the smaller the pixel value. If the pixel value of the edge pixel is higher than the preset optimization threshold, which indicates the maximum value of the image to be processed at the edge, the edge pixel will not be processed. If it is lower than the preset optimization threshold, the edge pixel needs to be indented for optimization.

[0071] For videos of different resolutions, the first intermediate image generated by the portrait segmentation algorithm is unified, and the degree of edge processing should be related to the size of the original image. From this reference, videos of different resolutions can achieve good processing effects after processing. Therefore, this application processes the edge pixels that need to be optimized by shrinking through the formula of step S30.

[0072] Furthermore, the value range of the optimization threshold is 0.780-0.810.

[0073] After performing multiple optimization threshold tests, the present application found that processing with a value in the range of 0.780-0.810 has a better processing effect.

[0074] Reference Figure 4 In one embodiment, after step S30, the following steps are performed:

[0075] S40, recording the cumulative number of times the current edge pixel is subjected to the indentation optimization process;

[0076] S41, determining whether the cumulative number of times the indentation optimization process of the current edge pixel point is greater than a preset cycle number threshold, if the cumulative number of times the indentation optimization process of the current edge pixel point is less than the preset cycle number threshold, sequentially executing steps S42 and S43; if the cumulative number of times the indentation optimization process of the current edge pixel point is greater than the preset cycle number threshold, obtaining a third intermediate image;

[0077] S42, performing mean filtering on the current edge pixel point;

[0078] S43, perform indentation optimization processing on the current edge pixel point, and return to step S40.

[0079] By determining the number of times the current edge pixel point has been subjected to the indentation optimization process in this embodiment, the edge pixel point that has been subjected to the indentation optimization process can be repeatedly subjected to the indentation optimization process, thereby further improving the effect of optimizing the edge. Specifically, when N / n<2, N / n=2, where N represents the width of the original image and n represents the width of the first intermediate image. Through such a design, the edge pixel point in the second intermediate image can be guaranteed to undergo at least two edge indentation processes to achieve the effect of optimizing the edge.

[0080] In step S104, the third intermediate image is enlarged using a bicubic interpolation method to obtain a target image of the same size as the original image.

[0081] It should be noted that the principles of the bicubic difference method in step S104 and step S11 are consistent, and finally the third intermediate image of size 0.5M×0.5N is re-enlarged to the target image of M×N. Through the optimization and improvement method of the present application, the generated grayscale image or binary image can be optimized after the portrait segmentation to achieve a natural transition of the image edge without obvious jagged edges and unnecessary blurred edges, thereby making the edge of the foreground of the re-encoded video portrait look more stable without obvious wavy shapes, thereby obtaining a better synthesis effect.

[0082] The embodiment of the present invention further provides a device for optimizing a portrait segmentation image, which is used to execute any embodiment of the above-mentioned method for optimizing a portrait segmentation image. Figure 5 , Figure 5 It is a schematic block diagram of a device for optimizing a portrait segmentation image provided by an embodiment of the present invention.

[0083] like Figure 5 As shown, the optimization device 500 for portrait segmentation pictures includes:

[0084] The reduction unit 501 is used to process each frame of the image sequence by using the portrait segmentation model after decoding the input initial video into the image sequence, and obtain a first intermediate image with a reduced size;

[0085] The preprocessing unit 502 is used to perform mean filtering on the first intermediate image, and to perform complement processing on the pixel value of each pixel point on the processed first intermediate image to obtain a second intermediate image, so that the pixel values ​​below the pixel threshold in the first intermediate image become smaller, the pixel values ​​above the pixel threshold become larger, and the pixel value of each pixel point is between 0 and 1;

[0086] The optimization unit 503 is used to perform mean filtering processing on the second intermediate image, and traverse all edge pixel points of all processed second intermediate images to determine whether the pixel value of the current edge pixel point is greater than a preset optimization threshold value. If the pixel value of the current edge pixel point is greater than the preset optimization threshold value, the corresponding pixel value is retained; if the pixel value of the current edge pixel point is less than the preset optimization threshold value, the current edge pixel point is subjected to indentation optimization processing to obtain a third intermediate image;

[0087] The enlarging unit 504 is used to enlarge the third intermediate image to obtain a target image of the same size as the original image.

[0088] The device can optimize the grayscale image or binary image generated after portrait segmentation to achieve natural image edge transition without obvious jagged edges and unnecessary blurred edges, thereby making the edge of the foreground of the re-encoded video portrait look more stable without obvious waves, thereby obtaining a better synthesis effect.

[0089] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0090] The above-mentioned device for optimizing the portrait segmentation picture can be implemented in the form of a computer program. The computer program can be used in Figure 6 Runs on the computer device shown.

[0091] See also Figure 6 , Figure 6 11 is a schematic block diagram of a computer device provided by an embodiment of the present invention. The computer device 1100 is a server, which may be an independent server or a server cluster composed of multiple servers.

[0092] See also Figure 6 The computer device 1100 includes a processor 1102 , a memory, and a network interface 1105 connected via a system bus 1101 , wherein the memory may include a non-volatile storage medium 1103 and an internal memory 1104 .

[0093] The non-volatile storage medium 1103 can store an operating system 11031 and a computer program 11032. When the computer program 11032 is executed, the processor 1102 can execute the optimization method for portrait segmentation pictures.

[0094] The processor 1102 is used to provide computing and control capabilities to support the operation of the entire computer device 1100 .

[0095] The internal memory 1104 provides an environment for the operation of the computer program 11032 in the non-volatile storage medium 1103. When the computer program 11032 is executed by the processor 1102, the processor 1102 can execute the optimization method for portrait segmentation pictures.

[0096] The network interface 1105 is used for network communication, such as providing data information transmission, etc. Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present invention, and does not constitute a limitation on the computer device 1100 to which the solution of the present invention is applied. The specific computer device 1100 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0097] Those skilled in the art will understand that Figure 6 The embodiments of the computer device shown in the figure do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and the processor are the same as those of the embodiment of the present invention. Figure 6 The embodiments shown are consistent and will not be described again here.

[0098] It should be understood that in the embodiment of the present invention, the processor 1102 may be a central processing unit (CPU), and the processor 1102 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0099] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the optimization method for the portrait segmentation picture of the embodiment of the present invention is implemented.

[0100] The storage medium is a physical, non-transient storage medium, for example, it can be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, etc., which can store program codes.

[0101] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0102] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for optimizing portrait segmentation images, characterized in that: include: After decoding the input initial video into an image sequence, processing each original frame of the image sequence using the portrait segmentation model to obtain a first intermediate image with a reduced size; Performing mean filtering on the first intermediate image, and completing pixel values ​​of each pixel point on the processed first intermediate image to obtain a second intermediate image, so that pixel values ​​below a pixel threshold in the first intermediate image become smaller, pixel values ​​above the pixel threshold become larger, and the pixel value of each pixel point is between 0 and 1; Performing mean filtering processing on the second intermediate image, and traversing all edge pixel points of all processed second intermediate images, determining whether the pixel value of the current edge pixel point is greater than a preset optimization threshold, if the pixel value of the current edge pixel point is greater than the preset optimization threshold, retaining the corresponding pixel value, and if the pixel value of the current edge pixel point is less than the preset optimization threshold, performing indentation optimization processing on the current edge pixel point to obtain a third intermediate image; Enlarging the third intermediate image to obtain a target image of the same size as the original image; If the pixel value of the current edge pixel point is less than the preset optimization threshold, the current edge pixel point is subjected to indentation optimization processing to obtain a third intermediate image, including: The pixel value of the current edge pixel is internally optimized as follows: II (x,y) =p2×(p2 / retrackThreshold) Where p2 represents the pixel value of the current edge pixel in the xth row and yth column of the second intermediate image, II (x,y) represents the pixel value of the pixel at the xth row and yth column in the third intermediate image, and retrackThreshold represents the optimization threshold.

2. The method for optimizing portrait segmentation images according to claim 1, characterized in that: After decoding the input initial video into an image sequence, using the portrait segmentation model to process each frame of the image sequence to obtain a first intermediate image with a reduced size, including: Decode the input initial video into an image sequence, and use the portrait segmentation model to perform portrait segmentation on each frame of the original image in the image sequence to obtain a grayscale image or a binary image with a size of M×N; The grayscale image or the binary image is reduced by using a bicubic difference method to obtain a first intermediate image of 0.5M×0.5N.

3. The method for optimizing portrait segmentation images according to claim 1, characterized in that: The step of completing the pixel value of each pixel point on the processed first intermediate image to obtain the second intermediate image includes: Completing the pixel value of the current pixel point is done as follows: I * (x,y) =p1×(p1 / s) Wherein, p1 represents the pixel value of the pixel at the xth row and yth column of the first intermediate image, and s represents the pixel threshold; The pixel value of the current pixel is intercepted according to the following formula: Among them, I (x,y) Represents the pixel value of the pixel at the xth row and yth column of the second intermediate image.

4. The method for optimizing portrait segmentation images according to claim 3, characterized in that: The pixel threshold value ranges from 0.27 to 0.

52.

5. The method for optimizing portrait segmentation images according to claim 1, characterized in that: The value range of the optimization threshold is 0.780-0.

810.

6. The method for optimizing portrait segmentation images according to claim 1 or 5, characterized in that: After the pixel value of the current edge pixel point is internally optimized according to the following formula, it includes: Record the cumulative number of times the indentation optimization process of the current edge pixel point has been processed, and determine whether the cumulative number of times the indentation optimization process of the current edge pixel point is greater than a preset cycle number threshold; If the cumulative number of indentation optimization processing of the current edge pixel point is less than the preset loop number threshold, continue to perform mean filtering and indentation optimization processing on the current edge pixel point until the cumulative number of indentation optimization processing of the current edge pixel point is greater than the preset loop number threshold, and obtain the third intermediate image.

7. An optimization device for portrait segmentation pictures, characterized in that: include: A reduction unit, configured to, after decoding the input initial video into an image sequence, process each original frame of the image sequence using a portrait segmentation model, and obtain a first intermediate image with a reduced size; A preprocessing unit, configured to perform mean filtering on the first intermediate image, and to perform complement processing on the pixel value of each pixel point on the processed first intermediate image, so as to obtain a second intermediate image, so that the pixel values ​​below the pixel threshold in the first intermediate image become smaller, the pixel values ​​above the pixel threshold become larger, and the pixel value of each pixel point is between 0 and 1; an optimization unit, configured to perform mean filtering processing on the second intermediate image, and traverse all edge pixel points of all processed second intermediate images, and determine whether a pixel value of a current edge pixel point is greater than a preset optimization threshold value; if the pixel value of the current edge pixel point is greater than the preset optimization threshold value, retain the corresponding pixel value; if the pixel value of the current edge pixel point is less than the preset optimization threshold value, perform indentation optimization processing on the current edge pixel point to obtain a third intermediate image; an enlarging unit, used for enlarging the third intermediate image to obtain a target image of the same size as the original image; If the pixel value of the current edge pixel point is less than the preset optimization threshold, the current edge pixel point is subjected to indentation optimization processing to obtain a third intermediate image, including: The pixel value of the current edge pixel is internally optimized as follows: II (x,y) =p2×(p2 / retrackThreshold) Where p2 represents the pixel value of the current edge pixel in the xth row and yth column of the second intermediate image, II (x,y) represents the pixel value of the pixel at the xth row and yth column in the third intermediate image, and retrackThreshold represents the optimization threshold.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for optimizing the portrait segmentation picture according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the method for optimizing a portrait segmentation image according to any one of claims 1 to 6.