Learning the 2-D Topology of Images