필터 지우기
필터 지우기

Saving segmented character sequentially (Matlab)

조회 수: 1 (최근 30일)
ana ain
ana ain 2016년 8월 2일
편집: per isakson 2017년 4월 2일
I have the code for word images segmentation into characters. The segmentation is running well. But I have to save all the result of segmented words (each character image as one file) sequentially. But this code just save the last segmented character in every word images. The code is as follow:
for z = 1: 300
name1 = strcat ('data (',int2str(z),').png');
name2 = strcat ('D:\1. Thesis FINISH!!!\source\', name1);
a = imread (name2);
myFolder = 'D:\1. Thesis FINISH!!!\coba';
%%Binarization %%
level = graythresh (a);
b = im2bw (a, level);
%%Complement %%
c = imcomplement (b);
%%PadArray %%
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;
% *Defining the threshold to determine baseline area* %
threshold=max(verticalProjection)/3;
% threshold = 0;
% threshold=min(verticalProjection)/3;
% threshold = 5; % Threshold >0 used for cursive characters
thresholdedProjection=verticalProjection > threshold;
count=0;
startingColumns = [];
startingColumnsIndex=0;
for j =1:length(thresholdedProjection)
if thresholdedProjection(j)
if(count>0)
startingColumnsIndex=startingColumnsIndex+1;
startingColumns(startingColumnsIndex)= j-floor(count/2);
count=0;
end
else
count=count+1;
end
end
endingColumns=[startingColumns(2:end)-1 j-floor(count/2)];
y = 1;
% *Extract each region, result of segmentation process*
for k = 1 : length(startingColumns)
% Get sub image of just one character
subImage = i(:, startingColumns(k):endingColumns(k));
% im = subImage;
s = subImage;
% Normalization using algorithm 2 %
p = normalization2 (s);
subplot(2,2,2);
imagesc (p);
axis equal off;
pause (1);
% figure,
imshow (p);
% Morphological Operation - Thinning %
t = bwmorph(p,'thin',Inf);
end
% savename = char (strcat (myFolder, name1));
baseFileName = sprintf('data.%d.png', y);
y=y+1;
% Prepend the folder to make the full file name.
fullFileName = fullfile(myFolder, baseFileName);
% Do the write to disk.
imwrite(t, fullFileName);
% imwrite (t, fullfile (myFolder, sprintf ('data.%d.png', y)));
% y = y+1;
end;
The saved file of segmented characters is supposed to be like this:
But the code doesn't work. Any help and explanation would be very appreciated.
Thank you
  댓글 수: 2
yamina jafri
yamina jafri 2017년 4월 2일
Hello @ana ain i try alot to do segmentation from word to character..but I did not succeed! can you please help me this is my email: yaminajafri@yahoo.com
Image Analyst
Image Analyst 2017년 4월 2일
As of the original post, no solution had been found by her. You might want to ask someone else after you read this link.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by