A comparison theorem for a piecewise Lipschitz continuous Hamiltonian and application to Shape-from-Shading problems