Ich habe meinen Code für Segmentierungsprozess geändert. Aber ich bekomme einen "Index überschreitet Matrix-Dimension" -Fehler. Der Code ist wie folgt.Wie zu lösen "Index überschreitet Matrix Dimension" im Segmentierungsprozess (Matlab)
for z = 1: 300
name1 = strcat ('data (',int2str(z),').png');
name2 = strcat ('D:\1. Thesis FINISH!!!\Data set\0 Isolated Dataset\Advertising Bold 14\source\', name1);
a = imread (name2);
myFolder = 'D:\1. Thesis FINISH!!!\Data set\0 Segmented Character\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=min(verticalProjection)/3;
% threshold = 5; % Threshold >0 used to detect the baseline of cursive characters
thresholdedProjection=verticalProjection > threshold;
count=0;
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)];
% *Extract each region, result of segmentation process* %
y=1;
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));
imwrite (t, fullfile (myFolder, sprintf ('data.%d.png', y)));
y = y+1;
end;
Ich habe 300 Wortbilder Daten, und ich muß Segment alle Daten Bilder in Zeichenbilder und sich als verschiedene Dateien für jedes segmentierte Zeichen speichern. Ich muss es sequentiell speichern.
Ich habe schon versucht
subImage = i(:, startingColumns(k):endingColumns(k));
zu
subImage = i(startingColumns(k):endingColumns(k),:);
Aber es hat nicht funktioniert noch zu ändern. Ich habe keine Ahnung, was mit dem Code nicht stimmt. Kann mir bitte jemand erklären und helfen?
In welcher Zeile erhalten Sie den Fehler? – Salman
Hallo Troja, || Der Index überschreitet die Matrixabmessungen. || Fehler in Segment (Zeile 64) || subImage = i (:, startende Spalten (k): endende Spalten (k)); –