From Avisynth wiki
Jump to: navigation, search
Author wonkey_monkey
Version v0.5beta
Download xyremap0.5beta.zip
Category Transformation
License Closed source
Discussion Doom9 Thread


[edit] Description

xyremap is a filter for remapping pixels using formulae written in reverse Polish notation (http://en.wikipedia.org/wiki/Reverse_Polish_notation)

[edit] Requirements

[edit] Syntax and Parameters

xyremap(clip, string "x", string "y", string "m", int "w", int "h", bool "draft", bool "static")

x: a formula, written in reverse Polish notation, to calculate source x coordinate for each remapped pixel
y: same as above for the y coordinate
m: same as above, used to multiply (darken) the pixel value
w: output width (defaults to input width)
h: output height (defaults to input height)
draft: nearest-neighbour interpolation if true (otherwise defaults to bicubic interpolation)
static: if the remapping is the same for all frames (no animation using variables n or t), set this to true to increase rendering speed

[edit] Examples

xyremap's formulae map output pixels to input pixels, with the origin at the top left.

To shift an image to the right by 10 pixels, use:

	xyremap(clip, "x 10 -")

Note that "-" is used instead of "+" because we are mapping from output to input pixels, not the other way around (which would be more intuitive).

Similarly to upscale a video in both dimensions:

	xyremap(clip, "x 0.5 *", "y 0.5 *")

To scale up from the center:

  xyremap(clip, "x w 0.5 * - 0.5 * u 0.5 * +", "y w 0.5 * - 0.5 * v 0.5 * +")

[edit] Reverse Polish Notation=

For more information on RPN itself, see http://en.wikipedia.org/wiki/Reverse_Polish_notation and also http://horman.net/avisynth/rpn.php

For a list of available operations in this implementation, 
see the included rpn.html document or here: http://horman.net/avisynth/rpn.php

xyremap sets the following variables:

	x: pixel x coordinate (note that this is the pixel center coordinate, so the leftmost pixel is x=0.5)
	y: pixel y coordinate (note that this is the pixel center coordinate, so the topmost pixel is y=0.5)
	a: pixel x coordinate normalised to [0-1]
	b: pixel y coordinate normalised to [0-1]
	c: pixel y coordinate normalised to [0-1*display_aspect_ratio]
	n: frame number
	t: t=n/framecount (so 0<=0<1)
	w: output width
	h: output height
	u: input width
	v: input height

[edit] Changelog

Version      Date            Changes
v0.5beta 2015/08/30 - some new RPN functions, a bug fix, and (approximately) gamma-aware interpolation (see https://forum.doom9.org/showthread.php?p=1736501#post1736501)
v0.4beta 2015/08/23 - new x86 RPN compiler; new functionality (see https://forum.doom9.org/showthread.php?p=1735605#post1735605)
v0.3 2015/03/15 - new parameter "static" to speed up non-animating remaps
v0.2 2012/11/01 - bug fixes to pixel interpolator, min/max functions, added new RPN parameters (see https://forum.doom9.org/showthread.php?p=1598673#post1598673)
v0.1 2012/10/14 - initial release

[edit] Archived Downloads

Version Download Mirror
v0.5beta xyremap0.5beta.zip xyremap0.5beta.zip
v0.3 xyremap0.3.zip xyremap0.3.zip

[edit] External Links

Back to External Filters

Personal tools