About the frame

1 view (last 30 days)
Pan
Pan on 29 Apr 2012
Hellow, everybody
I want to ask that a lot of frames can be became a short video. because I extract some ketframs from the video, then I must consist of video from the keyframes.
this is my current code
clear all;
load glasses % glasses.avi
[m,n,c,f]=size(xa); % [480 640 3 203]
h=zeros(1,256); % 0~255pixal
e=zeros(1,326);
a=zeros(1,326);
dif=zeros(1,326);
se=zeros(1,326);
b=zeros(1,326);
c=3;
for ix=3:326
h=zeros(1,256);
for ii=1:m
for jj=1:n
h(xa(ii,jj,c,ix)+1)= h(xa(ii,jj,c,ix)+1)+1;
end
end
% figure(1)
% plot(h)
pf=h/(m*n);
% figure(2)
% plot(pf)
for ii=1:256
if(pf(ii)==0) % pf為0,則q(消息量)為0
q(ii)=0;
else
q(ii)=-1.*log2(pf(ii)); %pf不為0,則用log去計算出q(消息量)
end
end
ef=pf.*q;
e(ix)=sum(pf.*q);
em=sort(ef,2,'descend');
s=0;
for k=1:256
s=s+em(k);
%if (s>=0.7*e(ix) )
if (s>=0.07*e(ix) )
se(ix)=s;
break;
end
end
a(ix)=k;
s=0;
for k=a(ix):256
s=s+em(k);
end
b(ix)=s;
end
i=1;
num=0;
for ix=3:326
if(ix<326)
dif(ix)=abs(b(ix)-b(ix+1));
if(dif(ix)>0.21)
ix
num=num+1;
figure(i)
i=i+1;
imshow(uint8(xa(:,:,:,ix)))
end
end
end
could you give me some advices,thanks!!

Answers (1)

Walter Roberson
Walter Roberson on 29 Apr 2012
See VideoWriter() or the earlier avifile(); or movie2avi()
  3 Comments
Walter Roberson
Walter Roberson on 29 Apr 2012
Use the VideoWriter class to open an AVI file for writing. Then in the loop, at each point that you have a frame ready to add to the video, use the appropriate VideoWriter class call to add the frame to the video. When you have finished processing all of the frames, close the VideoWriter object.
You can refer to the VideoWriter documentation for an example.
Pan
Pan on 29 Apr 2012
you say good, but now, I don't how to became to code

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!