function pi = pyramidit(img)

img = img([1:1228],[1:1228]);

% first generate the pyramids
maxlvl = ceil(nlevels(size(img,1),size(img,2),size(img, 1)) + 1);
[pyramids pyrsizes] = buildGpyr(img, maxlvl);

% debugging
size(pyramids)
pyrsizes

% % then upblur each one
bpyr(:,:,1) = pyrBand(pyramids,pyrsizes,1);
for py=2:maxlvl,
    % pull out the appropriate band
    pimg = pyrBand(pyramids,pyrsizes,py);
    % upsample
    blur = upBlur(pimg,py-1);
    % stash
    bpyr(:,:,py) = blur([1:1228],[1:1228]);
end

% bpyr = cat(3,img,bpyr);

% now, reconstruct ourselves a new image
pi = [];
for i=1:size(img,1),
    for j = 1:size(img,2),
        lvl = nlevels(i,j,size(img,1));
        mixing = (lvl - floor(lvl));
        pyr1ij = (1-mixing)*bpyr(i,j,floor(lvl + 1));
        pyr2ij = (mixing )* bpyr(i,j,ceil(lvl + 1));
        pi(i,j) = pyr1ij + pyr2ij;
    end
end
imshow(pi);

