1. An image processing apparatus comprising: a setting unit that sets two images; a specification unit that specifies common regions in (i) a long-time image, which is an image having a longer exposure time out of the two images, and (ii) a short-time image, which is an image having a shorter exposure time out of the two images, based on pixel values within a first pixel value range in a pixel value distribution of the long-time image and pixel values within a second pixel value range in a pixel value distribution of the short-time image; a calculation unit that calculates a location error correction amount between the long-time image and the short-time image to make the common region in the long-time image match the common region in the short-time image when the long-time image and the short-time image are overlapped with each other; and a unit that generates a composite image by compositing the long-time image and short-time image based on the location error correction amount, and outputs the generated composite image, wherein the specification unit includes (a) a first specification unit which specifies, in the long-time image, a region having a pixel value within the first pixel value range determined in accordance with a threshold set based on the pixel value distribution of the long-time image, and (b) a second specification unit which specifies, in the short-time image, a region having a pixel value within the second pixel value range determined in accordance with a threshold set based on the pixel value distribution of the short-time image, and wherein, when the region specified by the first specification unit and the region specified by the second specification unit have an overlapping portion not smaller than a predetermined size, upon compositing the long-time image and the short-time image, the region specified by the first specification unit and the region specified by the second specification unit are set as the common regions.