how to convert the processed frames into video
2 次查看(过去 30 天)
显示 更早的评论
Hi, I wrote the code for deleting the shadows in video. For the sake i am working on frame basis. So after completing the operation i wish to play back the video.I tried with imshow() in loop but it didnt workout.Also tried movie structure but not clear on command execution.after running the code, i got output as blinking frame instead of video.
a=VideoReader('cam4v.mp4');
vidHeight = a.Height;
vidWidth = a.Width;
s = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),...
'colormap',[]);
img=1;
for img = 1:20
x = read(a, img);
y = read(a,img+1);
% Do color conversion from rgb to hsv
x=rgb2hsv(x);
y=rgb2hsv(y);
% Split the hsv component to h,s,v value
Hx = x(:,:,1);
Sx = x(:,:,2);
Vx = x(:,:,3);
Hy = y(:,:,1);
Sy = y(:,:,2);
Vy = y(:,:,3);
%Find the absolute diffrence between h s v value of current and previous frame
dh=(abs(double(Hx) - double(Hy)));
ds1=(abs(double(Sx) - double(Sy)));
dv1=(abs(double(Vx) - double(Vy)));
%Perform the swt2 transformation on difference of s and v value
[as,hs,vs,ds] = swt2(ds1,1,'haar');
[av,hv,vv,dv] = swt2(dv1,1,'haar');
%Compute the skewness value of 'swt of v'
sav=skewness(av(:));
shv=skewness(hv(:));
svv=skewness(vv(:));
sdv=skewness(dv(:));
%Compute the skewness value of 'swt of s'
sas=skewness(as(:));
shs=skewness(hs(:));
svs=skewness(vs(:));
sds=skewness(ds(:));
b= (av>=sav);
c= (hv>=shv);
d=(vv>=svv);
e=(dv>=sdv);
f= (as>=sas);
g=(hs>=shs);
h=(vs>=svs);
i=(ds>=sds);
j=(b&f);
k=(c&g);
l=(d&h);
m=(e&i);
recv = iswt2(b,c,d,e,'haar');
recs= iswt2(j,k,l,m,'haar');
de_shadow=cat(3,dh,recs,recv);
rgb=hsv2rgb(de_shadow);
imshow(rgb);
title('outputframe');
movie(s);
end
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!