from Noise Reduction using Averaging by Madhu S. Nair
Noise Reduction using Averaging

noisereduct(x)
%Question No: 2
%Take a noisy image. Write a MATLAB function which reduces the noise by
%averaging the input image by 2, 8, 16, 32 and 128. Compare all the
%resulting images and find which is noise free.

function noisereduct(x)
f=imread(x);
[M,N]=size(f);
f=im2double(f);
A=zeros(M,N);
no=input('Enter the number of noisy images to be considered : ');
d=0.01;
for i=1:no
    A=A+imnoise(f,'salt & pepper',d);
    d=d+.004;
end
A=A/no;
figure, imshow(f),title('Original Image');
figure,imshow(A),title('Image After Noise Reduction');

Contact us at files@mathworks.com