clear all
close all

lsia = {'p', [-0.75 -0.25], [0], [0];'u', [0.125 0.375], [0], [1]; [1], [1], [], []};
% imagedata  = rotplane(64,64, 135);
imagedata = double(imread('barbara.pgm'));
% imagedata = zeros(256,256);

J = 5;
[y, dinfo, pinfo] = QDLifting2D(imagedata, J, lsia);
coeff = dwtcell2arr(y, J);
M = max(max(abs(coeff)))

fid = fopen('e:\\coeff','w');
fwrite(fid, coeff', 'int32');
fclose(fid);
figure;imshow(coeff, [])


% % fid = fopen('e:\\coeff_r','r');
% % coeff_r = fread(fid,[512,512],'int32');
% % coeff_r=coeff_r';
% % fclose(fid);
% % % figure;imshow(coeff_r, [])
% % 
% 
% drec = 8;
% dinfo{J}{1}=drec*ones(size(dinfo{1}{1}));
% dinfo{J}{2}=drec*ones(size(dinfo{1}{2}));
% y{J}{1}(5,5)=100;
% y{J}{2}(10,10)=100;
% y{J}{3}(10,5)=100;
% y_r = y;
% 
% y_r = dwtarr2cell(coeff, J);
% recimage = iQDLifting2D(y_r, J, dinfo, pinfo, lsia);
% 
% figure; imshow(recimage, [])
% calcpsnr(imagedata, recimage)