MATLAB Answers


Frames to video conversion

Asked by Lalit Patil on 5 Feb 2013
 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); 
 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..



No products are associated with this question.

1 Answer

Answer by Walter Roberson
on 5 Feb 2013
 Accepted answer

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


still problem.. colormap is empty for image.

 cmap = []

This is the image

Before the loop:

cmap = gray(256);

Then in the loop,

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

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!