Recurrent neural circuits for contour detection