clear all;
clc;
co=[26 6 13 10;-7 7 6 4;4 -4 4 -3;2 -2 -2 0]
ori=[26 6 13 10;-7 7 6 4;4 -4 4 -3;2 -2 -2 0]
cmax=max(max(abs(co)));
n=fix(log2(cmax));
d1=[co(1,3) co(1,4) co(2,3) co(2,4)];
d2=[co(3,1) co(3,2) co(4,1) co(4,2)];
d3=[co(3,3) co(3,4) co(4,3) co(4,4)];
rec=zeros(4,4);
opo=[];
t=[];
ref=zeros(4,4);
%Initialization
lsp=[];
lip=[co(1,1),co(1,2),co(2,1),co(2,2)];
lis=[d1 d2 d3];
x=n-1;
while n>=0
[lspo,lipo,liso,op,rec1,co1]=sphitfun(n,co,lsp,lis,lip,rec)
;
lsp=lspo
lis=liso
lip=lipo
rec=rec1
co=co1
op
opo=[opo op];
if x==n
[refo,opf]=sphitref(n,ori,rec1,ref);
opf
opo=[opo opf];
ref=refo
x=x-1;
rec=ref;
end
n=n-1;
end
err=0;
for i=1:4
for j=1:4
err=err+((ori(i,j)-rec(i,j))^2);
end
end
mse=err/16;
cr=(4*4*8)/length(opo);