A method for segmenting an image, the method comprising: calculating an a priori probability of appearing in a head-shoulder foreground for each pixel in an image having a preset size according to a positioning result of exterior facial contour points; selecting head-shoulder foreground sample pixels and background sample pixels from an image to be segmented according to the a priori probability, and a head-shoulder foreground probability threshold and a background probability threshold which are set in advance; calculating a first color likelihood probability of the head-shoulder foreground and a second color likelihood probability of the background according to color feature vectors of the head-shoulder foreground sample pixels and color feature vectors of the background sample pixels; calculating a first a posteriori probability of the head-shoulder foreground and a second a posteriori probability of the background according to the a priori probability, the first color likelihood probability and the second color likelihood probability; and performing head-shoulder segmentation on the image to be segmented according to the first a posteriori probability and the second a posteriori probability; characterised in that selecting the head-shoulder foreground sample pixels and the background sample pixels from the image to be segmented according to the a priori probability, and the head-shoulder foreground probability threshold and the background probability threshold which are set in advance comprises: identifying a gender of the face in the image to be segmented to obtain a gender identification result; determining an a priori probability corresponding to the image to be segmented according to the gender identification result; with respect to each pixel in the image to be segmented, determining whether the a priori probability of the pixel is larger than the head-shoulder foreground probability threshold; if the a priori probability of the pixel is larger than the head-shoulder foreground probability threshold, determining the pixel as the foreground sample pixel; and with respect to each pixel in the image to be segmented, determining whether the a priori probability of the pixel is smaller than the background probability threshold; if the a priori probability of the pixel is smaller than the background probability threshold, determining the pixel as the background sample pixel. calculating an a priori probability of appearing in a head-shoulder foreground for each pixel in an image having a preset size according to a positioning result of exterior facial contour points; selecting head-shoulder foreground sample pixels and background sample pixels from an image to be segmented according to the a priori probability, and a head-shoulder foreground probability threshold and a background probability threshold which are set in advance; calculating a first color likelihood probability of the head-shoulder foreground and a second color likelihood probability of the background according to color feature vectors of the head-shoulder foreground sample pixels and color feature vectors of the background sample pixels; calculating a first a posteriori probability of the head-shoulder foreground and a second a posteriori probability of the background according to the a priori probability, the first color likelihood probability and the second color likelihood probability; and performing head-shoulder segmentation on the image to be segmented according to the first a posteriori probability and the second a posteriori probability; identifying a gender of the face in the image to be segmented to obtain a gender identification result; determining an a priori probability corresponding to the image to be segmented according to the gender identification result; with respect to each pixel in the image to be segmented, determining whether the a priori probability of the pixel is larger than the head-shoulder foreground probability threshold; if the a priori probability of the pixel is larger than the head-shoulder foreground probability threshold, determining the pixel as the foreground sample pixel; and with respect to each pixel in the image to be segmented, determining whether the a priori probability of the pixel is smaller than the background probability threshold; if the a priori probability of the pixel is smaller than the background probability threshold, determining the pixel as the background sample pixel.