Based on the theoretical model published by Chen et al. [Chem. Phys. Lett. 397, 222 (2004)], we present an efficient scheme for studying the mechanism of the electro-optic (EO) effect in perovskite-type ferroelectrics employing the electronic density-functional theory and the generalized gradient approximation. The results show that the main contribution to the EO effect in KNbO3 and LiNbO3 crystals comes from the relative displacements of the central metal ion and oxygen in the NbO6 oxygen octahedron induced by a low frequency applied electric field. These displacements change the band wave functions of the electrons in the crystals through electron-phonon coupling, which then affects the electronic response of the lattice to the incident optical wave (i.e., induces a change of refractive index). Furthermore, the relationship between the microstructure of perovskite-type ferroelectrics and the clamped EO effect and the physical meaning of the parameter βk(ij) published by Chen et al. are explained.