1. An apparatus for decoding a two-dimensional code having a detection pattern, comprising: a detecting unit configured to binarize a multivalue image with a first binarization threshold value to detect the detection pattern; a correcting unit configured to correct a density of the two-dimensional code in the multivalue image at a position specified by the detected detection pattern, correction being based upon a density of the detection pattern, so as to obtain a corrected multivalue two-dimensional code; and a decoding unit configured to binarize, with a second binarization threshold value calculated using the multivalue image, the corrected multivalue two-dimensional code of which the density has been corrected by the correcting unit, so as to obtain a binarized and corrected two-dimensional code, and to decode the binarized and corrected two-dimensional code, wherein the first and second binarization threshold values are different from each other.