# How draw such picture which indicate the motion direction?

the direction picture is

In version 11.0.1,I notice a new function ImageDisplacements perhaps can do this,but maybe I miss something:

pics = Import["https://i.stack.imgur.com/TW75w.gif"];
Show[First[pics],
ListStreamPlot[#,
DataRange -> (PadLeft[#, 2] & /@
List /@ ImageDimensions[First[pics]]), VectorStyle -> Red] & /@
ImageDisplacements[pics]]


Poor effect..

### Updata for material

The gif just have three frame,so I upload a gif maybe is more suitable of this task:

You also can get is by this code:

Export["test.gif",
ExampleData /@
ExampleData[{"TestAnimation", "ToyVehicles"}, "Frames"],
"DisplayDurations" -> .5]

• I threw on code-request because I feel that this calls for nontrivial development. – Mr.Wizard Dec 20 '16 at 23:52
• @Mr.Wizard Thanks for edit. :) – yode Dec 21 '16 at 4:40

The problem is that ListStreamPlot expects the data array in a different order than it is arranged in an Image. You have to Transpose@*Reverse it:

flow = ImageDisplacements[pics];
ListStreamPlot[Transpose@Reverse@flow[[1]],
StreamPoints -> Fine, StreamColorFunction -> "CMYKColors"]


flow[[1]] is the flow from the first frame to the second frame. Replace it with flow[[2]] to visualize the flow from the second to the third.

• How was flow defined? – J. M. is in limbo Dec 21 '16 at 1:08
• @J.M.: Whoops, fixed. – Rahul Dec 21 '16 at 1:10
• So this is just a first frame to second frame? – yode Dec 21 '16 at 3:12
• @yode: "flow[[1]] is the flow from the first frame to the second frame. Replace it with flow[[2]] to visualize the flow from the second to the third." – Rahul Dec 21 '16 at 3:31
• @yode: Then call ImageDisplacements with a list containing only the first and last frame. – Rahul Dec 21 '16 at 4:32