The failure process of heterogeneous rock specimen with initially random material imperfections in uniaxial plane strain compression and the macroscopically mechanical response are numerically modeled by using FLAC (Fast Lagrangian Analysis of Continua). A FISH function is generated to prescribe the initial imperfections within the heterogeneous specimen by using Matlab. The imperfection is weaker than the intact rock. Beyond the failure of the imperfection, it undergoes ideal plastic behavior, while intact rock exhibits linear strain-softening behavior and then ideal plastic behavior once failure occurs. The specimen with smooth ends is loaded at a constant strain rate and is divided into 3200 elements. The maximum numbers of the initial imperfections in five schemes are 100, 300, 500, 700 and 900. The effects of the number of the imperfections on the fracture process, the final fracture pattern and the complete stress-strain curve are investigated. Prior to the peak stress, some imperfections extend in the axial direction and then a part of them coalesce to form inclined shear bands. Beyond the peak stress, shear bands progressively intersect the specimen; in the process the number of the yielded elements approximately remains a constant. With an increase of the number of the initial imperfections, the spacing of shear fractures decreases, the peak stress and corresponding axial strain decrease; the post-peak branch of stress-strain curve becomes steeper; much more elements fail in tension; the number of the yielded elements in tension in the vicinity of the two lateral edges of the specimen remarkably increases.