The accuracy of the Shack–Hartmann wavefront sensor for measuring the wavefront distortion is mainly dependent upon the measuring accuracy of the centroid of each spot. A modified center detection algorithm, which uses some power from the photon events of each pixel instead of photon events themselves, is analyzed theoretically and the computer simulations are given. The results show that photon noise error and sampling error increases as the power value goes up; and to some powers, the readout noise and background noise error decrease. An experiment is described through which the optimum power can be obtained.