Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Error In Getting Motion History Image In Matlab

Charis QuinstineCharis Quinstine Member Posts: 1

Hi, I have some problem in getting my motion history image. my video is already binarized. But can't get motion history image.

this is the code i m using. can someone tell me where i m wrong n how to fix it?

clear all

Video1 = VideoReader('C:\Users\User\Desktop\FYP\database\walking\person01_walking_d1_uncomp.avi');

for i=1:218
% keyboard
data(:,:,i)=mean(readFrame(Video1),3);
end

data = uint8(255 * mat2gray (data));

MHI = data;
% Define MHI parameter T
T = size(data,3)+20; % # of frames being considered; maximal value of MHI

% Load the first frame
frame1 = data(:,:,1);

% Get the dimensions of the frames
[y_max, x_max] = size(frame1);

% Compute H(x,y,1,T) (the first MHI)
fst = MHI(:,:,1);
fst(fst>0) = T;
MHI(:,:,1) = fst;

% start global loop for each frame
for frameIndex = 2 : size(data,3)
    %fprintf('Loading frame Index %d\n',frameIndex);

    % Load current frame from image array
    frame = data(:,frameIndex);
    frame_pre = MHI(:,frameIndex-1);

    MHI(:,frameIndex) = frame_pre - 1; 

    % Set of all non-zero value to T
    frame(frame > 0) = T;

    [y,x] = find(frame > 1);                

    for i = 1 : size(y,1)                    
        MHI(y(i,:), x(i,:), frameIndex) = frame(y(i,:), x(i,:));
    end

end

figure, imshow(MHI(:,:,218), []);
Tagged:
Sign In or Register to comment.