1. An image processing apparatus, comprising: a central processing unit (CPU) configured to: detect a plurality of faces of a number of people, each comprises a facial expression, from input image data; calculate an evaluation value, that expresses a degree of the facial expression, for each of a plurality of facial expressions of the detected plurality of faces; change, in an event only a first facial expression of the plurality of facial expressions is a facial expression that a smallest number of people have, only a first threshold value that corresponds to the first facial expression; change, in an event at least two facial expressions of the plurality of facial expressions are facial expressions that the smallest number of people have, only a second threshold value that corresponds to a second facial expression, among the at least two facial expressions, that a largest number of children have; and extract an image from the input image data in an event that each evaluation value, calculated for each of the plurality of facial expressions, exceeds the first threshold value in the event only the first facial expression of the plurality of facial expressions is the facial expression that the smallest number of people have or the second threshold value in the event at least two facial expressions of the plurality of facial expressions are facial expressions that the smallest number of people have.