% written by Ondrej Drbohlav for the Digital Image course 
% in 2011. 

h = [0 1 1 1 1 1 0
     1 0 0 0 0 0 1
     1 0 1 0 1 0 1
     1 0 0 0 0 0 1
     1 0 1 0 1 0 1
     1 0 0 1 0 0 1
     0 1 1 1 1 1 0];

im = zeros(20); 
im (3:9, 3:9) = h; 
r = conv2(h, im); 

figure; imagesc(h); title('kernel');
figure; imagesc(im); title('image')
figure; imagesc(r); title('conv2(kernel, image)');

fprintf('Number of 1s in the smiley: %i\n', sum(h(:)));
fprintf('Convolution of smiley with image, max:%i\n', max(r(:))); 
fprintf('Why is this not the same?\n'); 
