MATLAB: How to segment a paragraph into lines and words

one-word

119.jpg

Best Answer

Of course it's possible to segment the file. It's fairly trivial as well. Just close the image (if you're working with white text on black background which you should be, or open if you're working with black text on white background) and get the bounding box of the resulting objects in the image:
[rawimage, map] = imread('119.jpeg.png'); %for some reason the source image is indexed
greyimage = ind2gray(rawimage, map); %convert to greyscale
bwimage = ~imbinarize(greyimage); %for processing, binarise and invert so text is white on black background
joinedimage = imclose(bwimage, strel('square', 5)); %experiment with different structuring elements. This one works fine with your image
props = regionprops(joinedimage, 'BoundingBox'); %get bounding box of the objects
figure;
imshow(greyimage); %display image
arrayfun(@(prop) rectangle('Position', prop.BoundingBox, 'EdgeColor', 'red'), props); %and bounding boxes
segmented.png