How to Save Pictures in MATLAB

Save

MATLAB, or Matrix Laboratory, is a powerful computational tool designed for the manipulation of matrices. Because digital pictures are stored as matrices representing the pixels in the pictures, MATLAB is an ideal way to manipulate pictures on a fundamental level. When you've finished your work with a picture in MATLAB, use the "imwrite" function to save your altered picture to a file.

  • Call "imwrite" in the simplest way as follows:

    imwrite(x,'picture.jpg','jpg')

    Here, "x" is the matrix to be stored as a picture, "test.jpg" is the name of the file to save to and "jpg" is the format to use. Type the "imformats" command to see a list of picture formats compatible with your installation of MATLAB.

  • Insert an argument after the first to specify a color map if your picture format calls for it:

    imwrite(x,m,'picture.tiff','tiff')

    Here, "m" is the variable containing the color map.

  • Add optional arguments to the end of the list to specify parameters specific to your picture format:

    imwrite(x,m,'picture.gif','gif','TransparentColor',1)

    This example defines which color in the color map -- "m" -- will be transparent in the saved GIF file. Consult the MATLAB documentation, or type "help imwrite," to find information about the optional parameters for various picture formats.

References

Promoted By Zergnet

Comments

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!