function M=reconstruct(X) % Reconstruction of 'Lena' % % =========================================================== % M=reconstruct(X) % % This function builds 8 x 8 blocks from the column vectors in % X and put these blocks together in a matrix M. % M has dimension 256 x 256. % X should have dimension 64 x 1024 for rowblock=1:32 % 256/8 for colblock=1:32 % 256/8 Block=reshape(X(:,(rowblock-1)*32+colblock),8,8); M((colblock-1)*8+1:colblock*8,(rowblock-1)*8+1:rowblock*8)=Block; end end for rowblock = 1:size(M,1)/8 for colblock =1:size(M,2)/8 for rowOfPxls = 1:8 for colOfPxls = 1:8 % create block of size 8x8 out of the matrix block(rowOfPxls, colOfPxls) = M((rowblock - 1)*8 + ... rowOfPxls, (colblock - 1)*8 + colOfPxls); end end X(:, rowblock + (colblock - 1)*32) = block(:); end end