Save just image (and not full figure) in a loop without needing user input
4 views (last 30 days)
Show older comments
Hi all,
I'm working on a program which generates lots of figures/images in a for-loop. As I want to creat up to 1000 images I would like to avoid any user input when saving the images (I just want the program to run).
My problem is that I do only want to save the image and not the full figure. With imsave I can save an image (after being asked to specify the file-name myself for each loop), with saveas I can save all figures withtout user input (just with an updated string) but not just the image. How could I combine this so that I end up with a command which saves just a (tiff)-image from the generated plot/figure without needing a user input every time?
My code for the loop is as follows (with lcn as given 3D array):
for slice = 1:100; h = imagesc(squeeze(lcn(slice,:,:))); name = num2str(slice) saveas(h,slice,'tif') end
/David
0 Comments
Accepted Answer
Sean de Wolski
on 14 Mar 2011
h is a handle to the figure and a scalar value. What you want is
for ...
name = ...
imwrite(squeeze(lcn(slice,:,:)),name,'tif');
end
0 Comments
More Answers (3)
See Also
Categories
Find more on Computer Vision with Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!