www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/WriteIndexedImageToAVIFileExample.m

    %% Write Indexed Image to AVI File 
%%
% Read image and colormap data from the sample indexed image file, |corn.tif|.

% Copyright 2015 The MathWorks, Inc.

[X,map] = imread('corn.tif'); 
%%
% Create a |VideoWriter| object for a new indexed AVI file.
v = VideoWriter('myIndexed.avi','Indexed AVI');
%%
% Assign the colormap data to the |Colormap| property of |v|.
v.Colormap = map;
%%
% Open the file for writing. After you open the file, you cannot change the
% properties of |v|.
open(v)
%%
% Write the image data in |X| to the video file. Then, close the file.
writeVideo(v,X)
close(v)