Motion History Image (MHI) in Matlab -
my project detect human activity through stored video clips. able following:
- get motion history image (mhi) video using opencv
- train , classify set of images using matlab
however, want use matlab in order motion history image (mhi). possible, , if yes can guide me? thank you.
i have attached sample motion history image (mhi)

i have used following code mhi: http://www.ece.iastate.edu/~alexs/classes/2007_fall_401/code/09_motionhistory/motempl.c
mhi ways of implementing motion detection (and uses silhouettes basis of it).
let suppose silhouette of recent object has been created. uses timestamp identify if current silhouette recent or not. older silhouettes have compared current silhouette in order achieve movement detection. hence, earlier silhouettes saved in image, earlier timestamp.
mhi describes changes of moving objects on image sequence. basically, should maintain image every pixel encodes time information - whether silhouette recent or not or movement occurs @ given time.
therefore implementation of mhi simple e.g.:
function mhi = mhi(fg) % initialize output, mhi a.k.a. h(x,y,t,t) mhi = fg; % define mhi parameter t t = 15; % # of frames being considered; maximal value of mhi. % load first frame frame1 = fg{1}; % dimensions of frames [y_max x_max] = size(frame1); % compute h(x,y,1,t) (the first mhi) mhi{1} = fg{1} .* t; % start global loop each frame frameindex = 2:length(fg) %load current frame image cell frame = fg{frameindex}; % begin looping through each point y = 1:y_max x = 1:x_max if (frame(y,x) == 255) mhi{frameindex}(y,x) = t; else if (mhi{frameindex-1}(y,x) > 1) mhi{frameindex}(y,x) = mhi{frameindex-1}(y,x) - 1; else mhi{frameindex}(y,x) = 0; end end end end end code from: https://searchcode.com/codesearch/view/8509149/
update #1:
try draw follows:
% showmhi.m % input frame number , motion history vector display normalized mhi % @ specified frame. function showmhi(n, motion_history) framedisp = motion_history{n}; framedisp = double(framedisp); framedisp = framedisp ./ 15; figure, imshow(framedisp) title('mhi image');
Comments
Post a Comment