About the frame

1 回表示 (過去 30 日間)
Pan
Pan 2012 年 4 月 29 日
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!!

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 4 月 29 日
See VideoWriter() or the earlier avifile(); or movie2avi()
  3 件のコメント
Walter Roberson
Walter Roberson 2012 年 4 月 29 日
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 2012 年 4 月 29 日
you say good, but now, I don't how to became to code

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by