A method to measure the pupil diameter predsely based on morphological algorithm is presented. The original image is smoothed by reconstruction algorithms. Then the alternating-sequence filter is used to repair and smooth the pupil edge imperceptibly,finally the binary image is obtained. The experiment results show the presented approach adapts to pupil images that are photographed under infrared and different illumination visible light,and it is immune to noises smaller than the structure element.