hi my task is i have to split a video into frames and then the frames should color procssed from RGB to CMY and grouped up to create a negative videp...im getting errors can anyone help me ..??
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gohan
el 1 de Oct. de 2016
Comentada: Gohan
el 2 de Oct. de 2016
this is my code
vidobj = VideoReader('viptraffic.avi');
video = read(vidobj);
frameRate = get(vidobj,'FrameRate');
numFrames=vidobj.NumberOfFrames;
n=numFrames;
myVideo=VideoWriter('negative6.avi');
myVideo.FrameRate=30;
open(myVideo);
for i=1:n
F(i)=getframe;
img = frame2im(F);
img = im2double(img);
r=img(:,:,1);
g=img(:,:,2);
b=img(:,:,3);
c=1-r;
m=1-g;
y=1-b;
new_image=cat(3,c,m,y);
writeVideo(myVideo,new_image);
end
close(myVideo);
0 comentarios
Respuesta aceptada
Geoff Hayes
el 2 de Oct. de 2016
Chandrasekhar - what errors are you observing? Please copy and paste the full error message to your question.
One problem may be how you are reading your frames from the original video. Initially, you use
video = read(vidobj);
and then in the for loop you use
F(i)=getframe;
Why not just use read (this all depends on which version of MATLAB that you are using) in your for loop as
for k=1:n
kthImg = read(vidob,k); % no need to convert from frame since already image
% now convert to double, CYG etc.
end
In the above, on each iteration of the loop we read each image from the video and then do the conversion.
Más respuestas (0)
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!