% recon_im = reconFromDCTinRows(dct_col_quant,M,nblocks_ac,nblocks_dn);
%
% takes as input a matix with rows of DCT coefficients for an image,
% re-arranges the DCT coefficients back into MxM blocks, then takes
% the inverse DCT and returns the quantized image.
%
% J. Sabataitis
% November 7, 2000
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function recon_im = reconFromDCTinRows(dct_col_quant,M,nblocks_ac,nblocks_dn);

recon_im = zeros(M*nblocks_dn,M*nblocks_ac);
nblocks = nblocks_dn*nblocks_ac;

block_count = nblocks;
for a = nblocks_dn:-1:1,
  for b = nblocks_ac:-1:1,
    block = reshape(dct_col_quant(:,block_count),M,M);
    block = block';
    block_inv = idct2(block);
    recon_im((a-1)*M+1:a*M,(b-1)*M+1:b*M) = block_inv;
    block_count = block_count-1;
  end
end



