Automatic segmentation of anatomical structures in medical images is a valuable tool for efficient computer-aided radiotherapy and surgery planning and an enabling technology for dynamic adaptive radiotherapy. This paper presents the design, algorithms and validation of new software for the automatic segmentation of CT images used for radiotherapy treatment planning. A coarse to fine approach is followed that consists of presegmentation, anatomic orientation and structure segmentation. No user input or a priori information about the image content is required. In presegmentation, the body outline, the bones and lung equivalent tissue are detected. Anatomic orientation recognizes the patient's position, orientation and gender and creates an elastic mapping of the slice positions to a reference scale. Structure segmentation is divided into localization, outlining and refinement, performed by procedures with implicit anatomic knowledge using standard image processing operations. The presented version of algorithms automatically segments the body outline and bones in any gender and patient position, the prostate, bladder and femoral heads for male pelvis in supine position, and the spinal canal, lungs, heart and trachea in supine position. The software was developed and tested on a collection of over 600 clinical radiotherapy planning CT stacks. In a qualitative validation on this test collection, anatomic orientation correctly detected gender, patient position and body region in 98% of the cases, a correct mapping was produced for 89% of thorax and 94% of pelvis cases. The average processing time for the entire segmentation of a CT stack was less than 1 min on a standard personal computer. Two independent retrospective studies were carried out for clinical validation. Study I was performed on 66 cases (30 pelvis, 36 thorax) with dosimetrists, study II on 52 cases (39 pelvis, 13 thorax) with radio-oncologists as experts. The experts rated the automatically produced structures on the scale 1-excellent (no corrections necessary, maximum time saving), 2-good (corrections necessary for up to 1/3 of slices), 3-acceptable (major corrections necessary, but still time saving), 4-not acceptable (manual redrawing more efficient, no time saving). A rating<or=3 indicates a time saving in the treatment planning process and was given for pelvis segmentation in 70% (I) and 68% (II) of the cases, with average ratings 2.9 (I) and 2.6 (II). For the thorax, a rating<or=3 was given in 94% and 91% of the cases, with average ratings 2.1 and 1.9, respectively. For quantitative validation, automatically generated structures were compared geometrically in 2D and 3D to manually drawn structures created by experts on seven randomly selected cases. The quantitative validation was limited to pelvis structures. The results indicate that the accuracy of the algorithms is within the bandwidth of manual segmentation by experts, except for specific erroneous situations. Even though manual review and corrections of automatically segmented structures are still mandatory, it can be expected that due to the speed of the presented software and the quality of its results, its introduction in the radiotherapy treatment planning process will lead to a considerable amount of time being saved.