# Motion History Image In Matlab Error

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

for i=1:227
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)

% 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),[])``````