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 次查看(过去 30 天)
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);

采纳的回答

Geoff Hayes
Geoff Hayes 2016-10-2
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by