Author V. C. Mohan
Aug 2014

This plugin probably is better suited than 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 viz: r2q and q2r. As the names suggest r2q transforms rectangle to a quadrilateral, while q2r transforms quadrilateral to rectangle. Lanczos or cubic or 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 table of parameters 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. All color formats supported by Avisynth version are accepted. For reading coordinates correctly my plugin Grid can be used.

Description of parameters. Q stands for Quadrilateral and R for rectangle.
Parameter Parameter name Variable type Limits of values Default value
clip to be skewed into quadrilateral or deskewed into rectangle clip none
clip to be used as background clip none
Q left top x coordinate ltopx float none 0
Q left top y coordinate ltopy float none 0
Q left bottom x coordinate lbotx float none 0
Q left bot y coordinate lboty float none frame height-1
Q right top x coordinate rtopx float none frame width-1
Q right top y coordinate rtopy float none 0
Q right bottom x coordinate rbotx float none frame width-1
Q right bot y coordinate rboty float none frame height-1
R left x coordinate leftx float none 0
R right x coordinate rightx float none frame width-1
R top y coordinate ytop float none 0
R bottom y coordinate ybot float none frame height-1
End frame Q left top x coordinate eltopx float none ltopx
End frame Q left top y coordinate eltopy float none ltopy
End frame Q left bottom x coordinate elbotx float none lbotx
End frame Q left bot y coordinate elboty float none lboty
End frame Q right top x coordinate ertopx float none rtopx
End frame Q right top y coordinate ertopy float none rtopy
End frame Q right bottom x coordinate erbotx float none rbotx
End frame Q right bot y coordinate erboty float none rboty
End frame R left x coordinate eleftx float none leftx
End frame R right x coordinate erightx float none rightx
End frame R top y coordinate eytop float none ytop
End frame R bottom y coordinate eybot float none ybot
resize interpolation to use resize string "lanczos" "cubic" "line" "point" "lanczos"

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 due to 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)
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" )


To my index page
To Avisynth