writing an image into a new folder

1 次查看(过去 30 天)
I have a code which was given by image analyser
H = figure;
for ii = 321:326
subplot(ii)
imagesc(magic(ceil(rand*10))); %random fig with 6 subplots
end
print('-dbmp256' , 'picture_of_6_subplots') %save as bmp
i want it to be saved in a folder named 'new',because i will have 100 figure windows,in which each figure window contains 8 subplotted images

采纳的回答

Chandra Kurniawan
Chandra Kurniawan 2011-12-15
Maybe you are seeking for this sample code :
clear; clc;
I = imread('peppers.png');
J = imread('onion.png');
K = imread('pears.png');
Img = {I J K};
for cnt1 = 1 : length(Img)
figure,
subplot(2,3,1),imshow(Img{cnt1});
subplot(2,3,2),imshow(rgb2gray(Img{cnt1}));
subplot(2,3,3),imshow(im2bw(Img{cnt1}));
filename = strcat('picture_of_figure',num2str(cnt1));
print('-dbmp256',filename);
end
  4 个评论
Chandra Kurniawan
Chandra Kurniawan 2011-12-15
Then you need to specify your path folder
Eq : filename = strcat('E:\picture_of_figure',num2str(cnt1));
In your case is :
filename = strcat(pwd,'\New\picture_of_figure',num2str(cnt1));
If you have a folder named 'New' in your active directory.
Robert Cumming
Robert Cumming 2011-12-15
using fullfile ( folder, filename ) is better than strcat.

请先登录,再进行评论。

更多回答(1 个)

Robert Cumming
Robert Cumming 2011-12-15
help saveas
e.g.
SAVEAS(H,fullfile ( 'new', 'FILENAME' ),'FORMAT')
  6 个评论
Pat
Pat 2011-12-15
Robert i have seen save as in help ,but its for writing one figure window,but i want to write in folder as i said,where that folder will contain 100 figure window,as per your last code,i cant see the folder name
Robert Cumming
Robert Cumming 2011-12-15
I have given you all the information you need to workout the code yourself - I strongly encourage you to do that as you will learn more that way...

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by