%% blkgroupfreqs.m
% compute block dct, rearranging 
% all coefficients of same frequency in different blocks 
% into a single block  
% dX is the mxn block DCT of an image

% S. Allen Broughton - 29 OCt 10

function Y = blkgroupfreqs(dX,m,n)

[p,q]=size(dX);
r = p/m; s = q/n;
Y = zeros(p,q);
for k = 0:(m-1)
   for l = 0:(n-1)
       e = k*r+1;
       f = l*s+1;
       Y(e:(e+r-1),f:(f+s-1))= dX(1+k+m*(0:(r-1)),1+l+n*(0:(s-1)));
    end;
 end;
