Reformer

From Avisynth wiki
Jump to: navigation, search
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.



[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 to be used as background.


string  resize = "lanczos"
Resize interpolation to use: "lanczos" | "cubic" | "line" | "point"


float  ltopx = 0
float  ltopy = 0
Quadrilateral left top x and y coordinates.


float  lbotx = 0
float  lboty = height-1
Quadrilateral left bottom x and y coordinates.


float  rtopx = width-1
float  rtopy = 0
Quadrilateral right top x and y coordinates.


float  rbotx = width-1
float  rboty = height-1
Quadrilateral right bottom x and y coordinates.


float  leftx = 0
float  rightx = width-1
Rectangle coordinates: left x and right x.


float  ytop = 0
float  ybot = height-1
Rectangle coordinates: top y and bottom y.


float  eltopx = ltopx
float  eltopy = ltopy
End frame, Quadrilateral left top x and y coordinates.


float  elbotx = lbotx
float  elboty = lboty
End frame, Quadrilateral left bottom x and y coordinates.


float  ertopx = rtopx
float  ertopy = rtopy
End frame, Quadrilateral right top x and y coordinates.


float  erbotx = rbotx
float  erboty = rboty
End frame, Quadrilateral right bottom x and y coordinates.


float  eleftx = leftx
float  erightx = rightx
End frame Rectanlge coordinates: left x and right x.


float  eytop = ytop
float  eybot = ybot
End frame Rectanlge coordinates: top y and bottom y.


[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

Personal tools