Using figure to change to fullscreen size then save it as png

123 ビュー (過去 30 日間)
Zuhayer Anzum
Zuhayer Anzum 2021 年 10 月 20 日
コメント済み: Zuhayer Anzum 2021 年 10 月 20 日
Hello everyone,
I will show my code first:
%% for loop
for m = 1:3
% antialiase
imresize(img,resize_factor(m),'nearest','antialiasing',1);
figure(m);
subplot(1,2,1),imshow(img); %plot image
% no antialiase
imresize(img,resize_factor(m),'nearest','antialiasing',0);
subplot(1,2,2),imshow(img)
sgtitle(['Antialiase vs No Antialiase with resize factor ',num2str(resize_factor(m))]);
%print to file
saveas(figure(m),strcat(['imgfullscreen_',num2str(resize_factor(m)),'.png']),'png');
This code works well. However, I would like to enlarge each figure to fullscreen size before saving. I am not sure how I should approach that.
I tried using figure(m) and then using the line below to enlarge it. However, that does not work.
figure(m)
figure('Position', get(0,'Screensize'));
Note that my goal is to open each figure, enlarge it and show the plot ( or show the plot then enlarge it) and finally save it as a .png file.

採用された回答

Simon Chan
Simon Chan 2021 年 10 月 20 日
Try the following for the figure you want to enlarge:
fig1 = figure(1);
fig1.WindowState = 'maximized';
  1 件のコメント
Zuhayer Anzum
Zuhayer Anzum 2021 年 10 月 20 日
Yep, that worked for me.
Thank you.
I also should learn to read the documentation better, since it was mentioned there.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by