clear
clc
tic;

load GraphDataSyn_Sphere_Slope.mat
% load GraphDataSyn_Sphere_EricCartman.mat
% load GraphDataSyn_Sphere_Fingerprint.mat

M=length(L);

%%%% Extract Decomposition/Reconstruction Masks
FrameType='Linear';
[DFilters RFilters]=ExtractMasks(FrameType);

r=length(DFilters);
Lev=4; % Level of transform
View='EricCartman'; % Viewing angle

s=2; % Dilation scale
n=8; % n-1 = Degree of Chebyshev Polynomial Approximation
J=log(lambda_max/pi)/log(s)+Lev-1; % Dilation level to start the decomposition

%%%% Fast Tight Frame Decomposition 
d=GraphWFTG_Decomp(FD,L,DFilters,n,s,J,Lev);

figure;
subplot(221);ViewTriMesh(FV,1,FD,View);subplot(222);ViewTriMesh(FV,1,d{1,Lev},View);
subplot(223);ViewTriMesh(FV,1,d{2,Lev},View);subplot(224);ViewTriMesh(FV,1,d{3,Lev},View);

%%%% Fast Tight Frame Reconstruction
FD_rec=GraphWFTG_Recon(d,L,RFilters,n,s,J,Lev);

T=toc;
Rec_Error=norm(FD-FD_rec,'inf');
display(['Reconstruction error = ' num2str(Rec_Error) '; Time elapsed = ' num2str(T) '.'])

