1. A method implemented on a computer for segmenting an input image into line segments and word segments, the input image being a binary image containing text, the method 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.