How do I save a figure with the desired size in pixels?

12 views (last 30 days)
Hi everyone, I’m stuck with the following question: I want to save an image I created as a bmp-file with a size of 1080x1920 pixels. I just summarize how I crate my image:
- Creating a matrix Zeros(1080,1920)
- Imshow(matrix)
- Write a number on the current image using the text-command
Now, as described above, I would like to save the image as bmp, size 1080x1920 pixels. But it doesn’t work. No matter what I try (print, saveas…), I always get the wrong format. Usually it’s 1200x900. When I tried to set the resolution using the print command, I ended up with 1920x1440, which means it also somehow changed my aspect ratio. Can anyone help me out here?

Accepted Answer

Image Analyst
Image Analyst on 14 Jan 2016
Use imwrite() and it will save the image in whatever resolution it has as the variable.
If you want to save the image as part of a larger picture of the figure, with graphical overlays and axes and stuff, then use export_fig() by Yair Altman (in the File Exchange)
  3 Comments
Image Analyst
Image Analyst on 14 Jan 2016
You're not writing the image - you're trying to write the figure, which is the window that the image is on, complete with any axes tick marks and the text you put on it. To do that you'd use export_fig(). Your initial post was not clear so that's why I gave you both ways, depending on exactly what you wanted to save.
CrazyEngineer
CrazyEngineer on 15 Jan 2016
With Export_fig() and a bit of playing around it works :) Thank you for your help!

Sign in to comment.

More Answers (0)

Categories

Find more on Images 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!