Reformer
(Reformer: update documentation to match Reformer) |
|||
(One intermediate revision by one user not shown) | |||
Line 1: | Line 1: | ||
− | + | {{FilterCat4|External_filters|Plugins|Adjustment_filters|Transformation}} | |
− | {{FilterCat4|External_filters|Plugins| | + | |
− | + | ||
{{Filter3 | {{Filter3 | ||
− | |1= | + | |1={{Author/vcmohan}} |
− | |2= | + | |2=14 Oct 2015 |
− | |3= | + | |3=[http://www.avisynth.nl/users/vcmohan/Reformer/Reformer_2_6.zip Reformer_2_6.zip] |
− | |4= | + | |4=Transformation |
− | |5= | + | |5=[https://www.gnu.org/licenses/gpl-2.0.txt GPLv2] |
− | |6= | + | |6=[https://forum.doom9.org/showthread.php?t=166716 Doom9 Forum]}} |
− | + | ||
<br> | <br> | ||
== Description == | == Description == | ||
− | + | [[Reformer]] can be used to correct skewed images or vice versa. Useful if video is recorded with incorrectly located camera or for transitions or effects. | |
− | + | ||
+ | This plugin probably is better suited than the [[Reform]] plugin as it performs much better even if the rectangle is rotated by 90 degrees. Reform fails in such a situation. This Reformer uses matrix algebra for transformations unlike Reform which does a geometric transform. | ||
+ | |||
+ | [[Reformer]] has two functions: | ||
+ | |||
+ | *<code>r2q</code> transforms a rectangle to a quadrilateral. | ||
+ | |||
+ | *<code>q2r</code> transforms a quadrilateral to a rectangle. | ||
+ | |||
+ | Lanczos, cubic, linear or nearest point interpolation methods can be opted. The parameters are identical to both functions (and to the Reform plugin), and the coordinates can be specified as floating point or (since AviSynth accepts integers as floating point) in integer format. | ||
+ | |||
+ | While there are no limits for specifying parameters, it has to be ensured that the specified parameters do not twist or fold the Quadrlateral. In the parameter description R stands for Rectangle and Q stands for Quadrilateral. | ||
+ | |||
+ | Most of the parameters can be linearly varied over the length of the clip, and so it can be used to distort or correct distorted faces or objects progressively. Also can be used by proper scripting as transition. For reading coordinates correctly, the plugin [[Grid]] can be used. | ||
+ | |||
+ | |||
+ | * See official documentation: http://www.avisynth.nl/users/vcmohan/Reformer/Reformer.html | ||
+ | * For AviSynth+ see [[movePlus]], includes high bit depth colorspace support and 64-bit. | ||
<br> | <br> | ||
== Requirements == | == Requirements == | ||
− | * AviSynth+ | + | * [x86]: [[AviSynth+]] or [https://sourceforge.net/projects/avisynth2/ AviSynth 2.6] |
+ | * Supported color formats: [[RGB24]], [[RGB32]], [[YUY2]], [[Y8]], [[YV12]], [[YV16]], [[YV24]] | ||
<br> | <br> | ||
== [[Script variables|Syntax and Parameters]] == | == [[Script variables|Syntax and Parameters]] == | ||
− | :{{Template:FuncDef| | + | :{{Template:FuncDef|r2q (clip, clip, string "resize", float "ltopx", float "ltopy", float "lbotx", float "lboty", float "rtopx", float "rtopy", float "rbotx", float "rboty", float "leftx", float "rightx", float "ytop", float "ybot", float "eltopx", float "eltopy", float "elbotx", float "elboty", float "ertopx", float "ertopy", float "erbotx", float "erboty", float "eleftx", float "erightx", float "eytop", float "eybot")}} |
+ | |||
+ | :{{Template:FuncDef|q2r (clip, clip, string "resize", float "ltopx", float "ltopy", float "lbotx", float "lboty", float "rtopx", float "rtopy", float "rbotx", float "rboty", float "leftx", float "rightx", float "ytop", float "ybot", float "eltopx", float "eltopy", float "elbotx", float "elboty", float "ertopx", float "ertopy", float "erbotx", float "erboty", float "eleftx", float "erightx", float "eytop", float "eybot")}} | ||
<br> | <br> | ||
::{{Par2| |clip| }} | ::{{Par2| |clip| }} | ||
− | ::: | + | :::Input clip to be skewed into quadrilateral or deskewed into rectangle. |
<br> | <br> | ||
::{{Par2| |clip| }} | ::{{Par2| |clip| }} | ||
− | ::: Clip to be used as background | + | :::Clip to be used as background. |
<br> | <br> | ||
− | ::{{Par2|resize|string|" | + | ::{{Par2|resize|string|"lanczos"}} |
− | ::: | + | :::Resize interpolation to use: <code>"lanczos" | "cubic" | "line" | "point"</code> |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<br> | <br> | ||
::{{Par2|ltopx|float|0}} | ::{{Par2|ltopx|float|0}} | ||
− | |||
− | |||
::{{Par2|ltopy|float|0}} | ::{{Par2|ltopy|float|0}} | ||
− | ::: | + | :::Quadrilateral left top x and y coordinates. |
<br> | <br> | ||
::{{Par2|lbotx|float|0}} | ::{{Par2|lbotx|float|0}} | ||
− | ::: | + | ::{{Par2|lboty|float|height-1}} |
+ | :::Quadrilateral left bottom x and y coordinates. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|rtopx|float|width-1}} |
− | ::: | + | ::{{Par2|rtopy|float|0}} |
+ | :::Quadrilateral right top x and y coordinates. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|rbotx|float|width-1}} |
− | ::: | + | ::{{Par2|rboty|float|height-1}} |
+ | :::Quadrilateral right bottom x and y coordinates. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|leftx|float|0}} |
− | ::: | + | ::{{Par2|rightx|float| width-1}} |
+ | :::Rectangle coordinates: left x and right x. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|ytop|float|0}} |
− | ::: | + | ::{{Par2|ybot|float|height-1}} |
+ | :::Rectangle coordinates: top y and bottom y. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|eltopx|float|ltopx}} |
− | ::: | + | ::{{Par2|eltopy|float|ltopy}} |
+ | :::End frame, Quadrilateral left top x and y coordinates. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|elbotx|float|lbotx}} |
− | ::: | + | ::{{Par2|elboty|float|lboty}} |
+ | :::End frame, Quadrilateral left bottom x and y coordinates. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|ertopx|float|rtopx}} |
− | ::: | + | ::{{Par2|ertopy|float|rtopy}} |
+ | :::End frame, Quadrilateral right top x and y coordinates. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|erbotx|float|rbotx}} |
− | ::: | + | ::{{Par2|erboty|float|rboty}} |
+ | :::End frame, Quadrilateral right bottom x and y coordinates. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|eleftx|float|leftx}} |
− | ::: | + | ::{{Par2|erightx|float|rightx}} |
+ | :::End frame Rectanlge coordinates: left x and right x. | ||
<br> | <br> | ||
− | ::{{Par2| | + | ::{{Par2|eytop|float|ytop}} |
− | :: | + | ::{{Par2|eybot|float|ybot}} |
− | ::: | + | :::End frame Rectanlge coordinates: top y and bottom y. |
− | : | + | |
<br> | <br> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
== Examples == | == Examples == | ||
− | + | Script examples: | |
− | Script | + | |
ColorBars().ConvertToRGB32() | ColorBars().ConvertToRGB32() | ||
bg = blankclip(last) | bg = blankclip(last) | ||
− | + | r2q(bg, leftx=100, rightx=400, ytop=200, ybot=480, ltopx=200, ltopy=150, rbotx=500, rboty=400, resize="lanczos") | |
+ | |||
+ | Below is a suitably modified interesting script originally by Martin53 (Sept. 2012) in the [https://forum.doom9.org/showthread.php?p=1592937#post1592937 quad plugin thread.] By commenting either r2q call or q2r call or none the power of the plugin can be viewed. | ||
+ | <pre> | ||
+ | ColorBars().ConvertToYV12() | ||
+ | bg = BlankClip(last) | ||
+ | Subtitle("Flying Colorbars()",text_color=$d0c000,align=5,size=40) | ||
+ | ScriptClip(""" | ||
+ | c= last | ||
+ | |||
+ | bg = blankclip(last) | ||
+ | h = height(bg)-1 | ||
+ | w = width(bg)-1 | ||
+ | t = 0.061 *(current_frame) | ||
+ | t2 = 0.127 *( current_frame) | ||
+ | a = 0.501 + 0.5 * sin(t/pi) | ||
+ | t1x = (-0.2*cos(t2)) * w | ||
+ | t1y = (0.5-0.5*cos(t2)) * h | ||
+ | t2x = (1.0+0.2*cos(t2)) * w | ||
+ | t2y = (0.5-0.5*cos(t2)) * h | ||
+ | t3x = (1.0+0.2*cos(t2)) * w | ||
+ | t3y = (0.5+0.5*cos(t2)) * h | ||
+ | t4x = (-0.2*cos(t2)) * w | ||
+ | t4y = (0.5+0.5*cos(t2)) * h | ||
+ | c1x = (0.5+a*cos(t)) * w | ||
+ | c1y = (0.5+a*sin(t)) * h | ||
+ | c2x = (0.5-a*sin(t)) * w | ||
+ | c2y = (0.5+a*cos(t)) * h | ||
+ | c3x = (0.5-a*cos(t)) * w | ||
+ | c3y = (0.5-a*sin(t)) * h | ||
+ | c4x = (0.5+a*sin(t)) * w | ||
+ | c4y = (0.5-a*cos(t)) * h | ||
+ | # comment out call to r2q or to q2r or leave as it is | ||
+ | r2q(c, bg,leftx=t1x,rightx=t2x,ytop=t1y,ybot=t3y,ltopx=c1x,ltopy=c1y, rtopx=c2x,rtopy=c2y, rbotx=c3x,rboty=c3y,lbotx=c4x,lboty=c4y, resize = "point") | ||
+ | |||
+ | q2r( bg,leftx=t1x,rightx=t2x,ytop=t1y,ybot=t3y,ltopx=c1x,ltopy=c1y, rtopx=c2x,rtopy=c2y, rbotx=c3x,rboty=c3y,lbotx=c4x,lboty=c4y, resize = "point" ) | ||
+ | |||
+ | """) | ||
+ | </pre> | ||
+ | <br> | ||
<br> | <br> | ||
----------------------------------------------- | ----------------------------------------------- | ||
− | '''Back to [[External_filters|External Filters]] ←''' | + | '''Back to [[External_filters#Rotation.2FShear.2FSkew.2FPerspective|External Filters]] ←''' |
Latest revision as of 07:08, 9 June 2020
Abstract | |
---|---|
Author | V. C. Mohan |
Version | 14 Oct 2015 |
Download | Reformer_2_6.zip |
Category | Transformation |
License | GPLv2 |
Discussion | Doom9 Forum |
Contents |
[edit] Description
Reformer can be used to correct skewed images or vice versa. Useful if video is recorded with incorrectly located camera or for transitions or effects.
This plugin probably is better suited than the Reform plugin as it performs much better even if the rectangle is rotated by 90 degrees. Reform fails in such a situation. This Reformer uses matrix algebra for transformations unlike Reform which does a geometric transform.
Reformer has two functions:
r2q
transforms a rectangle to a quadrilateral.
q2r
transforms a quadrilateral to a rectangle.
Lanczos, cubic, linear or nearest point interpolation methods can be opted. The parameters are identical to both functions (and to the Reform plugin), and the coordinates can be specified as floating point or (since AviSynth accepts integers as floating point) in integer format.
While there are no limits for specifying parameters, it has to be ensured that the specified parameters do not twist or fold the Quadrlateral. In the parameter description R stands for Rectangle and Q stands for Quadrilateral.
Most of the parameters can be linearly varied over the length of the clip, and so it can be used to distort or correct distorted faces or objects progressively. Also can be used by proper scripting as transition. For reading coordinates correctly, the plugin Grid can be used.
- See official documentation: http://www.avisynth.nl/users/vcmohan/Reformer/Reformer.html
- For AviSynth+ see movePlus, includes high bit depth colorspace support and 64-bit.
[edit] Requirements
[edit] Syntax and Parameters
- r2q (clip, clip, string "resize", float "ltopx", float "ltopy", float "lbotx", float "lboty", float "rtopx", float "rtopy", float "rbotx", float "rboty", float "leftx", float "rightx", float "ytop", float "ybot", float "eltopx", float "eltopy", float "elbotx", float "elboty", float "ertopx", float "ertopy", float "erbotx", float "erboty", float "eleftx", float "erightx", float "eytop", float "eybot")
- q2r (clip, clip, string "resize", float "ltopx", float "ltopy", float "lbotx", float "lboty", float "rtopx", float "rtopy", float "rbotx", float "rboty", float "leftx", float "rightx", float "ytop", float "ybot", float "eltopx", float "eltopy", float "elbotx", float "elboty", float "ertopx", float "ertopy", float "erbotx", float "erboty", float "eleftx", float "erightx", float "eytop", float "eybot")
- clip =
- Input clip to be skewed into quadrilateral or deskewed into rectangle.
- clip =
- clip =
- Clip to be used as background.
- clip =
- string resize = "lanczos"
- Resize interpolation to use:
"lanczos" | "cubic" | "line" | "point"
- Resize interpolation to use:
- string resize = "lanczos"
- float ltopx = 0
- float ltopy = 0
- Quadrilateral left top x and y coordinates.
- float ltopx = 0
- float lbotx = 0
- float lboty = height-1
- Quadrilateral left bottom x and y coordinates.
- float lbotx = 0
- float rtopx = width-1
- float rtopy = 0
- Quadrilateral right top x and y coordinates.
- float rtopx = width-1
- float rbotx = width-1
- float rboty = height-1
- Quadrilateral right bottom x and y coordinates.
- float rbotx = width-1
- float leftx = 0
- float rightx = width-1
- Rectangle coordinates: left x and right x.
- float leftx = 0
- float ytop = 0
- float ybot = height-1
- Rectangle coordinates: top y and bottom y.
- float ytop = 0
- float eltopx = ltopx
- float eltopy = ltopy
- End frame, Quadrilateral left top x and y coordinates.
- float eltopx = ltopx
- float elbotx = lbotx
- float elboty = lboty
- End frame, Quadrilateral left bottom x and y coordinates.
- float elbotx = lbotx
- float ertopx = rtopx
- float ertopy = rtopy
- End frame, Quadrilateral right top x and y coordinates.
- float ertopx = rtopx
- float erbotx = rbotx
- float erboty = rboty
- End frame, Quadrilateral right bottom x and y coordinates.
- float erbotx = rbotx
- float eleftx = leftx
- float erightx = rightx
- End frame Rectanlge coordinates: left x and right x.
- float eleftx = leftx
- float eytop = ytop
- float eybot = ybot
- End frame Rectanlge coordinates: top y and bottom y.
- float eytop = ytop
[edit] Examples
Script examples:
ColorBars().ConvertToRGB32() bg = blankclip(last) r2q(bg, leftx=100, rightx=400, ytop=200, ybot=480, ltopx=200, ltopy=150, rbotx=500, rboty=400, resize="lanczos")
Below is a suitably modified interesting script originally by Martin53 (Sept. 2012) in the quad plugin thread. By commenting either r2q call or q2r call or none the power of the plugin can be viewed.
ColorBars().ConvertToYV12() bg = BlankClip(last) Subtitle("Flying Colorbars()",text_color=$d0c000,align=5,size=40) ScriptClip(""" c= last bg = blankclip(last) h = height(bg)-1 w = width(bg)-1 t = 0.061 *(current_frame) t2 = 0.127 *( current_frame) a = 0.501 + 0.5 * sin(t/pi) t1x = (-0.2*cos(t2)) * w t1y = (0.5-0.5*cos(t2)) * h t2x = (1.0+0.2*cos(t2)) * w t2y = (0.5-0.5*cos(t2)) * h t3x = (1.0+0.2*cos(t2)) * w t3y = (0.5+0.5*cos(t2)) * h t4x = (-0.2*cos(t2)) * w t4y = (0.5+0.5*cos(t2)) * h c1x = (0.5+a*cos(t)) * w c1y = (0.5+a*sin(t)) * h c2x = (0.5-a*sin(t)) * w c2y = (0.5+a*cos(t)) * h c3x = (0.5-a*cos(t)) * w c3y = (0.5-a*sin(t)) * h c4x = (0.5+a*sin(t)) * w c4y = (0.5-a*cos(t)) * h # comment out call to r2q or to q2r or leave as it is r2q(c, bg,leftx=t1x,rightx=t2x,ytop=t1y,ybot=t3y,ltopx=c1x,ltopy=c1y, rtopx=c2x,rtopy=c2y, rbotx=c3x,rboty=c3y,lbotx=c4x,lboty=c4y, resize = "point") q2r( bg,leftx=t1x,rightx=t2x,ytop=t1y,ybot=t3y,ltopx=c1x,ltopy=c1y, rtopx=c2x,rtopy=c2y, rbotx=c3x,rboty=c3y,lbotx=c4x,lboty=c4y, resize = "point" ) """)
Back to External Filters ←