Follow by Email

Lets Learn together... Happy Reading

" Two roads diverged in a wood, and I,
I took the one less traveled by,
And that has made all the difference "-Robert Frost

How to Save/Export Images in MATLAB

           This blog illustrates some simple stuff to deal with, when the images need to be saved with certain constraints.
Let’s start with simple text figure that needs to be saved in image format.
figure,axis off;
text(0.35,0.5,'\color[rgb]{red} E \color[rgb]{green}=\color[rgb]{blue} mc^2','FontSize',60,'FontName','Times New Roman','FontAngle','italic');

To save the above figure with different background:

The default background color is set to white in MATLAB. In order to have the different background color as in the figure, select ‘Export Setup’ in the figure window and select ‘Rendering’ from properties then unselect the custom color and finally select ‘Apply to figure’. Then select ‘Save As’ to save the image.

The step by step screenshots are as given below:

The final image saved in the local directory is as shown below.

To save the figure with black color background:
Select the custom color and type ‘k’ in the text box and select ‘Apply to figure’.
For Red, type ‘r’ or [1,0,0]. For Blue , type ‘b’ or [0,0,1]. For Green, type ‘g’ or [0 ,1,0]; For cyan ‘c’ or [0.5,1,1] and so on.
NOTE: ‘r’ denotes red color or a 1 x 3 Vector representing [R,G,B] can be used.  The value ranges between 0 and 1. [1,0,0] denotes value of red component is 1 whereas Green and Blue components are zero. In other words, the color Red is chosen.

The final image saved in the local directory is as shown below.

Example 2:

To save the image without the padded white space:
Select ‘Export Setup’ from File in the figure window and select ‘Size’ from properties, type the width and height of the image and change the units to ‘points’. Select  ‘Expand the axes to fill figure’ checkbox and finally select ‘Apply to figure’ to view the changes.
Now save the image.

Image saved in the local directory.

To save the image without the axes:
MATLAB code:
set(gca, 'XTickLabelMode', 'manual', 'XTickLabel', [],'YTickLabelMode', 'manual', 'YTickLabel', [],'Xtick',[],'Ytick',[]);

After executing the above code, follow the same procedure as the previous example to save the image without white spaces.

The image can be saved by selecting ‘Export’ tab as well.
Image stored in the local directory.

like button Like "IMAGE PROCESSING" page


Enjoyed Reading? Share Your Views

Next Post Home


Related Posts Plugin for WordPress, Blogger...
Google ping