error in saving overwritten images
3 ビュー (過去 30 日間)
古いコメントを表示
I am doing image analysis of particle tracking in a fluidized bed. Part of my code is to produce the figure of particle trajectory then save it as png and then finding the covered area. In order to avoid opening too many windows I invisibled the figure and overwrite the saved png images. But after about 900 iteration and images i get this error:
Error using name (line 102)
Cannot create output file '.\fig.png'.
Error in print (line 71)
pj = name( pj );
Error in saveas (line 168)
print( h, name, ['-d' dev{i}] )
Error in particle_centriod_mark4 (line 61)
saveas(f,'fig.png');
The part of the code which makes the images is a as below:
f = figure('visible','off');
plot(part_cen_x(1:i),part_cen_y(1:i),'k-o','LineWidth', 14)
xlim([30 440]);
ylim([30 640]);
axis off
ax = gca;
outerpos = ax.OuterPosition;
ti = ax.TightInset;
left = outerpos(1) + ti(1);
bottom = outerpos(2) + ti(2);
ax_width = outerpos(3) - ti(1) - ti(3);
ax_height = outerpos(4) - ti(2) - ti(4);
ax.Position = [left bottom ax_width ax_height];
saveas(f,'fig.png');
0 件のコメント
回答 (2 件)
Walter Roberson
2017 年 11 月 28 日
As a test, try changing
saveas(f,'fig.png');
to
try
saveas(f,'fig.png');
catch ME
fprintf('There was a problem saving the file.\n');
fprintf('List of open files is:\n')
fopen('all')
fprintf('End of list of open files\n');
rethrow(ME)
end
This tests the possibility that MATLAB might be failing to close files, and shows a list of all of the open files. If there are more than a very small number of files listed then MATLAB might be "leaking" files.
5 件のコメント
Image Analyst
2017 年 11 月 29 日
I wonder if your axes are just getting really overstuffed with content. Can you try to do this before you plot to each one:
axes(whateverHandle); % Switch to the axes you want to plot new stuff in.
hold off;
cla reset
% plot() or imshow()....
9 件のコメント
Image Analyst
2017 年 11 月 30 日
That won't work. Note, I did not do that. handles is a structure, not an structure array, and axes is the name of a built-in function. So calling handles(axes) will throw all kinds of errors.
参考
カテゴリ
Help Center および File Exchange で Printing and Saving についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!