A method for automatically segmenting a liver in digital medical images includes providing a 3-dimensional (3D) digital image I and a set of N training shapes {φi}i=1, . . . , N for a liver trained from a set of manually segmented images, selecting a seed point to initialize the segmentation, representing a level set function φα(θx+h) of a liver boundary Γ in the image asϕα(x)=ϕ0+∑i=1nαiVi(x),whereϕ0(x)=1N∑i=1Nϕi(x)is a mean shape, {Vi(x)}i=1, . . . , n are eigenmodes where n<N, αi are shape parameters, and h ε R3 and θε [0,2π]3 are translation and rotation parameters that align the training shapes, minimizing a first energy functional to determine the shape, translation, and rotation parameters to determine a shape template for the liver segmentation, defining a second energy functional of the shape template and a registration mapping weighted by image intensity histogram functions inside and outside the boundary, and minimizing the second energy functional to determine the registration mapping, where the registration mapping recovers local deformations of the liver.