optical flow, dynamic programming, shortest path