Windowing functions can be passed to the
window.type
argument in dtw
to put a global
constraint to the warping paths allowed. They take two integer
arguments (plus optional parameters) and must return a boolean value
TRUE
if the coordinates fall within the allowed region
for warping paths, FALSE
otherwise. dtwWindow.plot
can be used to visualize a chosen windowing
function. Some functions take parameters which must be set (e.g.
window.size). dtwWindow.plot
plots a 200 x 220 rectangular
region by default, which can be changed passing template.size
and query.size
arguments.
User-defined functions can read variables template.size
,
query.size
and window.size
; these are pre-set upon invocation.
User-defined functions are free to implement any window
shape, as long as at least one path is allowed between the initial and
final alignment points, i.e., they are compatible with the DTW
constraints.
The Sakoe-Chiba band is a band of window.size
elements
around the main diagonal. If the window size is too small, i.e.
$template.size
-query.size
> window.size
$, warping becomes
impossible.
A widely held misconception is that the "Itakura parallelogram" (as
described in reference [2]) is a global constraint, i.e. a
window. To the author's knowledge, it instead arises from the local
slope restrictions imposed to the warping path, such as the one
implemented by the asymmetricItakura
step pattern.
An itakuraWindow
global constraint is still provided with this
package. See example below for a demonstration of
the difference between a local the two.
The slantedBandWindow
(package-specific) is a band centered
around the (jagged) line segment which joins element [1,1]
to
element [query.size,template.size]
, and will be
window.size
columns wide. In other words, the "diagonal" goes
from one corner to the other of the possibly rectangular cost matrix,
therefore having a slope of M/N
, not 1.