clear all
close all
% %  [aaf, ssf] = Lift53;
% % af = aaf{1};
% % sf = ssf{1};
% % %   [af, sf] = bior22filter;
% % imagedata = zeros(32,32);
% % %  imagedata(13,13) = 100;
% % w = dwt2D(imagedata, 1, af);
% %  w{1}{1}(6,6) = 100;
% % rec = idwt2D(w, 1, sf);
% % c = dwtcell2arr(w, 1);
% % imshow([c, rec], [])
% % calcpsnr(rec, imagedata)
% lsia = {'p', [-0.75 -0.25], [0], [0];'u', [0.125 0.375], [0], [1]; [sqrt(2)], [1/sqrt(2)], [], []};
% % imagedata  = rotplane(64,64, 135);
%    imagedata = double(imread('lena512.bmp'));
% %     imagedata = zeros(64,64);
% 
% 
% % [L, H, dinfo1, pinfo] = DLifting(imagedata, lsia);
% % [LL, LH, dinfo2, pinfo] = DLifting(L', lsia);
% % [HL, HH, dinfo3, pinfo] = DLifting(H', lsia);
% 
% % [L1, H1] = ADLifting06(imagedata);
% % recimage = iADLifting06(L, H);
% 
% % [L2, H2] = Lifting(imagedata, lsia);
% % recimage = iLifting(L, H, dinfo, pinfo, lsia);
% 
% J = 5;
% [y, dinfo, pinfo] = DLifting2D(imagedata, J, lsia);
% coeff = dwtcell2arr(y, J);
% recimage = iDLifting2D(y, J, dinfo, pinfo, lsia);
% 
fid = fopen('e:\\coeff_r','r');
coeff_r = fread(fid,[512,512],'int32');
coeff_r=coeff_r';
fclose(fid);
figure;imshow(coeff_r, [])

recimage = iDLifting2D(y, J, dinfo, pinfo, lsia);
% 
% % [y] = ADLifting062D(imagedata, J);
% % coeff = dwtcell2arr(y, J);
% % recimage = iADLifting062D(y, J);
% 
% % directional basis illustration
% % global dindex;
% % [L, H] = DLifting_demo(imagedata, lsia);
% % [LL, LH] = DLifting_demo(L', lsia);
% % [HL, HH] = DLifting_demo(H', lsia);
% % %  H(6,6) = 100;
% % LH(12,12) = 1;
% % HL(18,18) = 1;
% % HH(8,8) = 1;
% % dindex = 1;
% % L = iDLifting_demo(LL, LH, lsia);
% % H = iDLifting_demo(HL, HH, lsia);
% % L = L';
% % H = H';
% % dindex = -1;
% % recimage = iDLifting_demo(L, H, lsia);
% 
% %  figure; imshow([imagedata, coeff], [])
%     calcpsnr(imagedata, recimage)
%    
% %  EH = sum(sum(H.^2))/prod(size(H))
% %  EL = sum(sum(L.^2))/prod(size(H))
% %  EH1 = sum(sum(H1.^2))/prod(size(H1))
% %  EL1 = sum(sum(L1.^2))/prod(size(H1))
% %  EH2 = sum(sum(H2.^2))/prod(size(H2))
% %  EL2 = sum(sum(L2.^2))/prod(size(H2))
% 
% % fid = fopen('coeff_matlab');
% % coeff = fread(fid, [512,512], 'int32');
% % fclose(fid);
% % figure;imshow(double(coeff'), [])