使用 MATLAB 保存图像

ana*_*ana 2 matlab

我在 MATLAB 中制作了一个程序来生成具有不同规格的图像,但是每次更改其中一个规格时,我都必须以不同的名称和路径重新保存该图像。所以,我做了一个 for 循环来改变这些规范,但我不知道如何让 MATLAB 以不同的名称和不同的路径保存生成的图像......

如何编写程序使 MATLAB 将多个生成的具有不同名称和不同路径的图像作为for–loop的一部分保存?

AGS*_*AGS 5

把这样的东西放在你的循环的末尾:

for i = 1:n
  <your loop code>
  file_name=sprintf('%d.jpg',i);  % assuming you are saving image as a .jpg
  imwrite(your_image, file_name);  % or something like this, however you choose to save your image
end
Run Code Online (Sandbox Code Playgroud)