Stereo matching using multi-directional dynamic programming