How to do segmentation for cursive character images?
1 次查看(过去 30 天)
显示 更早的评论
I've done segmentation process for isolated character image using the following code. But it just work for isolated character using vertical projection method.
Soumyadeep have explained, The graph at the letter location will start from 0 , reach the peak and then fall but it will never touch 0 as the letters in this case are connected. by looking at the graph we could define the threshold (if I'm not mistaken), which should be the maximum of the deepest points of the valleys we see in the graph. The problem is, I didn't know how to set the threshold. I've already try to modify several values, but it didn't gave me a suitable result.
% Preprocessing + Segmentation
% // Original Code of Vertical Projection for Segmentation by Soumyadeep Sinha //
% // Modified by Ana Ainul S. : anaainul@gmail.com, Last modified : 20/04/16 //
% Saving each single segmented character as one file
function [se] = segmentt (a)
myFolder = 'D:\1. Thesis FINISH!!!\Data set';
%%Binarization %%
level = graythresh (a);
b = im2bw (a, level);
%%Complement %
c = imcomplement (b);
i=padarray(c,[0 10]);
% Vertical Projecttion for Character Segmentation
verticalProjection = sum(i, 1);
set(gcf, 'Name', 'Segmentation Trial', 'NumberTitle', 'Off')
subplot(2, 2, 1);imshow(i);
subplot(2,2,3);
plot(verticalProjection, 'b-');
grid on;
t = verticalProjection;
t(t==0) = inf;
mayukh = min(t); % return smallest element of t
% 0 where there is background, 1 where there are letters
letterLocations = verticalProjection > mayukh;
% Find Rising and falling edges
d = diff(letterLocations);
startingColumns = find (d>0);
endingColumns = find(d<0);
% Extract each region
y=1;
for k = 1 : length(startingColumns)
% Get sub image of just one character...
subImage = i(:, startingColumns(k):endingColumns(k));
% im = subImage;
s = subImage;
figure, imshow (s);
imwrite( s, fullfile( myFolder, sprintf('data.%d.png', k ) ) );
end;
se = (s);
Isolated Characters
Cursive Characters
Any help would very appreciate. Thank You so much.
0 个评论
回答(1 个)
Image Analyst
2016-7-23
Try manually setting thresholds until you find one that works.
2 个评论
Image Analyst
2016-7-23
Pass in different levels to
b = im2bw (a, level);
Don't just blindly use what graythresh() tells you - that's often or usually not a good selection of a threshold.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!