%load einstein.mat;

im = imread('GuGong_bw.jpg');
figure(1);
imshow(im, 256);

im = double(im);

% block = im(89:96, 105:112);

% Do Gaussian Pyramid

[pyr, indices] = buildGpyr(im, 3);

figure(2);
showLpyr(pyr, indices, 'indep1');
title('Gaussian Pyramid');

g1 = pyrBand(pyr, indices, 1);
save g1 g1;
imwrite(g1, 'g1.jpg', 'jpg', 'Quality', 75);

g2 = pyrBand(pyr, indices, 2);
g2 = round(g2);
save g2 g2;
imwrite(g2, 'g2.jpg', 'jpg', 'Quality', 75);

g3 = pyrBand(pyr, indices, 3);

%-------------------------
%Do Laplacian Pyramid
%-------------------------

[lpyr, lindices] = buildLpyr(im, 3);
figure(3);
showLpyr(lpyr, lindices, 'indep1');
title('Laplacian Pyramid');

l1 = pyrBand(lpyr, lindices, 1);
l1 = round(l1);
save l1 l1;
imwrite(l1, 'l1.jpg', 'jpg', 'Quality', 75);

l2 = pyrBand(lpyr, lindices, 2);
l2 = round(l2);
save l2 l2;
imwrite(l2, 'l2.jpg', 'jpg', 'Quality', 75);
l3 = pyrBand(lpyr, lindices, 3);

