how save produced images in loop
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
nadia
am 8 Nov. 2014
Kommentiert: Image Analyst
am 8 Nov. 2014
hi i have a loop and produce blocks 32*32 with zeros now i want to save them in special folder how can i do it?
1 Kommentar
Akzeptierte Antwort
Geoff Hayes
am 8 Nov. 2014
Nadia - you are using backslashes in your string which is probably generating the following warnings
Warning: Control Character '\i' is not valid. See 'doc sprintf' for control characters valid in the format string.
Instead, build the filename separately from the path, and then use fullfile to build the full file name (with path) as
pathName = 'F:\b';
for k=1:4
b = zeros(32,32);
fileName = fullfile(pathName,sprintf('i%d.bmp',k));
imwrite(b,fileName);
end
Your file names will look something like
F:\b\i1.bmp
F:\b\i2.bmp
F:\b\i3.bmp
F:\b\i4.bmp
Note that I replaced your index of i with k since i (and j) are also used by MATLAB to represent the imaginary number. I also removed the bmp input argument to imwrite since the image file extension has already been specified in the file name.
2 Kommentare
Image Analyst
am 8 Nov. 2014
Or you can just use forward slashes. Windows understands forward slashes just fine - no need to use backslashes.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!