How to do segmentation for cursive character images?

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.

Réponses (1)

Image Analyst
Image Analyst le 23 Juil 2016

0 votes

Try manually setting thresholds until you find one that works.

2 commentaires

ana ain
ana ain le 23 Juil 2016
Which part I should change to set the threshold, would you provide a sample code Sir?
Thank you :)
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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Processing and Computer Vision dans Centre d'aide et File Exchange

Question posée :

le 21 Juil 2016

Commenté :

le 23 Juil 2016

Community Treasure Hunt

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

Start Hunting!

Translated by