将图像保存在循环中 [英] Saving Images Inside A Loop
本文介绍了将图像保存在循环中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个循环,每次循环时它与图像分开,我想用不同的图像名称自动保存它.我有以下代码 图
Hi I have a loop and each time it separates and image and i want to save it automatically with different image name. I have following code figure
for n=1:Ne
[r,c] = find(L==n);
n1=imagen(min(r):max(r),min(c):max(c));
imshow(~n1);
imwrite(~n1, test.jpg);
pause(0.5)
end
我遇到的问题是imwrite(〜n1,test.jpg);它只保存一个图像,而我需要保存它,以便所有图像都保存为test1.jpg,test2.jpg等. 谢谢您的帮助
Problem I have is in imwrite(~n1, test.jpg); it only saves one image while I need to save it so that all are saved like test1.jpg, test2.jpg so on ...anyone has an idea how to do that? Thank you for your help
推荐答案
我喜欢使用以下内容:
imwrite(~n1, sprintf('test%05d.jpg', n)); %this would pad with 5 zeros
使用零填充文件名,以便在目录中很好地对它们进行排序.
to pad the filename with zeros, so they are nicely sorted in the diretory.
这篇关于将图像保存在循环中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文