Segmentation of medical images is very important for clinical research and diagnosis, leading to a requirement for robust automatic methods. This paper reports on the combined use of a neural network (a multilayer perceptron, MLP) and active contour model ('snake') to segment structures in magnetic resonance (MR) images. The perceptron is trained to produce a binary classification of each pixel as either a boundary or a non-boundary point. Subsequently, the resulting binary (edge-point) image forms the external energy function for a snake, used to link the candidate boundary points into a continuous, closed contour. We report here on the segmentation of the lungs from multiple MR slices of the torso; lung-specific constraints have been avoided to keep the technique as general as possible. In initial investigations, the inputs to the MLP were limited to normalised intensity values of the pixels from an (7 × 7) window scanned across the image. The use of spatial coordinates as additional inputs to the MLP is then shown to provide an improvement in segmentation performance as quantified using the effectiveness measure (a weighted product of precision and recall). Training sets were first developed using a lengthy iterative process. Thereafter, a novel cost function based on effectiveness is proposed for training that allows us to achieve dramatic improvements in segmentation performance, as well as faster, non-iterative selection of training examples. The classifications produced using this cost function were sufficiently good that the binary image produced by the MLP could be post-processed using an active contour model to provide an accurate segmentation of the lungs from the multiple slices in almost all cases, including unseen slices and subjects.