How to get accumulated motion image in a video?

3 次查看(过去 30 天)
I need accumulated image of a video... I tried with the following code.... But i get wrong output... Can anyone help me and findout error in my code....
%Testing the input video file
%Accumulated motion%
[FileName PathName] = uigetfile('*.avi','Select a video file for testing','D:\ME PROJECT\daria bend.avi');
file = fullfile(PathName,FileName);
robj = mmreader(file);
vidfrm = read(robj);
%frm=double(vidfrm);
dur = robj.Duration
numF = robj.NumberOfFrames
%Computation of ami
m=0;
for k=2:numF;
f1=vidfrm(:,:,:,k);
imshow(f1);
h1=getframe;
%[x,map]=frame2im(h1);
g1=rgb2gray(f1);
f2=vidfrm(:,:,:,k-1);
imshow(f2);
h2=getframe;
%[x1,map1]=frame2im(h2);
g2=rgb2gray(f2);
g=imabsdiff(g1,g2);
m=m+g;
end
m;
figure(1),imshow(m);
ami=m/numF;
figure(2),imshow(ami);
Sorry i cannot upload video now.. use any grayscale video like weizmann dataset for it... Actually the figure(2) have to dipaly some accumulated o/p when it is divided by total num of frames.. But i get ly black screen... Pls help me...!
  2 个评论
Matt J
Matt J 2012-10-14
编辑:Matt J 2012-10-14
I suggest that you remove "Urgent..." from your title, before someone comes along and closes your question down.
Also, you should markup your code to make it more readable.
Ramya Sampath
Ramya Sampath 2012-10-16
Sorry... I removed it now... Pls explain and answer my question... Now its clear i think...

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2012-10-16
Those are probably floating point arrays, so use []:
imshow(ami, []);
imshow(m, []);

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by