How to save an image to a specific size without white borders

53 ビュー (過去 30 日間)
Daeil Noh
Daeil Noh 2021 年 8 月 23 日
コメント済み: Daeil Noh 2021 年 9 月 3 日
Hello everyone and thak you
Now I'm trying to generate the image for dataset.
I removed the axis data and legend from the figure.
I used export_fig function for getting transparent background.
but I can not make the specfic size image because that option will cut the white borders
so, here is the code I used.
f=figure();
pspectrum(value, fs, 'spectrogram', ...
'FrequencyLimits', [1.5e+9 3e+9], ...
'OverlapPercent', 0, 'MinThreshold', threshold);
axis off
colormap(f,jet);
colorbar off;
set(gca,'XColor', 'none','YColor','none', 'DefaultFigureRenderer', 'opengl');
title '';
export_fig('This is path to save the figure' ,'-transparent', '-jpg')
Thank you for your reply :)
  2 件のコメント
darova
darova 2021 年 8 月 23 日
Maybe you are looking for
export_fig -nocrop
Daeil Noh
Daeil Noh 2021 年 8 月 24 日
@darova first, thank you darova.
I already used "-nocrop" option, but when I use the nocrop option, export_fig can not cut the borders :(

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

採用された回答

Rishik Ramena
Rishik Ramena 2021 年 8 月 25 日
As I can understand from your query that you want to get a transparent background image of a specific size and without the borders.
From the documentation of the export_fig function, I see that the '-native' option could be of help in your code. And for getting a transparent background, you might want to consider using the 'png' format for saving the image. Here's what your save_fig call would look like.
export_fig('This is path to save the figure' ,'-transparent', '-png', '-native')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by