Testing Speed

Testing the Speed¶

A moving pattern (stimulus/image) can be thought as a set of pixels and that each pixel intensities are translated from one frame to the next frame (the intensities, not the pixel:

I(x,t)=I(x+u,t+1); space is a vector with coordinates (x1,x2)’ and time is t. u=(u1,u2) is the 2D velocity. Motion Clouds represent 2D + t images. x(t), each pixel follows a 2D path as a function of time. So we have a space-time function f(x,t) by translating a 2D signal f0(x) with velocity u, i.e, f(x,t)=f0(x-ut).

The Fourier transform of such a function is

F(wx, wy, wt)=F0(wx,wy) \delta(u1wx + u2wy + wt)

F0 is the 2D transform of f0 and \delta is the dirac delta. The energy spectrum is nonzero on a plane whose orientation gives the velocity.

In :
%matplotlib inline
import numpy as np
np.set_printoptions(precision=3, suppress=True)
import pylab
import matplotlib.pyplot as plt
#!rm -fr ../files/speed*

In :
import MotionClouds as mc
name = 'speed'
fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame)
help(mc.envelope_speed)

Help on function envelope_speed in module MotionClouds:

envelope_speed(fx, fy, ft, V_X=1.0, V_Y=0.0, B_V=0.5)
Returns the speed envelope:
selects the plane corresponding to the speed (V_X, V_Y) with some bandwidth B_V.

* (V_X, V_Y) = (0,1) is downward and  (V_X, V_Y) = (1, 0) is rightward in the movie.
* A speed of V_X=1 corresponds to an average displacement of 1/N_X per frame.
To achieve one spatial period in one temporal period, you should scale by
V_scale = N_X/float(N_frame)
If N_X=N_Y=N_frame and V=1, then it is one spatial period in one temporal
period. It can be seen along the diagonal in the fx-ft face of the MC cube.

A special case is used when B_V=0, where the fx-ft plane is used as
the speed plane: in that case it is desirable to set (V_X, V_Y) to (0, 0)
to avoid aliasing problems.

Run the 'test_speed' notebook to explore the speed parameters, see
http://motionclouds.invibe.net/posts/testing-speed.html


In :
# explore parameters
for V_X in [-1.0, -0.5, 0.0, 0.1, 0.5, 1.0, 4.0]:
name_ = name + '-V_X-' + str(V_X).replace('.', '_')
z = mc.envelope_gabor(fx, fy, ft, V_X=V_X)
mc.figures(z, name_)
mc.in_show_video(name_)              In :
for V_Y in [-1.0, -0.5, 0.5, 1.0, 2.0]:
name_ = name + '-V_Y-' + str(V_Y).replace('.', '_')
z = mc.envelope_gabor(fx, fy, ft, V_X=0.0, V_Y=V_Y)
mc.figures(z, name_)
mc.in_show_video(name_)          In :
for B_V in [0, 0.001, 0.01, 0.05, 0.1, 0.5, 1.0, 10.0]:
name_ = name + '-B_V-' + str(B_V).replace('.', '_')
z = mc.envelope_gabor(fx, fy, ft, B_V=B_V)
mc.figures(z, name_)
mc.in_show_video(name_)                