Automatic segmentation of medical images has become an urgent need and a trend of development .This paper proposes an optimized seed filling algorithm by applying morphology erosion and dilation to the basic algorithm.The method is applied to automatic segmentation of CT images of brain tissue.The selected seeds are optimized by using morphology ero-sion to remove noises.A segmented image is made more smooth and clearer by using morphology dilation to fill blank points.Experimental results have proved the validity of the proposed method.