Perceptual Organization of Visual Structure Requires a Flexible Learning Mechanism.