MATLAB: How to save the image in the original resolution

MATLABsaveas

I load an image in MATLAB using "imread" and then plot some additional curves on top of it. Now, using the "saveas" function to save the plot changes the image dimensions (compared to the image I had initially opened). How do I save the image in the original resolution?

Best Answer

Please try the following workaround to see if it resolves the issue:
1. Download the "export_fig" function from the File Exchange. Here is the link:
2. Extract the compressed folder and add it to the MATLAB path.
3. After you are done plotting, instead of using "saveas", please use the following command (where "test.png" is the name of the output image):
export_fig test.png -native
For more information, please refer to the following page: