% 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];[1], [1], [], []};
% lsi53 = {'u', [0.25 0.25], [0], [0];'p', [-0.5 -0.5], [1], [0]; [1], [1/2], [], []};
% lsi53 = {'p', [-0.5 -0.5], [1], [0];'u', [0.25 0.25], [0], [0]; [1], [1/2], [], []};
% imagedata  = rotplane(64,64, 135);
% imagedata = double(imread('barbara.pgm'));
%     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);

fid = fopen('e:\\coeff_r','r');
coeff_r = fread(fid,[512,512],'int32');
coeff_r=coeff_r';
fclose(fid);

% coeff_r = coeff_r*200;
% figure;imshow(coeff_r, [])

y_r = dwtarr2cell(coeff_r, J);
recimage = iDLifting2D_nodinfo(y_r, J,lsi53);
psnr=calcpsnr(imagedata, recimage)
% figure; imshow(recimage, [])