save image without the white border

166 views (last 30 days)
Xin
Xin on 8 Apr 2020
Answered: Image Analyst on 8 Apr 2020
Hello. I would like to save a phot, or any imagesc, pcolor or whatever 2D image. But the problem is that matlab alway automatically leaves a white border somehow. I would like to remove it because I have thousands of photos to process and I cannot crop them manually. I don't quite understand why this is automatically left and there is simply no option in print or saveas to remove the white border.
For example, to generate a random 2D matrix
h = figure(1)
x = rand(50,50);
imagesc(x)
xticks([]);yticks([])
print(['-dpng'],'Fig')
I always get a white border in the end. Could someone give a suggestion on how to remove it. Please, if you want to recommend export_fig, please give an example. This package seems to have no examples in the help. Thanks!

Answers (2)

KSSV
KSSV on 8 Apr 2020

Image Analyst
Image Analyst on 8 Apr 2020

Categories

Find more on Convert Image Type 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!