I want to save the figure in terms of filename. How can I do this? I use some saveas commands but I couldn't modify it for filename.
imagefilename='lena_gray_256.tif';
maskfilename='M3.tif';
filename = [imagefilename maskfilename];
%Creating plots
imshow(ML)
title('Masked image')
Regards;
imagefilename='lena_gray_256.tif';
maskfilename='M3.tif';
filename = [imagefilename maskfilename];
%Creating plots
imshow(ML)
title('Masked image')
saveas( gcf, filename, 'jpg' );
solved=)
I prefer using imwrite
:
%//After your code insert
imwrite(frame2im(getframe(gcf)),filename);
The command should recognize the image type by checking the extension. You might want to change the background color of your figure to white before writing the image:
set(gcf,'Color','w')
imwrite(frame2im(getframe(gcf)),filename);
Instead of gcf
you can use the function handle of your figure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.