Segmentation of femurs in Anterior-Posterior x-ray images is very important for fracture detection, computer-aided surgery and surgical planning. Existing methods do not perform well in segmenting bones in x-ray images due to the presence of large amount of spurious edges. This paper presents an atlas-based approach for automatic segmentation of femurs in x-ray images. A robust global alignment method based on consistent sets of edge segments registers the whole atlas to the image under joint constraints. After global alignment, the femur models undergo local refinement to extract detailed contours of the femurs. Test results show that the proposed algorithm is robust and accurate in segmenting the femur contours of different patients.