function [A, A_mask]=Creat_A_Mask(TrainImgs, TrainMasks);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% TrainImgs  H x W x T , T is frame number, H x W is pixel number
%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[H, W, D,T]=size(TrainImgs);
m=H*W;

TrainMasks=double(TrainMasks);
Tmp=sum(TrainMasks, 3);
TMask=Tmp>0;

A=reshape(TrainImgs, [m, D, T]); 
A_mask=reshape(TMask, [m, 1]); 

return