Magnetic resonance (MR) data are acquired with a two-point Dixon technique in which a first spectral component and a second spectral component, for example, a water component and a fat component, are determined. A computation grid of lower resolution in comparison to the MR data is determined, wherein each grid point of the computation grid encompasses a predetermined number of adjacent image points of the MR data. A numerical optimization is implemented for each image point of the MR data, and the first spectral component and the second spectral component are calculated analytically based on the result of the numerical optimization.