How to Segment the characters from left to right

조회 수: 8 (최근 30일)
Rutika Titre
Rutika Titre 2016년 1월 2일
댓글: sayar chit 2017년 11월 14일
Hello Sir,
I am segmenting line of text and then want to segment individual characters from left to right. In my code after applying bounding box of each character the character are not reading from left to right and even I want to display the output that the input text was what ever I give the input image.Thank you in advance.
%%Read Image
imagen=imread('2.png');
%%space
sp=10;
%%Show image
figure(1)
imshow(imagen);
title('INPUT IMAGE WITH NOISE')
%%Convert to gray scale
if size(imagen,3)==3 % RGB image
imagen=rgb2gray(imagen);
end
%%Convert to binary image
threshold = graythresh(imagen);
imagen =~im2bw(imagen,threshold);
%imagen = imclose(imagen, strel('rectangle',[3 ceil(Sp/2)]));
%%Remove all object containing fewer than 30 pixels
imagen = bwareaopen(imagen,15);
pause(1)
%%Show image binary image
figure(2)
imshow(~imagen);
title('INPUT IMAGE WITHOUT NOISE')
%%Label connected components
[L Ne]=bwlabel(imagen);
%%Measure properties of image regions
propied=regionprops(L,'BoundingBox');
hold on
%%Plot Bounding Box
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
end
hold off
pause (1)
%%Objects extraction
figure
for n=1:Ne
[r,c] = find(L==n);
n1=imagen(min(r):max(r),min(c):max(c));
imshow(~n1);
pause(0.5)
end
  댓글 수: 1
sayar chit
sayar chit 2017년 11월 14일
@Rutika Titre!
Can you give me character segmentation. My mail is chitsanlwin.maths.mm@gmail.com. Thank you in advance.

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

채택된 답변

Walter Roberson
Walter Roberson 2016년 1월 2일
You have the bounding boxes. Sort them by x coordinate.
  댓글 수: 5
Rutika Titre
Rutika Titre 2016년 1월 2일
Error using sort sorting direction must be 'ascend' or 'descend'.
Error in objectextrac (line 47) [~, sortorder] = sort(bounds, 'rows');
Sir, I m getting this error.It should segment each character as we read. First line all characters from left to right and then second line from left to right. Thanking You!
Walter Roberson
Walter Roberson 2016년 1월 2일
As the correction to the above,
bounds = vertcat(propied.BoundingBox);
[~, sortorder] = sortrows(bounds);
propied = propied(sortorder);
However this does not sort by line. To do that you need to figure out where the line boundaries are and proceed a line at a time sorting by the bounding box. You could consider horizontal profiling to find the line bounds.

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

추가 답변 (1개)

Reshma Viswambharan
Reshma Viswambharan 2016년 1월 15일
How can i do line by line segmentation? plz tell me which code i used for this and how i eliminate logos in number plate. plz help me...

Community Treasure Hunt

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

Start Hunting!

Translated by