Warp
From Avisynth wiki
| Abstract | |
|---|---|
| Author | wonkey_monkey |
| Version | v0.1b |
| Download | warp0.1b.zip |
| Category | Rotation |
| License | Open source |
| Discussion | Doom9 Thread |
Contents |
Description
A collection of geometry correction filters using control points, specified either as a list of numbers, a string, or with a Hugin project file (see http://hugin.sourceforge.net/).
Requirements
- [x86]: AviSynth+ or AviSynth 2.6
- [x64]: AviSynth+
- Supported color formats: RGB24, RGB32, YUY2, Y8, YV12, YV16, YV24
- AviSynth+: planar RGB/RGBA is also supported
Syntax and Parameters
warp
Description
===========
warp takes a list of control points - pairs of image coordinates - and
warps the input video using a thin plate spline (as used in morphing)
such that the coordinates of the first point in a pair are moved to the
position of the second point in the pair, with the rest of the image
distorted as smoothly as possible.
Control points are specified either directly as filter parameters, or as a
whitespace- and/or comma-separated string, or by passing the filename of a
Hugin project file (.pto).
Usage
=====
warp(
(clip)
(floats) (optional)
(string) string (optional)
(bool) swap = false
(bool) relative = false
(bool) pto_resize = true
(int) resample = WARP_BICUBIC = 2
(int) quality = 6
(float) scale = 1
(float) scalex = 1
(float) scaley = 1
(float) scale1 = 1
(float) scalex1 = 1
(float) scaley1 = 1
(float) scale2 = 1
(float) scalex2 = 1
(float) scaley2 = 1
(clip) overlay = NULL
(int) overlay_threshold = 0
(int) threads = 0 (automatic)
(int) debug = 0
(int) map = [undefined]
)
Parameters
==========
float list:
Control points may be specified as direct filter arguments, as source->target
pairs of x,y point coordinates:
warp(clip, 0,0, 10,12, 1920,1080, 1930,1070, 640,480, 641,479)
string:
A whitespace- or comma-separated list of numbers, each pair representing a
point, and each pair of points comprising one control point. At least
three control points must be specified.
Alternatively, the filename of a Hugin project (.pto). The control points
common to the first and second images in the project will be used.
swap:
If the control points have been specified in the wrong order (target->
source instead of source->target), set swap to true to swap them.
relative:
If set to true, the target control points are assumed to be relative to
the source control points. Setting target control point coordinates to 0,0
fixes a point at its original position (this still has an effect on the
warp if other control points are non-zero). The following are equivalent:
warp(clip, 0,0, 10,12, 1920,1080, 1930,1070, 640,480, 641,479)
warp(clip, 0,0, 10,12, 1920,1080, 10,-10, 640,480, 1,-1, relative=true)
pto_resize:
Resizes the output image to match the dimensions of the second image
specified in the Hugin project file (if applicable).
resample:
Specifies the resampling method used. warp registers the following
functions which can be used in place of the integer value:
WARP_DRAFT = 0 : nearest neighbour
WARP_BILINEAR = 1 : bilinear interpolation
WARP_BICUBIC = 2 : bicubic interpolation
Resampling works best when the scale of the output image is similar to or
greater than the input image.
quality:
Specifies the subpixel accuracy of the resampling. The default is 6;
accepted values are 4 (fastest) to 8 (slowest, best quality).
scale[x/y][1/2]:
These nine parameters multiply the coordinate values of control points.
All control points are scaled by [scale], all x-coordinates are scaled by
[scalex], all y-coordinates are scaled by [scaley], all source coordinates
are scaled by [scale1], all target coordinates are scaled by [scale2], and
so on.
overlay:
Specifies a clip to overlay with the output for comparison/debugging
purposes. This overrides the debug option WARP_DEBUG_OVERLAY.
overlay_threshold:
In combination with an [overlay] clip or the [debug] option
WARP_DEBUG_OVERLAY, this parameter causes any differences between the
output clip and the overlay which are greater than the value of the
parameter to be highlighted.
threads:
Specifies the number of threads to use. If unspecified, the number of
logical processors is used.
map:
Specifying this parameter outputs a map clip for use as an input to the
warp_series filter. The value of this parameter determines the frame
number associated with the map (see warp_series.txt). This parameter
disables any debugging options.
debug:
Specifies one or more debugging modes:
WARP_DEBUG_GRID = 1 : adds a grid to the input clip before remapping
WARP_DEBUG_OVERLAY = 2 : overlays the input clip on the remapped output
WARP_DEBUG_MARKERS = 4 : paints the locations of the control points
WARP_DEBUG_ISOMAP = 8 : displays a sort of isographic map of distortion
To specify multiple debugging modes, add their values, for example:
warp(..., debug = WARP_DEBUG_GRID + WARP_DEBUG_MARKERS)
WARP_DEBUG_ISOMAP overrides the other options. Specifying [map] as a
parameter disables all debugging options.
quad
Description
===========
quad performs quadrilateral-to-quadrilateral transformations, using four or
eight user-specified points.
Usage
=====
warp(
(clip)
(floats) (optional)
(string) string (optional)
(bool) swap = false
(bool) relative = false
(bool) pto_resize = true
(int) resample = WARP_BICUBIC = 2
(int) quality = 6
(float) scale = 1
(float) scalex = 1
(float) scaley = 1
(float) scale1 = 1
(float) scalex1 = 1
(float) scaley1 = 1
(float) scale2 = 1
(float) scalex2 = 1
(float) scaley2 = 1
(clip) overlay = NULL
(int) overlay_threshold = 0
(int) threads = 0 (automatic)
(bool) interleaved = false
(int) debug = 0
(int) map = [undefined]
)
Parameters
==========
float list:
quad accepts either four or eight points (eight or sixteen numbers). If four
points are specified they are interpreted as the target quadrilateral. If
eight points are specified they are interpreted as the source quadrilateral
followed by the target quadrilateral.
string:
A whitespace- or comma-separated list of numbers, following the same
specification as above - unless interleaved = true, in which case each pair
represents a point, and each pair of points comprises one control point.
Exactly four control points must be specified.
Alternatively, the filename of a Hugin project (.pto). The control points
common to the first and second images in the project will be used.
swap:
If the control points have been specified in the wrong order (target->
source instead of source->target), set swap to true to swap them.
relative:
If set to true, the target control points are assumed to be relative to
the source control points. Setting target control point coordinates to 0,0
fixes a point at its original position. The following are equivalent:
quad(clip, 0,0, 640,0, 640,480, 0,480, 10,12, 630,5, 630,480, 16,479)
quad(clip, 0,0, 640,0, 640,480, 0,480, 10,12, -10,5, -10,0, 16,-1, relative=true)
pto_resize:
Resizes the output image to match the dimensions of the second image
specified in the Hugin project file (if applicable).
resample:
Specifies the resampling method used. quad registers the following
functions which can be used in place of the integer value:
QUAD_DRAFT = 0 : nearest neighbour
QUAD_BILINEAR = 1 : bilinear interpolation
QUAD_BICUBIC = 2 : bicubic interpolation
Resampling works best when the scale of the output image is similar to or
greater than the input image.
quality:
Specifies the subpixel accuracy of the resampling. The default is 6;
accepted values are 4 (fastest) to 8 (slowest, best quality).
scale[x/y][1/2]:
These nine parameters multiply the coordinate values of control points.
All control points are scaled by [scale], all x-coordinates are scaled by
[scalex], all y-coordinates are scaled by [scaley], all source coordinates
are scaled by [scale1], all target coordinates are scaled by [scale2], and
so on.
overlay:
Specifies a clip to overlay with the output for comparison/debugging
purposes. This overrides the debug option QUAD_DEBUG_OVERLAY.
overlay_threshold:
In combination with an [overlay] clip or the [debug] option
QUAD_DEBUG_OVERLAY, this parameter causes any differences between the
output clip and the overlay which are greater than the value of the
parameter to be highlighted.
threads:
Specifies the number of threads to use. If unspecified, the number of
logical processors is used.
interleaved:
Setting this to true treats the control points as interleaved quadrilateral
coordinates.
map:
Specifying this parameter outputs a map clip for use as an input to the
warp_series filter. The value of this parameter determines the frame
number associated with the map (see warp_series.txt). This parameter
disables any debugging options.
debug:
Specifies one or more debugging modes:
QUAD_DEBUG_GRID = 1 : adds a grid to the input clip before remapping
QUAD_DEBUG_OVERLAY = 2 : overlays the input clip on the remapped output
QUAD_DEBUG_MARKERS = 4 : paints the locations of the control points
QUAD_DEBUG_ISOMAP = 8 : displays a sort of isographic map of distortion
To specify multiple debugging modes, add their values, for example:
quad(..., debug = QUAD_DEBUG_GRID + QUAD_DEBUG_MARKERS)
QUAD_DEBUG_ISOMAP overrides the other options. Specifying [map] as a
parameter disables all debugging options.
warp_rekey
Description =========== warp_rekey changes the frame number associated with a map, returning a new map clip. If a map needs to be used twice during an animation, warp_rekey should be used to avoid creating a brand new map (since this costs time and memory). Usage ===== warp( (clip), (int) ) Parameters ========== [clip]: Must be a map clip returned by warp(..., map = x) [int]: New frame number to be associated with the returned clip.
warp_series
Description
===========
warp_series is essentially a filter for animating warps. It blends between
the specified maps as the video progresses.
Usage
=====
warp(
(clip)
(clips)
(floats) (optional)
(string) string (optional)
(int) resample = WARP_BICUBIC = 2
(int) quality = 6
(int) transition = WARP_LINEAR = 0
(clip) overlay = NULL
(int) overlay_threshold = 0
(int) threads = 0 (automatic)
(int) debug = 0
)
Parameters
==========
clip list:
A set of map clips, as return by warp(..., map = x), where x is the frame
number associated with the map.
float list:
A list which overrides the frame numbers associated with the map clips.
Must be empty, or must have the same count as the map clips.
resample:
Specifies the resampling method used. quad registers the following
functions which can be used in place of the integer value:
WARP_DRAFT = 0 : nearest neighbour
WARP_BILINEAR = 1 : bilinear interpolation
WARP_BICUBIC = 2 : bicubic interpolation
Resampling works best when the scale of the output image is similar to or
greater than the input image.
quality:
Specifies the subpixel accuracy of the resampling. The default is 6;
accepted values are 4 (fastest) to 8 (slowest, best quality).
transition:
Specifies the transition between maps. WARP_LINEAR uses a linear transition
which may cause visible jumps at map frames, WARP_SINE uses a more gradual
acceleration between maps.
overlay:
Specifies a clip to overlay with the output for comparison/debugging
purposes. This overrides the debug option WARP_DEBUG_OVERLAY.
overlay_threshold:
In combination with an [overlay] clip or the [debug] option
WARP_DEBUG_OVERLAY, this parameter causes any differences between the
output clip and the overlay which are greater than the value of the
parameter to be highlighted.
threads:
Specifies the number of threads to use. If unspecified, the number of
logical processors is used.
debug:
Specifies one or more debugging modes:
WARP_DEBUG_GRID = 1 : adds a grid to the input clip before remapping
WARP_DEBUG_OVERLAY = 2 : overlays the input clip on the remapped output
WARP_DEBUG_MARKERS = 4 : paints the locations of the control points
WARP_DEBUG_ISOMAP = 8 : displays a sort of isographic map of distortion
To specify multiple debugging modes, add their values, for example:
warp_series(..., debug = QUAD_DEBUG_GRID + QUAD_DEBUG_MARKERS)
WARP_DEBUG_ISOMAP overrides the other options. Specifying [map] as a
parameter disables all debugging options.
warp_grid
Description =========== warp_grid is a helper filter which draws a grid on a video clip. Usage ===== warp_series( (clip) (int) size = 64 (float) darken = 0.9375 (int) color = 255 )
Examples
TODO
Changelog
Version Date Changes
v0.1b 2019/09/13 - Some fixes[1] v0.1 2019/01/14 - initial release
Archived Downloads
| Version | Download | Mirror |
|---|---|---|
| v0.1b | warp0.1b.zip | warp0.1b.zip |
| v0.1 | warp.zip | warp.zip |
External Links
Back to External Filters ←