An effective and efficient approximate two-dimensional dynamic programming algorithm for supporting advanced computer vision applications