% blobs: blob detection using Laplacian pyramid, for the example in class

im = imread('butterfly.jpg');
im = rgb2gray(im);
sigma = nthroot(2, 4);
figure; imagesc(im);

for i = 1:8
    
    % filter, compute difference between two Gaussian levels, and show
    fil = fspecial('gaussian', ceil(3*sigma), sigma);
    im_fil = imfilter(im, fil);
    blobs_at_this_level = im - im_fil;
    figure; imagesc(blobs_at_this_level);
    
    % overwrite image with blurred version
    im = im_fil;
    
    % subsample image at the end of this octave
    if(i == 4)
        im = im(1:2:end, 1:2:end);
    end
    
end

