I = imread('MRInoise.png'); 
%Define low pass filter
smooth=1/9*ones(3);
%Apply a simple filter
Ism=filter2(smooth,I);
%Apply an adaptive wiener filter
%Display results
K = wiener2 (I, [7 7]);
subplot(1,3,1), imshow(I),title('Initial Image');
subplot(1,3,2), imshow(uint8(Ism)),title('Smooth image');
subplot(1,3,3), imshow(K),title('Wiener filtering image');


%Notes on WIener filter: The wiener2 function locally applies 
%a linear averaging filter to the input image I. 
%The averaging operation will be performed using a neighbourhood
% of each pixel of size nhood. 
%The strength of the averaging depends on the local variance 
%in this neighborhood and on the given variance of the noise (of mean zero).
%As a result, pixels in a region with higher contrast will be smoothed less, 
%and pixels in a region with lower contrast will be smoothed more.


%Try the following as exercise
%J = imsmooth(I, 'Median' , [3 3]);
%J = imsmooth(I, 'Perona and Malik' , 20);
