MATLAB: Does the AVI movie, that was created using a TrueColor image in MATLAB, change when read in using AVIREAD in MATLAB 6.5 (R13)

aviaviinfoavireadchangeindexedMATLABtruecolor

Why does my AVI movie, that was created using a TrueColor image in MATLAB, change when read in using AVIREAD in MATLAB 6.5 (R13)?
If I have this code
n=10;
img=imread('flowers.tif');
cmap=rand(8,3);
for t=1:n,
mov(t).cdata = img;
mov(t).colormap = cmap;
end
movie2avi(mov,'test.avi','compression','none');
the movie appears differently when I load it into MATLAB using:
AviMovie=aviread('test.avi');
movie(AviMovie);
The movie displays correctly in Windows Media Player and Quicktime.

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
The AVIREAD function calls the AVIINFO function which tests if a colormap exists in the AVI file. If a colormap exists, MATLAB assumes the AVI file is an indexed image and AVIREAD reads it in accordingly. This is the reason for the behavior you are seeing. This problem has been reported to our development staff for investigation.
The only workaround is to make sure that if you are using a TrueColor image in a movie that the colormap field of the movie structure is empty.