Inserting Color Map value in an image

1 visualización (últimos 30 días)
Rishav
Rishav el 4 de Abr. de 2014
Comentada: Image Analyst el 10 de Jun. de 2014
I have a number of compressed image files in a folder named "Video". I wanted to reconstruct them into an avi video but it said that color map value cannot be non empty. Whats the problem and what is the remedy?

Respuestas (4)

Marta Salas
Marta Salas el 4 de Abr. de 2014
Editada: Marta Salas el 4 de Abr. de 2014
You can copy the code you are using to be able to help you. You can also try this function:
function make_video(video_dir,extension,aviname,fps)
resnames=dir(fullfile(video_dir,['*.' extension]));
aviobj=VideoWriter(aviname);
aviobj.FrameRate=fps;
open(aviobj);
for i=1:length(resnames)
img=imread(fullfile(video_dirs,resnames(i).name));
F=im2frame(img);
if sum(F.cdata(:))==0
error('black');
end
writeVideo(aviobj,F);
end
close(aviobj);
end
Example: make_video('/home/user/myImages/','jpg','myvideo.avi',5)
  2 comentarios
Rishav
Rishav el 4 de Abr. de 2014
I appreciate this but can you please give me this code as a stand alone .m file but not within a function? I am a newbie and having problem in function declaration and calling.
Marta Salas
Marta Salas el 4 de Abr. de 2014
Copy and paste on a .m file
video_dir ='/home/user/myImages/';
extension = 'jpg';
aviname = 'myvideo.avi';
fps =5;
resnames=dir(fullfile(video_dir,['*.' extension]));
aviobj=VideoWriter(aviname);
aviobj.FrameRate=fps;
open(aviobj);
for i=1:length(resnames)
img=imread(fullfile(video_dirs,resnames(i).name));
F=im2frame(img);
if sum(F.cdata(:))==0
error('black');
end
writeVideo(aviobj,F);
end
close(aviobj);

Iniciar sesión para comentar.


Rishav
Rishav el 4 de Abr. de 2014
I am working on Matlab 2010a and the videoWriter function doesnt work. Getting the error ??? Undefined function or method 'VideoWriter' for input arguments of type 'char'.
Error in ==> Formation2 at 7 aviobj=VideoWriter(aviname); So any solutions??
  1 comentario
Image Analyst
Image Analyst el 10 de Jun. de 2014
Rishav, why is it taking you so long to resolve this? What's the problem now?

Iniciar sesión para comentar.


Rishav
Rishav el 5 de Abr. de 2014
Used the previous code but still getting the error of "non Empty color map". Any Solution?
  1 comentario
Image Analyst
Image Analyst el 5 de Abr. de 2014
That's because it's not right. See my answer for how to do it. You will notice differences where the colormap is concerned.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 5 de Abr. de 2014
See my attached example. It first reads a video and writes out all the frames to disk. In the second part it reconstructs the video by reading in all those images from disk and building a movie from them. It's very well commented so even new people like yourself are able to follow it.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by