Landau levels in lattice QCD in an external magnetic field