最近,我手动完成了,但数据集会更大,浪费时间来逐个运行图像分割。 是否有任何建议我应该做些什么来简化和更有效地获得每个分段字符的结果(按顺序)?
%// Save %
[L,num] = bwlabel(im);
for z= 1 : num
bw= ismember( L, z);
%// Construct filename for this particular image.
%// Change basefilename for each word images %
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(bw, fullFileName);
subplot(2,2,4);
pause(1);
imshow(bw);
end
%// y=y+1;
非常感谢任何帮助。
答案 0 :(得分:0)
您可以在目录中列出所有.png文件,然后为每个文件运行您的函数。
myfolder = 'C:\myfolder'; % folder path
files = dir(fullfile(dirName,'*.png') );
files = {files.name}'; %Name of your .png image"
%then run your function
for i = 1:length(files)
img = imread(files{i});
.......
end
我认为您最好将分段图像放在新文件夹中。