%Noisy Images
%I = imread('MRI.jpeg'); 
%I = imread('MRInoise.png');
I = imread('MRInoise2.jpg');
%Filters
%Ism = imsmooth(I, 'Perona and Malik' , 9);%Ism=filter2(h1,I);
Ism=medfilt2 (I, [7 7]);
figure, imshow(I)
figure, imshow(mat2gray(Ism))
Idif=I-Ism;
figure, imshow(mat2gray(Idif),[])
% The differene image highlighted edges
Ienh=I+2*Idif;
%By adding the edges I sharpen the image 
figure, imshow(mat2gray(Ienh),[])

%This is a median filter that generates the denoised image
%Ism=medfilt2 (I, [9 9]);

%To smooth with a Gaussian filter I need to create a filter
%h1=fspecial('gaussian', [7 7],4);
%and then apply it to the image
%Ism=filter2(h1,I);
%h1=fspecial('average', [7 7]); %h1=ones(3)/9
%h=fspecial('gaussian', [100 100],2);
%figure, imagesc(h), colormap jet
%figure, surf(h), shading interp, colormap jet
