ImageDisplacements[{image1,image2,…,imagen}]
gives estimated horizontal and vertical displacements between consecutive images.
ImageDisplacements[video]
gives displacements between consecutive video frames.
ImageDisplacements[input,flow]
uses flow as an initial estimate for displacement between first two images or video frames.
ImageDisplacements
ImageDisplacements[{image1,image2,…,imagen}]
gives estimated horizontal and vertical displacements between consecutive images.
ImageDisplacements[video]
gives displacements between consecutive video frames.
ImageDisplacements[input,flow]
uses flow as an initial estimate for displacement between first two images or video frames.
Details and Options
- ImageDisplacements, also known as dense optical flow, compares consecutive images or video frames and returns a list of displacement matrices.
- For a pair of consecutive images imagei and imagei+1, the displacement matrix returns a {δx,δy} for every pixel of imagei.
- ImageDisplacements works with an AnimatedImage, a Video object or a sequence of images of the same dimensions.
- The following options are supported:
-
MaxIterations 10 number of iterations to run Method Automatic the method to use PerformanceGoal $PerformanceGoal aspects of performance to try to optimize - By default, the more suitable method is used. Possible method settings are "Farneback" and "DenseInverseSearch".
Examples
open all close allBasic Examples (2)
Compute the displacement between two images:
flow = ImageDisplacements[{[image], [image]}]Image[Rescale[flow[[1]]]]Compute the displacements between consecutive images of a list:
list = {[image], [image], [image], [image], [image]};flows = ImageDisplacements[list];Image /@ Rescale /@ flowsApplications (2)
Detect rotating objects in a wind farm:
seq = DynamicModule[«4»]["ImageList"];flow = Mean@ImageDisplacements[Append[seq, seq[[1]]]];Extract the rotation component of the flow by computing its curl:
listCurl =
flow ListConvolve[{{0.5, 0, -0.5}}, flow[[All, All, 2]], {{1, 2}, {1, 2}}, "Fixed"] - ListConvolve[{{-0.5}, {0}, {0.5}}, flow[[All, All, 1]], {{1, 2}, {1, 2}}, "Fixed"];
curl = ImageAdjust@Image@GaussianFilter[listCurl@flow, 8{3, 1}]Colorize the rotation map and superimpose it on top of the original image:
ImageCompose[seq[[1]], SetAlphaChannel[Colorize[curl, ColorFunction -> ColorData[{"TemperatureMap", "Reverse"}]], ColorNegate[curl]]]Compute and visualize divergence of a velocity field:
video = \!\(\*VideoBox[""]\);flow = ImageDisplacements[video];Compute divergence of displacements:
listDivergence = Function[flow, ListConvolve[{{-0.5, 0, 0.5}}, flow[[All, All, 1]], {{1, 2}, {1, 2}}, "Fixed"] + ListConvolve[{{-0.5}, {0}, {0.5}}, flow[[All, All, 2]], {{1, 2}, {1, 2}}, "Fixed"]
];Visualize the divergence on each frame:
VideoMap[
With[{div = (Image@listDivergence@flow[[Min[#FrameIndex, Length[flow]]]] + 2) / 4},
ImageCompose[#Image, {Colorize[div, IconizedObject[«cfun»]], .5}]]&, video]Interactive Examples (1)
original = {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image]};ListAnimate[original, DefaultDuration -> 2]flows = Map[vecField Transpose@Reverse[vecField], ImageDisplacements[original, MaxIterations -> 1] / 2];Construct the interpolated frames and insert them into the final sequence:
vecTrafo[xy_, motion_] := xy + Extract[motion, Ceiling[xy]];oflow = Table[
ImageForwardTransformation[original[[i]],
vecTrafo[#, flows[[i]]]&,
DataRange -> Full, Background -> White],
{i, Length@original - 1}];
slowmo = Riffle[original, oflow];ListAnimate[slowmo, DefaultDuration -> 4]Text
Wolfram Research (2016), ImageDisplacements, Wolfram Language function, https://reference.wolfram.com/language/ref/ImageDisplacements.html (updated 2025).
CMS
Wolfram Language. 2016. "ImageDisplacements." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/ImageDisplacements.html.
APA
Wolfram Language. (2016). ImageDisplacements. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ImageDisplacements.html
BibTeX
@misc{reference.wolfram_2026_imagedisplacements, author="Wolfram Research", title="{ImageDisplacements}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/ImageDisplacements.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_imagedisplacements, organization={Wolfram Research}, title={ImageDisplacements}, year={2025}, url={https://reference.wolfram.com/language/ref/ImageDisplacements.html}, note=[Accessed: 13-June-2026]}