Bayesian damage recognition in document images based on a joint global and local homogeneity model