1. A computer-readable non-transitory storage medium that stores a program causing a computer to function as a document recognition apparatus, the program causing said computer to execute a process comprising: extracting a group of connected components of pixels from an input image for each of a plurality of lines so that the elements that seem to be characters determined by said determining based on a histogram for a number of pixels obtained by projecting said connected components of pixels toward direction of a selected line identified by said group of connected components of pixels are enclosed, generating a reference element that is connected components of pixels extracted by said extracting and combined elements obtained by combining the reference element and connected components of pixels adjacent to the reference element as an element to be estimated; calculating a degree of certainty that indicates how much the element to be estimated generated by said generating seems to be a character; and determining elements that seem to be characters among said elements to be estimated based on the degree of certainty calculated by said calculation unit; wherein said generating newly generates said combined elements by combining connected components of pixels adjacent in directions of lower right of said elements to be estimated.