Thanks to the summary of the conscientious.
Reprint: http://blog.csdn.net/holybin/article/details/39502077
1. Using the Imwrite function
If the image is IMG, you can use Imwrite (img, ' result.jpg '); This method saves the image size and displays the same size. The following method does not get the same size as the original image:
2. Save directly as
In figure, use the menu file->saveas-> to select the Save form (which can be saved in the format fig,eps,jpeg,gif,png,bmp, etc.). The disadvantage of this is that there is a great sacrifice for the image sharpness that is saved.
3. Copy and paste
Using the menu edit->copyfigure in figure, the image is copied to the Clipboard. Note that you want to select "Bitmap" in the "copy Options".
4, with the SaveAs command
MATLAB provides a direct SaveAs function to save the image in a specified figure or a block diagram in Simulink. The SaveAs format is: SaveAs (GCA, filename, FileFormat), with three parameters:
(1) GCA: Graphic handle, if the graphics window title bar is "Figure 3", then the handle is 3; You can also get the current window handle directly from the GCF.
(2) FileName: Single quote string, specifying file name
(3) FileFormat: Single quote string, specifying storage format
Example:
[Plain] View plain copy SaveAs (GCF, ' save.jpg '); % Save the image of the current window in SaveAs (2, ' save.jpg '); % Save Figure 2 window image 5, print function
The print function operates the printer using the plot function followed by the print function to save the image. Print is in the format: print (Figure_handle,fileformat,filename) with three parameters:
(1) Figure_handle: Graphic handle, if the graphics window title bar is "Figure 3", then the handle is 3; You can also get the current window handle directly from the GCF
(2) FileFormat: Single quote string, specifying storage format:
PNG format: '-dpng '
JPEG format: '-djpeg ',
TIFF format: '-dtiff '
BMP format: '-dbitmap '
GIF format: '-dgif '
EMF lossless format: '-dmeta '
(3) FileName: file name
Example 1: Displaying an image and saving
[Plain] View plain copy x=-pi:2*pi/1000:pi; Y=cos (x); Plot (x, y);p rint (GCF, '-djpeg ', ' abc.jpg ')% draw the image and save it in JPG format
Example 2: Save directly without displaying an image
[Plain] View plain copy x=-pi:2*pi/1000:pi; Set (figure (1), ' visible ', ' off '); Plot (X,sin (x)); Print (GCF, '-dpng ', ' abc.png ')% does not display images directly saved to PNG format