Magnetic resonance images are commonly affected by intensity inhomogeneities which make it difficult to obtain any quantitative measures from them. We present a new method of automatically correcting this artifact using a nonparametric coarse to fine approach which allows bias fields to be modeled with different frequency ranges without user supervision. We also propose a new entropy-related cost function based on the combination of intensity and gradient image features for more robust homogeneity measurement. The proposed methodology has been evaluated for both synthetic and real data and compared with state of the art methods, showing the best results in the comparison. The proposed method is fully automatic and has no input parameters, making it very easy to use in a clinical environment.