International audienceMagnetic Resonance Imaging (MRI) uses the difference in tissue relaxation times to create contrast. Various image weightings can be obtained by tuning acquisition parameters which are usually empirically defined. In this article, optimal control theory is used to design excitation pulses that produce the optimal contrast between given tissues. The designed pulses are tested on numerical phantoms with and without magnetic field inhomogeneities and for the first time in vitro on a small-animal MRI. The reasonable match between simulation and real experiments is promising for the development of such pulses in further in vivo applications