function [A] = imread_compressed(filename) % A = imread_compressed(FILENAME) % reads the image A from FILENAME, % in experimental "DAVE" format. % much like imread. % Usage: % A = double(imread('cameraman.tif')); % imwrite_compressed(A, 'junk.dav'); % X = imread_compressed('junk.dav'); % if( isequal(A,X) ) % disp('perfect lossless reconstruction') % else, % error(' I messed up somewhere ... ') % end; % I wish I could use this with % imwrite(A, FILENAME, 'dave'); % X = imread(FILENAME, 'dave'); % See also IMWRITE_COMPRESSED, HUFFMAN_UNCOMPRESS, IMREAD. % Change Log % 1999-06-28:DAV: David Cary started. % Load the file as a binary file, rather than default to '-ASCII'. load(filename, '-mat'); % I expect 4 variables in this file: % 'header', 'shape', 'bitlengths', 'compressed_data'. recovered_data = huffman_uncompress(compressed_data, double(bitlengths), prod(shape)); recovered_matrix = reshape(recovered_data, shape); % FIXME: do funky inverse wavelet transform here. A = recovered_matrix; % end imread_compressed.m