Figの書き出しの時に不要な空白ができる

43 views (last 30 days)
Yumi Iwakami
Yumi Iwakami on 24 Jun 2016
Commented: Yumi Iwakami on 10 Jul 2016
これは黒と白2値の画像に赤い楕円をプロットして書き出したものです. 元の画像には周囲に白い空白がなかったのに,printやsaveasで書き出すとこのように画像の周囲に白い余白が できてしまいます. 余白ができないようにするにはどうしたらよいのでしょうか?

Accepted Answer

Akiko
Akiko on 24 Jun 2016
imshow コマンドで画像を表示する際、Border プロパティを 'tight' に設定することで、この領域を予め非表示にすることができます。
以下、簡単なサンプルコードです。
I = rgb2gray(imread('peppers.png')); % サンプル画像の読み込み
imshow(I,'Border','tight') % 周囲に枠を表示しない
hold on
rectangle('Position',[50 100 50 100],'Curvature',[1 1],'EdgeColor',[1 0 0])
print -dpng test.png % PNG 形式で保存
  1 Comment
Yumi Iwakami
Yumi Iwakami on 10 Jul 2016
ありがとうございます。やってみます。

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox 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!