Towards a Functional Theory of Vision Based on Visual Routines