MATLAB: Frames to video conversion

framesimagesvideo

aviObject = avifile('Myvid1.avi')
for ctr = 441:500
iFrame = clock;
fname = ['IMG' num2str(ctr),'.PNG'];
I = imread(fname);
F = im2frame(I);
aviObject = addframe(aviObject,I);
elapsed = etime(clock, iFrame);
pause(5 - elapsed);
end
aviObject = close(aviObject);
This is my code to create video from frames.. It shows error..
??? Error using ==> im2frame
Indexed movie frame must have a non-empty colormap
Why..? My images are 600*800uint8 type..

Best Answer

[I, cmap] = imread(fname);
F = im2frame(I, cmap);