MATLAB: HOW TO SEGMENT A WORD INTO CHARACTERS USING VERTICAL PROJECTION

character segmentationcursiveImage Processing Toolboxmatraocr

hello everyone! i am trying to segment a word into characters using vertical projection of histogram. i can find the histogram and i am able to find the threshold value. the histogram looks like this.
as you can see that there are 4 peaks in the histogram hence i am assuming it represents the 4 characters from the above figure.
the code is given in the figure below.
now i am stuck with how to segment each characters after finding the threshold. can anyone help me with this??

Best Answer

Histogram has nothing to do with it. You don't calculate it and you don't use it. I think you mean "profile" instead of histogram.
If you want to extract the vertical strips of your image where you have characters, then you need to threshold the profile and determine where each regions starts and stops.
% 0 where there is background, 1 where there are letters
letterLocations = verticalProjection > 0;
% Find Rising and falling edges
d = diff(letterLocations);
startingColumns = find(d>0);
endingColumns = find(d<0);
% Extract each region
for k = 1 : length(startingColumns)
% Get sub image of just one character...
subImage = binaryImage(:, startingColumns(k):endingColumns(k));
% Now process this subimage of a single character....
end
The above code is untested - just off the top of my head. You may need to debug it or move the starting and ending columns a pixel to the right or left.
Related Question