Codes for handwriting segmentation algorithm