私はすでにセグメンテーションプロセスのコードを変更しました。コードは以下の通りである:セグメンテーション結果の正確なイメージを保存するにはどうすればいいですか(垂直投影法によるセグメンテーション)?
% Preprocessing + Segmentation (VP with secondary element)
% // Original Code of Vertical Projection for Segmentation by Soumyadeep Sinha //
% // Modified by Ana Ainul S. : [email protected], Last modified : 14/07/16 //
% Saving each single segmented character as one file
function [ss] = segment (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)
% 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));
s = subImage;
figure, imshow (s);
% Save each segmented characters %
[L,num] = bwlabel(s);
for z = 1 : num
bw= ismember(L, z);
% Construct filename for this particular image.
baseFileName = sprintf('data1.%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(bw, fullFileName);
end
end;
ss = (s);
それは良い結果を与えたが、私は、各セグメント化された画像に対して1つのファイルとして保存する必要があるとき、私はいくつかの問題があります。
過程で切り出された文字。
私はそれを保存すると、結果が変わります。
二要素、私はそれを保存しようとすると、文字の本体が分離されていたと団結することになっていること。私はコードを修正しようとしましたが、まだ解決策を得ていませんでした。 私はプログラムで示したものと全く同じ画像を保存する必要があります。
ご協力いただきありがとうございます。
ありがとうございました。
あなたは[この回答](http://stackoverflow.com/a/37938764/1714410)の関連を見つけるかもしれません。 – Shai