%
% Spatial salt-and-pepper noise
% Written by: H.E.
% Date: 2/11

% clear workspace and close all windows
clear; close all;

% Read input and display it
im=imread('PCB_layout.jpg');
figure; imagesc(im); colormap('gray');
title('RGB image of PCB');

% Generate noise for only one band only so that pepper looks like 
% dark pixels and salt looks white in an RGB image
imn=im; imr=im(:,:,1); n=rand(size(imr));
for i=1:3
    band=im(:,:,i);
    band(n <= 0.2)=0; band(n >= 0.8)=255;
    imn(:,:,i)=band;
end

% Display the RGB noisy image
figure; imagesc(imn); title('Noisy RGB image of PCB');


