clear all;

arg_list = argv();
noise = str2num(arg_list{3,1});

img = imread(arg_list{2,1});

try
  if(size(img)(3)==3)
    img = rgb2gray(img);
  endif
end_try_catch

img = double(img);
img = img/max(max(img));

px = size(img)(1);
py = size(img)(2);

img = 1 - img;

noiseMatrix = rand(px,py)>noise;
img = img.*noiseMatrix;

img = 1 - img;

imwrite(img, arg_list{1,1})

