The input is treated as height field and the heights of pixels marked as free are calculated so that different levels are connected smoothly. The heights are found by solving Poisson's 2nd order differential equation in the free areas using modified Gauss-Seidel algorithm.