code for word segmentation to images, also first few images