Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export MATLAB figure into high resolution bitmap image

I have plotted a Mandelbrot image in using MATLAB with 7680*4320 pixels resolution, but when I export the image using bitmap or JPG format, the output file will have 1366*651 pixels which is my laptop screen resolution.

How can I export the figure image with its original quality(7680*4320)?

like image 759
Babi Avatar asked Oct 20 '22 11:10

Babi


1 Answers

I usually specify the absolute image size and the image resolution instead, because the image size in dots (or pixels) is the multiple of these. For example, if the absolute size is 16 cm x 12 cm, and the resolution is 500 dpi (or ppi), then the size in dots (or pixels) is 3150 x 2362, because (16 cm / 2.54 cm/in) * 500 dots/in (or px/in) = 3150 dots (or px), and (12 cm / 2.54 cm/in) * 500 dots/in (or px/in) = 2362 dots (or px).

Example code:

1. Create figure

x = 0:0.01:pi;
y = sin(x);
figure
plot(x, y)

2. Set image size before saving image. Let it be 16 cm x 12 cm:

width = 16; % cm 
height = 12; % cm
set(gcf, 'PaperPosition', [0, 0, width / 2.54, height / 2.54])

3. Set resolution when saving the image. Let it be 500 dpi (or ppi):

print -dtiff -r500 my_image

I hope this helps.

like image 111
kol Avatar answered Oct 27 '22 10:10

kol