1. An image processing apparatus synthesizing a plurality of pieces of images photographing an identical scene and having different exposure amounts to generate a synthetic image expanding a dynamic range and having a wide tonal range, the synthetic image being a high-contrast image, the image processing apparatus comprising: a selecting unit selecting a reference image based on information of brightness components of the pieces of images; a gain calculating unit calculating brightness ratios of remaining images to the reference image as gains of the remaining images based on the information of the brightness components of the pieces of images, the remaining images being images among the pieces of images excluding the reference image; a weight calculating unit calculating weights to be applied to the remaining images based on the gains being calculated and information of a brightness component of the reference image; and a generating unit generating the high-contrast image by performing weighting synthesis processing between the reference image and the remaining images by using the weights being calculated.