Techniques for efficiently and accurately organizing freeform handwriting
into lines. A global cost function is employed to find the simplest
partitioning of electronic ink strokes into line groups that also
maximize the "goodness" of the resulting lines and the consistency of
their configuration. The "goodness" of a line may be based upon its
linear regression error and the horizontal and vertical compactness of
the strokes making up the line. The line consistency configuration for a
grouping of strokes is measured by the angle difference between
neighboring groups. The global cost function also takes into account the
complexity of the stroke partitioning, measured by the number of lines
into which the strokes are grouped. An initial grouping of strokes is
made, and the cost for this initial grouping is determined. Alternate
groupings of the initial stroke grouping are then generated. The global
cost of each of these alternate stroke groupings is then calculated, and
the stroke grouping that produces the largest global cost decrease from
the global cost of the original grouping is selected. The alternate
grouping creation, cost determination and evaluation, and grouping
selection process then is repeated until the global cost for new grouping
alternates no longer decreases.