1. A computer program product embodied in a computer readable medium for performing a method of segmenting an anatomic entity in a digital medical image comprising: defining, for each of a number of landmarks in said image, an initial position of said landmark, sampling a neighborhood around said initial position, said neighborhood comprising a number of candidate locations of said landmark, associating a cost with each of said candidate locations, optimizing a cost function expressing a weighted sum of overall gray level cost and overall shape cost for all candidate locations, defining a segmented anatomic entity as a path through a selected combination of said candidate locations for which combination said cost function is optimized, and wherein said overall shape cost is a combination of all individual costs of connection vectors, said connection vectors connecting successive landmarks, for all landmarks, wherein said individual shape cost is expressed by the Mahalanobis distance defined as the distance of a connection vector between two successive landmarks to the mean connection vector weighted with the inverse of the covariance matrix, said mean connection vector and covariance matrix being retrieved from a shape model of said anatomic entity.