The wavefront-sensor is one of the most important components of any adaptive optics (AO) system. The simplicity of the Shack-Hartmann sensor has made it a popular choice for such systems. Its accuracy, which largely determines its performance depends on having a good and robust centroid algorithm. Despite a large number of studies, the general recipe for selecting the best centroiding algorithm and best pixel size in a Shack-Hartmann wavefront sensor is still lacking. We combine analytical theory with numerical simulations to compare various flavors of centroiding algorithms (thresholding, windowing, correlation, quad-cell) under different conditions of photon flux, read-out noise, and sampling. It is shown that the choice of the best method depends on those parameters. At very low signal to noise ratio, the performance of the quad-cell is close to optimum.© (2004) COPYRIGHT SPIE--The International Society for Optical Engineering. Downloading of the abstract is permitted for personal use only.