Layer Extraction with a Bayesian Model of Shapes