An image processing apparatus (100; 200; 300) comprising: a generation unit configured to generate a histogram of luminance values of a plurality of pixels included in an image; a luminance value calculation unit configured, given a set first ratio and a set second ratio, to calculate a first luminance value at which the set first ratio of the plurality of pixels of said image are present in descending order of the luminance values of the histogram, and a second luminance value at which the set second ratio of the plurality of pixels of said image are present in descending order of the luminance values of the histogram, where the second ratio is larger than the first ratio; a selection unit configured to compare the first luminance value and the second luminance value, and determine a third luminance value on the basis of a result of the comparing; and a correction unit configured to perform gradation correction that corrects the luminance values of the plurality of pixels of said image on the basis of the third luminance value and generate a corrected image, the gradation correction proportionally correcting the luminance values of the plurality of pixels of said image such that a luminance value equal to the third luminance value becomes a corrected luminance value equal to the maximum luminance value in a given range of luminance values, and such that when a corrected luminance value obtained by the proportional correction exceeds the maximum luminance value it is changed to the maximum luminance value, wherein the selection unit is configured to: calculate a difference between the first luminance value and the second luminance value; and set the second luminance value as the third luminance value when the difference is smaller than a threshold value, set a value between the second luminance value and the first luminance value as the third luminance value when the difference is equal to the threshold value, and set a value between the second luminance value and the first luminance value as the third luminance value when the difference is larger than the threshold value. a generation unit configured to generate a histogram of luminance values of a plurality of pixels included in an image; a luminance value calculation unit configured, given a set first ratio and a set second ratio, to calculate a first luminance value at which the set first ratio of the plurality of pixels of said image are present in descending order of the luminance values of the histogram, and a second luminance value at which the set second ratio of the plurality of pixels of said image are present in descending order of the luminance values of the histogram, where the second ratio is larger than the first ratio; a selection unit configured to compare the first luminance value and the second luminance value, and determine a third luminance value on the basis of a result of the comparing; and a correction unit configured to perform gradation correction that corrects the luminance values of the plurality of pixels of said image on the basis of the third luminance value and generate a corrected image, the gradation correction proportionally correcting the luminance values of the plurality of pixels of said image such that a luminance value equal to the third luminance value becomes a corrected luminance value equal to the maximum luminance value in a given range of luminance values, and such that when a corrected luminance value obtained by the proportional correction exceeds the maximum luminance value it is changed to the maximum luminance value, wherein the selection unit is configured to: calculate a difference between the first luminance value and the second luminance value; and set the second luminance value as the third luminance value when the difference is smaller than a threshold value, set a value between the second luminance value and the first luminance value as the third luminance value when the difference is equal to the threshold value, and set a value between the second luminance value and the first luminance value as the third luminance value when the difference is larger than the threshold value. calculate a difference between the first luminance value and the second luminance value; and set the second luminance value as the third luminance value when the difference is smaller than a threshold value, set a value between the second luminance value and the first luminance value as the third luminance value when the difference is equal to the threshold value, and set a value between the second luminance value and the first luminance value as the third luminance value when the difference is larger than the threshold value.