The features of terahertz images were analyzed, relying on the digital image processing technique and an efficient and real-time algorithm was proposed for a terahertz security system for human bodies. The noise in terahertz images was removed by using an improved nonlocal mean filter. The human body outline was detected by applying active shape model (ASM) algorithm. And a TSED(total square euclidean distance) based k-means algorithm was used to label objects in terahertz images. The experimental results demonstrate that the proposed method can well detect and segment suspicious objects from terahertz images.