1. A method of segmenting connected components of markings in a document image into smaller pieces, the segmenting comprising: detecting individual lines of aligned text in the document image by: grouping feature points of the connected components into strips of features points; fitting lines to the strips of feature points; and forming text line bounding boxes from pairs of fitted lines; generating an aligned text mask from the detected individual lines of aligned text; and using the aligned text mask from the detected aligned text to segment the document image into aligned text fragments, at least one of the aligned text fragments being a subset of one of the connected components.