Motion History Image In Matlab Error

Motion History Image In Matlab Error
0

#1

Hi, i have run my mhi code but the result is getting a white image.I don’t know which part is wrong.Can someone tell me?


clear all

v = VideoReader(‘C:\Users\User\Desktop\FYP\database\tumiitgait database\uploaded_video\Normal Walk\normal_id001_1.avi’);

for i=1:227
data(:,:,i)=mean(readFrame(v),3);
end

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);

% 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);

    %% ORIGINAL CODE
    % Begin looping through each point                
    %{
    for y = 1 : y_max
        for x = 1 : x_max

            if (frame(y,x) > 0)
                MHI(y,x,frameIndex) = T;
            else
                if(MHI(y,x,frameIndex-1)>1)
                    MHI(y,x,frameIndex) = MHI(y,x,frameIndex-1) - 1;
                else
                    MHI(y,x,frameIndex) = 0;
                end
            end                  

        end                    
    end
    %}
    %% END OF ORIGNAL CODE

    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(:,:,227),[])