% this script simulates defocus and motion blur

% read and display original image
IM=double(imread('blur-original.png'));
figure; imshow(IM,[]); title('The original image');

% defocus blur - square convolution mask, apply, display
blur=ones(5,5)/(5*5);
IMb=conv2(IM,blur,'same');
figure; imshow(IMb,[]); title('Defocus blur');

% motion blur - rectangle convolution mask, apply, display
blur=ones(1,9)/9;
IMb=conv2(IM,blur,'same');
figure; imshow(IMb,[]); title('Motion blur');

