1. An image pickup device comprising: an obtaining section configured to obtain a taken image; a specification section configured to specify an image area which is contained in the taken image obtained by the obtaining section and in which a value of nonflatness is less than or equal to a predetermined value; a determination section configured to determine whether a range of the image area specified by the specification section is greater than or equal to a predetermined range; a background generation section configured to generate an extraction background image used to extract a subject area from the taken image based on information on the image area when the determination section determines that the range is greater than or equal to the predetermined range; a subject extraction section configured to extract the subject area from the taken image, based on information on a difference between the extraction background image and the taken image; a division section configured to divide the taken image into a plurality of image blocks; and a nonflatness calculation section configured to calculate the value of nonflatness of each of the plurality of image blocks resulting from the division by the division section; wherein the specification section determines whether the value of nonflatness of each of the plurality of image blocks calculated by the nonflatness calculation section is less than or equal to a predetermined value, and specifies an image block in which the value of nonflatness is less than or equal to the predetermined value based on a result of the determination; wherein the determination section determines whether a number of image blocks specified by the specification section and in which the value of nonflatness is less than or equal to the predetermined value accounts for at least a predetermined rate of a total number of image blocks; and wherein when the determination section determines that the number of image blocks in which the value of nonflatness is less than or equal to the predetermined value accounts for at least the predetermined rate of the total number of image blocks, the background generation section generates the extraction background image.