1. An image processing apparatus that generates a halftone image of an input image by performing quantization, comprising: a processor; and a memory having stored thereon instructions that, when executed by the processor, cause the processor to: hold a threshold value matrix in which threshold values, corresponding to a plurality of pixels in the input image, are arranged; determine a candidate of a pixel position whose threshold value is to be rewritten based on each pixel value of a plurality of pixels included in a predetermined area of the input image; determine the threshold value of the pixel position determined to be the candidate by using at least one threshold value of a plurality of threshold values corresponding to the plurality pixels in the predetermined area; and generate the halftone image of the input image based on the determined threshold value.