我的项目是通过存储的视频片段来检测人类活动。我成功地做到了以下几点:
然而,我想使用Matlab来获得运动历史图像(MHI)。有可能吗?如果是的话,有人能指点我吗?谢谢。
我已附上一个运动历史图像样本(MHI)。

我对MHI使用了以下代码:MotionHistory/motempl.c
发布于 2015-04-30 08:28:17
MHI只是实现运动检测的一种方法(并以轮廓为基础)。
假设最近的对象的轮廓已经创建。它还使用时间戳来确定当前轮廓是否是最近的。为了实现运动检测,必须将较老的轮廓与当前的轮廓进行比较。因此,早期的剪影也保存在图像中,并带有较早的时间戳。
MHI描述了一些运动物体在图像序列上的变化。基本上,您应该只维护一个图像,每个像素都编码一个时间信息--不管剪影是最近的还是非最近的,或者运动发生在给定的时间。
因此,MHI的实施非常简单,例如:
function MHI = MHI(fg)
% Initialize the 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 the first frame
frame1 = fg{1};
% Get dimensions of the frames
[y_max x_max] = size(frame1);
% Compute H(x,y,1,T) (the first MHI)
MHI{1} = fg{1} .* T;
% Start global loop for each frame
for frameIndex = 2:length(fg)
%Load current frame from image cell
frame = fg{frameIndex};
% Begin looping through each point
for y = 1:y_max
for 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代码来自:https://searchcode.com/codesearch/view/8509149/
更新#1:
试着按以下方式画出来:
% showMHI.m
% Input frame number and motion history vector to display normalized MHI
% at the specified frame.
function showMHI(n, motion_history)
frameDisp = motion_history{n};
frameDisp = double(frameDisp);
frameDisp = frameDisp ./ 15;
figure, imshow(frameDisp)
title('MHI Image');https://stackoverflow.com/questions/29935425
复制相似问题