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

采纳的回答

Image Analyst
Image Analyst 2017-11-26
See attached demos that create videos. Adapt as needed.
  2 个评论
SHOBA MOHAN
SHOBA MOHAN 2017-11-27
@Image Analyst I tried with extractmovieframe.m, this code works fine till writing the frames into disk. thereafter i got this error: error extracting the movie frame. the frame must be 452 by 231. For your note my individual frame size is 480x640. So how can i playback the storedframes into video again?
SHOBA MOHAN
SHOBA MOHAN 2017-11-27
this code works after resizing the image by incorporating the following code thisFrame=imresize(thisFrame,[452, 231]); Please include this code prior to this code recalledMovie(frame) = im2frame(thisFrame); If you wish you can also change in demode code. Thank you.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by