How do I save a figure with the desired size in pixels?
12 views (last 30 days)
Show older comments
CrazyEngineer
on 14 Jan 2016
Commented: CrazyEngineer
on 15 Jan 2016
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?
0 Comments
Accepted Answer
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
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.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!