how to segment words in an image containing paragraph?

In the image,now line segmentation is done! How to segment words?? Pls help me with the code.. Thank you

Answers (2)

For each line, do the same process as you did for the lines. Sum the image vertically and look for gaps.

5 Comments

Thank you for the reply. Its your code only which i took from other link.. The code is attached below for line segmentation. What changes should be done for word segmentation?
After summing vertically, i.e verticalProfile = sum(thisLine,2); what should be done?
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.
Thank you for the reply.. After segmenting i have to get segmented words as i got lines.. I have attached the code.Please check whether its correct or not.After following the instructions which you gave,nothing is being displayed for word segmentation
for clear understanding, i have got the segmented line from previous code.Now how to segment words from this line? Please help me with code

Sign in to comment.

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

Asked:

on 26 Nov 2015

Answered:

on 17 Jan 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!