1. A pattern processing apparatus comprising: an acquisition unit configured to acquire a pattern image in which a plurality of pattern elements are arrayed in a grid, together with coordinate information of the pattern elements; an adjacent element identification unit configured to identify, for each of the pattern elements thus acquired, adjacent elements, in at least two directions, each having the shortest distance to the each of the pattern elements, wherein the distances between the each of the pattern elements and other pattern elements are calculated using the coordinate information; a connection unit configured to connect and group, as a connected component, the pattern elements that are adjacent to one another; and an assigning unit configured to assign position information in the array in order from the pattern element which is a starting point, among the pattern elements included in the connected component, according to a predetermined regularity.