Filter löschen
Filter löschen

How to get accumulated motion image in a video?

3 Ansichten (letzte 30 Tage)
Ramya Sampath
Ramya Sampath am 14 Okt. 2012
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 Kommentare
Matt J
Matt J am 14 Okt. 2012
Bearbeitet: Matt J am 14 Okt. 2012
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 am 16 Okt. 2012
Sorry... I removed it now... Pls explain and answer my question... Now its clear i think...

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by