In this paper a method for the automatic segmentation of the brain in magnetic resonance images is presented and validated. The proposed method involves two steps 1) the creation of an initial model and 2) the deformation of this model to fit the exact contours of the brain in the images. A new method to create the initial model has been developed and compared to a more traditional approach in which initial models are created by means of brain atlases. A comprehensive validation of the complete segmentation method has been conducted on a series of three-dimensional T1-weighted magnetization-prepared rapid gradient echo image volumes acquired both from control volunteers and patients suffering from Cushing's disease. This validation study compares results obtained with the method we propose and contours drawn manually. Averages differences between manual and automatic segmentation with the model creation method we propose are 1.7% and 2.7% for the control volunteers and the Cushing's patients, respectively. These numbers are 1.8% and 5.6% when the atlas-based method is used.