Clear Filters
Clear Filters

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 views (last 30 days)
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);

Accepted Answer

Geoff Hayes
Geoff Hayes on 2 Oct 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.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!