How to save filenames
2 views (last 30 days)
Show older comments
Hello friends,
I want to save files with dynamic name so I wrote the code:
for n=1:Ne
[r,c] = find(L==n);
n1=imagen(min(r):max(r),min(c):max(c));
imshow(~n1);
imwrite(~n1, n, 'png');
But the file is not saved, is there any mistake in the code? Please guide.
0 Comments
Accepted Answer
Image Analyst
on 2 Nov 2013
See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F for good sample code.
Your problem is you didn't look in the help to see what the proper arguments are for imwrite
imwrite(~n1, n, 'png');
is not correct. You need to come up with a filename, such as
baseFileName = sprintf('%d.png', n);
fullFileName = fullfile(yourFolder, baseFileName); % yourFolder can be pwd if you want.
imwrite(n1, fullFileName);
The format argument 'png' is not needed because it determines the format from the filename.
0 Comments
More Answers (1)
Azzi Abdelmalek
on 2 Nov 2013
Edited: Azzi Abdelmalek
on 2 Nov 2013
imwrite(~n1, n, 'png');
Will not save any file, n is not a valid file name.
What does ~n1 represent?
2 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!