Got a half-decent segmentation algorithm. Still requires some tuning and some parameters to be automatically set so it gives good results for all characters.