A method for calibrating a magnetic force microscope (MFM) or a scanning Hall probe microscope (SHPM), wherein a raw MFM- or SHPM-image S is measured by scanning a sample with a microscopic tip and an instrument response function IRF is determined for calibrating the MFM or SHPM, comprising the steps of
- a) providing the sample with an irregular sample magnetization pattern M or an irregular current distribution over an extended area,
- b) determining, based on the raw MFM- or SHPM-image S of the sample, an approximate sample magnetization pattern M0 and therefrom an approximate sample magnetic stray field distribution H0 and
- c) calculating the instrument response function IRF from the raw MFM- or SHPM-image S and the approximate sample magnetic stray field distribution H0.