how to segment words in an image containing paragraph?
Show older comments

In the image,now line segmentation is done! How to segment words?? Pls help me with the code.. Thank you
Answers (2)
Image Analyst
on 26 Nov 2015
0 votes
For each line, do the same process as you did for the lines. Sum the image vertically and look for gaps.
5 Comments
sindhu c
on 27 Nov 2015
sindhu c
on 27 Nov 2015
Image Analyst
on 27 Nov 2015
No - you're supposed to get the horizontal profile, NOT the vertical profile.
horizontalProfile = mean(thisLine, 1);
% Columns in a word will have a sum that's pretty low
darkColumns = horizontalProfile < 210; % or whatever works.
Now wherever darkColumns is true will be a column that has letters in it. You can find individual stretches of dark columns with bwlabel
labeledColumns = bwlabel(darkColumns);
Not sure what you want to do after this. If you want to extract separate words, use ismember(), for example to get the third word
word3 = ismember(labeledColumns, 3); These are logical columns
% Extract only those columns from word #3 from the sentence band:
wordNumber3 = thisLine(:, word3); % wordNumber3 is a 2D image.
sindhu c
on 27 Nov 2015
sindhu c
on 27 Nov 2015
Divya
on 17 Jan 2017
0 votes
Hi Image Analyst,
Thank you for the code to segment lines. But I'm unable to segment with this code.
For the same image given above, the statement "darkColumns = horizontalProfile < 210; " gives zero column.
And when labeling such column doesn't give any result.
I tried changing threshold values. But I am getting stuck in labeling the columns. Can you please help me
Categories
Find more on Language Support in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!