CN117793479B - Rapid generation method of smooth transition video mask - Google Patents

Rapid generation method of smooth transition video mask Download PDF

Info

Publication number
CN117793479B
CN117793479B CN202311799988.8A CN202311799988A CN117793479B CN 117793479 B CN117793479 B CN 117793479B CN 202311799988 A CN202311799988 A CN 202311799988A CN 117793479 B CN117793479 B CN 117793479B
Authority
CN
China
Prior art keywords
mask
reference mask
smooth transition
masks
control point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311799988.8A
Other languages
Chinese (zh)
Other versions
CN117793479A (en
Inventor
谷显峰
张磊
禚春升
刘国栋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dayang Technology Development Inc
Original Assignee
Beijing Dayang Technology Development Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dayang Technology Development Inc filed Critical Beijing Dayang Technology Development Inc
Priority to CN202311799988.8A priority Critical patent/CN117793479B/en
Publication of CN117793479A publication Critical patent/CN117793479A/en
Application granted granted Critical
Publication of CN117793479B publication Critical patent/CN117793479B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a method for rapidly generating a smooth transition video mask, which comprises the following steps: step 1, sketching a reference mask; step 2, determining a quantization control point reference mask; step 3: a smooth transition mask is generated. The method can quickly generate the smooth transition mask according to the front and rear adjacent reference masks without the condition limitation, has simple calculation mode and high efficiency and precision, realizes the gradual change of the mask shape without limitation, can lead an editor to finish the mask generation in the whole time period under the condition of only providing a small quantity of video mask forms, effectively reduces the labor and time cost and greatly improves the working efficiency of the editor.

Description

Rapid generation method of smooth transition video mask
Technical Field
The invention belongs to the technical field of video editing, and particularly relates to a method for rapidly generating a smooth transition video mask.
Background
With the development of universal media, video editing applications are becoming wider and wider, for example, in video editing, local color correction of video images, face beautification, secret shielding of image information of interviewees, etc. are required, and how to quickly implement such a video mask with long gradual change is a key to restrict editing efficiency.
The video mask is referred to as a video mask for short, which refers to a region enclosed by a closed curve in a video picture, and the shape of the video mask is a smooth region surrounded by a plurality of straight line segments and a plurality of Bezier curves. During video editing, the mask is time-varying, as the shape that the editor is circled in different time periods is different. Reference mask refers to both the start and end masks used to generate the transition mask. The transition mask refers to a gradual change mask generated according to the distance ratio and according to two reference masks of the start point and the end point. The smooth transition of the mask refers to any two adjacent masks at different time positions in a video, and the shape of the inner ring in the time period is changed from the mask A to the mask B smoothly, so that the abrupt change state does not exist. The gradual change of the mask shape is not limited, namely, a transition mask is generated between two reference masks, the generation process is not limited by the parameter conditions of the two reference masks, and the mask parameter conditions refer to the control form of a closed curve (such as Bezier curve (secondary, tertiary) or other curve control modes).
In the video clip editing process, a specific video area, that is, a video mask, may need to be specially processed, and the shape may be different according to the manner of processing. Moreover, as time progresses, the video mask is displaced, the shape is changed, and the like, so that editors need to change the mask shape at different time points, and the parameters of the closed curve forming the mask before and after the mask may be greatly changed, for example, the numbers of line segments forming the closed curve are different, the positions are different, and the like. The generated mask is used for secondary development, such as blurring the face of the mask region, beautifying the face of the mask region, bluing the sky of the mask region, and the like. The cost of both time and labor is significant if the editor is to draw a mask for each frame of image. Therefore, a rapid smooth intermediate mask state is needed to solve such problems.
The original mask transition mode is based on the number of line segments on a mask curve, and the line segment control points are correspondingly transformed. It is difficult for an editor to quickly create a transition mask when adding one or more control points to a profile to change shape. Therefore, how to quickly generate a transition mask to realize a smooth transition of the mask is a technical problem that needs to be solved in the art.
Disclosure of Invention
The invention aims to provide a method for quickly generating a smooth transition video mask so as to solve the technical problems.
In order to achieve the above purpose, the present invention provides the following technical solutions:
the invention discloses a method for rapidly generating a smooth transition video mask, which comprises the following steps:
Step 1, sketching a reference mask: drawing a region to be processed, namely a first reference mask, at a certain time position on a video file to be edited, moving a time line, drawing a region to be processed, namely a second reference mask, at another time position, and drawing a plurality of reference masks based on different time positions in sequence according to requirements;
Step 2, determining a quantization control point reference mask: finding out two adjacent reference masks before and after the appointed time position according to the appointed time position of the video file by the user, and determining a quantized control point reference mask;
Step 3, generating a smooth transition mask: determining the number of quantization control points according to the quantization control point reference masks, respectively dividing the two reference masks according to the determined number of the quantization control points by the respective equal division lengths, calculating points on the closed curves along the trend of the closed curves, carrying out point-to-point interpolation on the points on the two closed curves according to the time-distance ratio, generating new control points, and sequentially drawing the new control points into a closed curve, wherein the area enclosed by the closed curve is the transition mask.
Further, the manners of determining the quantization control point reference mask in the step 2 include two manners, which are respectively:
The first way is: calculating the circumferences of the front reference mask and the rear reference mask respectively, and taking the reference mask with larger circumferences of the front reference mask and the rear reference mask as a quantization control point reference mask;
The second way is: and respectively calculating the perimeter and the area of the front and rear reference masks, then respectively calculating the ratio of the perimeter to the area of the front and rear reference masks, and taking the reference mask with larger ratio of the perimeter to the area in the front and rear reference masks as the quantized control point reference mask.
Further, the specific process of determining the number of quantization control points in the step3 is as follows: and calculating the total curve length according to the bending state of the quantized control point reference mask, finding out the minimum broken line length, and dividing the total curve length by the minimum broken line length to calculate the number of the control points.
The beneficial effects of the invention are as follows: the method for quickly generating the smooth transition video mask can quickly generate the smooth transition mask according to the front and rear adjacent reference masks without the limitation, has simple calculation mode and high efficiency and precision, realizes that the shape gradient of the mask is not limited, can enable an editor to finish the mask generation of the whole time period under the condition that only a small amount of video mask forms are needed, effectively reduces the labor and time cost, and greatly improves the working efficiency of the editor.
The invention will be described in further detail with reference to the drawings and the detailed description.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
The invention discloses a method for rapidly generating a smooth transition video mask, as shown in fig. 1, which comprises the following steps:
step 1, sketching a reference mask: the video file to be edited is placed on a non-editing storyboard, a region to be processed, namely a first reference mask, is drawn by a mouse at a certain time position on the video file, a time line is moved, a region to be processed, namely a second reference mask, is drawn by a mouse at another time position, and a plurality of reference masks based on different time positions can be drawn sequentially according to requirements.
Step 2, determining a quantization control point reference mask: and according to any time position of the video file designated by the user, finding out two adjacent reference masks before and after the designated time position, and determining a quantized control point reference mask.
The method for determining the quantization control point reference mask comprises two modes, namely:
The first way is: calculating the circumferences of the front reference mask and the rear reference mask respectively, and taking the reference mask with larger circumferences of the front reference mask and the rear reference mask as a quantization control point reference mask;
the second way is: and respectively calculating the perimeter and the area of the surrounding area of the front reference mask and the rear reference mask, then respectively calculating the ratio of the perimeter to the area of the front reference mask and the rear reference mask, wherein the larger the ratio of the perimeter to the area is, the larger the complexity of the representative curve and the change of the curvature are, and taking the reference mask with the larger ratio of the perimeter to the area in the front reference mask and the rear reference mask as a quantization control point reference mask.
The two modes aim at determining the number of quantization control points of the transition mask, wherein the more the number of quantization control points is, the higher the precision is, but the speed is reduced; the number of generated control points is too small to meet the smoothness and shape accuracy of the closed curve, so that the appropriate number of quantized control points needs to be determined.
Step 3, generating a smooth transition mask: determining the number of quantization control points according to the quantization control point reference masks, respectively dividing the two reference masks according to the determined number of the quantization control points by the respective equal division lengths, calculating points on a closed curve along the trend of the closed curve, carrying out point-to-point interpolation on the points on the two closed curves according to the time-distance ratio, generating new control points, and drawing the new control points obtained by interpolation in sequence to form a closed curve, wherein the area enclosed by the closed curve is the transition mask.
The specific process for determining the number of the quantization control points is as follows: and calculating the total curve length (namely the perimeter of the quantized control point reference mask) according to the meandering state of the quantized control point reference mask, finding out the minimum polyline length, and dividing the total curve length by the minimum polyline length to calculate the number of the control points.
For a closed curve, the closed curve is approximated by a polygon, and the polygon is generated by the following steps: firstly, on a closed curve, dense line segments with a spacing of one pixel point are divided, then the dense line segments are simplified into approximately sparse line segments, namely, a plurality of adjacent line segments approximately in a straight line are integrated into a large straight line segment (a certain threshold value is adopted for integration, and the threshold value is set according to experience), so that a polygon (approximate curve) formed by a few line segments can be generated, and the shortest line segment of the polygon is found out as the minimum broken line of the curve.
According to the steps, a new transition mask can be generated at any time position of video editing and used for secondary rendering and the like, so that smooth transition of the video mask is realized, the generation process is not limited by parameter conditions of two reference masks, and the gradual change of the shape of the mask is realized.
Finally, it should be noted that the above description is only for the purpose of illustrating the technical solution of the present invention and not for the purpose of limiting the same, and that although the present invention has been described in detail with reference to the preferred arrangement, it will be understood by those skilled in the art that modifications and equivalents may be made thereto without departing from the spirit and scope of the technical solution of the present invention.

Claims (3)

1. A method for rapidly generating a smooth transition video mask is characterized by comprising the following steps:
Step 1, sketching a reference mask: drawing a region to be processed, namely a first reference mask, at a certain time position on a video file to be edited, moving a time line, drawing a region to be processed, namely a second reference mask, at another time position, and drawing a plurality of reference masks based on different time positions in sequence according to requirements;
Step 2, determining a quantization control point reference mask: finding out two adjacent reference masks before and after the appointed time position according to the appointed time position of the video file by the user, and determining a quantized control point reference mask;
Step 3, generating a smooth transition mask: determining the number of quantization control points according to the quantization control point reference masks, respectively dividing the two reference masks according to the determined number of the quantization control points by the respective equal division lengths, calculating points on the closed curves along the trend of the closed curves, carrying out point-to-point interpolation on the points on the two closed curves according to the time-distance ratio, generating new control points, and sequentially drawing the new control points into a closed curve, wherein the area enclosed by the closed curve is the transition mask.
2. The method for quickly generating a smooth transition video mask according to claim 1, wherein the method for determining the quantization control point reference mask in step 2 includes two methods, respectively:
The first way is: calculating the circumferences of the front reference mask and the rear reference mask respectively, and taking the reference mask with larger circumferences of the front reference mask and the rear reference mask as a quantization control point reference mask;
The second way is: and respectively calculating the perimeter and the area of the front and rear reference masks, then respectively calculating the ratio of the perimeter to the area of the front and rear reference masks, and taking the reference mask with larger ratio of the perimeter to the area in the front and rear reference masks as the quantized control point reference mask.
3. The method for quickly generating a smooth transition video mask according to claim 1, wherein the specific process of determining the number of quantization control points in step3 is as follows: and calculating the total curve length according to the bending state of the quantized control point reference mask, finding out the minimum broken line length, and dividing the total curve length by the minimum broken line length to calculate the number of the control points.
CN202311799988.8A 2023-12-26 2023-12-26 Rapid generation method of smooth transition video mask Active CN117793479B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311799988.8A CN117793479B (en) 2023-12-26 2023-12-26 Rapid generation method of smooth transition video mask

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311799988.8A CN117793479B (en) 2023-12-26 2023-12-26 Rapid generation method of smooth transition video mask

Publications (2)

Publication Number Publication Date
CN117793479A CN117793479A (en) 2024-03-29
CN117793479B true CN117793479B (en) 2024-05-14

Family

ID=90382762

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311799988.8A Active CN117793479B (en) 2023-12-26 2023-12-26 Rapid generation method of smooth transition video mask

Country Status (1)

Country Link
CN (1) CN117793479B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108592786A (en) * 2018-01-24 2018-09-28 清华大学深圳研究生院 A kind of device and method judging grating scale reference position
CN110728666A (en) * 2019-10-08 2020-01-24 中山大学附属第三医院 Typing method and system for chronic nasosinusitis based on digital pathological slide
CN113495424A (en) * 2020-04-08 2021-10-12 中芯国际集成电路制造(上海)有限公司 Optical proximity correction method and manufacturing method of mask
CN115587991A (en) * 2022-10-20 2023-01-10 东方晶源微电子科技(北京)有限公司 Curve mask extraction method, curve mask extraction device and storage medium
CN115953561A (en) * 2022-12-14 2023-04-11 广州虎牙信息科技有限公司 3D model hairstyle processing method and device and electronic equipment
CN116418932A (en) * 2021-12-30 2023-07-11 华为技术有限公司 Video frame interpolation method and device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9237322B2 (en) * 2013-02-07 2016-01-12 Cyberlink Corp. Systems and methods for performing selective video rendering

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108592786A (en) * 2018-01-24 2018-09-28 清华大学深圳研究生院 A kind of device and method judging grating scale reference position
CN110728666A (en) * 2019-10-08 2020-01-24 中山大学附属第三医院 Typing method and system for chronic nasosinusitis based on digital pathological slide
CN113495424A (en) * 2020-04-08 2021-10-12 中芯国际集成电路制造(上海)有限公司 Optical proximity correction method and manufacturing method of mask
CN116418932A (en) * 2021-12-30 2023-07-11 华为技术有限公司 Video frame interpolation method and device
CN115587991A (en) * 2022-10-20 2023-01-10 东方晶源微电子科技(北京)有限公司 Curve mask extraction method, curve mask extraction device and storage medium
CN115953561A (en) * 2022-12-14 2023-04-11 广州虎牙信息科技有限公司 3D model hairstyle processing method and device and electronic equipment

Also Published As

Publication number Publication date
CN117793479A (en) 2024-03-29

Similar Documents

Publication Publication Date Title
US8194974B1 (en) Merge and removal in a planar map of an image
CN104935832B (en) For the video keying method with depth information
US7929755B1 (en) Planar map to process a raster image
EP3005368B1 (en) Image edits propagation to underlying video sequence via dense motion fields.
Sýkora et al. StyleBlit: Fast Example‐Based Stylization with Local Guidance
AU6872798A (en) Methods and apparatus for changing a color of an image
CN116738579B (en) Automatic construction method and system for parting line of automobile panel
CN110248132B (en) Video frame rate interpolation method
CN106600663B (en) A kind of simple curve smoothing method based on quadratic b-spline curve
CN111179276B (en) Image processing method and device
AU2014277854A1 (en) Emboldening of outline fonts
CN108021097A (en) Tool path generating means, tool path generation method and storage medium
CN111951345B (en) GPU-based real-time image video oil painting stylization method
CN104155915A (en) Optical element random processing path planning method
Browning et al. Stylized keyframe animation of fluid simulations
Lawonn et al. Stylized image triangulation
CN117793479B (en) Rapid generation method of smooth transition video mask
CN113706648A (en) Down Ka element vectorization method based on diffusion curve
CN111522544B (en) Method and device for making visual track plug-in
CN116563443A (en) Shoe appearance design and user customization system based on 3D generation countermeasure network
CN114219877B (en) Portrait hair flowing special effect processing method and device, medium and electronic equipment
EP2821997A1 (en) Method and device for editing a video sequence
CN110853146B (en) Relief modeling method, system and relief processing equipment
CN111651033B (en) Face driving display method and device, electronic equipment and storage medium
Wyvill Painting with flowsnakes

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant