The active contour model is widely used to segment images. For the classical magnetostatic active contour (MAC) model, the magnetic field is computed based on the detected points by using an edge detector. However, noise and nontarget points are always detected. Thus, MAC is nonrobust to noise and the extracted objects may be deviant from the real objects. In this paper, a magnetostatic active contour model with a classification method of sparse representation is proposed. First, rough edge information is obtained with some edge detectors. Second, the extracted edge contours are divided into two parts by sparse classification, that is, the target object part and the redundant part. Based on the classified target points, a new magnetic field is generated, and contours evolve with MAC to extract the target objects. Experimental results show that the proposed model could decrease the influence of noise and robust segmentation results could be obtained.