% function to add noise to image

function newimage = add_noise(image,n)
[L,K] =size(image);
image=uint8(image);
% make random numbers between -n and n
noise1 = uint8(n*rand(L,K));
noise2 = uint8(n*rand(L,K));
newimage = image+noise1-noise2;
max(newimage-image)
newimage=min(newimage,255);
newimage=max(newimage,0);
newimage=round(newimage);
figure
hold on;
title('Original');
imshow(image);
figure
hold on;
title('Noisy Version');
imshow(newimage);
return