MATLAB: How to save an image from imshow() as a .jpeg

rgb image

I am creating an RGB image and displaying using imshow(). Once the image is displayed, if I save the image as .jpeg, it gets a white background to it and the image dimensions change. How can I keep it to its original dimensions? Attached image is what I got when I saved it as a .jpeg file and the dimensions are 240×170. Whereas the original dimensions of the constituting matrices are 100×100.

Best Answer

Have a look at print(), which pays attention to the figure PaperPosition* properties and to the figure InvertHardcopy property. It also allows a -r resolution option.
However, I would instead recommend using imwrite of the rgb matrix.
Related Question