필터 지우기
필터 지우기

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 ..??

조회 수: 1 (최근 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