Near-field imaging of periodic inhomogeneous media