This project fills holes in drawings according to an exponential distribution based on gradient magnitude and gradient angle. Gradient magnitude tells us how sharply the gray scale colors transition. Pairwise gradient angle represents shapes in the image.
Given the probability distribution, simulated annealing approximately solves the maximum likelihood estimator. When the hole is small, the inpainting result looks reasonable to human eyes.
Simulated annealing is fast enough to handle around 20 pixels. Beyond that, for future improvement, the exponential model can be seen as a Markov Random Field on the gradient field. There is a well-known optimization algorithm called Max-Product Belief Propagation.