Three-dimensional reconstruction of imperfect two-dimensional crystals