필터 지우기
필터 지우기

How to get accumulated motion image in a video?

조회 수: 3 (최근 30일)
Ramya Sampath
Ramya Sampath 2012년 10월 14일
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