2016-09-07 21 views
2

特定の解像度(320x240)で特定のプロットを出力するだけの時間があります。Matlabで特定の解像度で画像を保存

xmax = 320; ymax = 240; 
    xmin = 0; ymin = 0; 
    figure; 
    set(gcf,'position',[1060 860 320 240]); 
    axis([xmin,xmax,ymin,ymax]); 
    plot(someLinesAndPointsInTheRange320X240); 
    saveas(gca,outName,'jpg'); 
    export_fig(outName); 

ここで、saveasは、任意の解像度でjpgイメージを出力します。 export_figはまだ軸を表示しています。

axis offまたはaxis tightを追加することは役に立ちません。 アイデアはありますか?

更新日:
問題は解決しました。ただ、完全を期すためにここに私の現在のソリューションです:

xmax = 320; ymax = 240; 
    xmin = 0; ymin = 0; 
    figure; 
    set(gcf,'position',[1060 860 320 240]); 
    subaxis(1,1,1, 'Spacing', 0.01, 'Padding', 0, 'Margin', 0); % Removes padding 
    axis([xmin,xmax,ymin,ymax]); 
    plot(someLinesAndPointsInTheRange320X240); 
    axis([xmin,xmax,ymin,ymax]); 

    set(gca,'xtick',[],'ytick',[]); % Removes axis notation 
    I = frame2im(getframe(gcf)); %Convert plot to image (true color RGB matrix). 
    J = imresize(I, [240, 320], 'bicubic'); %Resize image to resolution 320x240 
    imwrite(J, 'outName.jpg'); %Save image to file 

答えて

3

解決策は、画像に数字を変換し、imresizeを使用しています。

図形の位置を320x240の解像度に固定することは可能ですが、imresizeを使用する方が簡単です(私は思う)。

次のコードサンプルで、画像に数字を変換して、320×240の解像度を設定するimrezieを使用します。

figure; 
% xmax = 320; ymax = 240; 
% xmin = 0; ymin = 0; 
% set(gcf,'position',[1060 860 320 240]); 
% axis([xmin,xmax,ymin,ymax]); 

plot(sin(-pi:0.01:pi)); %Example figure 
I = frame2im(getframe(gcf)); %Convert plot to image (true color RGB matrix). 
J = imresize(I, [240, 320], 'bicubic'); %Resize image to resolution 320x240 
imwrite(J, 'J.jpg'); %Save image to file 
+0

これは実際にそれを解決するために私を助けて、どうもありがとう。完全性のために、私の質問の下で(軸と詰め物なしで)完全な解決策を投稿します。 – mcExchange

+0

@mcExchange詰め物の除去と間隔の最小化が鍵です。ソリューションを投稿していただきありがとうございます。 – rayryeng