Image segmentation techniques currently used for X-ray inspection in pharmaceutical industry suffer from some limitations. The object in an image is close to the background and its contours are weak or blurred because of the X-ray imaging characteristic. Based on our research of X-ray inspection, a simple and efficient image segmentation method is proposed in this paper. It is implemented by treating the image and desired contours as three dimensional surface and holes respectively in order to simplify the model of segmentation, and making use of surface fitting and image subtraction to extract the target region efficiently. The novelty of this approach is that we need less selection of parameters to extract contours with low contrast by surface fitting. Experiments on real X-ray images demonstrate the advantages of the proposed method over active contour model (ACM) and Chan_Vese model (CV model) in terms of both accuracy and efficiency on fixed condition.