how to segment and display the words into letters

2 次查看(过去 30 天)
I have done pre-processing.and now i am trying to segment the word image(cursive) into letters and to display the segmentation columns.i couldn't display the segmentation columns.
my code is below:
clc;
clear all;
close all;
I=imread('a.jpg');
figure(1)
subplot(3,2,1);
imshow(I);
title('input image(from IAM)');
K=filter2(fspecial('average',3),I)/255;
subplot(3,2,2);
imshow(K);
title('average filter')
Km= medfilt2(K);
subplot(3,2,3);
imshow(Km);
title('median filter');
G = wiener2(Km,[5 5]);
subplot(3,2,4);
imshow(G);
title('gaussian filtering');
N = imcomplement(G);
subplot(3,2,5);
imshow(N);
title('inverted image');
B = im2bw(N,0.5);
subplot(3,2,6);
imshow(B);
title('binary image');
BW2 = bwmorph(B,'thin',inf);
figure(2)
subplot(3,2,1);
imshow(BW2);
title('output of thinning');
%BW2=padarray(BW2,[0 10]);
verticalprojection = sum(BW2, 1);
subplot(3,2,2);
stem(verticalprojection);
title('v.projection');
horizontalprojection=sum(BW2,2);
subplot(3,2,3);
stem(horizontalprojection);
title('H.projection');
histogram=imhist(I);
subplot(3,2,6)
plot(histogram)
title('Histogram of image data');
%L = bwlabel(BW2);
%subplot(3,2,5)
%imshow(L)
horizontalProfile = sum(double(B), 1);
logicalSpaceIndexes = horizontalProfile <=7;
actualSpaceIndexes = find(logicalSpaceIndexes);
display(actualSpaceIndexes)
croppedImage = grayImage(:, col1:col2);
imshow(croppedImage)

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by