In digital fringe projection (DFP) techniques, invalid points such as shadows and background cause ambiguity to the measurement. Manually segmenting the object and invalid points is time-wasting, and the improper selection of threshold makes errors in the measurement. In this paper, we propose an automatic threshold selection technique based on both modulation histogram and intensity histogram, which can segment the object from a complex background without losing useful information. The feasibility of this method is verified by experiments on binary defocusing technique at different defocus levels.