By measuring the thickness of the retinal nerve fiber layer, retinal optical coherence tomography (OCT) images are now increasingly used for the diagnosis of glaucoma. This paper reports an automatic OCT layer segmentation technique that can be used for computer-aided glaucoma diagnosis. In the proposed technique, blood vessels are first detected through an iterative polynomial smoothing procedure. OCT images are then filtered by a bilateral filter and a median filter sequentially. In particular, both filters suppress the local image noise but the bilateral filter has a special characteristic that keeps the global trend of the image value variation. After the image filtering, edges are detected and the edge segments corresponding to the layer boundary are further identified and clustered to form the layer boundary. Experiments over OCT images of four subjects show that the proposed technique segments layers of OCT images efficiently.