-3

I want to add Multiplicative Gamma Noise to a image using "randg" function in Matlab and remove that noise. We have to keep in mind that the noise should have mean 1 and level 4. It should follow Gamma law ( with Gamma Probability Distribution Function). The image after addition of noise becomes

f=u*v; where f=noisy image, u=original image, v=noisy image.

The gamma law is: gv(v)=L^L/(Γ(L)) v^(L-1) exp(-Lv) 1_(v≥0)

where L is the noise level and v is the noise.

Here is the code that I've tried:

  img = imread('lena.png');
  img1 = img./ 255;
  imgdob = double(img1);
  noisyimg = imgdob + randg(1,size(imgdob)) .* 0.4;
  noisyimg(noisyimg< 0) = 0;
  noisyimg(noisyimg> 1) = 1;
  figure,imshow(img);
  figure,imshow(noisyimg);
  imwrite(img, 'lenaOriginal.jpg', 'Quality', 100);
  imwrite(noisyimg, 'lenaNoisy.jpg', 'Quality', 100);

But I could not get the expected result. Please suggest me a way.

krisdestruction
  • 1,950
  • 1
  • 10
  • 20
  • 1
    Have you tried anything? Questions asking for code without any effort deployed will likely get closed. You can improve your question by showing what you have tried and where you are stuck. Thanks! – Benoit_11 Apr 20 '15 at 15:42
  • Yes I've tried the code and I've edited the question this time along with the code but the problem is I am not getting the expected result. Please suggest me a way. – unique_CODER Apr 20 '15 at 15:58
  • @unique_CODER Can you try my solution and let me know if it solves the issue? – krisdestruction Apr 21 '15 at 04:02
  • Yeah sure @krisdestruction. But please provide me a solution. – unique_CODER Apr 21 '15 at 05:51
  • @unique_CODER I wasn't sure if you tried my answer at the time. Let's continue on my answer's comments. – krisdestruction Apr 21 '15 at 06:05

1 Answers1

0

0.4 is VERY destructive. So destructive that it'll force it to threshold values to 0 or 1. You should try 0.2 instead. Also if you're looking for a normal distribution noise, you should use randn instead of randg. The following code is here.

Note that I don't have sexylena.png on my computer so I must use bag.png instead.

imgdob = im2double(imread('bag.png'));
noisyimg = imgdob + randg(1,size(imgdob)) .* 0.15;
noisyimg(noisyimg< 0) = 0;
noisyimg(noisyimg> 1) = 1;
figure,imshow(imgdob);
figure,imshow(noisyimg);
imwrite(imgdob, 'lenaOriginal.jpg', 'Quality', 100);
imwrite(noisyimg, 'lenaNoisy.jpg', 'Quality', 100);

These are the results. Normal image.

normal img

Noisy image using randg.

noisy img randg

If you wish to use randn instead, you can use this line of code instead.

noisyimg = imgdob + randn(size(imgdob)) .* 0.2;

Noisy image using randn.

noisy img randn

As for noise reduction, please refer to Matlab's tutorial for noise removal.

krisdestruction
  • 1,950
  • 1
  • 10
  • 20
  • But if I use 'randn' function then will the noise follow the gamma law? And how do I get the mean and the level? – unique_CODER Apr 21 '15 at 05:45
  • @unique_CODER If you wish to use `randg` for the gamma law, then you can use it. My point is just that `0.4` is WAY too strong and causes it to saturate. Check my results for `randg`. – krisdestruction Apr 21 '15 at 05:54