Geometric optimal control of the contrast problem in Magnetic Resonance Imaging