Wavefront sensing systems measure the slope or curvature of a surface by calculating the centroid displacement of two focal spot images. Accurately finding the centroid of each focal spot determines the measurement results. This paper studied several widely used centroid-finding techniques and observed that thresholding is the most critical factor affecting the centroid-finding accuracy. Since the focal spot image of a freeform surface usually suffers from various types of image degradation, it is difficult and sometimes impossible to set a best threshold value for the whole image. We propose an adaptive centroid-finding algorithm to tackle this problem and have experimentally proven its effectiveness in measuring freeform surfaces.