A figure can be converted into an image using the GETFRAME and FRAME2IM functions in MATLAB. For example, the following code creates a snapshot of the current figure and writes it to an image in variable "X" with colormap stored in "Map":
F = getframe(gcf);
[X, Map] = frame2im(F);
If the frame contains true-color data, then "Map" will be an empty matrix.
For more information on the GETFRAME and FRAME2IM functions, consult the documentation by executing the following at the MATLAB prompt: