1. An image processing apparatus comprising: an acquisition unit configured to acquire image data; an extraction unit configured to extract a set of candidate character components from the image data for each gradation of the image data on the basis of a predetermined first criterion; a removal unit configured to remove a non-character component from the set of the candidate character components on the basis of a predetermined second criterion; a pixel counting unit configured to count the number of character pixels representing the number of pixels included in the candidate character component after the non-character component is removed; an edge counting unit configured to count the number of edge pixels representing the number of edge pixels adjacent to the candidate character component after the non-character component is removed; an output image selection unit configured to select as an output image the candidate character component, from which the non-character component is removed, in the gradation having a largest number of pixels when there is a significant difference between the number of character pixels in the gradation having the largest number of character pixels and the number of character pixels in the gradation having the second largest number of character pixels, and select as the output image the candidate character component, from which the non-character component is removed, in the gradation having a smallest number of edge pixels when there is no significant difference between the number of character pixels in the gradation having the largest number of character pixels and the number of character pixels in the gradation having the second largest number of character pixels; and an output unit configured to output the output image being selected.