필터 지우기
필터 지우기

How to automatically identify text lines from projection plot?

조회 수: 2 (최근 30일)
Faraz
Faraz 2014년 1월 18일
댓글: Bachtiar Muhammad Lubis 2018년 12월 2일
I have been reading about automatic text line recognition in Matlab and although there are many advanced methods to do this every paper mentions that the simplest way of detecting text lines is via horizontal projections. So I decided to try this method for myself.
I am very new to this and have hit a brick wall, I have reached a level beyond which I do not know how to proceed. This is what I have achieved so far:
I'm trying for a system that is language independent and only interested in text lines, so I chose Arabic text:
I used the function ``radon`` to get the projections.
img = rgb2gray(imread('arabic.jpg'));
[R, xp] = radon(bw_closed, [0 90]);
figure; plot(xp,R(:,2)); title('at angle 90');
This is the plot(projection)
So clearly the 5 peaks represent the 5 lines detected but how do I go from here to segmenting the original document?
Can anyone help me beyond this point? All the papers I read make no mention of how to proceed from this step, they just say that from the projections we have our detected lines.
What I'm asking is how, from the plot data can I tell matlab what is the line of text and what is the gab between lines?
  댓글 수: 1
VIBHATH V B
VIBHATH V B 2015년 3월 3일
Hi.......... Can u send me the whole code for the above? What is 'bw-closed' here? My E-mail Id is : vibhathvb@gmail.com

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2014년 1월 18일
I would just find where the black is in the profile
darkPixels = R < 20; % Threshold
% label
labeledRegions = bwlabel(darkPixels);
% Find centroids
measurements = regionprops(labeledRegions, 'Centroid');
% Get them into an array
allCentroids = [measurements.Centroid];
Now you can just crop out some line of text you're interested in, into a separate image:
thisLine = yourImage(allCentroids(k):allCentroids(k+1), :);
  댓글 수: 28
Image Analyst
Image Analyst 2018년 8월 7일
I don't think it has a name. It's just something I thought up. Something that basic usually doesn't have a name.
Bachtiar Muhammad Lubis
Bachtiar Muhammad Lubis 2018년 12월 2일
@ HJ Akhtar : i've read some papers and found that this is projection profile algorihm. just googling "image segmentation using projection profile".

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

fawzi
fawzi 2014년 9월 25일
what if the lines are curved ? in this case the projection is not useful. Can you help me in this problem

Rinku
Rinku 2015년 1월 2일
편집: Walter Roberson 2015년 12월 19일
try this code;
img = rgb2gray(imread('arabic.jpg'));
[R, xp] = radon(bw_closed, [0 90]);
figure; plot(xp,R(:,2)); title('at angle 90');
r = R(:,2);
r=r(92:391); % your image region
blank = r < 3; % region without text
[labeled, n] = bwlabel(blank);
C = regionprops(labeled, 'Centroid'); % find the centers of blank regions
for i=1:length(C)-1
subplot(length(C)-1,1,i)
imshow(img(C(i).Centroid(2):C(i+1).Centroid(2),:));
end
  댓글 수: 5
moahaimen talib
moahaimen talib 2017년 5월 7일
great answering thank you i understand that now
Urooba zaki
Urooba zaki 2018년 1월 22일
respected sir this code shows an error... i think the function file is missing ... plz reply Undefined function or variable 'bw_closed'.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by