15. The computer program product of claim 9 , wherein step (c) comprises: (c1) putting all connected regions detected in step (b) in a set; (c2) selecting one of the connected regions from the set; (c3) searching for horizontal neighbors of the selected connected region, a horizontal neighbor being a connected region that (1) has a vertical position that is offset from that of the selected connected region by an amount smaller than a predetermined threshold, and (2) among all of the connected regions that meet criterion (1), is located closest horizontally to the selected connected region; (c4) adding any horizontal neighbors found in the search of step (c3) to a line list that contains the selected connected region, and removing the horizontal neighbors from the set; (c5) for the horizontal neighbors found in step (c3), repeating the searching step (c3) and the adding and removing step (c4), until no horizontal neighbors are found in a search, whereby a line list is generated; and (c6) selecting another connected region from the set, and repeating steps (c3), (c4) and (c5) to generate another line list, until the set is empty, whereby a plurality of line lists are generated.
9. A computer program product comprising a computer usable non-transitory medium having a computer readable program code embedded therein for controlling a data processing apparatus, the computer readable program code configured to cause the data processing apparatus to execute a process for segmenting an input image into line segments and word segments, the input image being a binary image containing text, the process comprising: (a) horizontally down sampling the input image using a first down-sampling ratio; (b) detecting connected regions in the down-sampled image obtained in step (a); (c) identifying horizontally neighboring connected regions that belong to same lines to form line lists containing such horizontally neighboring connected regions; (d) segmenting the input image into a plurality of line segments of the input image, each line segment of the input image being a region of the input image that corresponds to a bounding box in the down-sampled image containing all connected regions in a corresponding line list obtained in step (c); and for each of the line segments of the input image obtained in step (d), (e) horizontally down sampling the line segment of the input image using a second down-sampling ratio; (f) detecting connected regions in the down-sampled line segment obtained in step (e); and (g) segmenting the line segment of the input image into word segments at one or more word segmentation positions using the connected regions obtained in step (f), wherein the word segmentation positions are a subset of positions corresponding to locations in gaps between the connected regions in the down-sampled line segment of step (e) that have been detected in step (f), wherein the second down-sampling ratio is smaller than the first down-sampling ratio.