writing an image into a new folder

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일

1 개 추천

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

Robert Cumming
Robert Cumming 2011년 12월 15일
maybe the OP was - but they would learn more by working out the actual code themselves...
Pat
Pat 2011년 12월 15일
Chandra even in your code i could not find a folder name
this is what i want
a folder named "new"
want to save all those figure windows in it
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일

0 개 추천

help saveas
e.g.
SAVEAS(H,fullfile ( 'new', 'FILENAME' ),'FORMAT')

댓글 수: 6

Pat
Pat 2011년 12월 15일
thanks robert ,i have a for loop ,will those 100 images will be saved in that folder
please tell what that file name refers to
Robert Cumming
Robert Cumming 2011년 12월 15일
filename is the filename of your image....
e.g. sprintf ( 'image_%i', ii );
where ii is your loop...
Pat
Pat 2011년 12월 15일
Robert am little bit confused in file name ,i have only subplotted image ,from where i have to get file name
for ex
figure,
subplot(161),imshow(I1)
subplot(162),imshow(I2)
subplot(163),imshow(I3)
subplot(164),imshow(I4)
subplot(165),imshow(I5)
subplot(166),imshow(I6)
where I1 to I6 are the images after performing 6 different operations,please tell how to save this in folder,my folder name is 'new'.this is for one image performing 6 operaitons,i have 100 images ,i have to perform for all those,finally i will have 100 figure window of 6 subplotted images,i want to save all those to a folder named 'new'
please help
Robert Cumming
Robert Cumming 2011년 12월 15일
the filename is your choice. Have you looked at saveas? See the following code as an example you should be able to work it out from there...
h=figure
subplot(2,3,2); plot ( magic(100) );
saveas ( h, 'YOURFILENAME', 'bmp' )
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...

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

Pat
2011년 12월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by