function A = IDCT3(B)

[M, N, T] = size(B);
A = zeros(M,N,T);

for r=0:T-1
   tmpIDCT2 = idct2(B(:,:,r+1));  
   if (r==0) alpha = 1/sqrt(T);
  	else alpha = sqrt(2/T); end;
   for t=0:T-1
   	A(:,:,t+1) = A(:,:,t+1) + alpha*cos(pi*(2*t+1)*r/(2*T))*tmpIDCT2;
   end   
end

